diff --git a/OscCommentMacroListener.py b/OscCommentMacroListener.py index fea2bc7..f0b00cd 100644 --- a/OscCommentMacroListener.py +++ b/OscCommentMacroListener.py @@ -16,11 +16,18 @@ __status__ = "Prototype" import logging -from .CommentMacroParser import CommentMacroParser -from .CommentMacroListener import CommentMacroListener 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 + logger = logging.getLogger('__main__') diff --git a/comment.py b/comment.py index 1841d1b..41a01be 100755 --- a/comment.py +++ b/comment.py @@ -23,11 +23,19 @@ from antlr4 import CommonTokenStream from antlr4 import InputStream from antlr4 import ParseTreeWalker from antlr4.error.ErrorListener import ErrorListener -from .CommentMacroLexer import CommentMacroLexer -from .CommentMacroParser import CommentMacroParser -from .OscCommentMacroListener import OscCommentMacroListener 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 + # define an error listener that raises SyntaxError exceptions class SyntaxErrorListener(ErrorListener):