diff options
author | roy lewin <roy.lewin@gmail.com> | 2016-09-22 10:00:44 +0300 |
---|---|---|
committer | roy lewin <roy.lewin@gmail.com> | 2016-09-22 10:00:44 +0300 |
commit | bd3956dc019d7f56bfd2cb8b667e8cacf9e80f59 (patch) | |
tree | 98e8df2bfbe35dacb988b061a7521745bc8e1850 | |
parent | 403fb8666125e74617e89aae7e87823cb78d5485 (diff) |
Fixed conflicts in xml reader
-rw-r--r-- | .idea/workspace.xml | 89 | ||||
-rw-r--r-- | parsers/INL_xml_parser.py | 29 | ||||
-rw-r--r-- | readers/xml_reader.py | 5 |
3 files changed, 85 insertions, 38 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5299b52..f2b732c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,9 +3,11 @@ <component name="ChangeListManager"> <list default="true" id="b3a73108-18f8-44f3-8073-d1952fb9639d" name="Default" comment=""> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/parsers/INL_xml_parser.py" afterPath="$PROJECT_DIR$/parsers/INL_xml_parser.py" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/readers/xml_reader.py" afterPath="$PROJECT_DIR$/readers/xml_reader.py" /> </list> <ignored path="lib2wiki.iws" /> <ignored path=".idea/workspace.xml" /> + <ignored path=".idea/dataSources.local.xml" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="TRACKING_ENABLED" value="true" /> <option name="SHOW_DIALOG" value="false" /> @@ -13,6 +15,9 @@ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="LAST_RESOLUTION" value="IGNORE" /> </component> + <component name="CoverageDataManager"> + <SUITE FILE_PATH="coverage/lib2wiki$xml_reader.coverage" NAME="xml_reader Coverage Results" MODIFIED="1474527548475" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/readers" /> + </component> <component name="CreatePatchCommitExecutor"> <option name="PATCH_PATH" value="" /> </component> @@ -21,11 +26,40 @@ <favorites_list name="lib2wiki" /> </component> <component name="FileEditorManager"> - <leaf SIDE_TABS_SIZE_LIMIT_KEY="300" /> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> + <file leaf-file-name="xml_reader.py" pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/readers/xml_reader.py"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="435"> + <caret line="26" column="43" selection-start-line="26" selection-start-column="0" selection-end-line="27" selection-end-column="0" /> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="INL_xml_parser.py" pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/parsers/INL_xml_parser.py"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="333"> + <caret line="30" column="0" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" /> + <folding /> + </state> + </provider> + </entry> + </file> + </leaf> </component> <component name="Git.Settings"> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/parsers/INL_xml_parser.py" /> + <option value="$PROJECT_DIR$/readers/xml_reader.py" /> + </list> + </option> + </component> <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" /> <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" /> <component name="JsGulpfileManager"> @@ -158,11 +192,11 @@ </panes> </component> <component name="PropertiesComponent"> - <property name="last_opened_file_path" value="$PROJECT_DIR$" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$/readers/xml_reader.py" /> <property name="WebServerToolWindowFactoryState" value="false" /> <property name="prop_add_unversioned_files" value="true" /> </component> - <component name="RunManager"> + <component name="RunManager" selected="Python.xml_reader"> <configuration default="true" type="DjangoTestsConfigurationType" factoryName="Django tests"> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -220,7 +254,7 @@ <envs> <env name="PYTHONUNBUFFERED" value="1" /> </envs> - <option name="SDK_HOME" value="" /> + <option name="SDK_HOME" value="C:\Python27\python.exe" /> <option name="WORKING_DIRECTORY" value="" /> <option name="IS_MODULE_SDK" value="false" /> <option name="ADD_CONTENT_ROOTS" value="true" /> @@ -371,6 +405,27 @@ <option name="USE_KEYWORD" value="false" /> <method /> </configuration> + <configuration default="false" name="xml_reader" type="PythonConfigurationType" factoryName="Python"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs> + <env name="PYTHONUNBUFFERED" value="1" /> + </envs> + <option name="SDK_HOME" value="C:\Python27\python.exe" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/readers" /> + <option name="IS_MODULE_SDK" value="false" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="lib2wiki" /> + <EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/readers/xml_reader.py" /> + <option name="PARAMETERS" value="" /> + <option name="SHOW_COMMAND_LINE" value="false" /> + <method /> + </configuration> + <list size="1"> + <item index="0" class="java.lang.String" itemvalue="Python.xml_reader" /> + </list> </component> <component name="ShelveChangesManager" show_recycled="false"> <option name="remove_strategy" value="false" /> @@ -387,26 +442,26 @@ </component> <component name="ToolWindowManager"> <frame x="-8" y="-8" width="1616" height="876" extended-state="6" /> - <editor active="false" /> + <editor active="true" /> <layout> - <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> + <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> - <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> + <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32898173" sideWeight="0.5025" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> + <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32898173" sideWeight="0.4975" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> + <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> - <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> - <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> </layout> </component> <component name="Vcs.Log.UiProperties"> @@ -441,5 +496,21 @@ </state> </provider> </entry> + <entry file="file://$PROJECT_DIR$/readers/xml_reader.py"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="435"> + <caret line="26" column="43" selection-start-line="26" selection-start-column="0" selection-end-line="27" selection-end-column="0" /> + <folding /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/parsers/INL_xml_parser.py"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="333"> + <caret line="30" column="0" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" /> + <folding /> + </state> + </provider> + </entry> </component> </project>
\ No newline at end of file diff --git a/parsers/INL_xml_parser.py b/parsers/INL_xml_parser.py index c23cf20..4cd04ef 100644 --- a/parsers/INL_xml_parser.py +++ b/parsers/INL_xml_parser.py @@ -11,7 +11,6 @@ class INLXmlParser: self.reader = reader self.whitelist = whitelist or KNOWN_FIELD_TAGS -<<<<<<< HEAD def clearxml(self): newTreeRoot = ET.Element('data') @@ -29,30 +28,6 @@ class INLXmlParser: for data in field: subData = ET.SubElement(newTag, data.tag, data.attrib) subData.text = data.text -======= - #expects to get a record as ElementTree - def clearxml(self, record): - # root == list of tags - root = record.getroot() - - # scan the datafields in the records and copy to the new one only the tags in the whitelist - # create new record - newRecord = ET.Element('record') - for field in root: - fieldtag = field.attrib.get('tag') - if fieldtag in self.whitelist: - tempTag = fieldtag - # tag 700 and 400 are the same - if tempTag == '700': - tempTag = '400' - for data in field: - newFieldTag = tempTag - newFieldTag +='.' - newFieldTag += data.attrib.get('code') - newTag = ET.SubElement(newRecord, 'datafield', {'tag': newFieldTag}) - newTag.text = data.text ->>>>>>> 081eac29a20ab8485f2b8180654a6d4b808e2df7 - - # newRecordTree = ET.ElementTree(newRecord) - return newRecord + newRecordTree = ET.ElementTree(newRecord) + return newRecordTree diff --git a/readers/xml_reader.py b/readers/xml_reader.py index 8a819b0..55a0750 100644 --- a/readers/xml_reader.py +++ b/readers/xml_reader.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +# from __future__ import absolute_import import parsers try: @@ -23,7 +23,8 @@ def read_file(path, element_key): if element_key in element.tag: record_counter += 1 cleaned_element = parsers.INLXmlParser(element).clearxml() - print record_counter, cleaned_element.getroot().attrib + # import pdb; pdb.set_trace() + print record_counter, cleaned_element.getroot().tag, '@@@', cleaned_element.getroot().attrib, '@@@', cleaned_element.getroot().text element.clear() |