1
0
Fork 0

re-organize file tree

This commit is contained in:
Kevin Matz 2019-11-18 13:21:36 -05:00
parent 7fd48be3bc
commit 57a432f2bc
10 changed files with 12 additions and 78 deletions

View File

@ -1 +0,0 @@
__all__ = ["comment", "CommentMacroLexer", "CommentMacroListener", "CommentMacroParser", "OscCommentMacroListener"]

View File

@ -1,32 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""OscCommentMacroListener.py: Hog 4 comment macro antlr4 listener for OSC."""
__author__ = "Kevin Matz"
__copyright__ = "Copyright 2018, Company 235, LLC"
__credits__ = ["Kevin Matz"]
__license__ = "MIT"
__version__ = "3.9"
__maintainer__ = "Kevin Matz"
__email__ = "kevin@company235.com"
__status__ = "Prototype"
"""OscCommentMacroListener.py: Hog 4 comment macro antlr4 listener for OSC.
"""
import logging
from pythonosc import osc_message_builder
from time import sleep
try:
# include reletive path imports when a module
from .CommentMacroParser import CommentMacroParser
from .CommentMacroListener import CommentMacroListener
except ImportError:
# include directly when called directly
from CommentMacroParser import CommentMacroParser
from CommentMacroListener import CommentMacroListener
from .commentmacro.CommentMacroParser import CommentMacroParser
from .commentmacro.CommentMacroListener import CommentMacroListener
logger = logging.getLogger('__main__')

1
bacon/__init__.py Normal file
View File

@ -0,0 +1 @@
__all__ = ["baconscript", "OscCommentMacroListener"]

View File

@ -0,0 +1 @@
__all__ = ["CommentMacroLexer", "CommentMacroListener", "CommentMacroParser"]

59
comment.py → bacon/script.py Executable file → Normal file
View File

@ -1,40 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""comment.py: Hog 4 comment macro interpreter and OSC bridge."""
__author__ = "Kevin Matz"
__copyright__ = "Copyright 2018, Company 235, LLC"
__credits__ = ["Kevin Matz"]
__license__ = "MIT"
__version__ = "3.9"
__maintainer__ = "Kevin Matz"
__email__ = "kevin@company235.com"
__status__ = "Prototype"
"""comment.py: Hog 4 comment macro interpreter and OSC bridge.
"""
import configparser
import logging
import sys
from antlr4 import CommonTokenStream
from antlr4 import InputStream
from antlr4 import ParseTreeWalker
from antlr4 import CommonTokenStream, InputStream, ParseTreeWalker
from antlr4.error.ErrorListener import ErrorListener
from pythonosc import udp_client
try:
# include reletive path imports when a module
from .CommentMacroLexer import CommentMacroLexer
from .CommentMacroParser import CommentMacroParser
from .OscCommentMacroListener import OscCommentMacroListener
except ImportError:
# include directly when called directly
from CommentMacroLexer import CommentMacroLexer
from CommentMacroParser import CommentMacroParser
from OscCommentMacroListener import OscCommentMacroListener
from .commentmacro.CommentMacroLexer import CommentMacroLexer
from .commentmacro.CommentMacroParser import CommentMacroParser
from .OscListener import OscCommentMacroListener
# define an error listener that raises SyntaxError exceptions
@ -109,27 +86,3 @@ def comment(text):
except SyntaxError as e:
logger.debug(e) # antlr internal listener prints the error
# # log it to the debug logger anyway
# handle user input if run directly
if __name__ == '__main__':
if len(sys.argv) > 1:
# look for macros passed as arguments
logger.debug("found macro at argv[1]")
comment(sys.argv[1])
else:
# for input history and line editing
import readline
# be an interactive shell
while True:
# get user input
try:
text = input("comment# ")
except (KeyboardInterrupt, EOFError):
text = 'exit'
print(text)
# catch exit keyword
if text.lower() == 'exit':
break
# exec user input
comment(text)