Skip to content

Commit

Permalink
#5: Code in docs/__init__.py made interpreter independent.
Browse files Browse the repository at this point in the history
Partially rewritten to list comprehensions.
  • Loading branch information
Bystroushaak committed Apr 25, 2015
1 parent b8a8b6b commit b3a2692
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
0.4.1
-----
- Merged #5 to fix ``docs/__init__.py``, which didn't work at Python 3.
- Rewritten ``docs/__init__.py``, when the merge for Python 3 broken Python 2 support.

0.4.0
-----
Expand Down
21 changes: 14 additions & 7 deletions docs/__init__.py
100644 → 100755
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
))

0 comments on commit b3a2692

Please sign in to comment.