From 0aaf71edb6fe07c37831c702cfbb1a3020b49e35 Mon Sep 17 00:00:00 2001 From: RodionLisch Date: Thu, 28 Nov 2024 15:40:34 +0100 Subject: [PATCH] update LIDO-tutorial --- nfdinspector_tutorials/LIDO_tutorial.ipynb | 33 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/nfdinspector_tutorials/LIDO_tutorial.ipynb b/nfdinspector_tutorials/LIDO_tutorial.ipynb index adb267d..03329f0 100644 --- a/nfdinspector_tutorials/LIDO_tutorial.ipynb +++ b/nfdinspector_tutorials/LIDO_tutorial.ipynb @@ -82,7 +82,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -102,11 +102,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "OSError", + "evalue": "Error reading file '\\nfdinspector_tutorials\\LIDO_xml\\23318.xml': failed to load external entity \"/nfdinspector_tutorials/LIDO_xml/23318.xml\"", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mOSError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[12], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m file_path \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\\\\u001b[39;00m\u001b[38;5;124mnfdinspector_tutorials\u001b[39m\u001b[38;5;130;01m\\\\\u001b[39;00m\u001b[38;5;124mLIDO_xml\u001b[39m\u001b[38;5;130;01m\\\\\u001b[39;00m\u001b[38;5;124m23318.xml\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m----> 2\u001b[0m \u001b[43mlido_inspector\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_lido_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile_path\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\nfdinspector\\lido_inspector.py:137\u001b[0m, in \u001b[0;36mLIDOInspector.read_lido_file\u001b[1;34m(self, file_path)\u001b[0m\n\u001b[0;32m 130\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread_lido_file\u001b[39m(\u001b[38;5;28mself\u001b[39m, file_path: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 131\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 132\u001b[0m \u001b[38;5;124;03m Parse LIDO-XML from a file and assign LIDO records to the inspector.\u001b[39;00m\n\u001b[0;32m 133\u001b[0m \n\u001b[0;32m 134\u001b[0m \u001b[38;5;124;03m :param file_path: File path to a LIDO-XML file\u001b[39;00m\n\u001b[0;32m 135\u001b[0m \u001b[38;5;124;03m :type file_path: str\u001b[39;00m\n\u001b[0;32m 136\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 137\u001b[0m xml_root \u001b[38;5;241m=\u001b[39m \u001b[43mMetadataInspector\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_xml_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile_path\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 138\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlido_objects \u001b[38;5;241m=\u001b[39m [obj \u001b[38;5;28;01mfor\u001b[39;00m obj \u001b[38;5;129;01min\u001b[39;00m xml_root\u001b[38;5;241m.\u001b[39miter(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m{\u001b[39m\u001b[38;5;124m*}lido\u001b[39m\u001b[38;5;124m\"\u001b[39m)]\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\nfdinspector\\metadata_inspector.py:77\u001b[0m, in \u001b[0;36mMetadataInspector.read_xml_file\u001b[1;34m(file_path)\u001b[0m\n\u001b[0;32m 68\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 69\u001b[0m \u001b[38;5;124;03mParse XML from a file.\u001b[39;00m\n\u001b[0;32m 70\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 74\u001b[0m \u001b[38;5;124;03m:rtype: etree._Element\u001b[39;00m\n\u001b[0;32m 75\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 76\u001b[0m parser \u001b[38;5;241m=\u001b[39m etree\u001b[38;5;241m.\u001b[39mXMLParser(remove_blank_text\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, ns_clean\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m---> 77\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43metree\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparser\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mgetroot()\n", + "File \u001b[1;32msrc\\\\lxml\\\\etree.pyx:3590\u001b[0m, in \u001b[0;36mlxml.etree.parse\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:1952\u001b[0m, in \u001b[0;36mlxml.etree._parseDocument\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:1978\u001b[0m, in \u001b[0;36mlxml.etree._parseDocumentFromURL\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:1881\u001b[0m, in \u001b[0;36mlxml.etree._parseDocFromFile\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:1200\u001b[0m, in \u001b[0;36mlxml.etree._BaseParser._parseDocFromFile\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:633\u001b[0m, in \u001b[0;36mlxml.etree._ParserContext._handleParseResultDoc\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:743\u001b[0m, in \u001b[0;36mlxml.etree._handleParseResult\u001b[1;34m()\u001b[0m\n", + "File \u001b[1;32msrc\\\\lxml\\\\parser.pxi:670\u001b[0m, in \u001b[0;36mlxml.etree._raiseParseError\u001b[1;34m()\u001b[0m\n", + "\u001b[1;31mOSError\u001b[0m: Error reading file '\\nfdinspector_tutorials\\LIDO_xml\\23318.xml': failed to load external entity \"/nfdinspector_tutorials/LIDO_xml/23318.xml\"" + ] + } + ], "source": [ - "lido_inspector.read_lido_file('file_path')" + "file_path = '\\\\nfdinspector_tutorials\\\\LIDO_xml\\\\23318.xml'\n", + "lido_inspector.read_lido_file(file_path)" ] }, { @@ -129,7 +152,7 @@ "metadata": {}, "outputs": [], "source": [ - "lido_inspector.read_lido_files('files_path')" + "lido_inspector.read_lido_files('nfdinspector_tutorials\\LIDO_xml')" ] }, {