[Python-modules-commits] [python-pyld] 03/05: Reduce nesting.
Wolfgang Borgert
debacle at moszumanska.debian.org
Tue Oct 13 22:56:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag 0.6.7
in repository python-pyld.
commit 1f140dc9fcf1a4e846833dfce62d0fcf49b72d59
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Mon Jan 19 18:32:00 2015 -0500
Reduce nesting.
---
lib/pyld/jsonld.py | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 8f71844..32bb8e5 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -3536,28 +3536,28 @@ class JsonLdProcessor(object):
direction = 'p'
else:
bnode = self._get_adjacent_bnode_name(quad['object'], id_)
- if bnode is not None:
- # reference property
- direction = 'r'
-
- if bnode is not None:
- # get bnode name (try canonical, path, then hash)
- if namer.is_named(bnode):
- name = namer.get_name(bnode)
- elif path_namer.is_named(bnode):
- name = path_namer.get_name(bnode)
- else:
- name = self._hash_quads(bnode, bnodes)
+ if bnode is None:
+ continue
+ # reference property
+ direction = 'r'
+
+ # get bnode name (try canonical, path, then hash)
+ if namer.is_named(bnode):
+ name = namer.get_name(bnode)
+ elif path_namer.is_named(bnode):
+ name = path_namer.get_name(bnode)
+ else:
+ name = self._hash_quads(bnode, bnodes)
- # hash direction, property, and bnode name/hash
- group_md = hashlib.sha1()
- group_md.update(direction.encode('utf-8'))
- group_md.update(quad['predicate']['value'].encode('utf-8'))
- group_md.update(name.encode('utf-8'))
- group_hash = group_md.hexdigest()
+ # hash direction, property, and bnode name/hash
+ group_md = hashlib.sha1()
+ group_md.update(direction.encode('utf-8'))
+ group_md.update(quad['predicate']['value'].encode('utf-8'))
+ group_md.update(name.encode('utf-8'))
+ group_hash = group_md.hexdigest()
- # add bnode to hash group
- groups.setdefault(group_hash, []).append(bnode)
+ # add bnode to hash group
+ groups.setdefault(group_hash, []).append(bnode)
# iterate over groups in sorted hash order
for group_hash, group in sorted(groups.items()):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git
More information about the Python-modules-commits
mailing list