Skip to content

Commit

Permalink
Update the add_url_include function
Browse files Browse the repository at this point in the history
  • Loading branch information
code-geek committed Nov 30, 2023
1 parent 706841b commit 1c1484d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions config_generation/db_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,19 @@ def add_url_include(self, url_pattern: str) -> None:
includes a url or url pattern, such as
- https://webb.nasa.gov/content/forEducators/realworld*
- https://webb.nasa.gov/content/features/index.html
- *.rtf
I'm not sure if exclusion rules override includes or if includes override
exclusion rules.
"""

xml_root = self.xml_tree.getroot()
ET.SubElement(
xml_root, "UrlIndexIncluded"
).text = url_pattern # this adds an indexing rule (doesn't overwrite)

for url_index_included in xml_root.findall("UrlIndexIncluded"):
if url_index_included.text == url_pattern:
return # stop the function if the url pattern already exists

# add the url pattern if it doesn't already exist
ET.SubElement(xml_root, "UrlIndexIncluded").text = url_pattern

def _find_treeroot_field(self):
treeroot = self.xml_tree.find("TreeRoot")
Expand Down

0 comments on commit 1c1484d

Please sign in to comment.