1

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

3

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

5

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

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

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

9'''

10# make sure int/int division yields float quotient

11 from __future__ import division

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

13 if not division:

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

15 del division

16

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

18 _TypeError, _TypesError, _ValueError, _xkwds_get

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

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

21 _UNDER_, _version_ # _utf_8_

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

23 _getenv, _sys, _sys_version_info2

24

25 from copy import copy as _copy, deepcopy as _deepcopy

26 from math import copysign as _copysign

27 import inspect as _inspect

28

29__all__ = _ALL_LAZY.basics

30__version__ = '23.08.24'

31

32_0_0 = 0.0 # in .constants

33_below_ = 'below'

34_cannot_ = 'cannot'

35_list_tuple_types = (list, tuple)

36_list_tuple_set_types = (list, tuple, set)

37_odd_ = 'odd'

38_required_ = 'required'

39_PYGEODESY_XPACKAGES_ = 'PYGEODESY_XPACKAGES'

40

41 try: # Luciano Ramalho, "Fluent Python", O'Reilly, 2016 p. 395, 2022 p. 577+

42 from numbers import Integral as _Ints, Real as _Scalars

43 except 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

50 try:

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

60 except ImportError:

61 _Sequence = tuple # immutable for .points._Basequence

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

63

64 try:

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

92 except 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

114 def 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

132 def 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

141 def 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

149 def halfs2(str2):

150 '''Split a string in 2 halfs.

151

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

153

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

155

