Advertisement
Guest User

Untitled

a guest
Oct 8th, 2012
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. from simpleparse.parser import Parser
  2. from pprint import pprint
  3.  
  4. declaration = """
  5. file           := header, content
  6. header         := shebang, version
  7. shebang        := '#!', ts, word, ('-',[a-zA-Z0-9]+)?,'\n'
  8. version        := 'version', ts, [0-9], '.', [0-9], ts, 'v', [0-9], '\n'
  9. content        := node*
  10. node           := word, ts, '{\n', nodecontent*, '}\n'
  11. nodecontent    := ts, knobname, ts, knobvalue, '\n'
  12. knobname       := word
  13. knobvalue      := word / string / multiknobgroup / knobgroup
  14. knobgroup      := '{', (word / string, ts)*, '}'
  15. multiknobgroup := '{\n', (ts, knobgroup, '\n')*, ts, '}\n'
  16. string         := '"', word*, '"'
  17. word           := ([a-zA-Z0-9-_()/\~.<>?;:])+,ts
  18. ts             := [ \t]*
  19. """
  20.  
  21. script = """#! /opt/foundry/Nuke/6.3v7-x64/Nuke6.3 -nx
  22. version 6.3 v7
  23. Root {
  24. inputs 0
  25. name /path/to/file_name.nk
  26. first_frame 0
  27. last_frame 100
  28. lock_range true
  29. format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)"
  30. proxy_type scale
  31. proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)"
  32. addUserKnob {20 custom l Custom}
  33. addUserKnob {1 scene l Scene}
  34. views {
  35.  {left ""}
  36.  {right ""}
  37. }
  38. }
  39. """
  40.  
  41. parser = Parser(declaration, "file")
  42.  
  43. success, resultTree, nextCharacter = parser.parse(script)
  44. pprint(resultTree)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement