From a76dd860f302dac91202e2c4e9c4aec41f7d1089 Mon Sep 17 00:00:00 2001 From: Jochen Kupperschmidt Date: Sun, 5 Jun 2016 22:34:19 +0200 Subject: [PATCH] Use string literal delimiters consistently (triple double-quotes for docstrings, [triple] single quotes for everything else where feasible). --- gitfiti.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gitfiti.py b/gitfiti.py index 871f0017c..88e6ebe8e 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -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)