File: __init__.py

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (31 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import contextlib
import warnings

from ._odil import *

_open = open

@contextlib.contextmanager
def open(path, mode="rb"):
    fd = _open(path, mode)
    stream = iostream(fd)
    try:
        yield stream
    finally:
        fd.close()

def read(path, keep_group_length=False, halt_condition=None):
    warnings.warn("odil.read is deprecated. Use odil.open instead")
    with open(path) as stream:
        return Reader.read_file(stream, keep_group_length, halt_condition)

def write(
        data_set, path, meta_information=DataSet(),
        transfer_syntax=registry.ExplicitVRLittleEndian,
        item_encoding=Writer.ItemEncoding.ExplicitLength,
        use_group_length=False):
    warnings.warn("odil.write is deprecated. Use odil.open instead")
    with open(path, "wb") as stream:
        Writer.write_file(
            data_set, stream, meta_information, transfer_syntax, item_encoding,
            use_group_length)