mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-27 17:36:23 +02:00
ID field is used (#375)
This commit is contained in:
parent
80ec00f212
commit
9e9b21068c
1 changed files with 10 additions and 5 deletions
|
|
@ -22,7 +22,7 @@ default_user = 'trustgraph'
|
|||
class Loader:
|
||||
|
||||
def __init__(
|
||||
self, url, user, metadata, title, comments, kind, tags
|
||||
self, id, url, user, metadata, title, comments, kind, tags
|
||||
):
|
||||
|
||||
self.api = Api(url).library()
|
||||
|
|
@ -32,6 +32,7 @@ class Loader:
|
|||
self.title = title
|
||||
self.comments = comments
|
||||
self.kind = kind
|
||||
self.identifier = id
|
||||
|
||||
if tags:
|
||||
self.tags = tags.split(",")
|
||||
|
|
@ -51,9 +52,12 @@ class Loader:
|
|||
data = open(path, "rb").read()
|
||||
|
||||
# Create a SHA256 hash from the data
|
||||
id = hash(data)
|
||||
|
||||
id = to_uri(PREF_DOC, id)
|
||||
if self.identifier:
|
||||
id = self.identifier
|
||||
else:
|
||||
id = hash(data)
|
||||
id = to_uri(PREF_DOC, id)
|
||||
|
||||
|
||||
self.metadata.id = id
|
||||
|
||||
|
|
@ -157,7 +161,7 @@ def main():
|
|||
try:
|
||||
|
||||
document = DigitalDocument(
|
||||
id,
|
||||
args.identifier,
|
||||
name=args.name,
|
||||
description=args.description,
|
||||
copyright_notice=args.copyright_notice,
|
||||
|
|
@ -182,6 +186,7 @@ def main():
|
|||
)
|
||||
|
||||
p = Loader(
|
||||
id=args.identifier,
|
||||
url=args.url,
|
||||
user=args.user,
|
||||
metadata=document,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue