datastock 0.0.47__py3-none-any.whl → 0.0.49__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
datastock/_class2.py CHANGED
@@ -629,7 +629,7 @@ class DataStock2(DataStock1):
629
629
  v0['handle'].parent(),
630
630
  )
631
631
  except Exception as err:
632
- error = err
632
+ error = "1\n" + str(err)
633
633
  elif hasattr(v0['handle'], 'parent'):
634
634
  try:
635
635
  v0['handle'].manager.toolbar.__init__(
@@ -637,9 +637,12 @@ class DataStock2(DataStock1):
637
637
  v0['handle'].parent(),
638
638
  )
639
639
  except Exception as err:
640
- error = True
640
+ if "can't initialize an object twice" in str(err):
641
+ pass
642
+ else:
643
+ error = "2\n" + str(err)
641
644
  else:
642
- error = True
645
+ error = "3"
643
646
 
644
647
  if error is not False:
645
648
  import platform
@@ -648,6 +651,7 @@ class DataStock2(DataStock1):
648
651
  lstr0 = [f"\t- {k1}" for k1 in dir(v0['handle'])]
649
652
  lstr1 = [f"\t- {k1}" for k1 in dir(v0['handle'].manager.toolbar)]
650
653
  msg = (
654
+ "Problem with connect()\n"
651
655
  f"platform: {platform.platform()}\n"
652
656
  f"python: {sys.version}\n"
653
657
  f"backend: {plt.get_backend()}\n"
@@ -657,7 +661,7 @@ class DataStock2(DataStock1):
657
661
  + "\n".join(lstr1)
658
662
  )
659
663
  if error is not True:
660
- msg += '\n' + str(err)
664
+ msg += '\n' + str(error)
661
665
  warnings.warn(msg)
662
666
 
