-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| for elem in slide_dict: | ||
| if type(slide_dict[elem]) != list: | ||
| if slide_dict[elem].startswith("song") or slide_dict[elem].startswith("psalm"): | ||
| song_list.append(elem) | ||
| elif slide_dict[elem].startswith("catechism"): | ||
| catechism_list.append(elem) | ||
| elif type(slide_dict[elem]) == list: | ||
| for elem, value in slide_dict.items(): | ||
| if type(value) == list: | ||
| if "reading" in slide_dict[elem][0]: | ||
| reading_list.append(elem) | ||
| elif slide_dict[elem][0] not in ['call_to_worship'] and slide_dict[elem][0] not in ['prayers']: | ||
| elif slide_dict[elem][0] not in ['call_to_worship', 'prayers']: | ||
| component_list.append(elem) | ||
|
|
||
| elif slide_dict[elem].startswith("song") or slide_dict[elem].startswith("psalm"): | ||
| song_list.append(elem) | ||
| elif slide_dict[elem].startswith("catechism"): | ||
| catechism_list.append(elem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 125-134 refactored with the following changes:
- Use items() to directly unpack dictionary values (
use-dict-items) - Swap if/else branches (
swap-if-else-branches) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Remove redundant conditional (
remove-redundant-if) - Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| params = { | ||
| 'q': passage, | ||
| 'include-headings': False, | ||
| 'include-footnotes': False, | ||
| 'include-verse-numbers': True, | ||
| 'include-short-copyright': False, | ||
| 'include-passage-references': False | ||
| } | ||
|
|
||
| headers = { | ||
| 'Authorization': 'Token %s' % API_KEY | ||
| } | ||
|
|
||
| response = requests.get(API_URL, params=params, headers=headers) | ||
|
|
||
| passages = response.json()['passages'] | ||
|
|
||
| result = passages[0].strip() | ||
| result = super_verse(result) | ||
| result = replace_text(result) | ||
|
|
||
| if passages: | ||
| return (result,passage) | ||
| else: | ||
| return 'Error: Passage not found' | ||
| params = { | ||
| 'q': passage, | ||
| 'include-headings': False, | ||
| 'include-footnotes': False, | ||
| 'include-verse-numbers': True, | ||
| 'include-short-copyright': False, | ||
| 'include-passage-references': False | ||
| } | ||
|
|
||
| headers = {'Authorization': f'Token {API_KEY}'} | ||
|
|
||
| response = requests.get(API_URL, params=params, headers=headers) | ||
|
|
||
| passages = response.json()['passages'] | ||
|
|
||
| result = passages[0].strip() | ||
| result = super_verse(result) | ||
| result = replace_text(result) | ||
|
|
||
| return (result, passage) if passages else 'Error: Passage not found' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_esv_text refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Replace if statement with if expression (
assign-if-exp)
| match = re.search(r"^(Psalm )?(\d{1,3})(:(([1-9]\d{0,2})-([1-9]\d{0,2})))?(\s\(([a-zA-Z])\))?(\s\((\d{0,2})\))?$", psalm_name) | ||
|
|
||
| if match: | ||
| if match := re.search( | ||
| r"^(Psalm )?(\d{1,3})(:(([1-9]\d{0,2})-([1-9]\d{0,2})))?(\s\(([a-zA-Z])\))?(\s\((\d{0,2})\))?$", | ||
| psalm_name, | ||
| ): | ||
| if match.group(2): | ||
| psalm = match.group(2) | ||
| if match.group(7): | ||
| version = match.group(8) | ||
| else: | ||
| version = "a" | ||
| if match.group(9): | ||
| section = match.group(10) | ||
| else: | ||
| section = None | ||
| version = match.group(8) if match.group(7) else "a" | ||
| section = match.group(10) if match.group(9) else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function psalm_getter refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Use x is None rather than x == None (
none-compare) - Replace if statement with if expression [×2] (
assign-if-exp)
| slide = prs.slides.add_slide(slide_layout) | ||
| return slide | ||
| return prs.slides.add_slide(slide_layout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function slide_maker refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| params = { | ||
| 'q': passage, | ||
| 'include-headings': False, | ||
| 'include-footnotes': False, | ||
| 'include-verse-numbers': True, | ||
| 'include-short-copyright': False, | ||
| 'include-passage-references': False | ||
| } | ||
|
|
||
| headers = { | ||
| 'Authorization': 'Token %s' % API_KEY | ||
| } | ||
|
|
||
| response = requests.get(API_URL, params=params, headers=headers) | ||
|
|
||
| passages = response.json()['passages'] | ||
| params = { | ||
| 'q': passage, | ||
| 'include-headings': False, | ||
| 'include-footnotes': False, | ||
| 'include-verse-numbers': True, | ||
| 'include-short-copyright': False, | ||
| 'include-passage-references': False | ||
| } | ||
|
|
||
| result = passages[0].strip() | ||
| result = super_verse(result) | ||
| result = replace_text(result) | ||
|
|
||
| if passages: | ||
| return (result,passage) | ||
| else: | ||
| return 'Error: Passage not found' | ||
| headers = {'Authorization': f'Token {API_KEY}'} | ||
|
|
||
| response = requests.get(API_URL, params=params, headers=headers) | ||
|
|
||
| passages = response.json()['passages'] | ||
|
|
||
| result = passages[0].strip() | ||
| result = super_verse(result) | ||
| result = replace_text(result) | ||
|
|
||
| return (result, passage) if passages else 'Error: Passage not found' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_esv_text refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Replace if statement with if expression (
assign-if-exp)
| match = re.search(r"^(Psalm )?(\d{1,3})(:(([1-9]\d{0,2})-([1-9]\d{0,2})))?(\s\(([a-zA-Z])\))?(\s\((\d{0,2})\))?$", psalm_name) | ||
|
|
||
| if match: | ||
| if match := re.search( | ||
| r"^(Psalm )?(\d{1,3})(:(([1-9]\d{0,2})-([1-9]\d{0,2})))?(\s\(([a-zA-Z])\))?(\s\((\d{0,2})\))?$", | ||
| psalm_name, | ||
| ): | ||
| if match.group(2): | ||
| psalm = match.group(2) | ||
| if match.group(7): | ||
| version = match.group(8) | ||
| else: | ||
| version = "a" | ||
| if match.group(9): | ||
| section = match.group(10) | ||
| else: | ||
| section = None | ||
| version = match.group(8) if match.group(7) else "a" | ||
| section = match.group(10) if match.group(9) else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function psalm_getter refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Use x is None rather than x == None (
none-compare) - Replace if statement with if expression [×2] (
assign-if-exp)
| slide_layout = prs.slide_layouts[layout_type] | ||
| slide = prs.slides.add_slide(slide_layout) | ||
| return slide | ||
| return prs.slides.add_slide(slide_layout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function slide_maker refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| for elem in slide_dict: | ||
| if type(slide_dict[elem]) != list: | ||
| if slide_dict[elem].startswith("song") or slide_dict[elem].startswith("psalm"): | ||
| song_list.append(elem) | ||
| elif slide_dict[elem].startswith("catechism"): | ||
| catechism_list.append(elem) | ||
| elif type(slide_dict[elem]) == list: | ||
| for elem, value in slide_dict.items(): | ||
| if type(value) == list: | ||
| if "reading" in slide_dict[elem][0]: | ||
| reading_list.append(elem) | ||
| elif slide_dict[elem][0] not in ['call_to_worship'] and slide_dict[elem][0] not in ['prayers']: | ||
| elif slide_dict[elem][0] not in ['call_to_worship', 'prayers']: | ||
| component_list.append(elem) | ||
|
|
||
| elif slide_dict[elem].startswith("song") or slide_dict[elem].startswith("psalm"): | ||
| song_list.append(elem) | ||
| elif slide_dict[elem].startswith("catechism"): | ||
| catechism_list.append(elem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 109-118 refactored with the following changes:
- Use items() to directly unpack dictionary values (
use-dict-items) - Swap if/else branches (
swap-if-else-branches) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Remove redundant conditional (
remove-redundant-if) - Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run:Help us improve this pull request!