Use string literal delimiters consistently (triple double-quotes for docstrings, [triple] single quotes for everything else where feasible).
This commit is contained in:
42
gitfiti.py
42
gitfiti.py
@ -135,7 +135,7 @@ def str_to_sprite(content):
|
|||||||
return split_lines
|
return split_lines
|
||||||
|
|
||||||
|
|
||||||
ONEUP_STR = str_to_sprite("""
|
ONEUP_STR = str_to_sprite('''
|
||||||
*******
|
*******
|
||||||
*=~~-~~=*
|
*=~~-~~=*
|
||||||
*~~---~~*
|
*~~---~~*
|
||||||
@ -143,7 +143,7 @@ ONEUP_STR = str_to_sprite("""
|
|||||||
**-*-*-**
|
**-*-*-**
|
||||||
*-----*
|
*-----*
|
||||||
*****
|
*****
|
||||||
""")
|
''')
|
||||||
|
|
||||||
|
|
||||||
IMAGES = {
|
IMAGES = {
|
||||||
@ -198,7 +198,7 @@ def get_calendar(username, base_url='https://github.com/'):
|
|||||||
url = base_url + '/contributions'
|
url = base_url + '/contributions'
|
||||||
page = urllib2.urlopen(url)
|
page = urllib2.urlopen(url)
|
||||||
except (urllib2.HTTPError, urllib2.URLError) as e:
|
except (urllib2.HTTPError, urllib2.URLError) as e:
|
||||||
print("There was a problem fetching data from {0}".format(url))
|
print('There was a problem fetching data from {0}'.format(url))
|
||||||
print(e)
|
print(e)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ def max_commits(input):
|
|||||||
|
|
||||||
for line in input:
|
for line in input:
|
||||||
for day in line.split():
|
for day in line.split():
|
||||||
if "data-count=" in day:
|
if 'data-count=' in day:
|
||||||
commit = day.split('=')[1]
|
commit = day.split('=')[1]
|
||||||
commit = commit.strip('"')
|
commit = commit.strip('"')
|
||||||
output.add(int(commit))
|
output.add(int(commit))
|
||||||
@ -267,9 +267,9 @@ def values_in_date_order(image, multiplier=1):
|
|||||||
|
|
||||||
def commit(content, commitdate):
|
def commit(content, commitdate):
|
||||||
template = (
|
template = (
|
||||||
"""echo {0} >> gitfiti\n"""
|
'''echo {0} >> gitfiti\n'''
|
||||||
"""GIT_AUTHOR_DATE={1} GIT_COMMITTER_DATE={2} """
|
'''GIT_AUTHOR_DATE={1} GIT_COMMITTER_DATE={2} '''
|
||||||
"""git commit -a -m "gitfiti" > /dev/null\n"""
|
'''git commit -a -m "gitfiti" > /dev/null\n'''
|
||||||
)
|
)
|
||||||
return template.format(content, commitdate.isoformat(),
|
return template.format(content, commitdate.isoformat(),
|
||||||
commitdate.isoformat())
|
commitdate.isoformat())
|
||||||
@ -298,26 +298,26 @@ def fake_it(image, start_date, username, repo, offset=0, multiplier=1,
|
|||||||
for i in range(value):
|
for i in range(value):
|
||||||
strings.append(commit(i, date))
|
strings.append(commit(i, date))
|
||||||
|
|
||||||
return template.format(repo, "".join(strings), git_url, username)
|
return template.format(repo, ''.join(strings), git_url, username)
|
||||||
|
|
||||||
|
|
||||||
def save(output, filename):
|
def save(output, filename):
|
||||||
"""Saves the list to a given filename"""
|
"""Saves the list to a given filename"""
|
||||||
with open(filename, "w") as f:
|
with open(filename, 'w') as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print(TITLE)
|
print(TITLE)
|
||||||
|
|
||||||
print("Enter github url")
|
print('Enter github url')
|
||||||
ghe = raw_input("Enter nothing for https://github.com/ to be used: ")
|
ghe = raw_input('Enter nothing for https://github.com/ to be used: ')
|
||||||
|
|
||||||
print('Enter your github username:')
|
print('Enter your github username:')
|
||||||
username = raw_input(">")
|
username = raw_input('>')
|
||||||
|
|
||||||
if not ghe:
|
if not ghe:
|
||||||
git_base = "https://github.com/"
|
git_base = 'https://github.com/'
|
||||||
cal = get_calendar(username)
|
cal = get_calendar(username)
|
||||||
else:
|
else:
|
||||||
cal = get_calendar(username, base_url=ghe)
|
cal = get_calendar(username, base_url=ghe)
|
||||||
@ -326,10 +326,10 @@ def main():
|
|||||||
m = multiplier(max_commits(cal))
|
m = multiplier(max_commits(cal))
|
||||||
|
|
||||||
print('Enter name of the repo to be used by gitfiti:')
|
print('Enter name of the repo to be used by gitfiti:')
|
||||||
repo = raw_input(">")
|
repo = raw_input('>')
|
||||||
|
|
||||||
print('Enter the number of weeks to offset the image (from the left):')
|
print('Enter the number of weeks to offset the image (from the left):')
|
||||||
offset = raw_input(">")
|
offset = raw_input('>')
|
||||||
|
|
||||||
if not offset.strip():
|
if not offset.strip():
|
||||||
offset = 0
|
offset = 0
|
||||||
@ -346,21 +346,21 @@ def main():
|
|||||||
'(this option generates WAY more commits)\n'
|
'(this option generates WAY more commits)\n'
|
||||||
'Any other input will cause the default matching behavior'
|
'Any other input will cause the default matching behavior'
|
||||||
).format(max_commits(cal)))
|
).format(max_commits(cal)))
|
||||||
match = raw_input(">")
|
match = raw_input('>')
|
||||||
|
|
||||||
if match == "gitfiti":
|
if match == 'gitfiti':
|
||||||
match = m
|
match = m
|
||||||
else:
|
else:
|
||||||
match = 1
|
match = 1
|
||||||
|
|
||||||
print('enter file(s) to load images from (blank if not applicable)')
|
print('enter file(s) to load images from (blank if not applicable)')
|
||||||
img_names = raw_input(">").split(' ')
|
img_names = raw_input('>').split(' ')
|
||||||
|
|
||||||
images = dict(IMAGES, **load_images(img_names))
|
images = dict(IMAGES, **load_images(img_names))
|
||||||
|
|
||||||
print('enter the image name to gitfiti')
|
print('enter the image name to gitfiti')
|
||||||
print('images: ' + ", ".join(images.keys()))
|
print('images: ' + ', '.join(images.keys()))
|
||||||
image = raw_input(">")
|
image = raw_input('>')
|
||||||
|
|
||||||
if not image:
|
if not image:
|
||||||
image = IMAGES['kitty']
|
image = IMAGES['kitty']
|
||||||
@ -374,7 +374,7 @@ def main():
|
|||||||
output = fake_it(image, get_start_date(), username, repo,
|
output = fake_it(image, get_start_date(), username, repo,
|
||||||
offset, m * match)
|
offset, m * match)
|
||||||
else:
|
else:
|
||||||
git_url = raw_input("Enter git url like git@site.github.com: ")
|
git_url = raw_input('Enter git url like git@site.github.com: ')
|
||||||
output = fake_it(image, get_start_date(), username, repo,
|
output = fake_it(image, get_start_date(), username, repo,
|
||||||
offset, m * match, git_url=git_url)
|
offset, m * match, git_url=git_url)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user