33
44# Python Repo Template
55# ..................................
6- # Copyright (c) 2017-2019 , Kendrick Walls
6+ # Copyright (c) 2017-2022 , Kendrick Walls
77# ..................................
88# Licensed under MIT (the "License");
99# you may not use this file except in compliance with the License.
1818# limitations under the License.
1919
2020
21+ __module__ = """pythonrepo.pythonrepo"""
22+ """This is pythonrepo component Template."""
23+
24+
2125try :
22- import sys
26+ from . import sys
2327 import argparse
2428except Exception as err :
25- # Show Error Info
26- print (str (type (err )))
27- print (str (err ))
28- print (str (err .args ))
29- print (str ("" ))
30- # Clean up Error
31- err = None
32- del (err )
29+ # Collect Error Info
30+ baton = ImportError (err , str ("[CWE-758] Module failed completely." ))
31+ baton .module = __module__
32+ baton .path = __file__
33+ baton .__cause__ = err
3334 # Throw more relevant Error
34- raise ImportError (str ("Error Importing Python" ))
35+ raise baton
36+
37+
38+ from . import __version__
39+ """The version of this program."""
3540
3641
37- __prog__ = str ("""pythonrepo""" )
42+ __prog__ = str (__module__ )
3843"""The name of this program is PythonRepo"""
3944
4045
5055"""Contains the short epilog of the program CLI help text."""
5156
5257
53- __version__ = """1.1.1"""
54- """The version of this program."""
55-
56-
5758# Add your functions here
5859
5960
@@ -96,16 +97,8 @@ def parseArgs(arguments=None):
9697 return parser .parse_known_args (arguments )
9798
9899
99- def __checkToolArgs (args = None ):
100- """Handles None case for arguments as a helper function."""
101- if args is None :
102- args = [None ]
103- return args
104-
105-
106- def useTool (tool , arguments = None ):
100+ def useTool (tool , * arguments ):
107101 """Handler for launching the functions."""
108- arguments = __checkToolArgs (arguments )
109102 if (tool is not None ) and (tool in TASK_OPTIONS .keys ()):
110103 try :
111104 # print(str("launching: " + tool))
@@ -118,11 +111,11 @@ def useTool(tool, arguments=None):
118111 return None
119112
120113
121- def main (argv = None ):
114+ def main (* argv ):
122115 """The Main Event."""
123116 try :
124117 try :
125- args , extra = parseArgs (argv )
118+ args , extra = parseArgs (* argv )
126119 service_cmd = args .some_task
127120 useTool (service_cmd , extra )
128121 except Exception :
@@ -139,6 +132,7 @@ def main(argv=None):
139132 exit (0 )
140133
141134
142- if __name__ == '__main__' :
135+ if __name__ in '__main__' :
136+ # deepsource overlooks the readability of "if main" type code here. (See PTC-W0048)
143137 if (sys .argv is not None ) and (len (sys .argv ) >= 1 ):
144138 main (sys .argv [1 :])
0 commit comments