Coverage for pygeodesy/basics.py: 90%

210 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-05-28 09:02 -0400

1 

2# -*- coding: utf-8 -*- 

3 

4u'''Some, basic definitions, functions and dependencies. 

5 

6Use env variable C{PYGEODESY_XPACKAGES} to avoid import of dependencies 

7C{geographiclib}, C{numpy} and/or C{scipy}. Set C{PYGEODESY_XPACKAGES} 

8to a comma-separated list of package names to be excluded from import. 

9''' 

10# make sure int/int division yields float quotient 

11from __future__ import division 

12division = 1 / 2 # .albers, .azimuthal, .constants, etc., .utily 

13if not division: 

14 raise ImportError('%s 1/2 == %s' % ('division', division)) 

15del division 

16 

17from pygeodesy.errors import _AssertionError, _AttributeError, _ImportError, \ 

18 _TypeError, _TypesError, _ValueError, _xkwds_get 

19from pygeodesy.interns import MISSING, NN, _by_, _DOT_, _ELLIPSIS4_, _enquote, \ 

20 _EQUAL_, _in_, _invalid_, _N_A_, _SPACE_, \ 

21 _splituple, _UNDER_, _version_ 

22from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS, _FOR_DOCS, \ 

23 _getenv, _sys, _sys_version_info2 

24 

25from copy import copy as _copy, deepcopy as _deepcopy 

26from math import copysign as _copysign 

27import inspect as _inspect 

28 

29__all__ = _ALL_LAZY.basics 

30__version__ = '23.05.26' 

31 

32_0_0 = 0.0 # see .constants 

33_below_ = 'below' 

34_cannot_ = 'cannot' 

35_list_tuple_types = (list, tuple) 

36_odd_ = 'odd' 

37_required_ = 'required' 

38_PYGEODESY_XPACKAGES_ = 'PYGEODESY_XPACKAGES' 

39_XPACKAGES = _splituple(_getenv(_PYGEODESY_XPACKAGES_, NN)) 

40 

41try: # Luciano Ramalho, "Fluent Python", page 395, O'Reilly, 2016 

42 from numbers import Integral as _Ints, Real as _Scalars 

43except ImportError: 

44 try: 

45 _Ints = int, long # int objects (C{tuple}) 

46 except NameError: # Python 3+ 

47 _Ints = int, # int objects (C{tuple}) 

48 _Scalars = _Ints + (float,) 

49 

50try: 

51 try: # use C{from collections.abc import ...} in Python 3.9+ 

52 from collections.abc import Sequence as _Sequence # in .points 

53 except ImportError: # no .abc in Python 3.8- and 2.7- 

54 from collections import Sequence as _Sequence # in .points 

55 if isinstance([], _Sequence) and isinstance((), _Sequence): 

56 # and isinstance(range(1), _Sequence): 

57 _Seqs = _Sequence 

58 else: 

59 raise ImportError # _AssertionError 

60except ImportError: 

61 _Sequence = tuple # immutable for .points._Basequence 

62 _Seqs = list, _Sequence # , range for function len2 below 

63 

64try: 

65 _Bytes = unicode, bytearray # PYCHOK expected 

66 _Strs = basestring, str # XXX , bytes 

67 

68 def _NOP(x): 

69 '''NOP, pass thru.''' 

70 return x 

71 

72 str2ub = ub2str = _NOP # avoids UnicodeDecodeError 

73 

74 def _Xstr(exc): # PYCHOK no cover 

75 '''I{Invoke only with caught ImportError} B{C{exc}}. 

76 

77 C{... "cannot import name _distributor_init" ...} 

78 

79 only for C{numpy}, C{scipy} import errors occurring 

80 on arm64 Apple Silicon running macOS' Python 2.7.16? 

81 ''' 

82 t = str(exc) 

83 if '_distributor_init' in t: 

84 from sys import exc_info 

85 from traceback import extract_tb 

86 tb = exc_info()[2] # 3-tuple (type, value, traceback) 

87 t4 = extract_tb(tb, 1)[0] # 4-tuple (file, line, name, 'import ...') 

88 t = _SPACE_(_cannot_, t4[3] or _N_A_) 

89 del tb, t4 

90 return t 

91 

92except NameError: # Python 3+ 

93 from pygeodesy.interns import _utf_8_ 

94 

95 _Bytes = bytes, bytearray 

96 _Strs = str, # tuple 

97 _Xstr = str 

98 

99 def str2ub(sb): 

