15 from importlib.util
import spec_from_loader, module_from_spec
16 from importlib.machinery
import SourceFileLoader, ExtensionFileLoader
19 spec = spec_from_loader(
"markopy", SourceFileLoader(
"markopy", os.path.abspath(
"markopy.py")))
20 markopy = module_from_spec(spec)
21 spec.loader.exec_module(markopy)
22 except (ModuleNotFoundError,FileNotFoundError)
as e:
23 if(os.path.exists(
"../../../Markopy/src/CLI/markopy.py")):
24 spec = spec_from_loader(
"markopy", SourceFileLoader(
"markopy",
"../../../Markopy/src/CLI/markopy.py"))
25 markopy = module_from_spec(spec)
26 spec.loader.exec_module(markopy)
29 from cudammx
import CudaModelMatrixCLI
30 from mmx
import ModelMatrixCLI
31 from mp
import MarkovPasswordsCLI
33 except ModuleNotFoundError
as e:
35 if(os.path.exists(
"../../../Markopy/src/CLI/cudammx.py")):
36 sys.path.insert(1,
'../../../Markopy/src/CLI/')
37 from cudammx
import CudaModelMatrixCLI
38 from mmx
import ModelMatrixCLI
39 from mp
import MarkovPasswordsCLI
43 from termcolor
import colored
48 @brief CUDA extension to MarkopyCLI. Adds CudaModelMatrixCLI to the interface.
49 @belongsto Python::CudaMarkopy
50 @extends Python::Markopy::MarkopyCLI
51 @extends Python::CudaMarkopy::CudaModelMatrixCLI
54 "! @brief initialize CLI selector"
55 markopy.MarkopyCLI.__init__(self,add_help=
False)
56 self.
parserparser.epilog+=f
"""
57 {__file__.split("/")[-1]} -mt CUDA generate trained.mdl -n 500 -w output.txt
58 Import trained.mdl, and generate 500 lines to output.txt
62 "! @brief overload help string"
67 mp = MarkovPasswordsCLI()
69 mp.parser.print_help()
73 mp.parser.print_help()
77 mp.parser.print_help()
79 print(colored(
"Model Mode selection choices:",
"green"))
81 print(colored(
"Following are applicable for -mt MP mode:",
"green"))
82 mp = MarkovPasswordsCLI()
84 mp.parser.print_help()
85 print(colored(
"Following are applicable for -mt MMX mode:",
"green"))
88 mp.parser.print_help()
89 print(colored(
"Following are applicable for -mt CUDA mode:",
"green"))
92 mp.parser.print_help()
96 markopy.MarkopyCLI.parse(self)
99 "! @brief Not a valid model type"
103 markopy.MarkopyCLI.parse_fail(self)
106 if __name__ ==
"__main__":
107 mp = CudaMarkopyCLI()
CUDA extension to MarkopyCLI.
def help(self)
overload help function to print submodel helps
Python CLI wrapper for CudaModelMatrix.