Skip to content

Commit

Permalink
Merge pull request #116 from openmsr/allow_custom_delimited_tags
Browse files Browse the repository at this point in the history
add an option to set the delimiter to something custom
  • Loading branch information
ebknudsen authored Sep 10, 2024
2 parents 2ce5250 + fa9ee0d commit 9f20fdc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/CAD_to_OpenMC/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ def __init__(
self.sequential_tags = None
self.implicit_complement = implicit_complement
self.noextract_tags = True
self.tag_delim_pattern=r"^([^\s_@]+)"


@classmethod
def hdf5_in_moab(cls):
Expand All @@ -222,6 +224,9 @@ def hdf5_in_moab(cls):
)
return True

def set_tag_delim(self,delimiters: str):
self.tag_delim_pattern=r"^([^" + delimiters + r"]+)"

def dummy_h5m(self):
mbc, mbt = self.init_moab()
mbc.write_file("dummy.h5m")
Expand Down Expand Up @@ -315,7 +320,7 @@ def import_stp_files(
try:
s = gmsh.model.getEntityName(3, vid)
part = s.split("/")[-1]
g = re.match(r"^([^\s_@]+)", part)
g = re.match(self.tag_delim_pattern, part)
tag = unidecode(g[0])
if self.verbose > 1:
print(
Expand Down Expand Up @@ -351,7 +356,7 @@ def import_stp_files(
tag = self.default_tag
else:
#use tag from stepfile
g = re.match(r"^([^\s_@]+)", part)
g = re.match(self.tag_delim_pattern, part)
tags_set = tags_set + 1
tag=g[0]
else:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def testdb_wpartialtags():
t.check_tags(['zirconium'])
t.cleanup()

def testdb_switch_delims():
t = HarnessDB()
t.a.set_tag_delim('o')
t.run(merge=True, cleanup=False)
t.check_tags(['h2','zirc','u'])
t.cleanup()

if __name__=='__main__':
testdb()
testdb_wmerge()

0 comments on commit 9f20fdc

Please sign in to comment.