Skip to content

Commit

Permalink
Move schema_83_props to baseclass
Browse files Browse the repository at this point in the history
  • Loading branch information
IanCa committed Apr 4, 2024
1 parent 9bf38b8 commit 1329ebc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 0 additions & 12 deletions hed/schema/hed_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self):

self._sections = self._create_empty_sections()
self.source_format = None # The type of file this was loaded from(mediawiki, xml, or owl - None if mixed)
self._schema83 = False # If True, this is an 8.3 style schema for validation/attribute purposes

# ===============================================
# Basic schema properties
Expand Down Expand Up @@ -72,17 +71,6 @@ def schema_namespace(self):
"""Returns the schema namespace prefix"""
return self._namespace

@property
def schema_83_props(self):
"""Returns if this is an 8.3.0 or greater schema.
Returns:
is_83_schema(bool): True if standard or partnered schema is 8.3.0 or greater."""
if self._schema83 is not None:
return self._schema83

self._schema83 = schema_util.schema_version_greater_equal(self, "8.3.0")

def can_save(self):
""" Returns if it's legal to save this schema.
Expand Down
13 changes: 13 additions & 0 deletions hed/schema/hed_schema_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from hed.schema.hed_schema_constants import HedSectionKey
from abc import ABC, abstractmethod
from hed.schema.schema_io import schema_util


class HedSchemaBase(ABC):
Expand All @@ -12,6 +13,7 @@ class HedSchemaBase(ABC):
"""
def __init__(self):
self._name = "" # User provided identifier for this schema(not used for equality comparison or saved)
self._schema83 = None # If True, this is an 8.3 style schema for validation/attribute purposes
pass

@property
Expand All @@ -25,6 +27,17 @@ def name(self):
def name(self, name):
self._name = name

@property
def schema_83_props(self):
"""Returns if this is an 8.3.0 or greater schema.
Returns:
is_83_schema(bool): True if standard or partnered schema is 8.3.0 or greater."""
if self._schema83 is not None:
return self._schema83

self._schema83 = schema_util.schema_version_greater_equal(self, "8.3.0")

@abstractmethod
def get_schema_versions(self):
""" A list of HED version strings including namespace and library name if any of this schema.
Expand Down

0 comments on commit 1329ebc

Please sign in to comment.