1
0
Fork 0

only use relative imports when a module

This commit is contained in:
Kevin Matz 2019-11-17 13:27:08 -05:00
parent 3d7b0e13b5
commit b8aec65ee7
2 changed files with 20 additions and 5 deletions

View File

@ -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__')

View File

@ -23,10 +23,18 @@ from antlr4 import CommonTokenStream
from antlr4 import InputStream
from antlr4 import 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
from pythonosc import udp_client
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