mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-20 18:51:03 +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:
|
class Loader:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, url, user, metadata, title, comments, kind, tags
|
self, id, url, user, metadata, title, comments, kind, tags
|
||||||
):
|
):
|
||||||
|
|
||||||
self.api = Api(url).library()
|
self.api = Api(url).library()
|
||||||
|
|
@ -32,6 +32,7 @@ class Loader:
|
||||||
self.title = title
|
self.title = title
|
||||||
self.comments = comments
|
self.comments = comments
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
|
self.identifier = id
|
||||||
|
|
||||||
if tags:
|
if tags:
|
||||||
self.tags = tags.split(",")
|
self.tags = tags.split(",")
|
||||||
|
|
@ -51,9 +52,12 @@ class Loader:
|
||||||
data = open(path, "rb").read()
|
data = open(path, "rb").read()
|
||||||
|
|
||||||
# Create a SHA256 hash from the data
|
# Create a SHA256 hash from the data
|
||||||
id = hash(data)
|
if self.identifier:
|
||||||
|
id = self.identifier
|
||||||
id = to_uri(PREF_DOC, id)
|
else:
|
||||||
|
id = hash(data)
|
||||||
|
id = to_uri(PREF_DOC, id)
|
||||||
|
|
||||||
|
|
||||||
self.metadata.id = id
|
self.metadata.id = id
|
||||||
|
|
||||||
|
|
@ -157,7 +161,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
|
|
||||||
document = DigitalDocument(
|
document = DigitalDocument(
|
||||||
id,
|
args.identifier,
|
||||||
name=args.name,
|
name=args.name,
|
||||||
description=args.description,
|
description=args.description,
|
||||||
copyright_notice=args.copyright_notice,
|
copyright_notice=args.copyright_notice,
|
||||||
|
|
@ -182,6 +186,7 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
p = Loader(
|
p = Loader(
|
||||||
|
id=args.identifier,
|
||||||
url=args.url,
|
url=args.url,
|
||||||
user=args.user,
|
user=args.user,
|
||||||
metadata=document,
|
metadata=document,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue