Skip to content

Commit

Permalink
refactor(expandr): minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
dchiller committed Dec 17, 2024
1 parent 814e7e4 commit 40cbbef
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/public/cantusdata/helpers/expandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def expand_mode(mode_code: str) -> str:
"""
mode_code_stripped = mode_code.strip()
mode_output = []
mode_nums = {"1", "2", "3", "4", "5", "6", "7", "8"}
for char in mode_code_stripped:
if char in "12345678":
if char in mode_nums:
mode_output.append(char)
continue
match char:
Expand Down Expand Up @@ -63,14 +64,13 @@ def expand_genre(self, genre_code: str) -> str:
"""
Gets the genre description based on the genre code.
"""
if genre_code in self.genre_data:
description = self.genre_data[genre_code]
# some extra stuff in parentheses is showing up
paren = description.find("(")
return description[: paren - 1] if paren != -1 else description

# If nothing was found, return the original
return genre_code
if not genre_code in self.genre_data:
return genre_code

description = self.genre_data[genre_code]
# some extra stuff in parentheses is showing up
paren = description.find("(")
return description[: paren - 1] if paren != -1 else description


def expand_differentia(differentia_code: str) -> str:
Expand Down

0 comments on commit 40cbbef

Please sign in to comment.