pygeodesy 24.5.8__py2.py3-none-any.whl → 24.5.15__py2.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.
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/METADATA +2 -2
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/RECORD +51 -50
- pygeodesy/__init__.py +16 -12
- pygeodesy/__main__.py +9 -10
- pygeodesy/albers.py +2 -2
- pygeodesy/auxilats/__main__.py +7 -10
- pygeodesy/auxilats/auxLat.py +2 -1
- pygeodesy/basics.py +158 -171
- pygeodesy/booleans.py +4 -4
- pygeodesy/constants.py +8 -6
- pygeodesy/datums.py +9 -8
- pygeodesy/ecef.py +5 -4
- pygeodesy/elevations.py +2 -2
- pygeodesy/ellipsoidalBaseDI.py +7 -5
- pygeodesy/elliptic.py +10 -7
- pygeodesy/errors.py +6 -6
- pygeodesy/etm.py +3 -2
- pygeodesy/fmath.py +13 -12
- pygeodesy/fstats.py +32 -33
- pygeodesy/fsums.py +103 -89
- pygeodesy/geodesicw.py +14 -14
- pygeodesy/geodesicx/__main__.py +4 -4
- pygeodesy/geodesicx/gxarea.py +4 -4
- pygeodesy/geodsolve.py +3 -2
- pygeodesy/geoids.py +6 -6
- pygeodesy/heights.py +4 -4
- pygeodesy/internals.py +571 -0
- pygeodesy/interns.py +4 -202
- pygeodesy/iters.py +3 -2
- pygeodesy/karney.py +4 -4
- pygeodesy/ktm.py +7 -7
- pygeodesy/lazily.py +139 -217
- pygeodesy/mgrs.py +3 -2
- pygeodesy/named.py +13 -10
- pygeodesy/nvectorBase.py +4 -3
- pygeodesy/osgr.py +14 -12
- pygeodesy/points.py +5 -5
- pygeodesy/props.py +7 -7
- pygeodesy/rhumb/bases.py +3 -2
- pygeodesy/rhumb/solve.py +2 -2
- pygeodesy/solveBase.py +3 -2
- pygeodesy/streprs.py +5 -4
- pygeodesy/trf.py +4 -4
- pygeodesy/units.py +15 -17
- pygeodesy/ups.py +7 -6
- pygeodesy/utily.py +4 -4
- pygeodesy/utm.py +5 -4
- pygeodesy/utmupsBase.py +4 -3
- pygeodesy/vector3dBase.py +2 -1
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/WHEEL +0 -0
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/top_level.txt +0 -0
pygeodesy/lazily.py
CHANGED
|
@@ -27,38 +27,41 @@ and line number.
|
|
|
27
27
|
after all initial imports.
|
|
28
28
|
'''
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
from
|
|
45
|
-
|
|
30
|
+
from pygeodesy import internals as _internals, interns as _interns, \
|
|
31
|
+
_isfrozen # DON'T _lazy_import2
|
|
32
|
+
# from pygeodesy.errors import _error_init # _ALL_MODS
|
|
33
|
+
from pygeodesy.internals import _caller3, _dunder_nameof, _dunder_main, \
|
|
34
|
+
_headof, _osversion2, printf, _Pythonarchine, \
|
|
35
|
+
_tailof
|
|
36
|
+
from pygeodesy.interns import NN, _areaOf_, _attribute_, _by_, _COLONSPACE_, \
|
|
37
|
+
_COMMASPACE_, _doesn_t_exist_, _DOT_, _enabled_, \
|
|
38
|
+
_EQUALSPACED_, _from_, _HASH_, _immutable_, \
|
|
39
|
+
_isclockwise_, _ispolar_, _line_, _module_, \
|
|
40
|
+
_no_, _NorthPole_, _not_, _or_, _pygeodesy_, \
|
|
41
|
+
_pygeodesy_abspath_, _SouthPole_, \
|
|
42
|
+
_SPACE_, _sub_packages, _sys, _UNDER_, _version_, \
|
|
43
|
+
_intern # function
|
|
44
|
+
# from pygeodesy.streprs import unstr # _ALL_MODS
|
|
45
|
+
|
|
46
|
+
from os import getenv as _getenv
|
|
46
47
|
try:
|
|
47
48
|
from importlib import import_module
|
|
48
|
-
except ImportError: # Python 2.6-
|
|
49
|
+
except ImportError as x: # Python 2.6-
|
|
50
|
+
_str_x = str(x)
|
|
51
|
+
|
|
49
52
|
def import_module(name, *package):
|
|
50
53
|
t = _ALL_MODS.streprs.unstr(import_module, name, *package)
|
|
51
|
-
raise LazyImportError(t, txt=
|
|
54
|
+
raise LazyImportError(t, txt=_str_x)
|
|
52
55
|
|
|
53
|
-
_a_l_l_ = '__all__' # .__main__
|
|
54
56
|
__as__ = ' as '
|
|
57
|
+
_dunder_all_ = '__all__' # in .__main__
|
|
58
|
+
_dunder_package_ = '__package__'
|
|
55
59
|
_FOR_DOCS = _getenv('PYGEODESY_FOR_DOCS', NN) # for epydoc ...
|
|
56
60
|
_from_DOT__ = _SPACE_(NN, _from_, _DOT_)
|
|
57
61
|
_i0 = () # PYCHOK empty tuple
|
|
58
|
-
_init__all__ = _FOR_DOCS or _getenv('PYGEODESY_INIT__ALL__',
|
|
62
|
+
_init__all__ = _FOR_DOCS or _getenv('PYGEODESY_INIT__ALL__', _dunder_all_) == _dunder_all_ # PYCHOK exported
|
|
59
63
|
_lazily_ = 'lazily'
|
|
60
64
|
_lazily_imported__ = _SPACE_(_HASH_, _lazily_, 'imported', NN)
|
|
61
|
-
_p_a_c_k_a_g_e_ = '__package__'
|
|
62
65
|
_PYGEODESY_GEOCONVERT_ = 'PYGEODESY_GEOCONVERT' # PYCHOK .mgrs, test.bases
|
|
63
66
|
_PYGEODESY_GEODSOLVE_ = 'PYGEODESY_GEODSOLVE' # PYCHOK .geodsolve, test.bases
|
|
64
67
|
_PYGEODESY_LAZY_IMPORT_ = 'PYGEODESY_LAZY_IMPORT'
|
|
@@ -121,7 +124,7 @@ class _Dict(dict):
|
|
|
121
124
|
self[name] = mod_
|
|
122
125
|
|
|
123
126
|
def _NAME(self, which):
|
|
124
|
-
self._name = _intern(which.
|
|
127
|
+
self._name = _intern(_dunder_nameof(which).upper())
|
|
125
128
|
|
|
126
129
|
|
|
127
130
|
class _NamedEnum_RO(dict):
|
|
@@ -140,8 +143,8 @@ class _NamedEnum_RO(dict):
|
|
|
140
143
|
raise LazyAttributeError(t, txt=_doesn_t_exist_)
|
|
141
144
|
|
|
142
145
|
def __setattr__(self, attr, value): # PYCHOK no cover
|
|
143
|
-
t = _EQUALSPACED_(self._DOT_(attr), value)
|
|
144
|
-
raise LazyAttributeError(
|
|
146
|
+
t = _EQUALSPACED_(self._DOT_(attr), repr(value))
|
|
147
|
+
raise LazyAttributeError(_immutable_, txt=t)
|
|
145
148
|
|
|
146
149
|
def enums(self):
|
|
147
150
|
# Yield all C{(mod_, tuple)} pairs
|
|
@@ -149,14 +152,12 @@ class _NamedEnum_RO(dict):
|
|
|
149
152
|
n = m.replace(_UNDER_, _DOT_)
|
|
150
153
|
if n != m:
|
|
151
154
|
if m.startswith(_UNDER_):
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if isinstance(t, tuple):
|
|
159
|
-
yield n, t
|
|
155
|
+
continue # skip _name= ...
|
|
156
|
+
u = m.rstrip(_UNDER_)
|
|
157
|
+
if u != m:
|
|
158
|
+
u = len(u)
|
|
159
|
+
n = n[:u] + m[u:]
|
|
160
|
+
yield n, t
|
|
160
161
|
|
|
161
162
|
def fill_D(self, _D, which):
|
|
162
163
|
# Fill C{_Dict _D}.
|
|
@@ -203,8 +204,9 @@ _ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
|
203
204
|
'equidistant', 'gnomonic'),
|
|
204
205
|
basics=_i('clips', 'copysign0', 'copytype', 'halfs2',
|
|
205
206
|
'int1s', 'isbool', 'isCartesian', 'isclass', 'iscomplex', 'isDEPRECATED', 'isfloat',
|
|
206
|
-
'isidentifier', 'isinstanceof', 'isint', '
|
|
207
|
-
'
|
|
207
|
+
'isidentifier', 'isinstanceof', 'isint', 'isiterable', 'isiterablen', 'iskeyword',
|
|
208
|
+
'isLatLon', 'islistuple', 'isNvector', 'isodd', 'isscalar', 'issequence', 'isstr',
|
|
209
|
+
'issubclassof', 'itemsorted',
|
|
208
210
|
'len2', 'map1', 'map2', 'neg', 'neg_',
|
|
209
211
|
'signBit', 'signOf', 'splice', 'str2ub', 'ub2str', 'unsigned0'),
|
|
210
212
|
booleans=_i('BooleanFHP', 'BooleanGH', 'LatLonFHP', 'LatLonGH',
|
|
@@ -307,13 +309,14 @@ _ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
|
307
309
|
'HeightIDWeuclidean', 'HeightIDWexact', 'HeightIDWflatLocal', 'HeightIDWflatPolar',
|
|
308
310
|
'HeightIDWhaversine', 'HeightIDWhubeny', 'HeightIDWkarney', 'HeightIDWthomas',
|
|
309
311
|
'HeightIDWvincentys', 'HeightLinear', 'HeightLSQBiSpline', 'HeightSmoothBiSpline'),
|
|
310
|
-
|
|
312
|
+
internals=_internals.__all__,
|
|
313
|
+
interns=_interns.__all__,
|
|
311
314
|
iters=_i('LatLon2PsxyIter', 'PointsIter', 'points2',
|
|
312
315
|
'isNumpy2', 'isPoints2', 'isTuple2', 'iterNumpy2', 'iterNumpy2over'),
|
|
313
316
|
karney=_i('Area3Tuple', 'Caps', 'Direct9Tuple', 'GDict', 'Inverse10Tuple', 'Rhumb8Tuple'),
|
|
314
317
|
ktm=_i('KTMError', 'KTransverseMercator'),
|
|
315
318
|
latlonBase=_i(), # module only
|
|
316
|
-
lazily=_i('LazyAttributeError', 'LazyImportError', 'isLazy'
|
|
319
|
+
lazily=_i('LazyAttributeError', 'LazyImportError', 'isLazy'),
|
|
317
320
|
lcc=_i('Conic', 'Conics', 'Lcc', 'LCCError', 'toLcc'),
|
|
318
321
|
ltp=_i('Attitude', 'AttitudeError', 'ChLV', 'ChLVa', 'ChLVe', 'Frustum',
|
|
319
322
|
'LocalCartesian', 'LocalError', 'Ltp', 'tyr3d'),
|
|
@@ -429,12 +432,9 @@ _ALL_DEPRECATED = _NamedEnum_RO(_name='_ALL_DEPRECATED',
|
|
|
429
432
|
deprecated_nvector=_i('LatLonNvectorBase', 'Nvector', 'sumOf', 'NorthPole', 'SouthPole'),)
|
|
430
433
|
|
|
431
434
|
|
|
432
|
-
class _ALL_MODS(
|
|
433
|
-
'''(INTERNAL)
|
|
435
|
+
class _ALL_MODS(_internals._ALL_MODS_Base):
|
|
436
|
+
'''(INTERNAL) Memoized import of any L{pygeodesy} module.
|
|
434
437
|
'''
|
|
435
|
-
def _DOT_(self, name): # PYCHOK no cover
|
|
436
|
-
return _DOT_(self.__class__.__name__, name)
|
|
437
|
-
|
|
438
438
|
def __getattr__(self, name):
|
|
439
439
|
'''Get a C{pygeodesy} module or attribute by B{C{name}}.
|
|
440
440
|
|
|
@@ -444,18 +444,16 @@ class _ALL_MODS(object):
|
|
|
444
444
|
|
|
445
445
|
@raise AttributeError: No attribute named B{C{name}}.
|
|
446
446
|
'''
|
|
447
|
-
try:
|
|
448
|
-
|
|
447
|
+
try:
|
|
448
|
+
v = _lazy_dict[name] # package.__dict__
|
|
449
449
|
except KeyError:
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
t = _EQUALSPACED_(self._DOT_(attr), repr(value))
|
|
458
|
-
raise AttributeError(_COLONSPACE_(t, _immutable_))
|
|
450
|
+
v = _lazy_module(name) # package.__getattr__
|
|
451
|
+
if _tailof(_dunder_nameof(v)) != name:
|
|
452
|
+
try:
|
|
453
|
+
v = getattr(v, _tailof(name))
|
|
454
|
+
except AttributeError:
|
|
455
|
+
pass # XXX LazyAttributeError?
|
|
456
|
+
return v
|
|
459
457
|
|
|
460
458
|
def getattr(self, name, *attr_dflt): # , parent=_pygeodesy_
|
|
461
459
|
'''Get an attribute of/or a C{pygeodesy} module.
|
|
@@ -478,7 +476,7 @@ class _ALL_MODS(object):
|
|
|
478
476
|
def getmodule(self, name, parent=_pygeodesy_):
|
|
479
477
|
'''Get a C{pygeodesy} module.
|
|
480
478
|
|
|
481
|
-
@arg name:
|
|
479
|
+
@arg name: Un/qualified module name (C{str}).
|
|
482
480
|
|
|
483
481
|
@return: The C{pygeodesy} module.
|
|
484
482
|
|
|
@@ -494,24 +492,20 @@ class _ALL_MODS(object):
|
|
|
494
492
|
def items(self): # no module named 'items'
|
|
495
493
|
'''Yield the modules imported so far.
|
|
496
494
|
'''
|
|
495
|
+
_hd = _headof
|
|
497
496
|
for n, m in _sys.modules.items():
|
|
498
|
-
|
|
497
|
+
if _hd(n) == _pygeodesy_:
|
|
498
|
+
yield n, m
|
|
499
499
|
|
|
500
|
-
|
|
501
|
-
def name(self):
|
|
502
|
-
return self.__class__.__name__
|
|
503
|
-
|
|
504
|
-
_ALL_MODS = _ALL_MODS() # PYCHOK singleton
|
|
500
|
+
_internals._MODS = _ALL_MODS = _ALL_MODS() # PYCHOK singleton
|
|
505
501
|
|
|
506
502
|
__all__ = _ALL_LAZY.lazily
|
|
507
|
-
__version__ = '24.
|
|
503
|
+
__version__ = '24.05.15'
|
|
508
504
|
|
|
509
505
|
|
|
510
506
|
def _ALL_OTHER(*objs):
|
|
511
507
|
'''(INTERNAL) Get class and function B{C{objs}} for __all__.
|
|
512
508
|
'''
|
|
513
|
-
_interns = _ALL_MODS.interns # from pygeodesy import interns
|
|
514
|
-
|
|
515
509
|
def _interned(o): # intern'd base name
|
|
516
510
|
n = _tailof(_dunder_nameof(o))
|
|
517
511
|
i = NN(_UNDER_, n, _UNDER_) # intern'd
|
|
@@ -567,8 +561,8 @@ def _all_missing2(_all_):
|
|
|
567
561
|
|
|
568
562
|
_alzy = _Dict((a, a) for a in _ALL_INIT)
|
|
569
563
|
_alzy.update(_all_imports()) # without _all_backups!
|
|
570
|
-
return ((_DOT_(_lazily_, _all_imports.__name__),
|
|
571
|
-
(_DOT_(_pygeodesy_,
|
|
564
|
+
return ((_DOT_(_lazily_, _all_imports.__name__), _diff(_all_, _alzy)),
|
|
565
|
+
(_DOT_(_pygeodesy_, _dunder_all_), _diff(_alzy.keys(), _all_)))
|
|
572
566
|
|
|
573
567
|
|
|
574
568
|
def _attrof(attr_as): # .testDeprecated
|
|
@@ -576,38 +570,25 @@ def _attrof(attr_as): # .testDeprecated
|
|
|
576
570
|
return as_ or a_.rstrip(_DOT_)
|
|
577
571
|
|
|
578
572
|
|
|
579
|
-
def
|
|
580
|
-
|
|
581
|
-
for the caller B{C{up}} stack frames in the Python call stack.
|
|
582
|
-
'''
|
|
583
|
-
# sys._getframe(1) ... 'importlib._bootstrap' line 1032,
|
|
584
|
-
# may throw a ValueError('call stack not deep enough')
|
|
585
|
-
f = _sys._getframe(up + 1)
|
|
586
|
-
return (f.f_code.co_name, # caller name
|
|
587
|
-
_basename(f.f_code.co_filename), # file name
|
|
588
|
-
f.f_lineno) # line number
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
def _lazy_attr(unused): # PYCHOK overwritten in _lazy_import
|
|
592
|
-
pass
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
# def _lazy_attributes(_name_):
|
|
596
|
-
# '''(INTERNAL) Return a function to C{B{_name_}.__getattr__(attr)}
|
|
573
|
+
# def _lazy_attributes(_dunder_name_):
|
|
574
|
+
# '''(INTERNAL) Return a function to C{B{__name__}.__getattr__(attr)}
|
|
597
575
|
# on lazily imported modules and sub-modules.
|
|
598
576
|
# '''
|
|
599
577
|
# if _unlazy:
|
|
600
|
-
# raise AssertionError(_COMMASPACE_(
|
|
578
|
+
# raise AssertionError(_COMMASPACE_(_dunder_name_, _not_(_DEPRECATED_)))
|
|
601
579
|
#
|
|
602
580
|
# def _getattr(attr, *dflt):
|
|
603
581
|
# try: # a module name
|
|
604
582
|
# return _ALL_MODS.getmodule(attr)
|
|
605
583
|
# except (AttributeError, ImportError):
|
|
606
|
-
# return _ALL_MODS.getattr(
|
|
584
|
+
# return _ALL_MODS.getattr(_dunder_name_, attr, *dflt)
|
|
607
585
|
#
|
|
608
586
|
# return _getattr
|
|
609
587
|
|
|
610
588
|
|
|
589
|
+
_lazy_dict = {} # PYCHOK overwritten by _lazy_import2
|
|
590
|
+
|
|
591
|
+
|
|
611
592
|
def _lazy_import2(pack): # MCCABE 14
|
|
612
593
|
'''Check for and set up C{lazy import}.
|
|
613
594
|
|
|
@@ -634,14 +615,15 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
634
615
|
U{PEP 562<https://www.Python.org/dev/peps/pep-0562>} and the
|
|
635
616
|
U{new way<https://Snarky.Ca/lazy-importing-in-python-3-7/>}.
|
|
636
617
|
'''
|
|
637
|
-
if pack != _pygeodesy_ or _unlazy: #
|
|
638
|
-
t = _no_(_DOT_(pack, _lazy_import2
|
|
639
|
-
raise LazyImportError(t, txt=
|
|
618
|
+
if pack != _pygeodesy_ or _unlazy: # Python 3.7+
|
|
619
|
+
t = _no_(_DOT_(pack, _dunder_nameof(_lazy_import2))) # PYCHOK no cover
|
|
620
|
+
raise LazyImportError(t, txt=_Pythonarchine(sep=_SPACE_))
|
|
640
621
|
|
|
641
622
|
package, parent = _lazy_init2(pack) # _pygeodesy_
|
|
642
623
|
|
|
643
|
-
subpacks =
|
|
644
|
-
|
|
624
|
+
subpacks = set((parent, NN) + tuple(
|
|
625
|
+
_DOT_(parent, s) for s in _sub_packages))
|
|
626
|
+
MISSING = object() # DON'T interns.MISSING!
|
|
645
627
|
imports = _all_imports()
|
|
646
628
|
deprecates = _all_deprecates()
|
|
647
629
|
|
|
@@ -658,28 +640,28 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
658
640
|
attr = name
|
|
659
641
|
try:
|
|
660
642
|
t = _DOT_(pack, mod)
|
|
661
|
-
|
|
643
|
+
v = import_module(t, parent)
|
|
662
644
|
except ImportError:
|
|
663
645
|
# <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
|
|
664
646
|
raise LazyImportError(_no_(_module_), txt=t)
|
|
665
|
-
t = getattr(
|
|
647
|
+
t = getattr(v, _dunder_package_, None)
|
|
666
648
|
if t not in subpacks: # invalid module package
|
|
667
|
-
raise LazyImportError(_DOT_(mod,
|
|
649
|
+
raise LazyImportError(_DOT_(mod, _dunder_package_), t)
|
|
668
650
|
if attr: # get the attribute
|
|
669
|
-
|
|
670
|
-
if
|
|
651
|
+
v = getattr(v, attr, MISSING)
|
|
652
|
+
if v is MISSING: # PYCHOK no cover
|
|
671
653
|
t = _DOT_(mod, attr)
|
|
672
654
|
# <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
|
|
673
655
|
raise LazyAttributeError(_no_(_attribute_), txt=t)
|
|
674
656
|
|
|
675
|
-
elif name in (
|
|
676
|
-
|
|
657
|
+
elif name in (_dunder_all_,): # XXX _dunder_dir_, _dunder_members_?
|
|
658
|
+
v = _ALL_INIT + tuple(imports.keys())
|
|
677
659
|
else: # PYCHOK no cover
|
|
678
660
|
t = _no_(_module_, _or_, _attribute_)
|
|
679
661
|
# <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
|
|
680
662
|
raise LazyAttributeError(t, txt=_DOT_(parent, name))
|
|
681
663
|
|
|
682
|
-
setattr(package, name,
|
|
664
|
+
setattr(package, name, v) # package.__dict__[name] = val
|
|
683
665
|
if isLazy > 1:
|
|
684
666
|
t = NN(_lazily_imported__, _DOT_(parent, name))
|
|
685
667
|
if mod and _tailof(mod) != name:
|
|
@@ -692,32 +674,33 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
692
674
|
pass
|
|
693
675
|
printf(t) # XXX print
|
|
694
676
|
|
|
695
|
-
return
|
|
677
|
+
return v # __getattr__
|
|
696
678
|
|
|
697
|
-
global
|
|
698
|
-
|
|
679
|
+
global _lazy_dict, _lazy_module
|
|
680
|
+
_lazy_dict = package.__dict__
|
|
681
|
+
_lazy_module = __getattr__
|
|
699
682
|
|
|
700
683
|
return package, __getattr__ # _lazy_import2
|
|
701
684
|
|
|
702
685
|
|
|
703
|
-
# def _lazy_import_all(
|
|
686
|
+
# def _lazy_import_all(_dunder_name_):
|
|
704
687
|
# '''(INTERNAL) Return a function mimicking C{from B{__name__} import *},
|
|
705
688
|
# of all items, see .deprecated.__init__
|
|
706
689
|
# '''
|
|
707
690
|
# if _unlazy:
|
|
708
|
-
# raise AssertionError(_COMMASPACE_(
|
|
691
|
+
# raise AssertionError(_COMMASPACE_(_dunder_name_, _not_(_DEPRECATED_)))
|
|
709
692
|
#
|
|
710
|
-
# _getattr = _lazy_attributes(
|
|
711
|
-
# _import_start = _lazy_import_star(
|
|
693
|
+
# _getattr = _lazy_attributes(_dunder_name_) # __name__.__getattr__
|
|
694
|
+
# _import_start = _lazy_import_star(_dunder_name_, ALL_=_ALL_IMPORTS)
|
|
712
695
|
#
|
|
713
696
|
# def _import_all(attr, *dflt):
|
|
714
|
-
# return _import_star(
|
|
697
|
+
# return _import_star(_dunder_name_) if attr == _dunder_all_ else \
|
|
715
698
|
# _getattr(attr, *dflt)
|
|
716
699
|
#
|
|
717
700
|
# return _import_all
|
|
718
701
|
|
|
719
702
|
|
|
720
|
-
def _lazy_import_as(
|
|
703
|
+
def _lazy_import_as(_dunder_name_):
|
|
721
704
|
'''(INTERNAL) Return a function to C{import B{__name__}.mod as mod}
|
|
722
705
|
I{of modules only}, see .deprecated, .rhumb or get an attribute
|
|
723
706
|
lazily exported by C{__name__}.
|
|
@@ -727,25 +710,25 @@ def _lazy_import_as(_name_):
|
|
|
727
710
|
|
|
728
711
|
def _import_as(mod):
|
|
729
712
|
try:
|
|
730
|
-
return _ALL_MODS.getmodule(_DOT_(
|
|
713
|
+
return _ALL_MODS.getmodule(_DOT_(_dunder_name_, mod))
|
|
731
714
|
except ImportError:
|
|
732
|
-
return
|
|
715
|
+
return _lazy_module(mod)
|
|
733
716
|
|
|
734
717
|
return _import_as
|
|
735
718
|
|
|
736
719
|
|
|
737
|
-
# def _lazy_import_star(
|
|
720
|
+
# def _lazy_import_star(_dunder_name_, ALL_=_ALL_DEPRECATES):
|
|
738
721
|
# '''(INTERNAL) Return a function to mimick C{from B{__name__} import *},
|
|
739
722
|
# of all DEPRECATED items, see .deprecated, .testDeprecated
|
|
740
723
|
# '''
|
|
741
724
|
# if _unlazy:
|
|
742
|
-
# raise AssertionError(_COMMASPACE_(
|
|
725
|
+
# raise AssertionError(_COMMASPACE_(_dunder_name_, _not_(_DEPRECATED_)))
|
|
743
726
|
#
|
|
744
727
|
# def _import_star(_into_):
|
|
745
728
|
# '''Do C{from B{__name__} import *} inside module C{B{__into__}}.
|
|
746
729
|
# '''
|
|
747
730
|
# d = dict()
|
|
748
|
-
# nm = _tailof(
|
|
731
|
+
# nm = _tailof(_dunder_name_)
|
|
749
732
|
# _g = _ALL_MODS.getattr # pygeodesy.__getattr__
|
|
750
733
|
# _h = _headof
|
|
751
734
|
# for a, m in ALL_.items():
|
|
@@ -760,31 +743,6 @@ def _lazy_import_as(_name_):
|
|
|
760
743
|
# return _import_star
|
|
761
744
|
|
|
762
745
|
|
|
763
|
-
# def _lazy_subs(_name_, force=_FOR_DOCS, over=False):
|
|
764
|
-
# '''(INTERNAL) Return the names of a package's sub-packages and
|
|
765
|
-
# update the package's C{__dict__} accordingly.
|
|
766
|
-
# '''
|
|
767
|
-
# sm = dict()
|
|
768
|
-
# if force and _name_ != '__main__':
|
|
769
|
-
# nm = _tailof(_name_)
|
|
770
|
-
# _a = _ALL_MODS.getattr
|
|
771
|
-
# _m = _ALL_MODS.getmodule
|
|
772
|
-
# d = _a(_name_, '__dict__', {})
|
|
773
|
-
# for n in _a(_name_, _a_l_l_, ()):
|
|
774
|
-
# try: # n is a class name, get its mod name
|
|
775
|
-
# m = _a(_name_, n).__module__
|
|
776
|
-
# n, s = m.split(_DOT_)[-2:]
|
|
777
|
-
# if n == nm and s not in sm:
|
|
778
|
-
# # like import m as s
|
|
779
|
-
# m = _m(m)
|
|
780
|
-
# sm[s] = m if over else d.get(s, m)
|
|
781
|
-
# except (AttributeError, ImportError, ValueError) as x:
|
|
782
|
-
# pass
|
|
783
|
-
# d.update(sm)
|
|
784
|
-
#
|
|
785
|
-
# return _ALL_OTHER(*sm.values())
|
|
786
|
-
|
|
787
|
-
|
|
788
746
|
def _lazy_init2(pack):
|
|
789
747
|
'''(INTERNAL) Initialize lazy import and set globals C{isLazy} and C{_unLazy0}.
|
|
790
748
|
|
|
@@ -831,82 +789,45 @@ def _lazy_init2(pack):
|
|
|
831
789
|
return package, parent
|
|
832
790
|
|
|
833
791
|
|
|
834
|
-
def
|
|
835
|
-
|
|
836
|
-
return _ALL_MODS.streprs.pairs(*args, **kwds)
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
def print_(*args, **nl_nt_prefix_end_file_flush_sep): # PYCHOK no cover
|
|
840
|
-
'''Python 3+ C{print}-like formatting and printing.
|
|
841
|
-
|
|
842
|
-
@arg args: Arguments to be converted to C{str} and joined by B{C{sep}}
|
|
843
|
-
(any C{type}, all positional).
|
|
844
|
-
@kwarg nl_nt_prefix_end_file_flush_sep: Keyword arguments C{B{nl}=0}
|
|
845
|
-
for the number of leading blank lines (C{int}), C{B{nt}=0}
|
|
846
|
-
the number of trailing blank lines (C{int}), C{B{prefix}=NN}
|
|
847
|
-
to be inserted before the formatted text (C{str}) and Python
|
|
848
|
-
3+ C{print} keyword arguments C{B{end}}, C{B{sep}}, C{B{file}}
|
|
849
|
-
and C{B{flush}}.
|
|
850
|
-
|
|
851
|
-
@return: Number of bytes written.
|
|
792
|
+
def _lazy_module(name): # overwritten by _lazy_import2
|
|
793
|
+
'''(INTERNAL) Get or import a C{pygeodesy} module.
|
|
852
794
|
'''
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
795
|
+
try: # most likely ... module has been imported
|
|
796
|
+
m = _ALL_MODS.getmodule(name)
|
|
797
|
+
except (AttributeError, ImportError) as x:
|
|
798
|
+
raise LazyImportError(name, cause=x)
|
|
799
|
+
_lazy_dict[name] = m # cache
|
|
800
|
+
return m
|
|
858
801
|
|
|
859
|
-
@arg fmt: U{Printf-style<https://Docs.Python.org/3/library/stdtypes.html#
|
|
860
|
-
printf-style-string-formatting>} format specification (C{str}).
|
|
861
|
-
@arg args: Arguments to be formatted (any C{type}, all positional).
|
|
862
|
-
@kwarg nl_nt_prefix_end_file_flush_sep_kwds: Keyword arguments C{B{nl}=0}
|
|
863
|
-
for the number of leading blank lines (C{int}), C{B{nt}=0} the
|
|
864
|
-
number of trailing blank lines (C{int}), C{B{prefix}=NN} to
|
|
865
|
-
be inserted before the formatted text (C{str}) and Python 3+
|
|
866
|
-
C{print} keyword arguments C{B{end}}, C{B{sep}}, C{B{file}} and
|
|
867
|
-
C{B{flush}}. Any remaining C{B{kwds}} are U{printf-style
|
|
868
|
-
<https://Docs.Python.org/3/library/stdtypes.html#printf-style-string-formatting>}
|
|
869
|
-
keyword arguments to be formatted, I{iff no B{C{args}} are present}.
|
|
870
802
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
def _xprint7(nl=0, nt=0, prec=6, prefix=NN, sep=_SPACE_, file=_sys.stdout,
|
|
897
|
-
end=_NL_, flush=False, **kwds):
|
|
898
|
-
'''(INTERNAL) Unravel the C{printf} and remaining keyword arguments.
|
|
899
|
-
'''
|
|
900
|
-
if nl > 0:
|
|
901
|
-
prefix = NN(_NL_ * nl, prefix)
|
|
902
|
-
if nt > 0:
|
|
903
|
-
end = NN(end, _NL_ * nt)
|
|
904
|
-
return prefix, end, sep, file, flush, prec, kwds
|
|
803
|
+
# def _lazy_subs(_dunder_name_, force=_FOR_DOCS, over=False):
|
|
804
|
+
# '''(INTERNAL) Return the names of a package's sub-packages and
|
|
805
|
+
# update the package's C{__dict__} accordingly.
|
|
806
|
+
# '''
|
|
807
|
+
# sm = dict()
|
|
808
|
+
# if force and not _dunder_main(_dunder_name_):
|
|
809
|
+
# nm = _tailof(_dunder_name_)
|
|
810
|
+
# _a = _ALL_MODS.getattr
|
|
811
|
+
# _m = _ALL_MODS.getmodule
|
|
812
|
+
# d = _a(_dunder_name_, _dunder_dict_, {})
|
|
813
|
+
# for n in _a(_dunder_name_, _dunder_all_, ()):
|
|
814
|
+
# try: # n is a class name, get its mod name
|
|
815
|
+
# m = _a(_dunder_name_, n).__module__
|
|
816
|
+
# n, s = m.split(_DOT_)[-2:]
|
|
817
|
+
# if n == nm and s not in sm:
|
|
818
|
+
# # like import m as s
|
|
819
|
+
# m = _m(m)
|
|
820
|
+
# sm[s] = m if over else d.get(s, m)
|
|
821
|
+
# except (AttributeError, ImportError, ValueError) as x:
|
|
822
|
+
# pass
|
|
823
|
+
# d.update(sm)
|
|
824
|
+
#
|
|
825
|
+
# return _ALL_OTHER(*sm.values())
|
|
905
826
|
|
|
906
827
|
|
|
907
|
-
# del _i, _i0
|
|
828
|
+
# del _i, _i0
|
|
908
829
|
|
|
909
|
-
if __name__
|
|
830
|
+
if _dunder_main(__name__): # PYCHOK no cover
|
|
910
831
|
|
|
911
832
|
from timeit import timeit
|
|
912
833
|
|
|
@@ -921,21 +842,22 @@ if __name__ == '__main__':
|
|
|
921
842
|
|
|
922
843
|
t1 = timeit(t1, number=1000000)
|
|
923
844
|
t2 = timeit(t2, number=1000000)
|
|
924
|
-
v =
|
|
925
|
-
printf('%.
|
|
926
|
-
|
|
845
|
+
v = _SPACE_.join(_Pythonarchine() + _osversion2())
|
|
846
|
+
printf('%.6f import vs %.6f _ALL_MODS: %.2fX, %s', t1, t2, t1 / t2, v)
|
|
847
|
+
|
|
848
|
+
# del t1, t2, timeit, v
|
|
927
849
|
|
|
928
|
-
# python3.12 -m pygeodesy.lazily
|
|
929
|
-
# 0.
|
|
850
|
+
# python3.12 -W ignore -m pygeodesy.lazily
|
|
851
|
+
# 0.145177 import vs 0.075402 _ALL_MODS: 1.93X, Python 3.12.3 64bit arm64 macOS 14.4.1
|
|
930
852
|
|
|
931
|
-
#
|
|
932
|
-
# 0.
|
|
853
|
+
# python3.11 -W ignore -m pygeodesy.lazily
|
|
854
|
+
# 0.381723 import vs 0.251589 _ALL_MODS: 1.52X, Python 3.11.5 64bit arm64 macOS 14.4.1
|
|
933
855
|
|
|
934
|
-
#
|
|
935
|
-
# 0.
|
|
856
|
+
# python3.10 -W ignore -m pygeodesy.lazily
|
|
857
|
+
# 0.378293 import vs 0.266507 _ALL_MODS: 1.42X, Python 3.10.8 64bit arm64 macOS 14.4.1
|
|
936
858
|
|
|
937
|
-
#
|
|
938
|
-
# 1.
|
|
859
|
+
# python2 -m pygeodesy.lazily
|
|
860
|
+
# 1.213805 import vs 0.474075 _ALL_MODS: 2.56X, Python 2.7.18 64bit arm64_x86_64 macOS 10.16
|
|
939
861
|
|
|
940
862
|
# **) MIT License
|
|
941
863
|
#
|
pygeodesy/mgrs.py
CHANGED
|
@@ -55,7 +55,7 @@ from pygeodesy.utm import toUtm8, _to3zBlat, Utm, _UTM_ZONE_MAX, _UTM_ZONE_MIN
|
|
|
55
55
|
# from pygeodesy.utmupsBase import _UTM_ZONE_MAX, _UTM_ZONE_MIN # from .utm
|
|
56
56
|
|
|
57
57
|
__all__ = _ALL_LAZY.mgrs
|
|
58
|
-
__version__ = '
|
|
58
|
+
__version__ = '24.05.13'
|
|
59
59
|
|
|
60
60
|
_AN_ = 'AN' # default south pole grid tile and band B
|
|
61
61
|
_AtoPx_ = _AtoZnoIO_.tillP
|
|
@@ -654,7 +654,8 @@ def _um100km2(m):
|
|
|
654
654
|
if __name__ == '__main__':
|
|
655
655
|
|
|
656
656
|
from pygeodesy.ellipsoidalVincenty import fabs, LatLon
|
|
657
|
-
|
|
657
|
+
# from pygeodesy.internals import printf # from .lazily
|
|
658
|
+
from pygeodesy.lazily import _getenv, printf
|
|
658
659
|
|
|
659
660
|
# from math import fabs # from .ellipsoidalVincenty
|
|
660
661
|
from os import access as _access, linesep as _NL, X_OK as _X_OK
|