100 '''Convert C{str} to C{unicode bytes}. 

101 ''' 

102 if isinstance(sb, _Strs): 

103 sb = sb.encode(_utf_8_) 

104 return sb 

105 

106 def ub2str(ub): 

107 '''Convert C{unicode bytes} to C{str}. 

108 ''' 

109 if isinstance(ub, _Bytes): 

110 ub = str(ub.decode(_utf_8_)) 

111 return ub 

112 

113 

114def clips(sb, limit=50, white=NN): 

115 '''Clip a string to the given length limit. 

116 

117 @arg sb: String (C{str} or C{bytes}). 

118 @kwarg limit: Length limit (C{int}). 

119 @kwarg white: Optionally, replace all whitespace (C{str}). 

120 

121 @return: The clipped or unclipped B{C{sb}}. 

122 ''' 

123 T = type(sb) 

124 if len(sb) > limit > 8: 

125 h = limit // 2 

126 sb = T(_ELLIPSIS4_).join((sb[:h], sb[-h:])) 

127 if white: # replace whitespace 

128 sb = T(white).join(sb.split()) 

129 return sb 

130 

131 

132def copysign0(x, y): 

133 '''Like C{math.copysign(x, y)} except C{zero}, I{unsigned}. 

134 

135 @return: C{math.copysign(B{x}, B{y})} if B{C{x}} else 

136 C{type(B{x})(0)}. 

137 ''' 

138 return _copysign(x, (y if y else 0)) if x else copytype(0, x) 

139 

140 

141def copytype(x, y): 

142 '''Return the value of B{x} as C{type} of C{y}. 

143 

144 @return: C{type(B{y})(B{x})}. 

145 ''' 

146 return type(y)(x if x else _0_0) 

147 

148 

149def halfs2(str2): 

150 '''Split a string in 2 halfs. 

151 

152 @arg str2: String to split (C{str}). 

153 

154 @return: 2-Tuple (_1st, _2nd) half (C{str}). 

155 

156 @raise ValueError: Zero or odd C{len}(B{C{str2}}). 

157 ''' 

158 h, r = divmod(len(str2), 2) 

159 if r or not h: 

160 raise _ValueError(str2=str2, txt=_odd_) 

161 return str2[:h], str2[h:] 

162 

163 

164def isbool(obj): 

165 '''Check whether an object is C{bool}ean. 

166 

167 @arg obj: The object (any C{type}). 

168 

169 @return: C{True} if B{C{obj}} is C{bool}ean, 

170 C{False} otherwise. 

171 ''' 

172 return isinstance(obj, bool) # and (obj is False 

173# or obj is True) 

174 

175if isbool(1) or isbool(0): # PYCHOK assert 

176 raise _AssertionError(isbool=1) 

177 

178if _FOR_DOCS: # XXX avoid epidoc Python 2.7 error 

179 

180 def isclass(obj): 

181 '''Return C{True} if B{C{obj}} is a C{class} or C{type}. 

182 

183 @see: Python's C{inspect.isclass}. 

184 ''' 

185 return _inspect.isclass(obj) 

186else: 

187 isclass = _inspect.isclass 

188 

189 

190def iscomplex(obj): 

191 '''Check whether an object is C{complex}. 

192 

193 @arg obj: The object (any C{type}). 

194 

195 @return: C{True} if B{C{obj}} is C{complex}, 

196 C{False} otherwise. 

197 ''' 

198 # hasattr('conjugate'), hasattr('real') and hasattr('imag') 

199 return isinstance(obj, complex) # numbers.Complex? 

200 

201 

202def isfloat(obj): 

203 '''Check whether an object is a C{float} or float C{str}. 

204 

205 @arg obj: The object (any C{type}). 

206 

207 @return: C{True} if B{C{obj}} is a C{float}, 

208 C{False} otherwise. 

209 ''' 

210 try: 

211 return isinstance( obj, float) or (isstr(obj) 

212 and isinstance(float(obj), float)) 

213 except (TypeError, ValueError): 

214 return False 

215 

216 

217try: 

218 isidentifier = str.isidentifier # Python 3, must be str 

219except AttributeError: # Python 2- 

220 

221 def isidentifier(obj): 

222 '''Return C{True} if B{C{obj}} is a valid Python identifier. 

223 ''' 

224 return bool(obj and obj.replace(_UNDER_, NN).isalnum() 

225 and not obj[:1].isdigit()) 

226 

227 

228def isinstanceof(obj, *classes): 

