Пример #1
0
def read_tocfile_string(tocfile):
    """given a unicode string of .toc data, returns a TOCFile object

    raises SheetException if some error occurs parsing the file"""

    import audiotools.ply.lex as lex
    import audiotools.ply.yacc as yacc
    from audiotools.ply.yacc import NullLogger
    import audiotools.toc.tokrules
    import audiotools.toc.yaccrules
    from sys import version_info

    str_type = str if (version_info[0] >= 3) else unicode

    assert(isinstance(tocfile, str_type))

    lexer = lex.lex(module=audiotools.toc.tokrules)
    lexer.input(tocfile)
    parser = yacc.yacc(module=audiotools.toc.yaccrules,
                       debug=0,
                       errorlog=NullLogger(),
                       write_tables=0)
    try:
        return parser.parse(lexer=lexer)
    except ValueError as err:
        raise SheetException(str(err))
Пример #2
0
def read_cuesheet_string(cuesheet):
    """given a unicode string of cuesheet data returns a Cuesheet object

    raises SheetException if some error occurs parsing the file"""

    import audiotools.ply.lex as lex
    import audiotools.ply.yacc as yacc
    from audiotools.ply.yacc import NullLogger
    import audiotools.cue.tokrules
    import audiotools.cue.yaccrules
    from sys import version_info

    str_type = str if (version_info[0] >= 3) else unicode

    assert (isinstance(cuesheet, str_type))

    lexer = lex.lex(module=audiotools.cue.tokrules)
    lexer.input(cuesheet)
    parser = yacc.yacc(module=audiotools.cue.yaccrules,
                       debug=0,
                       errorlog=NullLogger(),
                       write_tables=0)
    try:
        return parser.parse(lexer=lexer)
    except ValueError as err:
        raise SheetException(str(err))
Пример #3
0
def read_tocfile_string(tocfile):
    """given a plain string of .toc data, returns a TOCFile object

    raises SheetException if some error occurs parsing the file"""

    import audiotools.ply.lex as lex
    import audiotools.ply.yacc as yacc
    from audiotools.ply.yacc import NullLogger
    import audiotools.toc.tokrules
    import audiotools.toc.yaccrules

    lexer = lex.lex(module=audiotools.toc.tokrules)
    lexer.input(tocfile)
    parser = yacc.yacc(module=audiotools.toc.yaccrules,
                       debug=0,
                       errorlog=NullLogger(),
                       write_tables=0)
    try:
        return parser.parse(lexer=lexer)
    except ValueError as err:
        raise SheetException(str(err))
Пример #4
0
def read_cuesheet_string(cuesheet):
    """given a plain string of cuesheet data returns a Cuesheet object

    raises SheetException if some error occurs parsing the file"""

    import audiotools.ply.lex as lex
    import audiotools.ply.yacc as yacc
    from audiotools.ply.yacc import NullLogger
    import audiotools.cue.tokrules
    import audiotools.cue.yaccrules

    lexer = lex.lex(module=audiotools.cue.tokrules)
    lexer.input(cuesheet)
    parser = yacc.yacc(module=audiotools.cue.yaccrules,
                       debug=0,
                       errorlog=NullLogger(),
                       write_tables=0)
    try:
        return parser.parse(lexer=lexer)
    except ValueError as err:
        raise SheetException(str(err))