[ckan-changes] commit/datautil: pudo: minor fixes
Bitbucket
commits-noreply at bitbucket.org
Fri Aug 26 06:32:29 UTC 2011
1 new changeset in datautil:
http://bitbucket.org/okfn/datautil/changeset/b8d13d135371/
changeset: b8d13d135371
user: pudo
date: 2011-08-26 08:31:36
summary: minor fixes
affected #: 3 files (961 bytes)
--- a/datautil/cache.py Thu Apr 28 14:12:51 2011 +0200
+++ b/datautil/cache.py Fri Aug 26 08:31:36 2011 +0200
@@ -95,8 +95,9 @@
:param overwrite: overwrite destination file if it exists (defaults to
False).
'''
+ url = url.encode('utf-8')
if not os.path.exists(dest) or overwrite:
- print 'Retrieving %s' % url
+ print 'Retrieving %s' % url
prog = _Progress()
urllib.urlretrieve(url, dest, reporthook=prog.dl_progress)
else:
--- a/datautil/normalization/table_based.py Thu Apr 28 14:12:51 2011 +0200
+++ b/datautil/normalization/table_based.py Fri Aug 26 08:31:36 2011 +0200
@@ -31,15 +31,23 @@
return item in self.keys()
def get(self, key, source_hint=None):
+ if key is None:
+ return {}
+ record = self.lookup(key)
+ if record:
+ return record
+ return self.add(_transform_key(key), source_hint).content
+
+ def lookup(self, key):
if key is None:
return {}
- key = _transform_key(key)
+ local_key = _transform_key(unicode(key))
for record in self.records:
# TODO #1: figure out FindRecords syntax
# TODO #2: fuzzy matching for longer keys
- if record.get(self.key_row) == key:
+ if record.get(self.key_row) == local_key:
return record
- return self.add(key, source_hint).content
+
def add(self, value, source_hint):
fields = self.table.fields
@@ -60,7 +68,7 @@
if key in self.second:
return self.second.get(key)
data = self.first.get(key, source_hint=source_hint)
- if self.second.key_row in data:
+ if self.second.key_row in data:
data.update(self.second.get(data.get(self.second.key_row)))
return data
Repository URL: https://bitbucket.org/okfn/datautil/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list