229 '''Check an instance of one or several C{classes}. 

230 

231 @arg obj: The instance (C{any}). 

232 @arg classes: One or more classes (C{class}). 

233 

234 @return: C{True} if B{C{obj}} is in instance of 

235 one of the B{C{classes}}. 

236 ''' 

237 return isinstance(obj, classes) 

238 

239 

240def isint(obj, both=False): 

241 '''Check for C{int} type or an integer C{float} value. 

242 

243 @arg obj: The object (any C{type}). 

244 @kwarg both: If C{true}, check C{float} and L{Fsum} 

245 type and value (C{bool}). 

246 

247 @return: C{True} if B{C{obj}} is C{int} or I{integer} 

248 C{float} or L{Fsum}, C{False} otherwise. 

249 

250 @note: Both C{isint(True)} and C{isint(False)} return 

251 C{False} (and no longer C{True}). 

252 ''' 

253 if isinstance(obj, _Ints) and not isbool(obj): 

254 return True 

255 elif both: # and isinstance(obj, (float, Fsum)) ... 

256 try: # ... NOT , Scalars) to include Fsum! 

257 return obj.is_integer() 

258 except AttributeError: 

259 pass # XXX float(int(obj)) == obj? 

260 return False 

261 

262 

263try: 

264 from keyword import iskeyword # Python 2.7+ 

265except ImportError: 

266 

267 def iskeyword(unused): 

268 '''Not Implemented. Return C{False}, always. 

269 ''' 

270 return False 

271 

272 

273def islistuple(obj, minum=0): 

274 '''Check for list or tuple C{type} with a minumal length. 

275 

276 @arg obj: The object (any C{type}). 

277 @kwarg minum: Minimal C{len} required C({int}). 

278 

279 @return: C{True} if B{C{obj}} is C{list} or C{tuple} with 

280 C{len} at least B{C{minum}}, C{False} otherwise. 

281 ''' 

282 return type(obj) in _list_tuple_types and len(obj) >= (minum or 0) 

283 

284 

285def isodd(x): 

286 '''Is B{C{x}} odd? 

287 

288 @arg x: Value (C{scalar}). 

289 

290 @return: C{True} if B{C{x}} is odd, 

291 C{False} otherwise. 

292 ''' 

293 return bool(int(x) & 1) # == bool(int(x) % 2) 

294 

295 

296def isscalar(obj): 

297 '''Check for scalar types. 

298 

299 @arg obj: The object (any C{type}). 

300 

301 @return: C{True} if B{C{obj}} is C{scalar}, C{False} otherwise. 

302 ''' 

303 return isinstance(obj, _Scalars) and not isbool(obj) 

304 

305 

306def issequence(obj, *excls): 

307 '''Check for sequence types. 

308 

309 @arg obj: The object (any C{type}). 

310 @arg excls: Classes to exclude (C{type}), all positional. 

311 

312 @note: Excluding C{tuple} implies excluding C{namedtuple}. 

313 

314 @return: C{True} if B{C{obj}} is a sequence, C{False} otherwise. 

315 ''' 

316 return isinstance(obj, _Seqs) and not (excls and isinstance(obj, excls)) 

317 

318 

319def isstr(obj): 

320 '''Check for string types. 

321 

322 @arg obj: The object (any C{type}). 

323 

324 @return: C{True} if B{C{obj}} is C{str}, C{False} otherwise. 

325 ''' 

326 return isinstance(obj, _Strs) 

327 

328 

329def issubclassof(Sub, *Supers): 

330 '''Check whether a class is a sub-class of some other class(es). 

331 

332 @arg Sub: The sub-class (C{class}). 

333 @arg Supers: One or more C(super) classes (C{class}). 

334 

335 @return: C{True} if B{C{Sub}} is a sub-class of any B{C{Supers}}, 

336 C{False} if not (C{bool}) or C{None} if B{C{Sub}} is not 

337 a class or if no B{C{Supers}} are given or none of those 

338 are a class. 

339 ''' 

340 if isclass(Sub): 

341 t = tuple(S for S in Supers if isclass(S)) 

342 if t: 

343 return bool(issubclass(Sub, t)) 

344 return None 

345 

346 

347def len2(items): 

348 '''Make built-in function L{len} work for generators, iterators, 

349 etc. since those can only be started exactly once. 

350 

351 @arg items: Generator, iterator, list, range, tuple, etc. 

352 

353 @return: 2-Tuple C{(n, items)} of the number of items (C{int}) 

354 and the items (C{list} or C{tuple}). 

355 ''' 

