only use relative imports when a module
This commit is contained in:
parent
3d7b0e13b5
commit
b8aec65ee7
|
@ -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__')
|
||||
|
||||
|
||||
|
|
14
comment.py
14
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):
|
||||
|
|
Loading…
Reference in New Issue