diff --git a/CHANGELOG.md b/CHANGELOG.md index ce41691..3cb08a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- TODO - +- `cor.hxltm.215.yml` can be use instead of `cor.hxltm.yml` (refs #7) + +### Changed +- Environment variable `HXLM_CONFIG_BASE` renamed to `HXLTM_DORMUM` +- Environment variable `HXLTM_TESTUM_BASIM_DEFALLO` renamed to `HXLTM_TESTUM` ## [v0.8.9-rc.2] - 2020-11-14 diff --git a/bin/hxltmcli.py b/bin/hxltmcli.py index c4c3e64..7914fa4 100755 --- a/bin/hxltmcli.py +++ b/bin/hxltmcli.py @@ -46,7 +46,7 @@ # COMPANY: EticaAI # LICENSE: Public Domain dedication OR Zero-Clause BSD # SPDX-License-Identifier: Unlicense OR 0BSD -# VERSION: v0.8.8 +# VERSION: v0.9.0-rc.1 # CREATED: 2021-06-27 19:50 UTC v0.5, de github.com/EticaAI # /HXL-Data-Science-file-formats/blob/main/bin/hxl2example # REVISION: 2021-06-27 21:16 UTC v0.6 de hxl2tab @@ -64,6 +64,7 @@ # 2021-10-15 17:08 UTC v0.8.7 MVP of --objectivum-formulam # 2021-10-15 17:08 UTC v0.8.8 --objectivum-formulam, allow # save result to file (was working for stdout) +# -------------------- v0.9.0 To be released # ============================================================================== """hxltmcli.py: Humanitarian Exchange Language Trānslātiōnem Memoriam CLI @@ -247,7 +248,7 @@ from liquid.context import Context as LiquidContext # from liquid.token import TOKEN_EXPRESSION as LIQUID_TOKEN_EXPRESSION -__VERSION__ = "v0.8.8" +__VERSION__ = "v0.9.0-rc.1" # _[eng-Latn] # Note: If you are doing a fork and making it public, please customize @@ -296,31 +297,22 @@ _HOME = str(Path.home()) -# TODO: clean up redundancy from hxlm/core/schema/urn/util.py -HXLM_CONFIG_BASE = os.getenv( - 'HXLM_CONFIG_BASE', _HOME + '/.config/hxlm') -# ~/.config/hxlm/cor.hxltm.yml +# cor.hxltm.215.ext: +# 1. HXLTM_RUNNING_DIR ; defallo . +# 2. HXLTM_DORMUM ; defallo ~/.config/hxlm/cor.hxltm.215.ext +# 3. HXLTM_SYSTEMA_DIR ; defallo hxltmcli.py dir # _[eng-Latn] -# This can be customized with enviroment variable HXLM_CONFIG_BASE -# -# Since hpd-toolchain is not a hard requeriment, we first try to load -# hdp-toolchain lib, but if hxltmcli is a standalone script with -# only libhxl, yaml, etc installed, we tolerate it +# Environment variables HXLTM_DORMUM (for default search place for +# configurations) HXLTM_TESTUM (for default place to search for test +# files) can be manually configured. # [eng-Latn]_ -try: - from hxlm.core.constant import ( - HXLM_ROOT, - HDATUM_EXEMPLUM - ) - HXLTM_SCRIPT_DIR = HXLM_ROOT + '/core/bin' - HXLTM_TESTUM_BASIM_DEFALLO = str(HDATUM_EXEMPLUM).replace('file://', '') -except ImportError: - HXLTM_SCRIPT_DIR = str(Path(__file__).parent.resolve()) - HXLTM_TESTUM_BASIM_DEFALLO = str(Path( - # HXLTM_SCRIPT_DIR + '/../../../testum/hxltm').resolve()) - HXLTM_SCRIPT_DIR + '/../../../testum').resolve()) +HXLTM_DORMUM = os.getenv('HXLTM_DORMUM', _HOME + '/.config/hxltm') +HXLTM_TESTUM = os.getenv( + 'HXLTM_TESTUM', HXLTM_DORMUM + '/testum') +# TODO: make HXLTM_TESTUM instalable as python package +HXLTM_SYSTEMA_DIR = str(Path(__file__).parent.resolve()) HXLTM_RUNNING_DIR = str(Path().resolve()) @@ -5967,7 +5959,7 @@ def testum_praefixum(archivum: str = None) -> str: _[eng-Latn] Note: this will try check if the enviroment variable - HXLTM_TESTUM_BASIM and only fallback to assume the entire + HXLTM_TESTUM and only fallback to assume the entire hdp-toolchain installation (or a fork from EticaAI/HXL-Data-Science-file-formats) on local disk. @@ -5989,9 +5981,9 @@ def testum_praefixum(archivum: str = None) -> str: # if HDATUM_EXEMPLUM: # hxltmtestum = str(Path( - # HXLTM_SCRIPT_DIR + '/../../../testum/hxltm').resolve()) + # HXLTM_SYSTEMA_DIR + '/../../../testum/hxltm').resolve()) - praefixum = os.getenv('HXLTM_TESTUM_BASIM', HXLTM_TESTUM_BASIM_DEFALLO) + praefixum = os.getenv('HXLTM_TESTUM', HXLTM_TESTUM) if archivum: return praefixum + '/' + archivum @@ -6014,8 +6006,8 @@ def datum( if not os.path.isfile(exemplum_archivum): raise RuntimeError( 'HXLTMTestumAuxilium non-datum [{}]. ' - 'Requīsītum: dēfīnītiōnem HXLTM_TESTUM_BASIM. Exemplum:' - '> HXLTM_TESTUM_BASIM="/home/marcus/testum/" ' + 'Requīsītum: dēfīnītiōnem HXLTM_TESTUM. Exemplum:' + '> HXLTM_TESTUM="/home/marcus/testum/" ' 'python3 -m doctest hxltmcli-de-marcus.py' ' <'.format(exemplum_archivum)) @@ -6749,8 +6741,8 @@ def load_hxltm_options(custom_file_option=None, is_debug=False): # pylint: disable=using-constant-test if is_debug: print('load_hxltm_options') - print('HXLM_CONFIG_BASE', HXLM_CONFIG_BASE) - print('HXLTM_SCRIPT_DIR', HXLTM_SCRIPT_DIR) + print('HXLTM_DORMUM', HXLTM_DORMUM) + print('HXLTM_SYSTEMA_DIR', HXLTM_SYSTEMA_DIR) print('HXLTM_RUNNING_DIR', HXLTM_RUNNING_DIR) if custom_file_option is not None: @@ -6764,13 +6756,25 @@ def load_hxltm_options(custom_file_option=None, is_debug=False): return HXLTMUtil._load_hxltm_options_file( HXLTM_RUNNING_DIR + '/cor.hxltm.yml', is_debug) - if Path(HXLM_CONFIG_BASE + '/cor.hxltm.yml').exists(): + if Path(HXLTM_RUNNING_DIR + '/cor.hxltm.215.yml').exists(): + return HXLTMUtil._load_hxltm_options_file( + HXLTM_RUNNING_DIR + '/cor.hxltm.215.yml', is_debug) + + if Path(HXLTM_DORMUM + '/cor.hxltm.yml').exists(): + return HXLTMUtil._load_hxltm_options_file( + HXLTM_DORMUM + '/cor.hxltm.yml', is_debug) + + if Path(HXLTM_DORMUM + '/cor.hxltm.215.yml').exists(): + return HXLTMUtil._load_hxltm_options_file( + HXLTM_DORMUM + '/cor.hxltm.215.yml', is_debug) + + if Path(HXLTM_SYSTEMA_DIR + '/cor.hxltm.yml').exists(): return HXLTMUtil._load_hxltm_options_file( - HXLM_CONFIG_BASE + '/cor.hxltm.yml', is_debug) + HXLTM_SYSTEMA_DIR + '/cor.hxltm.yml', is_debug) - if Path(HXLTM_SCRIPT_DIR + '/cor.hxltm.yml').exists(): + if Path(HXLTM_SYSTEMA_DIR + '/cor.hxltm.215.yml').exists(): return HXLTMUtil._load_hxltm_options_file( - HXLTM_SCRIPT_DIR + '/cor.hxltm.yml', is_debug) + HXLTM_SYSTEMA_DIR + '/cor.hxltm.215.yml', is_debug) # print('oioioi') raise RuntimeError( diff --git a/bin/hxltmdexml.py b/bin/hxltmdexml.py index fdae5cb..100d3cd 100755 --- a/bin/hxltmdexml.py +++ b/bin/hxltmdexml.py @@ -28,12 +28,13 @@ # COMPANY: EticaAI # LICENSE: Public Domain dedication OR Zero-Clause BSD # SPDX-License-Identifier: Unlicense OR 0BSD -# VERSION: v0.7.0 +# VERSION: v0.9.0-rc.1 # CREATED: 2021-07-24 00:04 UTC v0.1.0 de hxl2example # REVISION: 2021-07-24 17:49 UTC v0.2.0 hxltmdexml at least read XML # 2021-07-25 23:28 UTC v0.5.0 XLIFF 1.2 and XLIFF 2.1 (MVP) # 2021-07-28 22:01 UTC v0.7.0 TBX-IATE (MVP), TMX (MVP) # 2021-11-06 21:19 UTC v0.8.0 Fix cli importing; more stable +# -------------------- v0.9.0 To be released # ============================================================================== """hxltmdexml.py: Humanitarian Exchange Language Trānslātiōnem Memoriam de XML @@ -189,7 +190,7 @@ # pip3 install langcodes # import langcodes -__VERSION__ = "v0.7.1" +__VERSION__ = "v0.9.0-rc.1" # _[eng-Latn] # Note: If you are doing a fork and making it public, please customize @@ -274,30 +275,24 @@ _HOME = str(Path.home()) -# TODO: clean up redundancy from hxlm/core/schema/urn/util.py -HXLM_CONFIG_BASE = os.getenv( - 'HXLM_CONFIG_BASE', _HOME + '/.config/hxlm') -# ~/.config/hxlm/cor.hxltm.yml +# cor.hxltm.215.ext: +# 1. HXLTM_RUNNING_DIR ; defallo . +# 2. HXLTM_DORMUM ; defallo ~/.config/hxlm/cor.hxltm.215.ext +# 3. HXLTM_SYSTEMA_DIR ; defallo hxltmcli.py dir # _[eng-Latn] -# This can be customized with enviroment variable HXLM_CONFIG_BASE -# -# Since hpd-toolchain is not a hard requeriment, we first try to load -# hdp-toolchain lib, but if hxltmcli is a standalone script with -# only libhxl, yaml, etc installed, we tolerate it +# Environment variables HXLTM_DORMUM (for default search place for +# configurations) HXLTM_TESTUM (for default place to search for test +# files) can be manually configured. # [eng-Latn]_ -try: - from hxlm.core.constant import ( - HXLM_ROOT, - HDATUM_EXEMPLUM - ) - HXLTM_SCRIPT_DIR = HXLM_ROOT + '/core/bin' - HXLTM_TESTUM_BASIM_DEFALLO = str(HDATUM_EXEMPLUM).replace('file://', '') -except ImportError: - HXLTM_SCRIPT_DIR = str(Path(__file__).parent.resolve()) - HXLTM_TESTUM_BASIM_DEFALLO = str(Path( - HXLTM_SCRIPT_DIR + '/../../../testum/hxltm').resolve()) +HXLTM_DORMUM = os.getenv('HXLTM_DORMUM', _HOME + '/.config/hxltm') +HXLTM_TESTUM = os.getenv( + 'HXLTM_TESTUM', HXLTM_DORMUM + '/testum') +# TODO: make HXLTM_TESTUM instalable as python package + +# systēma +HXLTM_SYSTEMA_DIR = str(Path(__file__).parent.resolve()) HXLTM_RUNNING_DIR = str(Path().resolve()) # De Python Constants @@ -2904,8 +2899,8 @@ def load_hxltm_options(custom_file_option=None, is_debug=False): # pylint: disable=using-constant-test if is_debug: print('load_hxltm_options') - print('HXLM_CONFIG_BASE', HXLM_CONFIG_BASE) - print('HXLTM_SCRIPT_DIR', HXLTM_SCRIPT_DIR) + print('HXLTM_DORMUM', HXLTM_DORMUM) + print('HXLTM_SYSTEMA_DIR', HXLTM_SYSTEMA_DIR) print('HXLTM_RUNNING_DIR', HXLTM_RUNNING_DIR) if custom_file_option is not None: @@ -2919,13 +2914,25 @@ def load_hxltm_options(custom_file_option=None, is_debug=False): return HXLTMUtil._load_hxltm_options_file( HXLTM_RUNNING_DIR + '/cor.hxltm.yml', is_debug) - if Path(HXLM_CONFIG_BASE + '/cor.hxltm.yml').exists(): + if Path(HXLTM_RUNNING_DIR + '/cor.hxltm.yml').exists(): + return HXLTMUtil._load_hxltm_options_file( + HXLTM_RUNNING_DIR + '/cor.hxltm.215.yml', is_debug) + + if Path(HXLTM_DORMUM + '/cor.hxltm.yml').exists(): + return HXLTMUtil._load_hxltm_options_file( + HXLTM_DORMUM + '/cor.hxltm.yml', is_debug) + + if Path(HXLTM_DORMUM + '/cor.hxltm.215.yml').exists(): + return HXLTMUtil._load_hxltm_options_file( + HXLTM_DORMUM + '/cor.hxltm.215.yml', is_debug) + + if Path(HXLTM_SYSTEMA_DIR + '/cor.hxltm.yml').exists(): return HXLTMUtil._load_hxltm_options_file( - HXLM_CONFIG_BASE + '/cor.hxltm.yml', is_debug) + HXLTM_SYSTEMA_DIR + '/cor.hxltm.yml', is_debug) - if Path(HXLTM_SCRIPT_DIR + '/cor.hxltm.yml').exists(): + if Path(HXLTM_SYSTEMA_DIR + '/cor.hxltm.215.yml').exists(): return HXLTMUtil._load_hxltm_options_file( - HXLTM_SCRIPT_DIR + '/cor.hxltm.yml', is_debug) + HXLTM_SYSTEMA_DIR + '/cor.hxltm.215.yml', is_debug) # print('oioioi') raise RuntimeError( @@ -3030,7 +3037,7 @@ def testum_praefixum(archivum: str = None) -> str: _[eng-Latn] Note: this will try check if the enviroment variable - HXLTM_TESTUM_BASIM and only fallback to assume the entire + HXLTM_TESTUM and only fallback to assume the entire hdp-toolchain installation (or a fork from EticaAI/HXL-Data-Science-file-formats) on local disk. @@ -3052,9 +3059,9 @@ def testum_praefixum(archivum: str = None) -> str: # if HDATUM_EXEMPLUM: # hxltmtestum = str(Path( - # HXLTM_SCRIPT_DIR + '/../../../testum/hxltm').resolve()) + # HXLTM_SYSTEMA_DIR + '/../../../testum/hxltm').resolve()) - praefixum = os.getenv('HXLTM_TESTUM_BASIM', HXLTM_TESTUM_BASIM_DEFALLO) + praefixum = os.getenv('HXLTM_TESTUM', HXLTM_TESTUM) if archivum: return praefixum + '/' + archivum @@ -3077,8 +3084,8 @@ def datum( if not os.path.isfile(exemplum_archivum): raise RuntimeError( 'HXLTMTestumAuxilium non-datum [{}]. ' - 'Requīsītum: dēfīnītiōnem HXLTM_TESTUM_BASIM. Exemplum:' - '> HXLTM_TESTUM_BASIM="/home/marcus/testum/" ' + 'Requīsītum: dēfīnītiōnem HXLTM_TESTUM. Exemplum:' + '> HXLTM_TESTUM="/home/marcus/testum/" ' 'python3 -m doctest hxltmcli-de-marcus.py' ' <'.format(exemplum_archivum)) diff --git a/tox.ini b/tox.ini index 53a6faf..b4d996f 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,7 @@ # To run even if flake8 is not enabled by default # tox -e flake8 # To run doctests (not integrated yet with tox) -# pytest -vv bin/ --doctest-modules +# HXLTM_TESTUM=./testum pytest -vv src/hxltm/bin/ --doctest-module ### To run with travis ........................................................ # @see .travis.yml @@ -59,6 +59,9 @@ deps = pyyaml langcodes +setenv = + HXLTM_TESTUM = ./testum + commands = # pytest -vv bin/ --doctest-modules pytest -vv src/hxltm/bin/ --doctest-modules @@ -75,6 +78,9 @@ deps = langcodes python-liquid +setenv = + HXLTM_TESTUM = ./testum + commands = pytest # pylint @@ -92,6 +98,8 @@ deps = pyyaml langcodes +setenv = + HXLTM_TESTUM = ./testum [testenv:flake8] deps = @@ -100,6 +108,9 @@ deps = libhxl pyyaml +setenv = + HXLTM_TESTUM = ./testum + commands = # pytest -vv bin/ --doctest-modules pytest -vv src/hxltm/bin/ --doctest-modules