Browse Source

main.py: add `fqmod` param; add test/misc/opts.py launcher

The MMGen Project 1 year ago
parent
commit
5c419c802b
2 changed files with 10 additions and 2 deletions
  1. 2 2
      mmgen/main.py
  2. 8 0
      test/misc/opts.py

+ 2 - 2
mmgen/main.py

@@ -22,7 +22,7 @@ main: Script launcher for the MMGen Project
 
 import sys,os
 
-def launch(*, mod=None, func=None, package='mmgen'):
+def launch(*, mod=None, func=None, fqmod=None, package='mmgen'):
 
 	if sys.platform == 'linux' and sys.stdin.isatty():
 		import termios,atexit
@@ -31,7 +31,7 @@ def launch(*, mod=None, func=None, package='mmgen'):
 		atexit.register(lambda: termios.tcsetattr(fd,termios.TCSADRAIN,old))
 
 	try:
-		__import__(f'{package}.main_{mod}') if mod else func()
+		__import__(f'{package}.main_{mod}') if mod else func() if func else __import__(fqmod)
 	except KeyboardInterrupt:
 		from .color import yellow
 		sys.stderr.write(yellow('\nUser interrupt\n'))

+ 8 - 0
test/misc/opts.py

@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+
+from mmgen.main import launch
+import sys
+
+sys.path.insert(0,'test')
+
+launch(fqmod='misc.opts_main')