python-stdnum commit: r69 - in python-stdnum: . stdnum
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum commit: r69 - in python-stdnum: . stdnum
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org
- Subject: python-stdnum commit: r69 - in python-stdnum: . stdnum
- Date: Sun, 6 Mar 2011 22:56:22 +0100 (CET)
Author: arthur
Date: Sun Mar 6 22:56:20 2011
New Revision: 69
URL: http://arthurdejong.org/viewvc/python-stdnum?view=rev&revision=69
Log:
also support Python3 with the same codebase (see #3)
Modified:
python-stdnum/setup.py
python-stdnum/stdnum/numdb.py
Modified: python-stdnum/setup.py
==============================================================================
--- python-stdnum/setup.py Sun Mar 6 20:54:49 2011 (r68)
+++ python-stdnum/setup.py Sun Mar 6 22:56:20 2011 (r69)
@@ -29,7 +29,7 @@
# fix permissions for sdist
if 'sdist' in sys.argv:
os.system('chmod -R a+rX .')
- os.umask(022)
+ os.umask(int('022', 8))
setup(name='python-stdnum',
version='0.4',
Modified: python-stdnum/stdnum/numdb.py
==============================================================================
--- python-stdnum/stdnum/numdb.py Sun Mar 6 20:54:49 2011 (r68)
+++ python-stdnum/stdnum/numdb.py Sun Mar 6 22:56:20 2011 (r69)
@@ -1,7 +1,7 @@
# numdb.py - module for handling hierarchically organised numbers
#
-# Copyright (C) 2010 Arthur de Jong
+# Copyright (C) 2010, 2011 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -81,10 +81,13 @@
def _merge(results):
"""Merge the provided list of possible results into a single result
list (this is a generator)."""
- results.append([])
- for parts in map(None, *results):
+ # expand the results to all have the same length
+ ml = max(len(x) for x in results)
+ results = [ x + (ml - len(x)) * [None] for x in results ]
+ # go over each part
+ for parts in zip(*results):
# regroup parts into parts list and properties list
- partlist, proplist = zip(*(x for x in parts if x))
+ partlist, proplist = list(zip(*(x for x in parts if x)))
part = min(partlist, key=len)
props = {}
for p in proplist:
@@ -125,7 +128,7 @@
def _parse(fp):
"""Read lines of text from the file pointer and generate indent, length,
low, high, properties tuples."""
- for line in fp.xreadlines():
+ for line in fp:
# ignore comments
if line[0] == '#' or line.strip() == '':
continue
@@ -159,5 +162,7 @@
def get(name):
"""Opens a database with the specified name to perform queries on."""
if name not in _open_databases:
- _open_databases[name] = read(resource_stream(__name__, name + '.dat'))
+ import codecs
+ reader = codecs.getreader('utf-8')
+ _open_databases[name] = read(reader(resource_stream(__name__, name +
'.dat')))
return _open_databases[name]
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits
- python-stdnum commit: r69 - in python-stdnum: . stdnum,
Commits of the python-stdnum project