Use string literal delimiters consistently (triple double-quotes for docstrings, [triple] single quotes for everything else where feasible).

This commit is contained in:
Jochen Kupperschmidt
2016-06-05 22:34:19 +02:00
parent b717414e7b
commit a76dd860f3

View File

@ -135,7 +135,7 @@ def str_to_sprite(content):
return split_lines
ONEUP_STR = str_to_sprite("""
ONEUP_STR = str_to_sprite('''
*******
*=~~-~~=*
*~~---~~*
@ -143,7 +143,7 @@ ONEUP_STR = str_to_sprite("""
**-*-*-**
*-----*
*****
""")
''')
IMAGES = {
@ -198,7 +198,7 @@ def get_calendar(username, base_url='https://github.com/'):
url = base_url + '/contributions'
page = urllib2.urlopen(url)
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)
raise SystemExit
@ -211,7 +211,7 @@ def max_commits(input):
for line in input:
for day in line.split():
if "data-count=" in day:
if 'data-count=' in day:
commit = day.split('=')[1]
commit = commit.strip('"')
output.add(int(commit))
@ -267,9 +267,9 @@ def values_in_date_order(image, multiplier=1):
def commit(content, commitdate):
template = (
"""echo {0} >> gitfiti\n"""
"""GIT_AUTHOR_DATE={1} GIT_COMMITTER_DATE={2} """
"""git commit -a -m "gitfiti" > /dev/null\n"""
'''echo {0} >> gitfiti\n'''
'''GIT_AUTHOR_DATE={1} GIT_COMMITTER_DATE={2} '''
'''git commit -a -m "gitfiti" > /dev/null\n'''
)
return template.format(content, 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):
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):
"""Saves the list to a given filename"""
with open(filename, "w") as f:
with open(filename, 'w') as f:
f.write(output)
def main():
print(TITLE)
print("Enter github url")
ghe = raw_input("Enter nothing for https://github.com/ to be used: ")
print('Enter github url')
ghe = raw_input('Enter nothing for https://github.com/ to be used: ')
print('Enter your github username:')
username = raw_input(">")
username = raw_input('>')
if not ghe:
git_base = "https://github.com/"
git_base = 'https://github.com/'
cal = get_calendar(username)
else:
cal = get_calendar(username, base_url=ghe)
@ -326,10 +326,10 @@ def main():
m = multiplier(max_commits(cal))
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):')
offset = raw_input(">")
offset = raw_input('>')
if not offset.strip():
offset = 0
@ -346,21 +346,21 @@ def main():
'(this option generates WAY more commits)\n'
'Any other input will cause the default matching behavior'
).format(max_commits(cal)))
match = raw_input(">")
match = raw_input('>')
if match == "gitfiti":
if match == 'gitfiti':
match = m
else:
match = 1
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))
print('enter the image name to gitfiti')
print('images: ' + ", ".join(images.keys()))
image = raw_input(">")
print('images: ' + ', '.join(images.keys()))
image = raw_input('>')
if not image:
image = IMAGES['kitty']
@ -374,7 +374,7 @@ def main():
output = fake_it(image, get_start_date(), username, repo,
offset, m * match)
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,
offset, m * match, git_url=git_url)