-
Notifications
You must be signed in to change notification settings - Fork 22
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
Refactor github backup script #63
Refactor github backup script #63
Conversation
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.
Looks great! Just a couple of comments, mostly style related so feel free to ignore those. +1 for pep8! 😃
backup_github.py
Outdated
gh = Github(user, password) | ||
repos_l = [] # list of repos iterators | ||
for org in organizations: | ||
gh_org = gh.get_organization(org) |
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.
Just to be picky, maybe consider renaming some variables here? 😉 Perhaps github_instance instead of gh, repositories instead of repos_l, organization instead of org, and github_organization instead of gh_org, or something similar?
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.
Yes, I might have some personal abbreviations which I don't realise are not common to everyone
backup_github.py
Outdated
except CalledProcessError as e: | ||
logger.error("ERROR: Error cloning repository {}, " | ||
"skipping it".format(repo.name)) | ||
logger.error(str(e)) | ||
pass |
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.
Should this be indented one more time? 🤔
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.
I think it can be deleted - doesn't look like it is doing anything to me..
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.
Very good catch!
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.
@ewels, true. except-pass
doesn't do anything else than the default for just except
right?
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.
It’s not even that. pass
does literally nothing, but you need something after except
to avoid an indentation error. So if you have any code there at all it’s not necessary (eg. a log message)
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.
It’s not even that
I mean, it’s not a default (assuming that a default usually does something)
backup_github.py
Outdated
pass | ||
|
||
def compressAndMove(source): | ||
|
||
def compressAndMove(source, final_dest): |
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.
For pep8: function names should be lowercase, with words separated by underscores
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.
Fixed!
Ended up rewriting most of the code. It's now: