Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reduce_content_size(self, content):
to_delete = []
for key, value in iteritems(content):
if value is not None:
if isinstance(value, list):
continue
if value['type'] in ('sequence', 'choice') and value.get('content'):
try:
new_value = (value['type'], # TODO: can we set only sequence?
tuple((x['ref'], (x.get('min', 0), x.get('max', -1))) for x in value['content']))
except:
new_value = None
elif value['type'] == 'annotation':
new_value = ('leaf', value['datatype'], value.get('libraryLongName'), value.get('table'))
else:
new_value = None
if new_value is None:
to_delete.append(key)
else:
output_file.write("}\n")
output_file.write("for k, v in GROUPS.iteritems():\n")
output_file.write(" for item in v[1]:\n")
output_file.write(" if item[3] == 'GRP':\n")
output_file.write(" item[1] = GROUPS[item[0]]\n")
parse_res = self.parse_schema("messages.xsd")
content, message_files = parse_res[0], parse_res[1]
message_def = {}
groups = {}
for f in message_files: # each file describes an HL7 message
message, ext = os.path.splitext(f)
content = self.parse_schema(f)[0]
message_def[message] = content[message.upper()]
groups.update(g for g in iteritems(content) if g[0] != message)
self.generate_module("messages.py", message_def, ["groups", "segments"], message_writer)
self.generate_module("groups.py", groups, ["segments"], groups_writer)
('XTN_6', DATATYPES['XTN_6'], (0, 1), 'CMP'),
('XTN_7', DATATYPES['XTN_7'], (0, 1), 'CMP'),
('XTN_8', DATATYPES['XTN_8'], (0, 1), 'CMP'),
('XTN_9', DATATYPES['XTN_9'], (0, 1), 'CMP'),
('XTN_10', DATATYPES['XTN_10'], (0, 1), 'CMP'),
('XTN_11', DATATYPES['XTN_11'], (0, 1), 'CMP'),
('XTN_12', DATATYPES['XTN_12'], (0, 1), 'CMP'),
('XTN_13', DATATYPES['XTN_13'], (0, 1), 'CMP'),
('XTN_14', DATATYPES['XTN_14'], (0, 1), 'CMP'),
('XTN_15', DATATYPES['XTN_15'], (0, 1), 'CMP'),
('XTN_16', DATATYPES['XTN_16'], (0, 1), 'CMP'),
('XTN_17', DATATYPES['XTN_17'], (0, 1), 'CMP'),
('XTN_18', DATATYPES['XTN_18'], (0, 1), 'CMP'),),
}
for k, v in iteritems(DATATYPES):
if v[0] == 'sequence':
v[1] = DATATYPES_STRUCTS[v[2]]
'XTN': (
('XTN_1', DATATYPES['XTN_1'], (0, 1), 'CMP'),
('XTN_2', DATATYPES['XTN_2'], (0, 1), 'CMP'),
('XTN_3', DATATYPES['XTN_3'], (0, 1), 'CMP'),
('XTN_4', DATATYPES['XTN_4'], (0, 1), 'CMP'),
('XTN_5', DATATYPES['XTN_5'], (0, 1), 'CMP'),
('XTN_6', DATATYPES['XTN_6'], (0, 1), 'CMP'),
('XTN_7', DATATYPES['XTN_7'], (0, 1), 'CMP'),
('XTN_8', DATATYPES['XTN_8'], (0, 1), 'CMP'),
('XTN_9', DATATYPES['XTN_9'], (0, 1), 'CMP'),
('XTN_10', DATATYPES['XTN_10'], (0, 1), 'CMP'),
('XTN_11', DATATYPES['XTN_11'], (0, 1), 'CMP'),
('XTN_12', DATATYPES['XTN_12'], (0, 1), 'CMP'),),
}
for k, v in iteritems(DATATYPES):
if v[0] == 'sequence':
v[1] = DATATYPES_STRUCTS[v[2]]
def _find_structure(self, reference=None):
if self.name is not None:
structure = ElementFinder.get_structure(self, reference)
for k, v in iteritems(structure):
setattr(self, k, v)
def _find_structure(self, reference=None):
if self.name is not None or reference is not None:
structure = ElementFinder.get_structure(self, reference)
for k, v in iteritems(structure):
setattr(self, k, v)