356 if not isinstance(items, _Seqs): # NOT hasattr(items, '__len__'): 

357 items = list(items) 

358 return len(items), items 

359 

360 

361def map1(fun1, *xs): # XXX map_ 

362 '''Apply each argument to a single-argument function and 

363 return a C{tuple} of results. 

364 

365 @arg fun1: 1-Arg function to apply (C{callable}). 

366 @arg xs: Arguments to apply (C{any positional}). 

367 

368 @return: Function results (C{tuple}). 

369 ''' 

370 return tuple(map(fun1, xs)) # note xs, not *xs 

371 

372 

373def map2(func, *xs): 

374 '''Apply arguments to a function and return a C{tuple} of results. 

375 

376 Unlike Python 2's built-in L{map}, Python 3+ L{map} returns a 

377 L{map} object, an iterator-like object which generates the 

378 results only once. Converting the L{map} object to a tuple 

379 maintains the Python 2 behavior. 

380 

381 @arg func: Function to apply (C{callable}). 

382 @arg xs: Arguments to apply (C{list, tuple, ...}). 

383 

384 @return: Function results (C{tuple}). 

385 ''' 

386 return tuple(map(func, *xs)) # note *xs, not xs 

387 

388 

389def neg(x): 

390 '''Negate C{x} unless C{zero} or C{NEG0}. 

391 

392 @return: C{-B{x}} if B{C{x}} else C{0.0}. 

393 ''' 

394 return -x if x else _0_0 

395 

396 

397def neg_(*xs): 

398 '''Negate all of C{xs} with L{neg}. 

399 

400 @return: A C{tuple(neg(x) for x in B{xs})}. 

401 ''' 

402 return tuple(map(neg, xs)) # like map1 

403 

404 

405def signBit(x): 

406 '''Return C{signbit(B{x})}, like C++. 

407 

408 @return: C{True} if C{B{x} < 0} or C{NEG0} (C{bool}). 

409 ''' 

410 return x < 0 or _MODS.constants.isneg0(x) 

411 

412 

413def _signOf(x, off): 

414 '''(INTERNAL) Return the sign of B{C{x}} versus B{C{off}}. 

415 ''' 

416 return +1 if x > off else (-1 if x < off else 0) 

417 

418 

419def signOf(x): 

420 '''Return sign of C{x} as C{int}. 

421 

422 @return: -1, 0 or +1 (C{int}). 

423 ''' 

424 try: 

425 s = x.signOf() # Fsum instance? 

426 except AttributeError: 

427 s = _signOf(x, 0) 

428 return s 

429 

430 

431def _sizeof(inst): 

432 '''(INTERNAL) Recursive size of an C{inst}ance. 

433 

434 @return: Size in bytes (C{int}), ignoring 

435 class attributes and counting 

436 duplicates only once. 

437 ''' 

438 try: 

439 r = inst.__dict__.values() 

440 except AttributeError: # None, int, etc. 

441 r = inst, 

442 lts = _list_tuple_types + (set,) 

443 

444 def _2ts(r): 

445 _id, _is = id, isinstance 

446 for o in r: 

447 if _is(o, lts): 

448 for o in _2ts(o): 

449 yield _id(o), o 

450 elif _is(o, dict): 

451 for o in _2ts(o.values()): 

452 yield _id(o), o 

453# for o in _2ts(o.keys()): 

454# yield _id(o), o 

455 else: 

456 yield _id(o), o 

457 

458 d = dict(_2ts(r)) # ignore duplicates 

459 _ = d.pop(id(inst), None) # avoid recursion 

460 return sum(map(_sys.getsizeof, d.values())) 

461 

462 

463def splice(iterable, n=2, **fill): 

464 '''Split an iterable into C{n} slices. 

465 

466 @arg iterable: Items to be spliced (C{list}, C{tuple}, ...). 

467 @kwarg n: Number of slices to generate (C{int}). 

468 @kwarg fill: Optional fill value for missing items. 

469 

470 @return: A generator for each of B{C{n}} slices, 

471 M{iterable[i::n] for i=0..n}. 

472 

473 @raise TypeError: Invalid B{C{n}}. 

474 

475 @note: Each generated slice is a C{tuple} or a C{list}, 

476 the latter only if the B{C{iterable}} is a C{list}. 

477 

478 @example: 

479 

480 >>> from pygeodesy import splice 

481 

482 >>> a, b = splice(range(10)) 

483 >>> a, b 

484 ((0, 2, 4, 6, 8), (1, 3, 5, 7, 9)) 

485 

486 >>> a, b, c = splice(range(10), n=3) 

487 >>> a, b, c 

488 ((0, 3, 6, 9), (1, 4, 7), (2, 5, 8)) 

489 

490 >>> a, b, c = splice(range(10), n=3, fill=-1) 

491 >>> a, b, c 

492 ((0, 3, 6, 9), (1, 4, 7, -1), (2, 5, 8, -1)) 

493 

494 >>> tuple(splice(list(range(9)), n=5)) 

495 ([0, 5], [1, 6], [2, 7], [3, 8], [4]) 

496 

497 >>> splice(range(9), n=1) 

498 <generator object splice at 0x0...> 

499 ''' 

