Skip to content

Commit

Permalink
HXlm._DT (#5): inicial draft as internal HXLm library
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Mar 31, 2021
1 parent 0a16b09 commit d818399
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
6 changes: 4 additions & 2 deletions hxlm/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
HDATUM_UDHR
)

import hxlm.core.hdp as HDP # noqa: F401

import hxlm.core.localization as L10N # noqa: F401
import hxlm.core.util as util # noqa: F401


import hxlm.core.hdp as HDP # noqa: F401
import hxlm.core._dt as _DT # noqa: F401
3 changes: 3 additions & 0 deletions hxlm/core/_dt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""hxlm.core._dt
"""
import hxlm.core._dt.test # noqa: F401
6 changes: 6 additions & 0 deletions hxlm/core/_dt/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""hxlm.core._dt.test
"""


def test():
print('test test test')
41 changes: 30 additions & 11 deletions hxlm/core/hdp/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
>>> import hxlm.core as HXLm
>>> # Loading single file
>>> hp = HXLm.HDP.project(HXLm.HDATUM_UDHR)
>>> hp = HXLm.HDP.project(HXLm.HDATUM_UDHR).load()
>>> hp.ok
True
Expand Down Expand Up @@ -82,6 +82,8 @@ class HDPProject:

_entrypoint: str

_entrypoint_str: str

_l10n: L10NContext
"""Current active user context."""

Expand All @@ -103,17 +105,18 @@ class HDPProject:
allow user correct in running time)
"""

policy_loader: HDPPolicyLoad
"""An HDP policy about what rules could be loaded
(ex.: restrict domains)"""

def __init__(self, entrypoint: Any,
user_l10n: L10NContext,
policy: HDPPolicyLoad):
# self._entry_point = entrypoint
policy_loader: HDPPolicyLoad):
self._entrypoint_str = entrypoint
self._l10n = user_l10n
self._parse_entrypoint(entrypoint)
self.policy_loader = policy_loader

if is_not_acceptable_load_this(entrypoint, policy):
raise SyntaxError('[' + entrypoint +
'] ¬ is_acceptable_load_this [' +
str(policy) + ']')
# return self

def _parse_entrypoint(self, entrypoint: Any):
"""Generic parser for the initial entrypoint
Expand Down Expand Up @@ -199,8 +202,22 @@ def info(self, dotted_key: str = None) -> str:

return info

def load(self):
if is_not_acceptable_load_this(self._entrypoint_str,
self.policy_loader):
raise SyntaxError('[' + self._entrypoint_str +
'] ¬ is_acceptable_load_this [' +
str(self.policy_loader) + ']')
self._parse_entrypoint(self._entrypoint_str)

return self

def reload(self):
self.load()
return self


def project(entry_point: str) -> HDPProject:
def project(entrypoint: str) -> HDPProject:
"""Initialize an HDP project (load collections of HDP files)
Args:
Expand All @@ -213,6 +230,8 @@ def project(entry_point: str) -> HDPProject:

# TODO: eventually the policy should be configurable also on startup
# not only when running
policy = get_policy_HDSL1()
result = HDPProject(entry_point, user_l10n=user_l10n, policy=policy)
policy_loader = get_policy_HDSL1()
result = HDPProject(entrypoint,
user_l10n=user_l10n,
policy_loader=policy_loader)
return result
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ install_requires =
namespace_packages = hxlm
packages =
hxlm.core
hxlm.core._dt
hxlm.core.bin
hxlm.core.hdp
hxlm.core.htype
Expand Down

0 comments on commit d818399

Please sign in to comment.