Skip to content

Commit 570d5aa

Browse files
committed
externalize generation of internal id to a helper method [ci skip]
1 parent adcb93d commit 570d5aa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

rdflib_sqlalchemy/store.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
Any = None
4949

5050

51+
def generate_interned_id(identifier):
52+
return "{prefix}{identifier_hash}".format(
53+
prefix=INTERNED_PREFIX,
54+
identifier_hash=hashlib.sha1(identifier.encode("utf8")).hexdigest()[:10],
55+
)
56+
57+
5158
class SQLAlchemy(Store, SQLGeneratorMixin, StatisticsMixin):
5259
"""
5360
SQL-92 formula-aware implementation of an rdflib Store.
@@ -84,10 +91,7 @@ def __init__(self, identifier=None, configuration=None, engine=None):
8491
self.engine = engine
8592

8693
# Use only the first 10 bytes of the digest
87-
self._interned_id = "{prefix}{identifier_hash}".format(
88-
prefix=INTERNED_PREFIX,
89-
identifier_hash=hashlib.sha1(self.identifier.encode("utf8")).hexdigest()[:10],
90-
)
94+
self._interned_id = generate_interned_id(self.identifier)
9195

9296
# This parameter controls how exlusively the literal table is searched
9397
# If true, the Literal partition is searched *exclusively* if the

0 commit comments

Comments
 (0)