def _parse_category(fname, categories):
        """Parse unicode category tables."""
        version, date, values = None, None, []
        print("parsing {} ..".format(fname))
        for line in open(fname, 'rb'):
            uline = line.decode('utf-8')
            if version is None:
                version = uline.split(None, 1)[1].rstrip()
                continue
            elif date is None:
                date = uline.split(':', 1)[1].rstrip()
                continue
            if uline.startswith('#') or not uline.lstrip():
                continue
            addrs, details = uline.split(';', 1)
            addrs, details = addrs.rstrip(), details.lstrip()
            if any(details.startswith('{} #'.format(value))
                   for value in categories):
                start, stop = addrs, addrs
                if '..' in addrs:
                    start, stop = addrs.split('..')
                values.extend(range(int(start, 16), int(stop, 16) + 1))
        return version, date, sorted(values)
def _parse_category ( fname , categories ) : version , date , values = None , None , [ ] print ( "parsing {} .." . format ( fname ) ) for line in open ( fname , 'rb' ) : uline = line . decode ( 'utf-8' ) if version is None : version = uline . split ( None , 1 ) [ 1 ] . rstrip ( ) continue elif date is None : date = uline . split ( ':' , 1 ) [ 1 ] . rstrip ( ) continue if uline . startswith ( '#' ) or not uline . lstrip ( ) : continue addrs , details = uline . split ( ';' , 1 ) addrs , details = addrs . rstrip ( ) , details . lstrip ( ) if any ( details . startswith ( '{} #' . format ( value ) ) for value in categories ) : start , stop = addrs , addrs if '..' in addrs : start , stop = addrs . split ( '..' ) values . extend ( range ( int ( start , 16 ) , int ( stop , 16 ) + 1 ) ) return version , date , sorted ( values )
Parse unicode category tables.