def create_xml_changes(amended_labels, section, notice_changes, subpart_label=None): """For PUT/POST, match the amendments to the section nodes that got parsed, and actually create the notice changes. """ def per_node(node): node.child_labels = [c.label_id() for c in node.children] struct.walk(section, per_node) amend_map = changes.match_labels_and_changes(amended_labels, section) for label, amendments in amend_map.iteritems(): for amendment in amendments: if amendment['action'] in ('POST', 'PUT'): if (subpart_label and amendment['action'] == 'POST' and len(label.split('-')) == 2): amendment['extras'] = {'subpart': subpart_label} if 'field' in amendment: nodes = changes.create_field_amendment(label, amendment) else: nodes = changes.create_add_amendment(amendment) for n in nodes: notice_changes.update(n) elif amendment['action'] == 'RESERVE': change = changes.create_reserve_amendment(amendment) notice_changes.update(change) elif amendment['action'] not in ('DELETE', 'MOVE'): logging.info('NOT HANDLED: %s' % amendment['action'])
def create_xml_changes(amended_labels, section, notice_changes): """For PUT/POST, match the amendments to the section nodes that got parsed, and actually create the notice changes. """ def per_node(node): node.child_labels = [c.label_id() for c in node.children] walk(section, per_node) amend_map = changes.match_labels_and_changes(amended_labels, section) for label, amendments in amend_map.items(): for amendment in amendments: if amendment['action'] in ('POST', 'PUT', 'INSERT'): if 'field' in amendment: nodes = changes.create_field_amendment(label, amendment) else: nodes = changes.create_add_amendment(amendment) for n in nodes: notice_changes.add_changes(amendment['amdpar_xml'], n) elif amendment['action'] == 'RESERVE': change = changes.create_reserve_amendment(amendment) notice_changes.add_changes(amendment['amdpar_xml'], change) else: logger.warning("Unknown action: %s", amendment['action'])