500 if not isint(n): 

501 raise _TypeError(n=n) 

502 

503 t = iterable 

504 if not isinstance(t, (list, tuple)): 

505 t = tuple(t) # force tuple, also for PyPy3 

506 

507 if n > 1: 

508 if fill: 

509 fill = _xkwds_get(fill, fill=MISSING) 

510 if fill is not MISSING: 

511 m = len(t) % n 

512 if m > 0: # same type fill 

513 t = t + type(t)((fill,)) * (n - m) 

514 for i in range(n): 

515 # XXX t[i::n] chokes PyChecker 

516 yield t[slice(i, None, n)] 

517 else: 

518 yield t 

519 

520 

521def unsigned0(x): 

522 '''Return C{0.0} unsigned. 

523 

524 @return: C{B{x}} if B{C{x}} else C{0.0}. 

525 ''' 

526 return x if x else _0_0 

527 

528 

529def _xargs_names(callabl): 

530 '''(INTERNAL) Get the C{callabl}'s args names. 

531 ''' 

532 try: 

533 args_kwds = _inspect.signature(callabl).parameters.keys() 

534 except AttributeError: # .signature new Python 3+ 

535 args_kwds = _inspect.getargspec(callabl).args 

536 return tuple(args_kwds) 

537 

538 

539def _xcopy(inst, deep=False): 

540 '''(INTERNAL) Copy an object, shallow or deep. 

541 

542 @arg inst: The object to copy (any C{type}). 

543 @kwarg deep: If C{True} make a deep, otherwise 

544 a shallow copy (C{bool}). 

545 

546 @return: The copy of B{C{inst}}. 

547 ''' 

548 return _deepcopy(inst) if deep else _copy(inst) 

549 

550 

551def _xdup(inst, **items): 

552 '''(INTERNAL) Duplicate an object, replacing some attributes. 

553 

554 @arg inst: The object to copy (any C{type}). 

555 @kwarg items: Attributes to be changed (C{any}). 

556 

557 @return: Shallow duplicate of B{C{inst}} with modified 

558 attributes, if any B{C{items}}. 

559 

560 @raise AttributeError: Some B{C{items}} invalid. 

561 ''' 

562 d = _xcopy(inst, deep=False) 

563 for n, v in items.items(): 

564 if not hasattr(d, n): 

565 t = _MODS.named.classname(inst) 

566 t = _SPACE_(_DOT_(t, n), _invalid_) 

567 raise _AttributeError(txt=t, this=inst, **items) 

568 setattr(d, n, v) 

569 return d 

570 

571 

572def _xgeographiclib(where, *required): 

573 '''(INTERNAL) Import C{geographiclib} and check required version 

574 ''' 

575 try: 

576 _xpackage(_xgeographiclib) 

577 import geographiclib 

578 except ImportError as x: 

579 raise _xImportError(x, where) 

580 return _xversion(geographiclib, where, *required) 

581 

582 

583def _xImportError(x, where, **name): 

584 '''(INTERNAL) Embellish an C{ImportError}. 

585 ''' 

586 t = _SPACE_(_required_, _by_, _xwhere(where, **name)) 

587 return _ImportError(_Xstr(x), txt=t, cause=x) 

588 

589 

590def _xinstanceof(*Types, **name_value_pairs): 

591 '''(INTERNAL) Check C{Types} of all C{name=value} pairs. 

592 

593 @arg Types: One or more classes or types (C{class}), 

594 all positional. 

595 @kwarg name_value_pairs: One or more C{B{name}=value} pairs 

596 with the C{value} to be checked. 

597 

598 @raise TypeError: One of the B{C{name_value_pairs}} is not 

599 an instance of any of the B{C{Types}}. 

600 ''' 

