Skip to content

Commit 18b0e01

Browse files
Ademola AdefioyeAdemola Adefioye
authored andcommitted
refactoring slugs and name
1 parent 148377e commit 18b0e01

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

src/models/graph_models.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,25 @@ def model_post_init(self, __context: Any) -> None:
2626
word.lower() for word in re.split(r"(?=[A-Z])", self.label) if word
2727
)
2828

29-
def _slugify(text: str) -> str:
30-
return re.sub(r"[^a-z0-9]+", "_", text.lower()).strip("_")
31-
32-
new_alias_slug = new_alias_name
33-
existing_alias = next((a for a in self.aliases if a.name == new_alias_slug), None)
34-
35-
source_urls_val = self.properties.get("sourceUrls", "")
36-
if isinstance(source_urls_val, list):
37-
new_urls = [
38-
url.strip() for url in source_urls_val if isinstance(url, str) and url.strip()
39-
]
40-
elif isinstance(source_urls_val, str):
41-
new_urls = (
42-
[url.strip() for url in source_urls_val.split(",") if url.strip()]
43-
if source_urls_val
44-
else []
45-
)
46-
else:
47-
new_urls = []
29+
existing_alias = next((a for a in self.aliases if a.name == new_alias_name), None)
4830

4931
if not existing_alias:
32+
source_urls_val = self.properties.get("sourceUrls", "")
33+
if isinstance(source_urls_val, list):
34+
new_urls = [
35+
url.strip()
36+
for url in source_urls_val
37+
if isinstance(url, str) and url.strip()
38+
]
39+
elif isinstance(source_urls_val, str):
40+
new_urls = (
41+
[url.strip() for url in source_urls_val.split(",") if url.strip()]
42+
if source_urls_val
43+
else []
44+
)
45+
else:
46+
new_urls = []
47+
5048
new_alias = Alias(name=new_alias_name, source_files=new_urls)
5149
self.aliases.append(new_alias)
5250

0 commit comments

Comments
 (0)