-
Notifications
You must be signed in to change notification settings - Fork 2
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
modularize the script #7
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Sanjana Nayar <[email protected]>
reparo.py
Outdated
PATH_TO_FILE2 = items2.replace(dirname, '') | ||
PATH_TO_FILE = PATH_TO_FILE2.strip('/') | ||
CHAOSS_HTTP = "https://api.github.com/repos/chaoss/" | ||
LINK = "https://api.github.com/repos/chaoss/" |
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.
seems like this is a constant variable, how about putting this on the top?
Hi @sanjana091001 Let me know if you have any doubts. Thanks for the effort. :) |
years = "2015-2020" | ||
owner = "Bitergia" |
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.
these are constants too
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.
Hi @sanjana091001
I have left some comments, please check and solve them.Let me know if you have any doubts.
Also, push commits to this branch. After this PR becomes perfect, you can merge all the commits into a single commit.Thanks for the effort. :)
yup!
I'll make the changes
Signed-off-by: Sanjana Nayar <[email protected]>
with open(file_name, 'r') as f: | ||
contents = f.readlines() | ||
i = 0 | ||
for item in contents: | ||
if item.startswith('#'): | ||
i += 1 | ||
|
||
with open(items2, 'w') as f: | ||
with open(file_name, 'w') as f: | ||
f.writelines(contents[i:]) | ||
|
||
with open(items2, 'r') as f: | ||
with open(file_name, 'r') as f: | ||
contents = f.readlines() | ||
contents.insert(0, result+"\n") | ||
|
||
with open(items2, 'w') as f: | ||
with open(file_name, 'w') as f: | ||
contents = "".join(contents) | ||
f.write(contents) |
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.
How about having the whole thing in one seperate function?
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.
seems like all these steps are being called in a for
loop
https://github.com/vchrombie/reparo/pull/7/files#r399426460
we just need to replace the license only once, and that too in the last step
for item in FILES: | ||
api_func(item, dirname) |
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.
Signed-off-by: Sanjana Nayar [email protected]