601 for n, v in name_value_pairs.items(): 

602 if not isinstance(v, Types): 

603 raise _TypesError(n, v, *Types) 

604 

605 

606def _xnumpy(where, *required): 

607 '''(INTERNAL) Import C{numpy} and check required version 

608 ''' 

609 try: 

610 _xpackage(_xnumpy) 

611 import numpy 

612 except ImportError as x: 

613 raise _xImportError(x, where) 

614 return _xversion(numpy, where, *required) 

615 

616 

617def _xpackage(_xpkg): 

618 '''(INTERNAL) Check dependency to be excluded. 

619 ''' 

620 n = _xpkg.__name__[2:] 

621 if n in _XPACKAGES: 

622 x = _SPACE_(n, _in_, _PYGEODESY_XPACKAGES_) 

623 e = _enquote(_getenv(_PYGEODESY_XPACKAGES_, NN)) 

624 raise ImportError(_EQUAL_(x, e)) 

625 

626 

627def _xor(x, *xs): 

628 '''(INTERNAL) Exclusive-or C{x} and C{xs}. 

629 ''' 

630 for x_ in xs: 

631 x ^= x_ 

632 return x 

633 

634 

635def _xscipy(where, *required): 

636 '''(INTERNAL) Import C{scipy} and check required version 

637 ''' 

638 try: 

639 _xpackage(_xscipy) 

640 import scipy 

641 except ImportError as x: 

642 raise _xImportError(x, where) 

643 return _xversion(scipy, where, *required) 

644 

645 

646def _xsubclassof(*Classes, **name_value_pairs): 

647 '''(INTERNAL) Check (super) class of all C{name=value} pairs. 

648 

649 @arg Classes: One or more classes or types (C{class}), 

650 all positional. 

651 @kwarg name_value_pairs: One or more C{B{name}=value} pairs 

652 with the C{value} to be checked. 

653 

654 @raise TypeError: One of the B{C{name_value_pairs}} is not 

655 a (sub-)class of any of the B{C{Classes}}. 

656 ''' 

657 for n, v in name_value_pairs.items(): 

658 if not issubclassof(v, *Classes): 

659 raise _TypesError(n, v, *Classes) 

660 

661 

662def _xversion(package, where, *required, **name): # in .karney 

663 '''(INTERNAL) Check the C{package} version vs B{C{required}}. 

664 ''' 

665 n = len(required) 

666 if n: 

667 t = _xversion_info(package) 

668 if t[:n] < required: 

669 t = _SPACE_(package.__name__, _version_, _DOT_(*t), 

670 _below_, _DOT_(*required), 

671 _required_, _by_, _xwhere(where, **name)) 

672 raise ImportError(t) 

673 return package 

674 

675 

676def _xversion_info(package): # in .karney 

677 '''(INTERNAL) Get the C{package.__version_info__} as a 2- or 

678 3-tuple C{(major, minor, revision)} if C{int}s. 

679 ''' 

680 try: 

681 t = package.__version_info__ 

682 except AttributeError: 

683 t = package.__version__.strip() 

684 t = t.replace(_DOT_, _SPACE_).split()[:3] 

685 return map2(int, t) 

686 

687 

688def _xwhere(where, **name): 

689 '''(INTERNAL) Get the fully qualified name. 

690 ''' 

691 m = _MODS.named.modulename(where, prefixed=True) 

692 n = _xkwds_get(name, name=NN) 

693 if n: 

694 m = _DOT_(m, n) 

695 return m 

696 

697 

698if _sys_version_info2 < (3, 10): # see .errors 

699 _zip = zip # PYCHOK exported 

700else: # Python 3.10+ 

701 

702 def _zip(*args): 

703 return zip(*args, strict=True) 

704 

705# **) MIT License 

706# 

707# Copyright (C) 2016-2023 -- mrJean1 at Gmail -- All Rights Reserved. 

708# 

709# Permission is hereby granted, free of charge, to any person obtaining a 

710# copy of this software and associated documentation files (the "Software"), 

711# to deal in the Software without restriction, including without limitation 

712# the rights to use, copy, modify, merge, publish, distribute, sublicense, 

713# and/or sell copies of the Software, and to permit persons to whom the 

714# Software is furnished to do so, subject to the following conditions: 

715# 

716# The above copyright notice and this permission notice shall be included 

717# in all copies or substantial portions of the Software. 

718# 

719# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

720# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

721# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 

722# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 

723# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

724# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 

725# OTHER DEALINGS IN THE SOFTWARE.