Coverage for pygeodesy/internals.py: 87%
267 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-09 12:50 -0400
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-09 12:50 -0400
2# -*- coding: utf-8 -*-
4u'''Mostly INTERNAL functions, except L{machine}, L{print_} and L{printf}.
5'''
6# from pygeodesy.basics import isiterablen # _MODS
7# from pygeodesy.errors import _AttributeError, _error_init, _UnexpectedError, _xError2 # _MODS
8from pygeodesy.interns import NN, _BAR_, _COLON_, _DASH_, _DOT_, _ELLIPSIS_, _EQUALSPACED_, \
9 _immutable_, _NL_, _pygeodesy_, _PyPy__, _python_, _QUOTE1_, \
10 _QUOTE2_, _s_, _SPACE_, _sys, _UNDER_, _utf_8_
11from pygeodesy.interns import _COMMA_, _Python_ # PYCHOK used!
12# from pygeodesy.streprs import anstr, pairs, unstr # _MODS
14import os as _os # in .lazily, ...
15import os.path as _os_path
16# import sys as _sys # from .interns
18_0_0 = 0.0 # PYCHOK in .basics, .constants
19_arm64_ = 'arm64'
20_iOS_ = 'iOS'
21_macOS_ = 'macOS'
22_SIsecs = 'fs', 'ps', 'ns', 'us', 'ms', 'sec' # reversed
23_Windows_ = 'Windows'
26def _dunder_nameof(inst, *dflt):
27 '''(INTERNAL) Get the double_underscore __name__ attr.
28 '''
29 try:
30 return inst.__name__
31 except AttributeError:
32 pass
33 return dflt[0] if dflt else inst.__class__.__name__
36def _dunder_nameof_(*names__): # in .errors._IsnotError
37 '''(INTERNAL) Yield the _dunder_nameof or name.
38 '''
39 return map(_dunder_nameof, names__, names__)
42def _Property_RO(method):
43 '''(INTERNAL) Can't I{recursively} import L{props.property_RO}.
44 '''
45 name = _dunder_nameof(method)
47 def _del(inst, attr): # PYCHOK no cover
48 delattr(inst, attr) # force error
50 def _get(inst, **unused): # PYCHOK 2 vs 3 args
51 try: # to get the cached value immediately
52 v = inst.__dict__[name]
53 except (AttributeError, KeyError):
54 # cache the value in the instance' __dict__
55 inst.__dict__[name] = v = method(inst)
56 return v
58 def _set(inst, val): # PYCHOK no cover
59 setattr(inst, name, val) # force error
61 return property(_get, _set, _del)
64class _MODS_Base(object):
65 '''(INTERNAL) Base-class for C{lazily._ALL_MODS}.
66 '''
67 def __delattr__(self, attr): # PYCHOK no cover
68 self.__dict__.pop(attr, None)
70 def __setattr__(self, attr, value): # PYCHOK no cover
71 m = _MODS.errors
72 t = _EQUALSPACED_(self._DOT_(attr), repr(value))
73 raise m._AttributeError(_immutable_, txt=t)
75 @_Property_RO
76 def bits_machine2(self):
77 '''Get platform 2-list C{[bits, machine]}, I{once}.
78 '''
79 import platform as p
81 m = p.machine() # ARM64, arm64, x86_64, iPhone13,2, etc.
82 m = m.replace(_COMMA_, _UNDER_)
83 if m.lower() == 'x86_64': # PYCHOK on Intel or Rosetta2 ...
84 v = p.mac_ver()[0] # ... and only on macOS ...
85 if v and _version2(v) > (10, 15): # ... 11+ aka 10.16
86 # <https://Developer.Apple.com/forums/thread/659846>
87 # _sysctl_uint('hw.optional.arm64') and \
88 if _sysctl_uint('sysctl.proc_translated'):
89 m = _UNDER_(_arm64_, m) # Apple Si emulating Intel x86-64
90 return [p.architecture()[0], # bits
91 m] # arm64, arm64_x86_64, x86_64, etc.
93 @_Property_RO
94 def ctypes3(self):
95 '''Get 3-tuple C{(ctypes.CDLL, ._dlopen, .util.findlibrary)}, I{once}.
96 '''
97 if _ismacOS():
98 from ctypes import CDLL, DEFAULT_MODE, _dlopen
100 def dlopen(name):
101 return _dlopen(name, DEFAULT_MODE)
102 else: # PYCHOK no cover
103 from ctypes import CDLL
104 dlopen = _passarg
106 from ctypes.util import find_library
107 return CDLL, dlopen, find_library
109 @_Property_RO
110 def ctypes5(self):
111 '''Get 5-tuple C{(ctypes.byref, .c_char_p, .c_size_t, .c_uint, .sizeof)}, I{once}.
112 '''
113 from ctypes import byref, c_char_p, c_size_t, c_uint, sizeof # get_errno
114 return byref, c_char_p, c_size_t, c_uint, sizeof
116 def _DOT_(self, name): # PYCHOK no cover
117 return _DOT_(self.name, name)
119 @_Property_RO
120 def errors(self):
121 '''Get module C{pygeodesy.errors}, I{once}.
122 '''
123 from pygeodesy import errors # DON'T _lazy_import2
124 return errors
126 def ios_ver(self):
127 '''Mimick C{platform.xxx_ver} for C{iOS}.
128 '''
129 try: # Pythonista only
130 from platform import iOS_ver
131 return iOS_ver()
132 except (AttributeError, ImportError):
133 return NN, (NN, NN, NN), NN
135 @_Property_RO
136 def libc(self):
137 '''Load C{libc.dll|dylib}, I{once}.
138 '''
139 return _load_lib('libc')
141 @_Property_RO
142 def name(self):
143 '''Get this name (C{str}).
144 '''
145 return _dunder_nameof(self.__class__)
147 @_Property_RO
148 def nix2(self): # PYCHOK no cover
149 '''Get Linux 2-list C{[distro, version]}, I{once}.
150 '''
151 import platform as p
153 n, v = p.uname()[0], NN
154 if n.lower() == 'linux':
155 try: # use distro only for Linux, not macOS, etc.
156 import distro # <https://PyPI.org/project/distro>
157 _a = _MODS.streprs.anstr
158 v = _a(distro.version()) # first
159 n = _a(distro.id()) # .name()?
160 except (AttributeError, ImportError):
161 pass # v = str(_0_0)
162 n = n.capitalize()
163 return n, v
165 def nix_ver(self): # PYCHOK no cover
166 '''Mimick C{platform.xxx_ver} for C{*nix}.
167 '''
168 _, v = _MODS.nix2
169 t = _version2(v, n=3) if v else (NN, NN, NN)
170 return v, t, machine()
172 @_Property_RO
173 def osversion2(self):
174 '''Get 2-list C{[OS, release]}, I{once}.
175 '''
176 import platform as p
178 _Nix, _ = _MODS.nix2
179 # - mac_ver() returns ('10.12.5', ..., 'x86_64') on
180 # macOS and ('10.3.3', ..., 'iPad4,2') on iOS
181 # - win32_ver is ('XP', ..., 'SP3', ...) on Windows XP SP3
182 # - platform() returns 'Darwin-16.6.0-x86_64-i386-64bit'
183 # on macOS and 'Darwin-16.6.0-iPad4,2-64bit' on iOS
184 # - sys.platform is 'darwin' on macOS, 'ios' on iOS,
185 # 'win32' on Windows and 'cygwin' on Windows/Gygwin
186 # - distro.id() and .name() return 'Darwin' on macOS
187 for n, v in ((_iOS_, _MODS.ios_ver),
188 (_macOS_, p.mac_ver),
189 (_Windows_, p.win32_ver),
190 (_Nix, _MODS.nix_ver),
191 ('Java', p.java_ver),
192 ('uname', p.uname)):
193 v = v()[0]
194 if v and n:
195 break
196 else:
197 n = v = NN # XXX AssertioError?
198 return [n, v]
200 @_Property_RO
201 def Pythonarchine(self):
202 '''Get 3- or 4-list C{[PyPy, Python, bits, machine]}, I{once}.
203 '''
204 v = _sys.version
205 l3 = [_Python_(v)] + self.bits_machine2
206 pypy = _PyPy__(v)
207 if pypy: # PYCHOK no cover
208 l3.insert(0, pypy)
209 return l3
211 @_Property_RO
212 def _Str_Bytes(self):
213 '''Get all C{str} and C{bytes} types.
214 '''
215 import pygeodesy.basics as m
216 return m._Strs + m._Bytes # + (range, map)
218 @_Property_RO
219 def streprs(self):
220 '''Get module C{pygeodesy.streprs}, I{once}.
221 '''
222 from pygeodesy import streprs # DON'T _lazy_import2
223 return streprs
225 @_Property_RO
226 def version(self):
227 '''Get pygeodesy version, I{once}.
228 '''
229 from pygeodesy import version
230 return version
232_MODS = _MODS_Base() # PYCHOK overwritten by .lazily
235def _caller3(up): # in .lazily, .named
236 '''(INTERNAL) Get 3-tuple C{(caller name, file name, line number)}
237 for the caller B{C{up}} stack frames in the Python call stack.
238 '''
239 # sys._getframe(1) ... 'importlib._bootstrap' line 1032,
240 # may throw a ValueError('call stack not deep enough')
241 f = _sys._getframe(up + 1)
242 c = f.f_code
243 return (c.co_name, # caller name
244 _os_path.basename(c.co_filename), # file name .py
245 f.f_lineno) # line number
248def _dunder_ismain(name):
249 '''(INTERNAL) Return C{name == '__main__'}.
250 '''
251 return name == '__main__'
254def _enquote(strs, quote=_QUOTE2_, white=NN): # in .basics, .solveBase
255 '''(INTERNAL) Enquote a string containing whitespace or replace
256 whitespace by C{white} if specified.
257 '''
258 if strs:
259 t = strs.split()
260 if len(t) > 1:
261 strs = white.join(t if white else (quote, strs, quote))
262 return strs
265def _fper(p, q, per=100.0, prec=1):
266 '''Format a percentage C{B{p} * B{per} / B{q}} (C{str}).
267 '''
268 return '%.*f%%' % (prec, (float(p) * per / float(q)))
271def _headof(name):
272 '''(INTERNAL) Get the head name of qualified C{name} or the C{name}.
273 '''
274 i = name.find(_DOT_)
275 return name if i < 0 else name[:i]
278# def _is(a, b): # PYCHOK no cover
279# '''(INTERNAL) C{a is b}? in C{PyPy}
280# '''
281# return (a == b) if _isPyPy() else (a is b)
284def _isAppleM():
285 '''(INTERNAL) Is this C{Apple Silicon}? (C{bool})
286 '''
287 return _ismacOS() and machine().startswith(_arm64_)
290def _isiOS(): # in test/bases.py
291 '''(INTERNAL) Is this C{iOS}? (C{bool})
292 '''
293 return _MODS.osversion2[0] is _iOS_
296def _ismacOS(): # in test/bases.py
297 '''(INTERNAL) Is this C{macOS}? (C{bool})
298 '''
299 return _sys.platform[:6] == 'darwin' and \
300 _MODS.osversion2[0] is _macOS_ # and os.name == 'posix'
303def _isNix(): # in test/bases.py
304 '''(INTERNAL) Is this a C{Linux} distro? (C{str} or L{NN})
305 '''
306 return _MODS.nix2[0]
309def _isPyChecker():
310 '''(INTERNAL) Is C{PyChecker} running? (C{bool}).
311 '''
312 # .../pychecker/checker.py --limit 0 --stdlib pygeodesy/<mod>/<name>.py
313 return _sys.argv[0].endswith('/pychecker/checker.py')
316def _isPyPy(): # in test/bases.py
317 '''(INTERNAL) Is this C{PyPy}? (C{bool})
318 '''
319 # platform.python_implementation() == 'PyPy'
320 return _MODS.Pythonarchine[0].startswith(_PyPy__)
323def _isWindows(): # in test/bases.py
324 '''(INTERNAL) Is this C{Windows}? (C{bool})
325 '''
326 return _sys.platform[:3] == 'win' and \
327 _MODS.osversion2[0] is _Windows_
330def _load_lib(name):
331 '''(INTERNAL) Load a C{dylib}, B{C{name}} must startwith('lib').
332 '''
333 # macOS 11+ (aka 10.16) no longer provides direct loading of
334 # system libraries. As a result, C{ctypes.util.find_library}
335 # will not find any library, unless previously installed by a
336 # low-level dlopen(name) call (with the library base C{name}).
337 CDLL, dlopen, find_lib = _MODS.ctypes3
339 ns = find_lib(name), name
340 if dlopen is not _passarg: # _ismacOS()
341 ns += (_DOT_(name, 'dylib'),
342 _DOT_(name, 'framework'), _os_path.join(
343 _DOT_(name, 'framework'), name))
344 for n in ns:
345 try:
346 if n and dlopen(n): # pre-load handle
347 lib = CDLL(n) # == ctypes.cdll.LoadLibrary(n)
348 if lib._name: # has a qualified name
349 return lib
350 except (AttributeError, OSError):
351 pass
353 return None # raise OSError
356def machine():
357 '''Return standard C{platform.machine}, but distinguishing Intel I{native}
358 from Intel I{emulation} on Apple Silicon (on macOS only).
360 @return: Machine C{'arm64'} for Apple Silicon I{native}, C{'x86_64'}
361 for Intel I{native}, C{"arm64_x86_64"} for Intel I{emulation},
362 etc. (C{str} with C{comma}s replaced by C{underscore}s).
363 '''
364 return _MODS.bits_machine2[1]
367def _Math_K_2():
368 '''(INTERNAL) Return the I{Karney} Math setting.
369 '''
370 return _MODS.karney._wrapped.Math_K_2
373def _name_version(pkg):
374 '''(INTERNAL) Return C{pskg.__name__ + ' ' + .__version__}.
375 '''
376 return _SPACE_(pkg.__name__, pkg.__version__)
379def _name_binary(path):
380 '''(INTERNAL) Return C{(basename + ' ' + version)} of an executable.
381 '''
382 if path:
383 try:
384 _, r = _MODS.solveBase._popen2((path, '--version'))
385 return _SPACE_(_os_path.basename(path), r.split()[-1])
386 except (IndexError, IOError, OSError):
387 pass
388 return NN
391def _osversion2(sep=NN): # in .lazily, test/bases.versions
392 '''(INTERNAL) Get the O/S name and release as C{2-list} or C{str}.
393 '''
394 l2 = _MODS.osversion2
395 return sep.join(l2) if sep else l2 # 2-list()
398def _passarg(arg):
399 '''(INTERNAL) Helper, no-op.
400 '''
401 return arg
404def _passargs(*args):
405 '''(INTERNAL) Helper, no-op.
406 '''
407 return args
410def _plural(noun, n, nn=NN):
411 '''(INTERNAL) Return C{noun}['s'] or C{NN}.
412 '''
413 return NN(noun, _s_) if n > 1 else (noun if n else nn)
416def print_(*args, **nl_nt_prec_prefix__end_file_flush_sep__kwds): # PYCHOK no cover
417 '''Python 3+ C{print}-like formatting and printing.
419 @arg args: Values to be converted to C{str} and joined by B{C{sep}},
420 all positional.
422 @see: Function L{printf} for further details.
423 '''
424 return printf(NN, *args, **nl_nt_prec_prefix__end_file_flush_sep__kwds)
427def printf(fmt, *args, **nl_nt_prec_prefix__end_file_flush_sep__kwds):
428 '''C{Printf-style} and Python 3+ C{print}-like formatting and printing.
430 @arg fmt: U{Printf-style<https://Docs.Python.org/3/library/stdtypes.html#
431 printf-style-string-formatting>} format specification (C{str}).
432 @arg args: Arguments to be formatted (any C{type}, all positional).
433 @kwarg nl_nt_prec_prefix__end_file_flush_sep__kwds: Optional keyword arguments
434 C{B{nl}=0} for the number of leading blank lines (C{int}), C{B{nt}=0}
435 the number of trailing blank lines (C{int}), C{B{prefix}=NN} to be
436 inserted before the formatted text (C{str}) and Python 3+ C{print}
437 keyword arguments C{B{end}}, C{B{sep}}, C{B{file}} and C{B{flush}}.
438 Any remaining C{B{kwds}} are C{printf-style} name-value pairs to be
439 formatted, I{iff no B{C{args}} are present} using C{B{prec}=6} for
440 the number of decimal digits (C{int}).
442 @return: Number of bytes written.
443 '''
444 b, e, f, fl, p, s, kwds = _print7(**nl_nt_prec_prefix__end_file_flush_sep__kwds)
445 try:
446 if args:
447 t = (fmt % args) if fmt else s.join(map(str, args))
448 elif kwds:
449 t = (fmt % kwds) if fmt else s.join(
450 _MODS.streprs.pairs(kwds, prec=p))
451 else:
452 t = fmt
453 except Exception as x:
454 _E, s = _MODS.errors._xError2(x)
455 unstr = _MODS.streprs.unstr
456 t = unstr(printf, fmt, *args, **nl_nt_prec_prefix__end_file_flush_sep__kwds)
457 raise _E(s, txt=t, cause=x)
458 try:
459 n = f.write(NN(b, t, e))
460 except UnicodeEncodeError: # XXX only Windows
461 t = t.replace('\u2032', _QUOTE1_).replace('\u2033', _QUOTE2_)
462 n = f.write(NN(b, t, e))
463 if fl: # PYCHOK no cover
464 f.flush()
465 return n
468def _print7(nl=0, nt=0, prec=6, prefix=NN, sep=_SPACE_, file=_sys.stdout,
469 end=_NL_, flush=False, **kwds):
470 '''(INTERNAL) Unravel the C{printf} and remaining keyword arguments.
471 '''
472 if nl > 0:
473 prefix = NN(_NL_ * nl, prefix)
474 if nt > 0:
475 end = NN(end, _NL_ * nt)
476 return prefix, end, file, flush, prec, sep, kwds
479def _Pythonarchine(sep=NN): # in .lazily, test/bases.py versions
480 '''(INTERNAL) Get PyPy and Python versions, bits and machine as C{3- or 4-list} or C{str}.
481 '''
482 l3 = _MODS.Pythonarchine
483 return sep.join(l3) if sep else l3 # 3- or 4-list
486def _secs2str(secs): # in .geoids, ../test/bases.py
487 '''Convert a time in C{secs} to C{str}.
488 '''
489 if secs < _MODS.constants._100_0:
490 unit = len(_SIsecs) - 1
491 while 0 < secs < 1 and unit > 0:
492 secs *= 1e3 # _1000_0
493 unit -= 1
494 t = '%.3f %s' % (secs, _SIsecs[unit])
495 else:
496 m, s = divmod(secs, 60)
497 if m < 60:
498 t = '%d:%06.3f' % (int(m), s)
499 else:
500 h, m = divmod(int(m), 60)
501 t = '%d:%02d:%06.3f' % (h, m, s)
502 return t
505def _sizeof(obj, deep=True):
506 '''(INTERNAL) Recursively size an C{obj}ect.
508 @kwarg deep: If C{True}, include the size of all
509 C{.__dict__.values()} (C{bool}).
511 @return: The C{obj} size in bytes (C{int}), ignoring
512 class attributes and counting instances only
513 once or C{None}.
515 @note: With C{PyPy}, the returned size is always C{None}.
516 '''
517 try:
518 _zB = _sys.getsizeof
519 _zD = _zB(None) # some default
520 except TypeError: # PyPy3.10
521 return None
523 _isiterablen = _MODS.basics.isiterablen
525 def _zR(s, iterable):
526 z, _s = 0, s.add
527 for o in iterable:
528 i = id(o)
529 if i not in s:
530 _s(i)
531 z += _zB(o, _zD)
532 if isinstance(o, dict):
533 z += _zR(s, o.keys())
534 z += _zR(s, o.values())
535 elif _isiterablen(o) and not \
536 isinstance(o, _MODS._Str_Bytes):
537 z += _zR(s, o)
538 elif deep:
539 try: # size instance' attr values only
540 z += _zR(s, o.__dict__.values())
541 except AttributeError: # None, int, etc.
542 pass
543 return z
545 return _zR(set(), (obj,))
548def _sysctl_uint(name):
549 '''(INTERNAL) Get an unsigned int sysctl item by name, use on macOS ONLY!
550 '''
551 libc = _MODS.libc
552 if libc: # <https://StackOverflow.com/questions/759892/python-ctypes-and-sysctl>
553 byref, char_p, size_t, uint, sizeof = _MODS.ctypes5
554 n = name if str is bytes else bytes(name, _utf_8_) # PYCHOK isPython2 = str is bytes
555 u = uint(0)
556 z = size_t(sizeof(u))
557 r = libc.sysctlbyname(char_p(n), byref(u), byref(z), None, size_t(0))
558 else: # could find or load 'libc'
559 r = -2
560 return int(r if r else u.value) # -1 ENOENT error, -2 no libc
563def _tailof(name):
564 '''(INTERNAL) Get the base name of qualified C{name} or the C{name}.
565 '''
566 i = name.rfind(_DOT_) + 1
567 return name[i:] if i > 0 else name
570def _under(name): # PYCHOK in .datums, .auxilats, .ups, .utm, .utmupsBase, ...
571 '''(INTERNAL) Prefix C{name} with an I{underscore}.
572 '''
573 return name if name.startswith(_UNDER_) else NN(_UNDER_, name)
576def _usage(file_py, *args, **opts_help): # in .etm, .geodesici
577 '''(INTERNAL) Build "usage: python -m ..." cmd line for module B{C{file_py}}.
578 '''
579 if opts_help:
581 def _help(alts=(), help=NN, **unused):
582 if alts and help:
583 h = NN(help, _SPACE_).lstrip(_DASH_)
584 for a in alts:
585 if a.startswith(h):
586 return NN(_DASH_, a),
588 def _opts(opts=NN, alts=(), **unused):
589 # opts='T--v-C-R meter-c|i|n|o'
590 d, fmt = NN, _MODS.streprs.Fmt.SQUARE
591 for o in (opts + _BAR_(*alts)).split(_DASH_):
592 if o:
593 yield fmt(NN(d, _DASH_, o.replace(_BAR_, ' | -')))
594 d = NN
595 else:
596 d = _DASH_
598 args = _help(**opts_help) or (tuple(_opts(**opts_help)) + args)
600 u = _COLON_(_dunder_nameof(_usage)[1:], NN)
601 return _SPACE_(u, *_usage_argv(file_py, *args))
604def _usage_argv(argv0, *args):
605 '''(INTERNAL) Return 3-tuple C{(python, '-m', module, *args)}.
606 '''
607 m = _os_path.dirname(argv0).replace(_os.getcwd(), _ELLIPSIS_) \
608 .replace(_os.sep, _DOT_).strip()
609 b, x = _os_path.splitext(_os_path.basename(argv0))
610 if x == '.py' and not _dunder_ismain(b):
611 m = _DOT_(m or _pygeodesy_, b)
612 p = NN(_python_, _sys.version_info[0])
613 return (p, '-m', _enquote(m)) + args
616def _version2(version, n=2):
617 '''(INTERNAL) Split C{B{version} str} into a C{1-, 2- or 3-tuple} of C{int}s.
618 '''
619 t = _version_ints(version.split(_DOT_, 2))
620 if len(t) < n:
621 t += (0,) * n
622 return t[:n]
625def _version_info(package): # in .Base.karney, .basics
626 '''(INTERNAL) Get the C{package.__version_info__} as a 2- or
627 3-tuple C{(major, minor, revision)} if C{int}s.
628 '''
629 try:
630 return _version_ints(package.__version_info__)
631 except AttributeError:
632 return _version2(package.__version__.strip(), n=3)
635def _version_ints(vs):
636 # helper for _version2 and _version_info above
638 def _ints(vs):
639 for v in vs:
640 try:
641 yield int(v.strip())
642 except (TypeError, ValueError):
643 pass
645 return tuple(_ints(vs))
648def _versions(sep=_SPACE_):
649 '''(INTERNAL) Get pygeodesy, PyPy and Python versions, bits, machine and OS as C{7- or 8-list} or C{str}.
650 '''
651 l7 = [_pygeodesy_, _MODS.version] + _Pythonarchine() + _osversion2()
652 return sep.join(l7) if sep else l7 # 5- or 6-list
655__all__ = tuple(map(_dunder_nameof, (machine, print_, printf)))
656__version__ = '24.09.04'
658if _dunder_ismain(__name__): # PYCHOK no cover
660 from pygeodesy import _isfrozen, isLazy
662 print_(*(_versions(sep=NN) + ['_isfrozen', _isfrozen,
663 'isLazy', isLazy]))
665# **) MIT License
666#
667# Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved.
668#
669# Permission is hereby granted, free of charge, to any person obtaining a
670# copy of this software and associated documentation files (the "Software"),
671# to deal in the Software without restriction, including without limitation
672# the rights to use, copy, modify, merge, publish, distribute, sublicense,
673# and/or sell copies of the Software, and to permit persons to whom the
674# Software is furnished to do so, subject to the following conditions:
675#
676# The above copyright notice and this permission notice shall be included
677# in all copies or substantial portions of the Software.
678#
679# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
680# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
681# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
682# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
683# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
684# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
685# OTHER DEALINGS IN THE SOFTWARE.