Skip to content

Commit

Permalink
convert Paths to str; expose LD_CONTEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
bkuczenski committed Oct 29, 2024
1 parent 4a0393f commit 943d6de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion antelope_core/archives/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from antelope import NoReference, EntityNotFound

from .entity_store import EntityStore, EntityExists, uuid_regex
from .basic_archive import BasicArchive, BASIC_ENTITY_TYPES, InterfaceError, ArchiveError
from .basic_archive import BasicArchive, BASIC_ENTITY_TYPES, InterfaceError, ArchiveError, LD_CONTEXT
from .archive_index import index_archive, BasicIndex, LcIndex
from .term_manager import TermManager
from .lc_archive import LcArchive, LC_ENTITY_TYPES
Expand Down
5 changes: 3 additions & 2 deletions antelope_core/archives/basic_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ..from_json import from_json, to_json



class OldJson(Exception):
pass

Expand Down Expand Up @@ -396,7 +395,7 @@ def load_from_dict(self, j, _check=True, jsonfile=None):
if 'flows' in j:
for e in j['flows']:
e['entityType'] = 'flow'
self.entity_from_json(e)
self.entity_from_json(e) # do we need to catch EntityNotFound?

if 'loaded' in j:
self._loaded = j['loaded']
Expand Down Expand Up @@ -489,6 +488,8 @@ def _serialize_quantities(self, domesticate=False):

def serialize(self, characterizations=False, values=False, domesticate=False):
"""
Serialize flows and quantities. If characterizations==True, also save Term Manager content
(characterizations, contexts, flowables)
:param characterizations:
:param values:
Expand Down
11 changes: 8 additions & 3 deletions antelope_core/entities/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ def _print_ref_field(self):
return '%s' % self.reference_entity.external_ref

def serialize(self, domesticate=False, drop_fields=()):
"""
'domesticate=True' causes the entity to be saved without its origin, allowing it to take on the local origin
whenever it is loaded.
:param domesticate: [False] if True, drop origin.
:param drop_fields: fields to ignore from serialization
:return:
"""
j = {
'entityType': self.entity_type,
'externalId': self.external_ref,
Expand Down Expand Up @@ -300,9 +307,7 @@ def __setitem__(self, key, value):
self._d[key] = value

def merge(self, other):
if False: # not isinstance(other, LcEntity): ## This is not a requirement! cf. EntityRefs, Disclosure objs
raise EntityMergeError('Incoming is not an LcEntity: %s' % other)
elif self.entity_type != other.entity_type:
if self.entity_type != other.entity_type:
raise EntityMergeError('Incoming entity type %s mismatch with %s' % (other.entity_type, self.entity_type))
elif self.external_ref != other.external_ref:
raise EntityMergeError('Incoming External ref %s conflicts with existing %s' % (other.external_ref,
Expand Down
2 changes: 1 addition & 1 deletion antelope_core/lc_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def origin(self):

@property
def source(self):
return self._source
return str(self._source)

@property
def ds_type(self):
Expand Down

0 comments on commit 943d6de

Please sign in to comment.