-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5: Code in docs/__init__.py made interpreter independent.
Partially rewritten to list comprehensions.
- Loading branch information
1 parent
b8a8b6b
commit b3a2692
Showing
2 changed files
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Interpreter version: python 2.7, 3.4 | ||
# | ||
|
||
|
||
def allSame(s): | ||
return not filter(lambda x: x != s[0], s) | ||
return not any(filter(lambda x: x != s[0], s)) | ||
|
||
|
||
def hasDigit(s): | ||
return any(map(lambda x: x.isdigit(), s)) | ||
return any(char.isdigit() for char in s) | ||
|
||
|
||
def getVersion(data): | ||
""" | ||
Parse version from changelog written in RST format. | ||
""" | ||
data = data.splitlines() | ||
return filter( | ||
lambda x, y: | ||
len(x) == len(y) and allSame(y) and hasDigit(x) and "." in x, | ||
zip(data, data[1:]) | ||
)[0][0] | ||
return next(( | ||
v | ||
for v, u in zip(data, data[1:]) # v = version, u = underline | ||
if len(v) == len(u) and allSame(u) and hasDigit(v) and "." in v | ||
)) |