<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Export Assetpackage with UNtools - Problem with duplicate class names (StructureJunction_1) in Water Utilities Questions</title>
    <link>https://community.esri.com/t5/water-utilities-questions/export-assetpackage-with-untools-problem-with/m-p/1079139#M1798</link>
    <description>&lt;P&gt;Hi all. I'm trying to use the "Export Assetpackage" function with UNtools (2.6.2) but I'm running into a rather annoying error, and I'm hoping someone might be able to help me correct it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to me testing out some other functions regarding dataloading workbooks I have created more than one Utility network in the same local geodatabase. This has resulted in me having class names ending with "_1" in the second Utility network I created. This goes for all the different names in that utility network model.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Example of name problem" style="width: 220px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18509iF0AD5D319F0BD18B/image-size/large?v=v2&amp;amp;px=999" role="button" title="UNTools_Problem_1.JPG" alt="Example of name problem" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Example of name problem&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I try to export this UN to an assetpackage, I get the following error:&lt;/P&gt;&lt;P&gt;"line 623, in parse_un_class&lt;BR /&gt;raise ValueError("'{}' did not satisfy regex".format(name))&lt;BR /&gt;ValueError: 'StructureBoundary_1' did not satisfy regex"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I take a look at line 623 in the "common.py" file the error refers to it to be part of the following function:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;@lru_cache()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;def parse_un_class(class_name: str, structure_as_none: bool = False) -&amp;gt; Tuple:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"""Parses class_name to extract the domain name and class type&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Args:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;class_name (str): The path to the UN class.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;structure_as_none (bool): Return Structure Network as ``None``; defaults to ``False``.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Returns:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;tuple: (Domain name, class type)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Examples:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt; parse_un_class("Naper.un.ElectricLine")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;("Electric", "Line")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt; parse_un_class("C:/con.sde/Naper.un.Electric/Naper.un.StructureBoundary")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;("Structure", "StructureBoundary")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt; parse_un_class("C:/con.sde/Naper.un.Electric/Naper.un.StructureBoundary", structure_as_none=True)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(None, "StructureBoundary")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Raises:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ValueError: If ``class_name`` is not a valid UN class.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if class_name is None:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return None, None&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# TODO: rewrite this to handle duplicate class names (eg StructureJunction_2)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;name = os.path.split(class_name)[-1].rpartition('.')[-1]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# Using lazy quantifier so Subnet is included with Line and not the domain name&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;res = re.findall('(.+?)(Assembly|Device|Junction|Line|SubnetLine|Boundary|EdgeObject|JunctionObject)$',&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;name, re.IGNORECASE)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if not res:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;raise ValueError("'{}' did not satisfy regex".format(name))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;else:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;domain, class_type = res[0]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# Structure domain class types are 'Structure(Junction|Line|Boundary)'&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if domain.upper() == 'STRUCTURE':&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;class_type = "Structure" + class_type&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if structure_as_none:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;domain = None&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;return domain, class_type&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Now I can see the creator has put in a "TODO" for him/her/it self to rewrite the function so it can support duplicate class names.&lt;BR /&gt;&lt;BR /&gt;Does anyone have any ideas about how I would go about editing part of the "parse_un_class(class_name: str, structure_as_none: bool = Fals) -&amp;gt; Tuple:" function so it would accept my "_1" UN elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;EM&gt;res = re.findall('(.+?)(Assembly|Device|Junction|Line|SubnetLine|Boundary|EdgeObject|JunctionObject)$',&lt;BR /&gt;name, re.IGNORECASE)&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;to have "_1" at the end like so:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;res = re.findall('(.+?)(Assembly_1|Device_1|Junction_1|Line|SubnetLine_1|Boundary_1|EdgeObject_1|JunctionObject_1)$',&lt;BR /&gt;name, re.IGNORECASE)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;But it throws the same error as before. I don't want to edit too much around in places I have no business editing, but I spend WAY too much time setting up the model to just throw it away and do it again.&lt;BR /&gt;&lt;BR /&gt;Any tips, thoughts or ideas are most welcome!&lt;BR /&gt;&lt;BR /&gt;PS. I can't upgrade to a higher untools version, since I'm forced to stick to the version of our enterprise server where the UNM will eventually end up.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jul 2021 09:03:13 GMT</pubDate>
    <dc:creator>Maulingo</dc:creator>
    <dc:date>2021-07-15T09:03:13Z</dc:date>
    <item>
      <title>Export Assetpackage with UNtools - Problem with duplicate class names (StructureJunction_1)</title>
      <link>https://community.esri.com/t5/water-utilities-questions/export-assetpackage-with-untools-problem-with/m-p/1079139#M1798</link>
      <description>&lt;P&gt;Hi all. I'm trying to use the "Export Assetpackage" function with UNtools (2.6.2) but I'm running into a rather annoying error, and I'm hoping someone might be able to help me correct it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Due to me testing out some other functions regarding dataloading workbooks I have created more than one Utility network in the same local geodatabase. This has resulted in me having class names ending with "_1" in the second Utility network I created. This goes for all the different names in that utility network model.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Example of name problem" style="width: 220px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18509iF0AD5D319F0BD18B/image-size/large?v=v2&amp;amp;px=999" role="button" title="UNTools_Problem_1.JPG" alt="Example of name problem" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Example of name problem&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I try to export this UN to an assetpackage, I get the following error:&lt;/P&gt;&lt;P&gt;"line 623, in parse_un_class&lt;BR /&gt;raise ValueError("'{}' did not satisfy regex".format(name))&lt;BR /&gt;ValueError: 'StructureBoundary_1' did not satisfy regex"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I take a look at line 623 in the "common.py" file the error refers to it to be part of the following function:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;@lru_cache()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;def parse_un_class(class_name: str, structure_as_none: bool = False) -&amp;gt; Tuple:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"""Parses class_name to extract the domain name and class type&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Args:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;class_name (str): The path to the UN class.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;structure_as_none (bool): Return Structure Network as ``None``; defaults to ``False``.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Returns:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;tuple: (Domain name, class type)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Examples:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt; parse_un_class("Naper.un.ElectricLine")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;("Electric", "Line")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt; parse_un_class("C:/con.sde/Naper.un.Electric/Naper.un.StructureBoundary")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;("Structure", "StructureBoundary")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt;&amp;gt; parse_un_class("C:/con.sde/Naper.un.Electric/Naper.un.StructureBoundary", structure_as_none=True)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(None, "StructureBoundary")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Raises:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ValueError: If ``class_name`` is not a valid UN class.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"""&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if class_name is None:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;return None, None&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# TODO: rewrite this to handle duplicate class names (eg StructureJunction_2)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;name = os.path.split(class_name)[-1].rpartition('.')[-1]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# Using lazy quantifier so Subnet is included with Line and not the domain name&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;res = re.findall('(.+?)(Assembly|Device|Junction|Line|SubnetLine|Boundary|EdgeObject|JunctionObject)$',&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;name, re.IGNORECASE)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if not res:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;raise ValueError("'{}' did not satisfy regex".format(name))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;else:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;domain, class_type = res[0]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;# Structure domain class types are 'Structure(Junction|Line|Boundary)'&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if domain.upper() == 'STRUCTURE':&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;class_type = "Structure" + class_type&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if structure_as_none:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;domain = None&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;return domain, class_type&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Now I can see the creator has put in a "TODO" for him/her/it self to rewrite the function so it can support duplicate class names.&lt;BR /&gt;&lt;BR /&gt;Does anyone have any ideas about how I would go about editing part of the "parse_un_class(class_name: str, structure_as_none: bool = Fals) -&amp;gt; Tuple:" function so it would accept my "_1" UN elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;EM&gt;res = re.findall('(.+?)(Assembly|Device|Junction|Line|SubnetLine|Boundary|EdgeObject|JunctionObject)$',&lt;BR /&gt;name, re.IGNORECASE)&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;to have "_1" at the end like so:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;res = re.findall('(.+?)(Assembly_1|Device_1|Junction_1|Line|SubnetLine_1|Boundary_1|EdgeObject_1|JunctionObject_1)$',&lt;BR /&gt;name, re.IGNORECASE)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;But it throws the same error as before. I don't want to edit too much around in places I have no business editing, but I spend WAY too much time setting up the model to just throw it away and do it again.&lt;BR /&gt;&lt;BR /&gt;Any tips, thoughts or ideas are most welcome!&lt;BR /&gt;&lt;BR /&gt;PS. I can't upgrade to a higher untools version, since I'm forced to stick to the version of our enterprise server where the UNM will eventually end up.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 09:03:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/water-utilities-questions/export-assetpackage-with-untools-problem-with/m-p/1079139#M1798</guid>
      <dc:creator>Maulingo</dc:creator>
      <dc:date>2021-07-15T09:03:13Z</dc:date>
    </item>
  </channel>
</rss>

