def __init__(self, file_path=None, xmin=0, xmax=None, codec='utf-8'):
        """Construct either a new TextGrid object or read one from a
        file/stream. When you create an empty TextGrid you must at least
        specify the xmax. When you want to load a TextGrid from file you need
        to specify at least the file_path and optionally the codec. Binary,
        short and normal TextGrids are supported.

        :param str file_path: Path to read from, - for stdin. If ``None`` an
                              empty TextGrid will be created.
        :param int xmin: Xmin value, only needed when not loading from file.
        :param int xmax: Xmax value, needed when not loading from file.
        :param str codec: Text encoding for the input. Note that this will be
            ignored for binary TextGrids.
        :raises Exception: If filepath is not specified but no xmax
        """
        self.tiers = []
        self.codec = codec
        if not file_path:
            if xmax is None:
                raise Exception('No xmax specified')
            self.tier_num = 0
            self.xmin = xmin
            self.xmax = xmax
        else:
            with open(file_path, 'rb') as f:
                self.from_file(f, codec)
def __init__ ( self , file_path = None , xmin = 0 , xmax = None , codec = 'utf-8' ) : self . tiers = [ ] self . codec = codec if not file_path : if xmax is None : raise Exception ( 'No xmax specified' ) self . tier_num = 0 self . xmin = xmin self . xmax = xmax else : with open ( file_path , 'rb' ) as f : self . from_file ( f , codec )
Construct either a new TextGrid object or read one from a
        file/stream. When you create an empty TextGrid you must at least
        specify the xmax. When you want to load a TextGrid from file you need
        to specify at least the file_path and optionally the codec. Binary,
        short and normal TextGrids are supported.

        :param str file_path: Path to read from, - for stdin. If ``None`` an
                              empty TextGrid will be created.
        :param int xmin: Xmin value, only needed when not loading from file.
        :param int xmax: Xmax value, needed when not loading from file.
        :param str codec: Text encoding for the input. Note that this will be
            ignored for binary TextGrids.
        :raises Exception: If filepath is not specified but no xmax