texttaglib/ttlig.py
def _read_header(ig_stream):
        ''' Read the TTLIG header from a stream '''
        lines = piter(ig_stream)
        first = next(lines)
        if first.strip() != '# TTLIG':
            raise Exception("Invalid TTLIG header. TTLIG files must start with # TTLIG")
        meta = OrderedDict()
        for line in lines:
            if line.startswith("#"):
                continue
            m = IGStreamReader.META_LINE.match(line)
            if m:
                key = m.group('key').strip()
                value = m.group('value')
                if key in meta:
                    getLogger().warning("Key {} is duplicated in the header".format(key))
                meta[key] = value
            else:
                # this line is weird
                break
            if not lines.peep() or not lines.peep().value.strip():
                # if next line is empty, break
                break
        return meta
 Read the TTLIG header from a stream 
Read the TTLIG header from a stream
Read the TTLIG header from a stream
def _read_header(ig_stream):
        lines = piter(ig_stream)
        first = next(lines)
        if first.strip() != '# TTLIG':
            raise Exception("Invalid TTLIG header. TTLIG files must start with # TTLIG")
        meta = OrderedDict()
        for line in lines:
            if line.startswith("#"):
                continue
            m = IGStreamReader.META_LINE.match(line)
            if m:
                key = m.group('key').strip()
                value = m.group('value')
                if key in meta:
                    getLogger().warning("Key {} is duplicated in the header".format(key))
                meta[key] = value
            else:
                break
            if not lines.peep() or not lines.peep().value.strip():
                break
        return meta
def _read_header ( ig_stream ) : lines = piter ( ig_stream ) first = next ( lines ) if first . strip ( ) != '# TTLIG' : raise Exception ( "Invalid TTLIG header. TTLIG files must start with # TTLIG" ) meta = OrderedDict ( ) for line in lines : if line . startswith ( "#" ) : continue m = IGStreamReader . META_LINE . match ( line ) if m : key = m . group ( 'key' ) . strip ( ) value = m . group ( 'value' ) if key in meta : getLogger ( ) . warning ( "Key {} is duplicated in the header" . format ( key ) ) meta [ key ] = value else : break if not lines . peep ( ) or not lines . peep ( ) . value . strip ( ) : break return meta
Read the TTLIG header from a stream
Read the TTLIG header from a stream
''' Read the TTLIG header from a stream ''' # this line is weird # if next line is empty, break
ig_stream