only use relative imports when a module
This commit is contained in:
parent
3d7b0e13b5
commit
b8aec65ee7
|
@ -16,11 +16,18 @@ __status__ = "Prototype"
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from .CommentMacroParser import CommentMacroParser
|
|
||||||
from .CommentMacroListener import CommentMacroListener
|
|
||||||
from pythonosc import osc_message_builder
|
from pythonosc import osc_message_builder
|
||||||
from time import sleep
|
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__')
|
logger = logging.getLogger('__main__')
|
||||||
|
|
||||||
|
|
||||||
|
|
10
comment.py
10
comment.py
|
@ -23,10 +23,18 @@ from antlr4 import CommonTokenStream
|
||||||
from antlr4 import InputStream
|
from antlr4 import InputStream
|
||||||
from antlr4 import ParseTreeWalker
|
from antlr4 import ParseTreeWalker
|
||||||
from antlr4.error.ErrorListener import ErrorListener
|
from antlr4.error.ErrorListener import ErrorListener
|
||||||
|
from pythonosc import udp_client
|
||||||
|
|
||||||
|
try:
|
||||||
|
# include reletive path imports when a module
|
||||||
from .CommentMacroLexer import CommentMacroLexer
|
from .CommentMacroLexer import CommentMacroLexer
|
||||||
from .CommentMacroParser import CommentMacroParser
|
from .CommentMacroParser import CommentMacroParser
|
||||||
from .OscCommentMacroListener import OscCommentMacroListener
|
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
|
# define an error listener that raises SyntaxError exceptions
|
||||||
|
|
Loading…
Reference in New Issue