datastock 0.0.47__tar.gz → 0.0.49__tar.gz

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.
Files changed (56) hide show
  1. {datastock-0.0.47/datastock.egg-info → datastock-0.0.49}/PKG-INFO +35 -20
  2. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class2.py +9 -5
  3. {datastock-0.0.47 → datastock-0.0.49}/datastock/_generic_check.py +3 -52
  4. {datastock-0.0.47 → datastock-0.0.49}/datastock/version.py +1 -1
  5. {datastock-0.0.47 → datastock-0.0.49/datastock.egg-info}/PKG-INFO +35 -20
  6. {datastock-0.0.47 → datastock-0.0.49}/datastock.egg-info/SOURCES.txt +6 -1
  7. datastock-0.0.49/datastock.egg-info/entry_points.txt +2 -0
  8. {datastock-0.0.47 → datastock-0.0.49}/datastock.egg-info/requires.txt +6 -0
  9. {datastock-0.0.47 → datastock-0.0.49}/datastock.egg-info/top_level.txt +1 -0
  10. datastock-0.0.49/pyproject.toml +64 -0
  11. datastock-0.0.49/scripts/__init__.py +0 -0
  12. datastock-0.0.49/scripts/_bash_version.py +77 -0
  13. datastock-0.0.49/scripts/_dparser.py +109 -0
  14. datastock-0.0.49/scripts/main.py +147 -0
  15. {datastock-0.0.47 → datastock-0.0.49}/setup.py +10 -6
  16. datastock-0.0.47/pyproject.toml +0 -4
  17. {datastock-0.0.47 → datastock-0.0.49}/LICENSE +0 -0
  18. {datastock-0.0.47 → datastock-0.0.49}/MANIFEST.in +0 -0
  19. {datastock-0.0.47 → datastock-0.0.49}/README.md +0 -0
  20. {datastock-0.0.47 → datastock-0.0.49}/_updateversion.py +0 -0
  21. {datastock-0.0.47 → datastock-0.0.49}/datastock/_DataCollection_utils.py +0 -0
  22. {datastock-0.0.47 → datastock-0.0.49}/datastock/__init__.py +0 -0
  23. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class.py +0 -0
  24. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class0.py +0 -0
  25. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1.py +0 -0
  26. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_binning.py +0 -0
  27. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_check.py +0 -0
  28. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_color_touch.py +0 -0
  29. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_compute.py +0 -0
  30. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_domain.py +0 -0
  31. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_interpolate.py +0 -0
  32. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_show.py +0 -0
  33. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class1_uniformize.py +0 -0
  34. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class2_interactivity.py +0 -0
  35. {datastock-0.0.47 → datastock-0.0.49}/datastock/_class3.py +0 -0
  36. {datastock-0.0.47 → datastock-0.0.49}/datastock/_direct_calls.py +0 -0
  37. {datastock-0.0.47 → datastock-0.0.49}/datastock/_export_dataframe.py +0 -0
  38. {datastock-0.0.47 → datastock-0.0.49}/datastock/_find_plateau.py +0 -0
  39. {datastock-0.0.47 → datastock-0.0.49}/datastock/_generic_utils.py +0 -0
  40. {datastock-0.0.47 → datastock-0.0.49}/datastock/_generic_utils_plot.py +0 -0
  41. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_BvsA_as_distribution.py +0 -0
  42. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_BvsA_as_distribution_check.py +0 -0
  43. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_as_array.py +0 -0
  44. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_as_array_1d.py +0 -0
  45. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_as_array_234d.py +0 -0
  46. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_as_mobile_lines.py +0 -0
  47. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_as_profile1d.py +0 -0
  48. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_correlations.py +0 -0
  49. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_old_backup.py +0 -0
  50. {datastock-0.0.47 → datastock-0.0.49}/datastock/_plot_text.py +0 -0
  51. {datastock-0.0.47 → datastock-0.0.49}/datastock/_saveload.py +0 -0
  52. {datastock-0.0.47 → datastock-0.0.49}/datastock/tests/__init__.py +0 -0
  53. {datastock-0.0.47 → datastock-0.0.49}/datastock/tests/output/__init__.py +0 -0
  54. {datastock-0.0.47 → datastock-0.0.49}/datastock/tests/test_01_DataStock.py +0 -0
  55. {datastock-0.0.47 → datastock-0.0.49}/datastock.egg-info/dependency_links.txt +0 -0
  56. {datastock-0.0.47 → datastock-0.0.49}/setup.cfg +0 -0
