Skip to content

Commit

Permalink
Remove unnecessary else after guard condition
Browse files Browse the repository at this point in the history
  • Loading branch information
bpepple committed Aug 6, 2022
1 parent 5e49550 commit 6bc5af9
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions metrontagger/filerenamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ def is_token(word: str) -> bool:

if value is not None:
return text.replace(token, str(value))

if self.smart_cleanup:
# smart cleanup means we want to remove anything appended to token if it's empty
# (e.g "#%issue%" or "v%volume%")
# (TODO: This could fail if there is more than one token appended together, I guess)
text_list = text.split()

# special case for issuecount, remove preceding non-token word,
# as in "...(of %issuecount%)..."
if token == "%issuecount%":
for idx, word in enumerate(text_list):
if token in word and not is_token(text_list[idx - 1]):
text_list[idx - 1] = ""

text_list = [x for x in text_list if token not in x]
return " ".join(text_list)
else:
if self.smart_cleanup:
# smart cleanup means we want to remove anything appended to token if it's empty
# (e.g "#%issue%" or "v%volume%")
# (TODO: This could fail if there is more than one token appended together, I guess)
text_list = text.split()

# special case for issuecount, remove preceding non-token word,
# as in "...(of %issuecount%)..."
if token == "%issuecount%":
for idx, word in enumerate(text_list):
if token in word and not is_token(text_list[idx - 1]):
text_list[idx - 1] = ""

text_list = [x for x in text_list if token not in x]
return " ".join(text_list)
else:
return text.replace(token, "")
return text.replace(token, "")

@staticmethod
def _remove_empty_separators(value: str) -> str:
Expand Down

0 comments on commit 6bc5af9

Please sign in to comment.