Skip to content

Commit

Permalink
Refactor two methods moved to core
Browse files Browse the repository at this point in the history
  • Loading branch information
triole committed Mar 20, 2018
1 parent 093b4d8 commit 6a54dc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
20 changes: 20 additions & 0 deletions rdmo/core/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
log = logging.getLogger(__name__)


def utf8_to_bool(instring):
r = None
s = instring.decode('utf-8')
truelist = ['True', 'true']
falselist = ['False', 'false']
if s in truelist:
r = True
elif s in falselist:
r = False
return r


def get_value_from_xml_node(xml_node, element, what_to_get=None):
r = ''
try:
Expand Down Expand Up @@ -59,3 +71,11 @@ def validate_xml(tempfilename, root_tag):
log.info('Validation failed. Xml\'s root node is "' + root.tag + '" and not "' + root_tag + '".')
exit_code = 1
return exit_code, tree


# NOTE: not used yet
def find_rec(node, element, result):
for item in node.findall(element):
result.append(item)
find_rec(item, element, result)
return result
8 changes: 0 additions & 8 deletions rdmo/domain/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,3 @@ def import_verbose_name(verbosename_node, entity):
except Exception as e:
log.info('An exception occured: ' + str(e))
pass


# NOTE: not used yet
def find_rec(node, element, result):
for item in node.findall(element):
result.append(item)
find_rec(item, element, result)
return result
14 changes: 1 addition & 13 deletions rdmo/options/imports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from rdmo.core.imports import get_value_from_xml_node
from rdmo.core.imports import utf8_to_bool, get_value_from_xml_node
from rdmo.core.utils import get_ns_map, get_ns_tag


Expand All @@ -9,18 +9,6 @@
log = logging.getLogger(__name__)


def utf8_to_bool(instring):
r = None
s = instring.decode('utf-8')
truelist = ['True', 'true']
falselist = ['False', 'false']
if s in truelist:
r = True
elif s in falselist:
r = False
return r


def import_options(optionsets_node):
log.info("Importing options")

Expand Down

0 comments on commit 6a54dc9

Please sign in to comment.