[github] uniform indentation

This commit is contained in:
依云 2016-03-14 15:13:31 +08:00
parent 89acf137a0
commit 3c97b5c693

View file

@ -16,14 +16,14 @@ def get_version(name, conf, callback):
use_max_tag = conf.getboolean('use_max_tag', False) use_max_tag = conf.getboolean('use_max_tag', False)
ignored_tags = conf.get("ignored_tags", "").split() ignored_tags = conf.get("ignored_tags", "").split()
if use_latest_release: if use_latest_release:
url = GITHUB_LATEST_RELEASE % repo url = GITHUB_LATEST_RELEASE % repo
elif use_max_tag: elif use_max_tag:
url = GITHUB_MAX_TAG % repo url = GITHUB_MAX_TAG % repo
else: else:
url = GITHUB_URL % (repo, br) url = GITHUB_URL % (repo, br)
headers = {'Accept': "application/vnd.github.quicksilver-preview+json"} headers = {'Accept': "application/vnd.github.quicksilver-preview+json"}
if 'NVCHECKER_GITHUB_TOKEN' in os.environ: if 'NVCHECKER_GITHUB_TOKEN' in os.environ:
headers['Authorization'] = 'token %s' % os.environ['NVCHECKER_GITHUB_TOKEN'] headers['Authorization'] = 'token %s' % os.environ['NVCHECKER_GITHUB_TOKEN']
request = HTTPRequest(url, headers=headers, user_agent='lilydjwg/nvchecker') request = HTTPRequest(url, headers=headers, user_agent='lilydjwg/nvchecker')
AsyncHTTPClient().fetch(request, AsyncHTTPClient().fetch(request,
callback=partial(_github_done, name, use_latest_release, use_max_tag, ignored_tags, callback)) callback=partial(_github_done, name, use_latest_release, use_max_tag, ignored_tags, callback))
@ -31,13 +31,13 @@ def get_version(name, conf, callback):
def _github_done(name, use_latest_release, use_max_tag, ignored_tags, callback, res): def _github_done(name, use_latest_release, use_max_tag, ignored_tags, callback, res):
data = json.loads(res.body.decode('utf-8')) data = json.loads(res.body.decode('utf-8'))
if use_latest_release: if use_latest_release:
version = data['tag_name'] version = data['tag_name']
elif use_max_tag: elif use_max_tag:
data = [tag["name"] for tag in data if tag["name"] not in ignored_tags] data = [tag["name"] for tag in data if tag["name"] not in ignored_tags]
data.sort(key=parse_version) data.sort(key=parse_version)
version = data[-1] version = data[-1]
else: else:
# YYYYMMDD.HHMMSS # YYYYMMDD.HHMMSS
version = data[0]['commit']['committer']['date'] \ version = data[0]['commit']['committer']['date'] \
.replace('-', '').replace(':', '').replace('T', '.') .replace('-', '').replace(':', '').replace('T', '.')
callback(name, version) callback(name, version)