156 @raise ValueError: Zero or odd C{len(B{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

164 def 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

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

176 raise _AssertionError(isbool=1)

177

178 if _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)

186 else:

187 isclass = _inspect.isclass

188

189

190 def iscomplex(obj):

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

192

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

194

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

196 C{False}.

197 '''

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

199 return isinstance(obj, complex) or (isstr(obj)

200 and isinstance(complex(obj), complex)) # numbers.Complex?

201 except (TypeError, ValueError):

202 return False

203

204

205 def isfloat(obj):

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

207

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

209

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

211 C{False}.

212 '''

213 try:

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

215 and isinstance(float(obj), float))

216 except (TypeError, ValueError):

217 return False

218

219

220 try:

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

222 except AttributeError: # Python 2-

223

224 def isidentifier(obj):

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

226 '''

227 return bool(obj and isstr(obj)

228 and obj.replace(_UNDER_, NN).isalnum()

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

230

231

232 def isinstanceof(obj, *classes):

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

234

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

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

237

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

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

240 '''

241 return isinstance(obj, classes)

242

243

244 def isint(obj, both=False):

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

246

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

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

249 type and value (C{bool}).

250

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

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

253

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

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

256 '''

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

258 return True

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

260 try: # NOT , _Scalars) to include Fsum!

261 return obj.is_integer()

262 except AttributeError:

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

264 return False

265

266

267 try:

268 from keyword import iskeyword # Python 2.7+

269 except ImportError:

270

271 def iskeyword(unused):

272 '''Not Implemented, C{False} always.

273 '''

274 return False

275

276

277 def islistuple(obj, minum=0):

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

279

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

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

282

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

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

285 '''

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

287

288

289 def isodd(x):

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

291

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

293

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

295 C{False} otherwise.

296 '''

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

298

299

300 def isscalar(obj):

301 '''Check for scalar types.

302

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

304

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

306 '''

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

308

309

310 def issequence(obj, *excls):

311 '''Check for sequence types.

312

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

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

315

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

317

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

319 '''

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

321

322

323 def isstr(obj):

324 '''Check for string types.

325

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

327

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

329 '''

330 return isinstance(obj, _Strs)

331

332

333 def issubclassof(Sub, *Supers):

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

335

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

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

338

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

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

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

342 are a class.

343 '''

344 if isclass(Sub):

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

346 if t:

347 return bool(issubclass(Sub, t))

348 return None

349

350

351 def len2(items):

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

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

354

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

356

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

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

359 '''

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

361 items = list(items)

362 return len(items), items

363

364

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

366 '''Apply each B{C{xs}} to a single-argument function and

367 return a C{tuple} of results.

368

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

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

371

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

373 '''

374 return tuple(map(fun1, xs))

375

376

377 def map2(func, *xs):

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

379

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

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

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

383 maintains the Python 2 behavior.

384

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

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

387

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

389 '''

390 return tuple(map(func, *xs))

391

392

393 def neg(x):

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

395

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

397 '''

398 return (-x) if x else _0_0

399

400

401 def neg_(*xs):

402 '''Negate all C{xs} with L{neg}.

403

404 @return: A C{map(neg, B{xs})}.

405 '''

406 return map(neg, xs)

407

408

409 def _reverange(n):

410 '''(INTERNAL) Reversed range yielding (n-1, n-2, ..., 1, 0).

411 '''

412 return range(n - 1, -1, -1)

413

414

415 def signBit(x):

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

417

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

419 '''

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

421

422

423 def _signOf(x, ref): # in .fsums

424 '''(INTERNAL) Return the sign of B{C{x}} versus B{C{ref}}.

425 '''

426 return +1 if x > ref else (-1 if x < ref else 0)

427

428

429 def signOf(x):

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

431

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

433 '''

434 try:

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

436 except AttributeError:

437 s = _signOf(x, 0)

438 return s

439

440

441 def _sizeof(inst):

442 '''(INTERNAL) Recursively size an C{inst}ance.

443

444 @return: Instance' size in bytes (C{int}),

445 ignoring class attributes and

446 counting duplicates only once or

447 C{None}.

448

449 @note: With C{PyPy}, the size is always C{None}.

450 '''

451 try:

452 _zB = _sys.getsizeof

453 _zD = _zB(None) # get some default

454 except TypeError: # PyPy3.10

455 return None

456

457 def _zR(s, iterable):

458 z, _s = 0, s.add

459 for o in iterable:

460 i = id(o)

461 if i not in s:

462 _s(i)

463 z += _zB(o, _zD)

464 if isinstance(o, dict):

465 z += _zR(s, o.keys())

466 z += _zR(s, o.values())

467 elif isinstance(o, _list_tuple_set_types):

468 z += _zR(s, o)

469 else:

470 try: # size instance' attr values only

471 z += _zR(s, o.__dict__.values())

472 except AttributeError: # None, int, etc.

473 pass

474 return z

475

476 return _zR(set(), (inst,))

477

478

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

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

481

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

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

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

485

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

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

488

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

490

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

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

493

494 @example:

495

496 >>> from pygeodesy import splice

497

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

499 >>> a, b

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

501

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

503 >>> a, b, c

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

505

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

507 >>> a, b, c

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

509

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

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

512

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

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

515 '''

516 if not isint(n):

517 raise _TypeError(n=n)

518

519 t = iterable

520 if not isinstance(t, _list_tuple_types):

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

522

523 if n > 1:

524 if fill:

525 fill = _xkwds_get(fill, fill=MISSING)

526 if fill is not MISSING:

527 m = len(t) % n

528 if m > 0: # same type fill

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

530 for i in range(n):

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

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

533 else:

534 yield t

535

536

537 def _splituple(strs, *sep_splits): # in .mgrs, .osgr, .webmercator

538 '''(INTERNAL) Split a C{comma}- or C{whitespace}-separated

539 string into a C{tuple} of stripped strings.

540 '''

541 t = (strs.split(*sep_splits) if sep_splits else

542 strs.replace(_COMMA_, _SPACE_).split()) if strs else ()

543 return tuple(s.strip() for s in t if s)

544

545

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

547

548

549 def unsigned0(x):

550 '''Unsign if C{0.0}.

551

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

553 '''

554 return x if x else _0_0

555

556

557 def _xargs_names(callabl):

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

559 '''

560 try:

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

562 except AttributeError: # .signature new Python 3+

563 args_kwds = _inspect.getargspec(callabl).args

564 return tuple(args_kwds)

565

566

567 def _xcopy(inst, deep=False):

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

569

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

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

572 a shallow copy (C{bool}).

573

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

575 '''

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

577

578

579 def _xdup(inst, **items):

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

581

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

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

584

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

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

587

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

589 '''

590 d = _xcopy(inst, deep=False)

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

592 if not hasattr(d, n):

593 t = _MODS.named.classname(inst)

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

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

596 setattr(d, n, v)

597 return d

598

599

600 def _xgeographiclib(where, *required):

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

602 '''

603 try:

604 _xpackage(_xgeographiclib)

605 import geographiclib

606 except ImportError as x:

607 raise _xImportError(x, where)

608 return _xversion(geographiclib, where, *required)

609

610

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

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

613 '''

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

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

616

617

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

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

620

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

622 all positional.

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

624 with the C{value} to be checked.

625

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

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

628 '''

629 if Types and name_value_pairs:

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

631 if not isinstance(v, Types):

632 raise _TypesError(n, v, *Types)

633 else:

634 raise _AssertionError(Types=Types, name_value_pairs=name_value_pairs)

635

636

637 def _xnumpy(where, *required):

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

639 '''

640 try:

641 _xpackage(_xnumpy)

642 import numpy

643 except ImportError as x:

644 raise _xImportError(x, where)

645 return _xversion(numpy, where, *required)

646

647

648 def _xpackage(_xpkg):

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

650 '''

651 n = _xpkg.__name__[2:]

652 if n in _XPACKAGES:

653 x = _SPACE_(n, _in_, _PYGEODESY_XPACKAGES_)

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

655 raise ImportError(_EQUAL_(x, e))

656

657

658 def _xor(x, *xs):

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

660 '''

661 for x_ in xs:

662 x ^= x_

663 return x

664

665

666 def _xscipy(where, *required):

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

668 '''

669 try:

670 _xpackage(_xscipy)

671 import scipy

672 except ImportError as x:

673 raise _xImportError(x, where)

674 return _xversion(scipy, where, *required)

675

676

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

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

679

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

681 all positional.

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

683 with the C{value} to be checked.

684

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

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

687 '''

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

689 if not issubclassof(v, *Classes):

690 raise _TypesError(n, v, *Classes)

691

692

693 def _xversion(package, where, *required, **name):

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

695 '''

696 n = len(required)

697 if n:

698 t = _xversion_info(package)

699 if t[:n] < required:

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

701 _below_, _DOT_(*required),

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

703 raise ImportError(t)

704 return package

705

706

707 def _xversion_info(package): # in .karney

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

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

710 '''

711 try:

712 t = package.__version_info__

713 except AttributeError:

714 t = package.__version__.strip()

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

716 return map2(int, t)

717

718

719 def _xwhere(where, **name):

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

721 '''

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

723 if name:

724 n = _xkwds_get(name, name=NN)

725 if n:

726 m = _DOT_(m, n)

727 return m

728

729

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

731 _zip = zip # PYCHOK exported

732 else: # Python 3.10+

733

734 def _zip(*args):

735 return zip(*args, strict=True)

736

737# **) MIT License

738#

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

740#

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

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

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

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

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

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

747#

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

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

750#

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

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

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

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

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

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

757# OTHER DEALINGS IN THE SOFTWARE.