663
667
  self._dobj['canvas'][k0]['cid'] = {
@@ -1393,4 +1397,4 @@ class DataStock2(DataStock1):
1393
1397
 
1394
1398
  __all__ = [
1395
1399
  sorted([k0 for k0 in locals() if k0.startswith('DataStock')])[-1]
1396
- ]
1400
+ ]
@@ -362,8 +362,6 @@ def _check_dict_valid_keys(
362
362
  var[k0] = None
363
363
  continue
364
364
 
365
- vv = var.get(k0)
366
-
367
365
  # routine to call
368
366
  if any([ss in v0.keys() for ss in lkarray]):
369
367
  var[k0] = _check_flat1darray(
@@ -610,7 +608,7 @@ def _check_all_broadcastable(
610
608
  ndim = lndim[0]
611
609
 
612
610
  else:
613
- lstr = [f"-t {k0}: {v0}" for k0, v0 in dndim.items()]
611
+ lstr = [f"\t- {k0}: {v0}" for k0, v0 in dndim.items()]
614
612
  msg = (
615
613
  "Some keyword args have non-compatible dimensions:\n"
616
614
  + "\n".join(lstr)
@@ -675,48 +673,6 @@ def _check_all_broadcastable(
675
673
  # Utilities for plotting
676
674
  # #############################################################################
677
675
 
678
- # DEPRECATED
679
- # def _check_inplace(coll=None, keys=None):
680
- # """ Check key to data and inplace """
681
-
682
- # # -----------------------------
683
- # # keys of data to be extracted
684
- # # ----------------------------
685
-
686
- # if isinstance(keys, str):
687
- # keys = [keys]
688
- # keys = _check_var_iter(
689
- # keys, 'keys',
690
- # default=None,
691
- # types=list,
692
- # types_iter=str,
693
- # allowed=list(coll.ddata.keys()),
694
- # )
695
-
696
- # # ----------------------
697
- # # extract sub-collection
698
- # # ----------------------
699
-
700
- # lk0 = list(keys)
701
- # for key in keys:
702
-
703
- # # Include all data matching any single ref
704
- # for rr in coll._ddata[key]['ref']:
705
- # for k0, v0 in coll._ddata.items():
706
- # if v0['ref'] == (rr,):
707
- # if k0 not in lk0:
708
- # lk0.append(k0)
709
-
710
- # # include all data matching all refs
711
- # for k0, v0 in coll._ddata.items():
712
- # if v0['ref'] == coll._ddata[key]['ref']:
713
- # if k0 not in lk0:
714
- # lk0.append(k0)
715
-
716
- # coll2 = coll.extract(lk0)
717
-
718
- # return keys, coll2
719
-
720
676
 
721
677
  def _check_dax(dax=None, main=None):
722
678
 
@@ -844,7 +800,7 @@ def _check_lim(lim):
844
800
  if len(dfail) > 0:
845
801
  lstr = [f"\t- lim[{ii}]: {vv}" for ii, vv in dfail.items()]
846
802
  msg = (
847
- "The following non-conformities in lim have been identified:\n"*
803
+ "The following non-conformities in lim have been identified:\n"
848
804
  + "\n".join(lstr)
849
805
  )
850
806
  raise Exception(msg)
@@ -900,7 +856,6 @@ def _apply_lim(lim=None, data=None, logic=None):
900
856
  return ind
901
857
 
902
858
 
903
-
904
859
  def _apply_dlim(dlim=None, logic_intervals=None, logic=None, ddata=None):
905
860
 
906
861
  # ------------
@@ -960,6 +915,7 @@ def _apply_dlim(dlim=None, logic_intervals=None, logic=None, ddata=None):
960
915
  lstr = [f"\t- {k0}: {v0}" for k0, v0 in dfail.items()]
961
916
  msg = (
962
917
  "The following keys have non-compatible shapes:\n"
918
+ + "\n".join(lstr)
963
919
  )
964
920
  raise Exception(msg)
965
921
 
@@ -1021,11 +977,6 @@ def _apply_dlim(dlim=None, logic_intervals=None, logic=None, ddata=None):
1021
977
 
1022
978
  def _check_cmap_vminvmax(data=None, cmap=None, vmin=None, vmax=None):
1023
979
  # cmap
1024
- c0 = (
1025
- cmap is None
1026
- or vmin is None
1027
- or vmax is None
1028
- )
1029
980
  if cmap is None or vmin is None or vmax is None:
1030
981
  nanmax = np.nanmax(data)
1031
982
  nanmin = np.nanmin(data)
datastock/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # Do not edit, pipeline versioning governed by git tags!
2
- __version__ = '0.0.47'
2
+ __version__ = '0.0.49'
@@ -1,20 +1,43 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datastock
3
- Version: 0.0.47
4
- Summary: A python library for generic class and data handling
3
+ Version: 0.0.49
4
+ Summary: Generic handler for multiple heterogenous numpy arrays and subclasses
5
5
  Home-page: https://github.com/ToFuProject/datastock
6
6
  Author: Didier VEZINET
7
- Author-email: didier.vezinet@gmail.com
8
- License: MIT
9
- Keywords: data analysis class container generic interactive plot
10
- Classifier: Development Status :: 4 - Beta
7
+ Author-email: Didier VEZINET <didier.vezinet@gmail.com>
8
+ Maintainer-email: Didier VEZINET <didier.vezinet@gmail.com>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2022 ToFuProject
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+ Keywords: data,analysis,interactive,heterogeneous arrays,numpy,Collection
32
+ Classifier: Development Status :: 5 - Production/Stable
11
33
  Classifier: Intended Audience :: Science/Research
12
- Classifier: Topic :: Scientific/Engineering :: Physics
13
- Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
14
35
  Classifier: Programming Language :: Python :: 3.6
15
36
  Classifier: Programming Language :: Python :: 3.7
16
37
  Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Natural Language :: English
38
+ Classifier: Programming Language :: Python :: 3.9
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
18
41
  Requires-Python: >=3.6
19
42
  Description-Content-Type: text/markdown
20
43
  License-File: LICENSE
@@ -29,6 +52,10 @@ Requires-Dist: pytest; extra == "dev"
29
52
  Requires-Dist: sphinx; extra == "dev"
30
53
  Requires-Dist: sphinx-gallery; extra == "dev"
31
54
  Requires-Dist: sphinx-bootstrap-theme; extra == "dev"
55
+ Provides-Extra: formatting
56
+ Requires-Dist: ruff; extra == "formatting"
57
+ Provides-Extra: linting
58
+ Requires-Dist: ruff; extra == "linting"
32
59
 
33
60
  [![Conda]( https://anaconda.org/conda-forge/datastock/badges/version.svg)](https://anaconda.org/conda-forge/datastock)
34
61
  [![](https://anaconda.org/conda-forge/datastock/badges/downloads.svg)](https://anaconda.org/conda-forge/datastock)
@@ -12,13 +12,13 @@ datastock/_class1_domain.py,sha256=_xUCnwWJX5wPPYrpiGGrRwrPLmiO5BMm3nmYvn_YEOg,6
12
12
  datastock/_class1_interpolate.py,sha256=3VKGMDsiWFQUguMHxMaTQTyMhcN8Ikg1PmaH6TjIeLg,38348
13
13
  datastock/_class1_show.py,sha256=hqd-FeJ1NqiOzbrHzGMrwIo8_lLsjC199Zmw68NqkDQ,11745
14
14
  datastock/_class1_uniformize.py,sha256=dEJime_0SqmW8hX8ooZpHsPI_d8CIE9U9Yz9GhqsEUY,28433
15
- datastock/_class2.py,sha256=FG-ZGPVdZEdkRc_3Z9LRzYdRm9Xat7HI06E3-hI5rCk,45422
15
+ datastock/_class2.py,sha256=Mkqwhkl-YDAT0Wx5bHkUHwMW2L6feACkxmifvvzUnYk,45626
16
16
  datastock/_class2_interactivity.py,sha256=glAqqkIyH8JBVj0AsgJPNlaltcTIXB0iCqNBq3gKSb8,17198
17
17
  datastock/_class3.py,sha256=CH1oD_lTfVlcDp29L_iwzSfP78vX6_edDmZG9aSb1Ks,10848
18
18
  datastock/_direct_calls.py,sha256=EHFwI2mGMDqGz8_Bv2BseMBX4J8dSdE_RcNX3pt0ZYY,1801
19
19
  datastock/_export_dataframe.py,sha256=fy-uJR3EhDlHvd9ls1EQna_C8fyha1jCJLu1DTKTkdo,1576
20
20
  datastock/_find_plateau.py,sha256=sqnAuy0361DXkqBb_Lo1MmIGjn35tnKFvcv6MW6hifs,2685
21
- datastock/_generic_check.py,sha256=yKnxlLSJomRCYzBayEy-i0O6FhOGt1rR98iu2XSd37U,27940
21
+ datastock/_generic_check.py,sha256=4NmG7iPa02bxOC5K-6qw63UahQ2FNDbeKu_AGBpNMtc,26717
22
22
  datastock/_generic_utils.py,sha256=_iV51SiujEmQfAlvyIEW4BvzIXdhPCD-vumV5DmUL44,23421
23
23
  datastock/_generic_utils_plot.py,sha256=xrWzeZFtdTAs-RO2DfpCRveJPqw_p4lRFtQuuAn1pD8,3709
24
24
  datastock/_plot_BvsA_as_distribution.py,sha256=fpRhlbv3Bk96buANC46Brc9hdLxkOAsoKpE5A9pohG0,15389
@@ -32,12 +32,17 @@ datastock/_plot_correlations.py,sha256=ITOypu_AEoKl0ihxocV-JVTXIHqut6p9TfG-xZmQy
32
32
  datastock/_plot_old_backup.py,sha256=XixTi2CiihKjtQP0TRycH0b25caWN1m35DgpsDeiWZE,21729
33
33
  datastock/_plot_text.py,sha256=wQPqjfpLyIioS2JeOt3E9C9HgYUJ49YEoOgRuKYvAR8,3143
34
34
  datastock/_saveload.py,sha256=1vAMp27KfqXbo5b_Pi8hJux0stsHq6dO5vy8k1d4_iA,14141
35
- datastock/version.py,sha256=mPvpgVj454Vfs5m6V8fuocNdwJDUMd-Yv6J6PlDaGVA,80
35
+ datastock/version.py,sha256=3LGOrbR0FKVCMYF5gFB0Z3jb_YfYLLDyuMY0M-oeJrU,80
36
36
  datastock/tests/__init__.py,sha256=teOo2xP0IO7PQMuMDmum61XVHe2TuxW3BiHiL73X8jQ,35
37
37
  datastock/tests/test_01_DataStock.py,sha256=aUseXH2zYnFtNDJSCuEROgPxfKKNeLCkCQSR--_Fheg,19176
38
38
  datastock/tests/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- datastock-0.0.47.dist-info/LICENSE,sha256=V1uXqi3vxR0QhB4QdFyjkynl6jpN4wZmlB5EMYJk0NM,1068
40
- datastock-0.0.47.dist-info/METADATA,sha256=pCzvjokhOrHGFpDFABU6QbnPT7MvBZ1NQW_Mbd1vxnQ,8660
41
- datastock-0.0.47.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
42
- datastock-0.0.47.dist-info/top_level.txt,sha256=BzJsLLK_zZw13WQCoMhC74qWVKalnVCjBxdPXvJn7HQ,25
43
- datastock-0.0.47.dist-info/RECORD,,
39
+ scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ scripts/_bash_version.py,sha256=B-NJPgjuqGiXVVUEBJDHP4uDc5yBDFvBX2mmvL2T4E0,1837
41
+ scripts/_dparser.py,sha256=TvJ4ZWbOX0sN8Xqa-IRhcqtyOIIewRTkeb-OE0vXWbs,2755
42
+ scripts/main.py,sha256=JrRRQK3BCnepBa0RMsG3OtpMCoVRo_RcElMScPcbvF4,3530
43
+ datastock-0.0.49.dist-info/LICENSE,sha256=V1uXqi3vxR0QhB4QdFyjkynl6jpN4wZmlB5EMYJk0NM,1068
44
+ datastock-0.0.49.dist-info/METADATA,sha256=KVm2w4WDF--bfwCyc8TaKyn_5vvc45wReU07WuhnkVY,10197
45
+ datastock-0.0.49.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
46
+ datastock-0.0.49.dist-info/entry_points.txt,sha256=GqmxVVp9G2ulEDaS9gLpwSVOBLF_FEBlj8k5Z6TJKsc,42
47
+ datastock-0.0.49.dist-info/top_level.txt,sha256=4mahLJQfvNnKq213ODWrMXeNzyoyjzRRke_OAw07iA8,33
48
+ datastock-0.0.49.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.2)
2
+ Generator: bdist_wheel (0.45.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,2 @@
1
+ [datastock]
2
+ datastock = scripts.main:main
@@ -1,2 +1,3 @@
1
1
  _updateversion
2
2
  datastock
3
+ scripts
scripts/__init__.py ADDED
File without changes
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Built-in
4
+ import os
5
+
6
+
7
+ ###################################################
8
+ ###################################################
9
+ # DEFAULTS
10
+ ###################################################
11
+
12
+
13
+ _PATH_HERE = os.path.dirname(__file__)
14
+
15
+
16
+ ###################################################
17
+ ###################################################
18
+ # function
19
+ ###################################################
20
+
21
+
22
+ def main(
23
+ verb=None,
24
+ envvar=None,
25
+ path=None,
26
+ warn=None,
27
+ force=None,
28
+ ddef=None,
29
+ ):
30
+ """ Print version """
31
+
32
+ # --------------
33
+ # Check inputs
34
+ # --------------
35
+
36
+ kwd = locals()
37
+ for k0 in set(ddef.keys()).intersection(kwd.keys()):
38
+ if kwd[k0] is None:
39
+ kwd[k0] = ddef[k0]
40
+ verb, path = kwd['verb'], kwd['path']
41
+
42
+ # verb, warn, force
43
+ dbool = {'verb': verb}
44
+ for k0, v0 in dbool.items():
45
+ if v0 is None:
46
+ dbool[k0] = ddef[k0]
47
+ if not isinstance(dbool[k0], bool):
48
+ msg = (
49
+ f"Arg '{k0}' must be a bool\n"
50
+ f"\t- provided: {dbool[k0]}\n"
51
+ )
52
+ raise Exception(msg)
53
+
54
+ # --------------
55
+ # Fetch version from git tags, and write to version.py
56
+ # Also, when git is not available (PyPi package), use stored version.py
57
+
58
+ pfe = os.path.join(path, 'version.py')
59
+ if not os.path.isfile(pfe):
60
+ msg = (
61
+ "It seems your current install has no version.py:\n"
62
+ f"\t- looked for: {pfe}"
63
+ )
64
+ raise Exception(msg)
65
+
66
+ # --------------
67
+ # Read file
68
+
69
+ with open(pfe, 'r') as fh:
70
+ version = fh.read().strip().split("=")[-1].replace("'", '')
71
+ version = version.lower().replace('v', '').replace(' ', '')
72
+
73
+ # --------------
74
+ # Outputs
75
+
76
+ if dbool['verb'] is True:
77
+ print(version)
scripts/_dparser.py ADDED
@@ -0,0 +1,109 @@
1
+ import sys
2
+ import os
3
+ import getpass
4
+ import argparse
5
+
6
+
7
+ # test if in a git repo
8
+ _HERE = os.path.abspath(os.path.dirname(__file__))
9
+ _REPOPATH = os.path.dirname(_HERE)
10
+ _REPO_NAME = 'datastock'
11
+
12
+
13
+ # #############################################################################
14
+ # utility functions
15
+ # #############################################################################
16
+
17
+
18
+ def _str2bool(v):
19
+ if isinstance(v, bool):
20
+ return v
21
+ elif v.lower() in ['yes', 'true', 'y', 't', '1']:
22
+ return True
23
+ elif v.lower() in ['no', 'false', 'n', 'f', '0']:
24
+ return False
25
+ else:
26
+ raise argparse.ArgumentTypeError('Boolean value expected!')
27
+
28
+
29
+ def _str2boolstr(v):
30
+ if isinstance(v, bool):
31
+ return v
32
+ elif isinstance(v, str):
33
+ if v.lower() in ['yes', 'true', 'y', 't', '1']:
34
+ return True
35
+ elif v.lower() in ['no', 'false', 'n', 'f', '0']:
36
+ return False
37
+ elif v.lower() == 'none':
38
+ return None
39
+ else:
40
+ return v
41
+ else:
42
+ raise argparse.ArgumentTypeError('Boolean, None or str expected!')
43
+
44
+
45
+ def _str2tlim(v):
46
+ c0 = (v.isdigit()
47
+ or ('.' in v
48
+ and len(v.split('.')) == 2
49
+ and all([vv.isdigit() for vv in v.split('.')])))
50
+ if c0 is True:
51
+ v = float(v)
52
+ elif v.lower() == 'none':
53
+ v = None
54
+ return v
55
+
56
+
57
+ # #############################################################################
58
+ # Parser for version
59
+ # #############################################################################
60
+
61
+
62
+ def parser_version():
63
+ msg = f""" Get {_REPO_NAME} version from bash
64
+
65
+ If run from a git repo containing {_REPO_NAME}, just returns git describe
66
+ Otherwise reads the version stored in {_REPO_NAME}/version.py
67
+
68
+ """
69
+ ddef = {
70
+ 'path': os.path.join(_REPOPATH, _REPO_NAME),
71
+ 'envvar': False,
72
+ 'verb': True,
73
+ 'warn': True,
74
+ 'force': False,
75
+ 'name': f'{_REPO_NAME.upper()}_VERSION',
76
+ }
77
+
78
+ # Instanciate parser
79
+ parser = argparse.ArgumentParser(description=msg)
80
+
81
+ # optional path
82
+ parser.add_argument(
83
+ '-p', '--path',
84
+ type=str,
85
+ help='source directory where version.py is found',
86
+ required=False,
87
+ default=ddef['path'],
88
+ )
89
+
90
+ # verb
91
+ parser.add_argument(
92
+ '-v', '--verb',
93
+ type=_str2bool,
94
+ help='flag indicating whether to print the version',
95
+ required=False,
96
+ default=ddef['verb'],
97
+ )
98
+
99
+ return ddef, parser
100
+
101
+
102
+ # #############################################################################
103
+ # Parser dict
104
+ # #############################################################################
105
+
106
+
107
+ _DPARSER = {
108
+ 'version': parser_version,
109
+ }
scripts/main.py ADDED
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Built-in
4
+ import sys
5
+ import os
6
+ import argparse
7
+
8
+
9
+ # import parser dicti
10
+ from . import _dparser
11
+ from . import _bash_version
12
+
13
+
14
+ ###################################################
15
+ ###################################################
16
+ # default values
17
+ ###################################################
18
+
19
+
20
+ _PATH_HERE = os.path.abspath(os.path.dirname(__file__))
21
+
22
+
23
+ _LOPTIONS = ['--version']
24
+ _LOPSTRIP = [ss.strip('--') for ss in _LOPTIONS]
25
+
26
+
27
+ ###################################################
28
+ ###################################################
29
+ # function
30
+ ###################################################
31
+
32
+
33
+ def datastock_bash(option=None, ddef=None, **kwdargs):
34
+ """ Print tofu version and / or store in environment variable """
35
+
36
+ # --------------
37
+ # Check inputs
38
+ # --------------
39
+
40
+ if option not in _LOPSTRIP:
41
+ msg = (
42
+ "Provided option is not acceptable:\n"
43
+ f"\t- available: {_LOPSTRIP}\n"
44
+ f"\t- provided: {option}"
45
+ )
46
+ raise Exception(msg)
47
+
48
+ # --------------
49
+ # call corresponding bash command
50
+ # --------------
51
+
52
+ if option == 'version':
53
+ _bash_version.main(
54
+ ddef=ddef,
55
+ **kwdargs,
56
+ )
57
+
58
+
59
+ ###################################################
60
+ ###################################################
61
+ # main
62
+ ###################################################
63
+
64
+
65
+ def main():
66
+ # Parse input arguments
67
+ msg = """ Get tofu version from bash optionally set an enviroment variable
68
+
69
+ If run from a git repo containing tofu, simply returns git describe
70
+ Otherwise reads the tofu version stored in tofu/version.py
71
+
72
+ """
73
+
74
+ # ------------------
75
+ # Instanciate parser
76
+ # ------------------
77
+
78
+ parser = argparse.ArgumentParser(description=msg)
79
+
80
+ # ---------------------
81
+ # which script to call
82
+ # ---------------------
83
+
84
+ parser.add_argument(
85
+ 'option',
86
+ nargs='?',
87
+ type=str,
88
+ default='None',
89
+ )
90
+
91
+ #
92
+ parser.add_argument(
93
+ '-v', '--version',
94
+ help='get tofu current version',
95
+ required=False,
96
+ action='store_true',
97
+ )
98
+
99
+ # Others
100
+ # parser.add_argument('kwd', nargs='?', type=str, default='None')
101
+
102
+ # -------------------
103
+ # check options
104
+ # -------------------
105
+
106
+ if sys.argv[1] not in _LOPTIONS:
107
+ msg = (
108
+ "Provided option is not acceptable:\n"
109
+ f"\t- available: {_LOPTIONS}\n"
110
+ f"\t- provided: {sys.argv[1]}\n"
111
+ )
112
+ raise Exception(msg)
113
+
114
+ if len(sys.argv) > 2:
115
+ if any([ss in sys.argv[2:] for ss in _LOPTIONS]):
116
+ lopt = [ss for ss in sys.argv[1:] if ss in _LOPTIONS]
117
+ msg = (
118
+ "Only one option can be provided!\n"
119
+ f"\t- provided: {lopt}"
120
+ )
121
+ raise Exception(msg)
122
+
123
+ # ----------------------
124
+ # def values and parser
125
+ # ----------------------
126
+
127
+ option = sys.argv[1].strip('--')
128
+ ddef, parser = _dparser._DPARSER[option]()
129
+ if len(sys.argv) > 2:
130
+ kwdargs = dict(parser.parse_args(sys.argv[2:])._get_kwargs())
131
+ else:
132
+ kwdargs = {}
133
+
134
+ # ----------------------
135
+ # Call function
136
+ # ----------------------
137
+
138
+ datastock_bash(option=option, ddef=ddef, **kwdargs)
139
+
140
+
141
+ ###################################################
142
+ ###################################################
143
+ # __main__
144
+ ###################################################
145
+
146
+ if __name__ == '__main__':
147
+ main()