MCPcopy Create free account
hub / github.com/PyTables/PyTables / _check_mode

Method _check_mode

tables/nodes/filenode.py:373–400  ·  view source on GitHub ↗
(self, mode)

Source from the content-addressed store, hash-verified

371 raise TypeError('only nodes with atom "UInt8Atom" are allowed')
372
373 def _check_mode(self, mode):
374 if not isinstance(mode, str):
375 raise TypeError("invalid mode: %r" % mode)
376
377 modes = set(mode)
378 if modes - set("arwb+tU") or len(mode) > len(modes):
379 raise ValueError("invalid mode: %r" % mode)
380
381 reading = "r" in modes
382 writing = "w" in modes
383 appending = "a" in modes
384 # updating = "+" in modes
385 text = "t" in modes
386 binary = "b" in modes
387
388 if "U" in modes:
389 if writing or appending:
390 raise ValueError("can't use U and writing mode at once")
391 reading = True
392
393 if text and binary:
394 raise ValueError("can't have text and binary mode at once")
395
396 if reading + writing + appending > 1:
397 raise ValueError("can't have read/write/append mode at once")
398
399 if not (reading or writing or appending):
400 raise ValueError("must have exactly one of read/write/append mode")
401
402 def _cross_check_mode(self, mode, h5filemode):
403 # XXX: check

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected