manage exiting without external dependency
This commit is contained in:
parent
1aaf12b6f3
commit
999624bd49
15
comment.py
15
comment.py
|
@ -19,7 +19,6 @@ import antlr4
|
|||
import configparser
|
||||
import logging
|
||||
import readline
|
||||
import signal
|
||||
import sys
|
||||
|
||||
from CommentMacroLexer import CommentMacroLexer
|
||||
|
@ -58,20 +57,18 @@ def comment(text):
|
|||
walker.walk(oscMacro, tree)
|
||||
|
||||
|
||||
def orderly_exit():
|
||||
logger.info('Goodbye.')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
signal.signal(signal.SIGINT, orderly_exit)
|
||||
if len(sys.argv) > 1:
|
||||
logger.debug("found macro at argv[1]")
|
||||
comment(sys.argv[1])
|
||||
else:
|
||||
while True:
|
||||
text = input("comment# ")
|
||||
try:
|
||||
text = input("comment# ")
|
||||
except KeyboardInterrupt:
|
||||
print()
|
||||
sys.exit(0)
|
||||
if text == 'exit':
|
||||
orderly_exit()
|
||||
sys.exit(0)
|
||||
else:
|
||||
comment(text)
|
||||
|
|
Loading…
Reference in New Issue