@@ -1,34 +1,49 @@
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
- License-File: LICENSE
21
- Requires-Dist: numpy
22
- Requires-Dist: scipy
23
- Requires-Dist: matplotlib
24
- Requires-Dist: astropy
25
43
  Provides-Extra: dev
26
- Requires-Dist: check-manifest; extra == "dev"
27
- Requires-Dist: coverage; extra == "dev"
28
- Requires-Dist: pytest; extra == "dev"
29
- Requires-Dist: sphinx; extra == "dev"
30
- Requires-Dist: sphinx-gallery; extra == "dev"
31
- Requires-Dist: sphinx_bootstrap_theme; extra == "dev"
44
+ Provides-Extra: linting
45
+ Provides-Extra: formatting
46
+ License-File: LICENSE
32
47
 
33
48
  [![Conda]( https://anaconda.org/conda-forge/datastock/badges/version.svg)](https://anaconda.org/conda-forge/datastock)
34
49
  [![](https://anaconda.org/conda-forge/datastock/badges/downloads.svg)](https://anaconda.org/conda-forge/datastock)
@@ -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)
@@ -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,34 +1,49 @@
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
- License-File: LICENSE
21
- Requires-Dist: numpy
22
- Requires-Dist: scipy
23
- Requires-Dist: matplotlib
24
- Requires-Dist: astropy
25
43
  Provides-Extra: dev
26
- Requires-Dist: check-manifest; extra == "dev"
27
- Requires-Dist: coverage; extra == "dev"
28
- Requires-Dist: pytest; extra == "dev"
29
- Requires-Dist: sphinx; extra == "dev"
30
- Requires-Dist: sphinx-gallery; extra == "dev"
31
- Requires-Dist: sphinx_bootstrap_theme; extra == "dev"
44
+ Provides-Extra: linting
45
+ Provides-Extra: formatting
46
+ License-File: LICENSE
32
47
 
33
48
  [![Conda]( https://anaconda.org/conda-forge/datastock/badges/version.svg)](https://anaconda.org/conda-forge/datastock)
34
49
  [![](https://anaconda.org/conda-forge/datastock/badges/downloads.svg)](https://anaconda.org/conda-forge/datastock)
@@ -42,8 +42,13 @@ datastock/version.py
42
42
  datastock.egg-info/PKG-INFO
43
43
  datastock.egg-info/SOURCES.txt
44
44
  datastock.egg-info/dependency_links.txt
45
+ datastock.egg-info/entry_points.txt
45
46
  datastock.egg-info/requires.txt
46
47
  datastock.egg-info/top_level.txt
47
48
  datastock/tests/__init__.py
48
49
  datastock/tests/test_01_DataStock.py
49
- datastock/tests/output/__init__.py
50
+ datastock/tests/output/__init__.py
51
+ scripts/__init__.py
52
+ scripts/_bash_version.py
53
+ scripts/_dparser.py
54
+ scripts/main.py
@@ -0,0 +1,2 @@
1
+ [datastock]
2
+ datastock = scripts.main:main
@@ -10,3 +10,9 @@ pytest
10
10
  sphinx
11
11
  sphinx-gallery
12
12
  sphinx_bootstrap_theme
13
+
14
+ [formatting]
15
+ ruff
16
+
17
+ [linting]
18
+ ruff
@@ -1,2 +1,3 @@
1
1
  _updateversion
2
2
  datastock
3
+ scripts
@@ -0,0 +1,64 @@
1
+ [project]
2
+ name = "datastock"
3
+ license = {file = "LICENSE"}
4
+ dynamic = ["version"]
5
+ description = "Generic handler for multiple heterogenous numpy arrays and subclasses"
6
+ readme = "README.md"
7
+ requires-python = ">=3.6"
8
+ authors = [
9
+ {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"},
10
+ ]
11
+ maintainers = [
12
+ {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"},
13
+ ]
14
+ keywords = ["data", "analysis", "interactive", "heterogeneous arrays", "numpy", "Collection"]
15
+ classifiers = [
16
+ # How mature is this project? Common values are
17
+ # 3 - Alpha
18
+ # 4 - Beta
19
+ # 5 - Production/Stable
20
+ "Development Status :: 5 - Production/Stable",
21
+
22
+ # Indicate who your project is intended for
23
+ "Intended Audience :: Science/Research",
24
+
25
+ # Specify the Python versions you support here.
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.6",
28
+ "Programming Language :: Python :: 3.7",
29
+ "Programming Language :: Python :: 3.8",
30
+ "Programming Language :: Python :: 3.9",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ ]
34
+ dependencies = [
35
+ "numpy",
36
+ "scipy",
37
+ "matplotlib",
38
+ "astropy",
39
+ ]
40
+
41
+
42
+ [build-system]
43
+ requires = [
44
+ "setuptools>=40.8.0, <64",
45
+ "wheel",
46
+ "Cython>=0.26",
47
+ "numpy",
48
+ ]
49
+
50
+ [dependency-groups]
51
+ dev = [
52
+ "pytest",
53
+ ]
54
+
55
+ [project.optional-dependencies]
56
+ linting = [
57
+ 'ruff'
58
+ ]
59
+ formatting = [
60
+ 'ruff'
61
+ ]
62
+
63
+ [project.entry-points."datastock"]
64
+ datastock = "scripts.main:main"
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)
@@ -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
+ }
@@ -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()
@@ -6,7 +6,6 @@ https://github.com/ToFuProject/datastock
6
6
 
7
7
  # Built-in
8
8
  import os
9
- import subprocess
10
9
  from codecs import open
11
10
  # ... setup tools
12
11
  from setuptools import setup, find_packages
@@ -16,7 +15,7 @@ from setuptools import setup, find_packages
16
15
  import _updateversion as up
17
16
 
18
17
 
19
- # == Getting version =====================================================
18
+ # == Getting version ===========================================
20
19
  _HERE = os.path.abspath(os.path.dirname(__file__))
21
20
 
22
21
  version = up.updateversion()
@@ -26,7 +25,7 @@ print("Version for setup.py : ", version)
26
25
  print("")
27
26
 
28
27
 
29
- # =============================================================================
28
+ # ==============================================================
30
29
  # Get the long description from the README file
31
30
  # Get the readme file whatever its extension (md vs rst)
32
31
 
@@ -45,10 +44,10 @@ else:
45
44
  long_description_content_type = "text/x-rst"
46
45
 
47
46
 
48
- # =============================================================================
47
+ # =============================================================
49
48
 
50
49
 
51
- # =============================================================================
50
+ # ==============================================================
52
51
  # Compiling files
53
52
 
54
53
  setup(
@@ -167,7 +166,12 @@ setup(
167
166
  # Theye are generally preferable over scripts because they provide
168
167
  # cross-platform support and allow pip to create the appropriate form
169
168
  # of executable for the target platform.
170
- # entry_points={},
169
+ entry_points={
170
+ 'console_scripts': [
171
+ 'datastock=scripts.main:main',
172
+ ],
173
+ },
174
+
171
175
  # include_dirs=[np.get_include()],
172
176
 
173
177
  py_modules=['_updateversion'],
@@ -1,4 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=40.8.0",
3
- "wheel",
4
- ]
File without changes
File without changes
File without changes
File without changes
File without changes