Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from simpleparse.parser import Parser
- from pprint import pprint
- declaration = """
- file := header, content
- header := shebang, version
- shebang := '#!', ts, word, ('-',[a-zA-Z0-9]+)?,'\n'
- version := 'version', ts, [0-9], '.', [0-9], ts, 'v', [0-9], '\n'
- content := node*
- node := word, ts, '{\n', nodecontent*, '}\n'
- nodecontent := ts, knobname, ts, knobvalue, '\n'
- knobname := word
- knobvalue := word / string / multiknobgroup / knobgroup
- knobgroup := '{', (word / string, ts)*, '}'
- multiknobgroup := '{\n', (ts, knobgroup, '\n')*, ts, '}\n'
- string := '"', word*, '"'
- word := ([a-zA-Z0-9-_()/\~.<>?;:])+,ts
- ts := [ \t]*
- """
- script = """#! /opt/foundry/Nuke/6.3v7-x64/Nuke6.3 -nx
- version 6.3 v7
- Root {
- inputs 0
- name /path/to/file_name.nk
- first_frame 0
- last_frame 100
- lock_range true
- format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)"
- proxy_type scale
- proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)"
- addUserKnob {20 custom l Custom}
- addUserKnob {1 scene l Scene}
- views {
- {left ""}
- {right ""}
- }
- }
- """
- parser = Parser(declaration, "file")
- success, resultTree, nextCharacter = parser.parse(script)
- pprint(resultTree)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement