Skip to content
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

Sourcery refactored master branch #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions gmailApp/gmail_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ def searchMessages(
:param fields:
:return:
"""
params = {}
params['userId'] = userId
params['labelIds'] = labelIds
params['q'] = q
params['pageToken'] = pageToken
params['maxResults'] = maxResults
params['includeSpamTrash'] = includeSpamTrash
params['fields'] = fields
params = {
'userId': userId,
'labelIds': labelIds,
'q': q,
'pageToken': pageToken,
'maxResults': maxResults,
'includeSpamTrash': includeSpamTrash,
'fields': fields,
}

Comment on lines -55 to +64
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GmailApp.searchMessages refactored with the following changes:

  • Merge dictionary assignment with declaration (merge-dict-assign)

return self.__service.users().messages().list(**params).execute()

def deleteMessages(self, ids, userId='me'):
Expand All @@ -72,8 +74,7 @@ def deleteMessages(self, ids, userId='me'):
if not isinstance(ids, list):
raise ValueError('Ids should be a list of id')
else:
body = {}
body['ids'] = ids
body = {'ids': ids}
Comment on lines -75 to +77
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GmailApp.deleteMessages refactored with the following changes:

  • Merge dictionary assignment with declaration (merge-dict-assign)

return self.__service.users().messages().batchDelete(userId=userId, body=body).execute()

def trashMessages(self, messageId, userId='me'):
Expand Down
4 changes: 2 additions & 2 deletions kimsufi/verify-server-availabilty-kimsufi.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def send_mail(me, you, message, subject):
you=args.target,
message='Purchase link : https://www.kimsufi.com/fr/commande/kimsufi.xml?reference=' + args.server,
subject=MAIL_SUBJECT.format(args.server))
logging.info('Done.')
else:
logging.info(args.server + ' not found.')
logging.info('Done.')

logging.info('Done.')
Comment on lines -128 to +131
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 128-131 refactored with the following changes:

  • Hoist repeated code outside conditional statement (hoist-statement-from-if)

8 changes: 4 additions & 4 deletions rancher-services-check-updates/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ def get_last_tag(image_name):
# Ask for credentials if not set on cli
ask = input(
'Image {} unknown\nDo you want to try with your DockerHub credentials ? (y/n) '.format(image_name))
if ask == 'y' or ask == 'Y' or ask == 'yes':
if ask in ['y', 'Y', 'yes']:
DOCKER_HUB_USERNAME = input('Username ? ')
DOCKER_HUB_PASSWORD = input('Password ? ')
else:
return 'undefined (Private repository ?)'

r = get_request(url, jwt_auth=True, token=get_docker_token())
if 'results' not in r:
logging.error('Invalid password or username, by pass')
return 'undefined'
if 'results' not in r:
logging.error('Invalid password or username, by pass')
return 'undefined'
Comment on lines -155 to +164
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_last_tag refactored with the following changes:

  • Hoist conditional out of nested conditional (hoist-if-from-if)
  • Replace multiple comparisons of same variable with in operator (merge-comparisons)


# on each case, return the last tag
for tag in r['results']:
Expand Down