59
59
60
60
__all__ = [
61
61
"""__package__""" , """__module__""" , """__name__""" , """__doc__""" ,
62
- """NoOp""" , """ McastNope""" , """McastRecvHearDispatch""" , """McastDispatch""" , """main""" ,
62
+ """McastNope""" , """McastRecvHearDispatch""" , """McastDispatch""" , """main""" ,
63
63
]
64
64
65
65
66
- __package__ = """multicast"""
66
+ __package__ = """multicast""" # skipcq: PYL-W0622
67
67
68
68
69
- __module__ = """multicast.__main__"""
69
+ __module__ = """multicast.__main__""" # skipcq: PYL-W0622
70
70
71
71
72
72
__file__ = """multicast/__main__.py"""
76
76
77
77
78
78
try :
79
- from . import sys as sys
79
+ from . import sys as sys # skipcq: PYL-C0414
80
80
except Exception :
81
81
# Throw more relevant Error
82
82
raise ImportError (str ("[CWE-440] Error Importing Python" ))
83
83
84
84
85
85
try :
86
86
if 'multicast.__version__' not in sys .modules :
87
- from . import __version__ as __version__
87
+ from . import __version__ as __version__ # skipcq: PYL-C0414
88
88
else : # pragma: no branch
89
89
__version__ = sys .modules ["""multicast.__version__""" ]
90
90
except Exception as importErr :
94
94
95
95
try :
96
96
if 'multicast._MCAST_DEFAULT_PORT' not in sys .modules :
97
- from . import _MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT
97
+ from . import _MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT # skipcq: PYL-C0414
98
98
else : # pragma: no branch
99
99
_MCAST_DEFAULT_PORT = sys .modules ["""multicast._MCAST_DEFAULT_PORT""" ]
100
100
except Exception as importErr :
104
104
105
105
try :
106
106
if 'multicast._MCAST_DEFAULT_GROUP' not in sys .modules :
107
- from . import _MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP
107
+ from . import _MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP # skipcq: PYL-C0414
108
108
else : # pragma: no branch
109
109
_MCAST_DEFAULT_GROUP = sys .modules ["""multicast._MCAST_DEFAULT_GROUP""" ]
110
110
except Exception as importErr :
114
114
115
115
try :
116
116
if 'multicast.mtool' not in sys .modules :
117
- from . import mtool as mtool
117
+ from . import mtool as mtool # skipcq: PYL-C0414
118
118
else : # pragma: no branch
119
119
mtool = sys .modules ["""multicast.mtool""" ]
120
120
except Exception as importErr :
124
124
125
125
try :
126
126
if 'multicast.recv' not in sys .modules :
127
- from . import recv as recv
127
+ from . import recv as recv # skipcq: PYL-C0414
128
128
else : # pragma: no branch
129
129
recv = sys .modules ["""multicast.recv""" ]
130
130
except Exception as importErr :
134
134
135
135
try :
136
136
if 'multicast.send' not in sys .modules :
137
- from . import send as send
137
+ from . import send as send # skipcq: PYL-C0414
138
138
else : # pragma: no branch
139
139
send = sys .modules ["""multicast.send""" ]
140
140
except Exception as importErr :
144
144
145
145
try :
146
146
if 'multicast.hear' not in sys .modules :
147
- from . import hear as hear
147
+ from . import hear as hear # skipcq: PYL-C0414
148
148
else : # pragma: no branch
149
149
hear = sys .modules ["""multicast.hear""" ]
150
150
except Exception as importErr :
151
151
del importErr
152
152
import multicast .hear as hear
153
153
154
154
155
- def NoOp (* args , ** kwargs ):
156
- """Do Nothing.
157
-
158
- The meaning of Nothing. This function should be self-explanitory;
159
- it does 'no operation' i.e. nothing.
160
-
161
- Minimal Acceptance Testing:
162
-
163
- First setup test fixtures by importing multicast.
164
-
165
- >>> import multicast.__main__
166
- >>>
167
-
168
- Testcase 0: multicast.__main__ should have a doctests.
169
-
170
- >>> import multicast.__main__
171
- >>> multicast.__main__.__module__ is not None
172
- True
173
- >>>
174
-
175
- Testcase 1: multicast.NoOp should return None.
176
-
177
- >>> import multicast.__main__
178
- >>> multicast.__main__.NoOp() is None
179
- True
180
- >>> multicast.__main__.NoOp() is not None
181
- False
182
- >>>
183
-
184
- """
185
- return None # noqa
186
-
187
-
188
155
class McastNope (mtool ):
189
156
"""
157
+ The trivial implementation of mtool.
190
158
191
159
Testing:
192
160
@@ -251,8 +219,44 @@ class McastNope(mtool):
251
219
def setupArgs (cls , parser ):
252
220
pass
253
221
222
+ @staticmethod
223
+ def NoOp (* args , ** kwargs ):
224
+ """Do Nothing.
225
+
226
+ The meaning of Nothing. This function should be self-explanitory;
227
+ it does 'no operation' i.e. nothing.
228
+
229
+ Minimal Acceptance Testing:
230
+
231
+ First setup test fixtures by importing multicast.
232
+
233
+ >>> import multicast.__main__
234
+ >>>
235
+
236
+ Testcase 0: multicast.__main__ should have a McastNope class.
237
+
238
+ >>> import multicast.__main__
239
+ >>> multicast.__main__.McastNope is not None
240
+ True
241
+ >>>
242
+
243
+ Testcase 1: multicast.NoOp should return None.
244
+
245
+ >>> import multicast.__main__
246
+ >>> multicast.__main__.McastNope.NoOp() is None
247
+ True
248
+ >>> multicast.__main__.McastNope.NoOp() is not None
249
+ False
250
+ >>>
251
+ >>> multicast.__main__.McastNope.NoOp("Junk")
252
+ None
253
+ >>>
254
+
255
+ """
256
+ return None # noqa
257
+
254
258
def doStep (self , * args , ** kwargs ):
255
- return NoOp (* args , ** kwargs )
259
+ return self . NoOp (* args , ** kwargs )
256
260
257
261
258
262
class McastRecvHearDispatch (mtool ):
@@ -326,7 +330,7 @@ class McastRecvHearDispatch(mtool):
326
330
327
331
@classmethod
328
332
def setupArgs (cls , parser ):
329
- """Will attempt add send args.
333
+ """Will attempt to add send args.
330
334
331
335
Testing:
332
336
@@ -375,8 +379,36 @@ def setupArgs(cls, parser):
375
379
>>> multicast.__main__.McastRecvHearDispatch.setupArgs(parser=tst_fxtr_args)
376
380
>>>
377
381
382
+ Testcase 3: setupArgs should return None untouched.
383
+ A: Test that the multicast component is initialized.
384
+ B: Test that the __main__ component is initialized.
385
+ C: Test that the McastRecvHearDispatch class is initialized.
386
+ D: Test that the McastRecvHearDispatch.setupArgs() function yields None.
387
+
388
+ >>> multicast.__main__ is not None
389
+ True
390
+ >>> multicast.__main__.McastRecvHearDispatch is not None
391
+ True
392
+ >>> multicast.__main__.McastRecvHearDispatch.setupArgs is not None
393
+ True
394
+ >>> tst_fxtr_N = None
395
+ >>> test_fixture = multicast.__main__.McastRecvHearDispatch.setupArgs(tst_fxtr_N)
396
+ >>> test_fixture is not None
397
+ False
398
+ >>> type(test_fixture) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
399
+ <...None...>
400
+ >>> tst_fxtr_N == test_fixture
401
+ True
402
+ >>> tst_fxtr_N is None
403
+ True
404
+ >>>
405
+ >>> test_fixture is None
406
+ True
407
+ >>>
408
+
409
+
378
410
"""
379
- if parser is not None :
411
+ if parser is not None : # pragma: no branch
380
412
parser .add_argument ("""--port""" , type = int , default = _MCAST_DEFAULT_PORT )
381
413
__tmp_help = """local interface to use for listening to multicast data; """
382
414
__tmp_help += """if unspecified, any one interface may be chosen."""
@@ -399,8 +431,9 @@ def setupArgs(cls, parser):
399
431
help = """multicast groups (ip addrs) to listen to join."""
400
432
)
401
433
402
- def _help_deamon_dispatch (self , * args , ** kwargs ):
403
- _useHear = False if "is_deamon" not in kwargs .keys () else kwargs ["is_deamon" ]
434
+ @staticmethod
435
+ def _help_deamon_dispatch (* args , ** kwargs ):
436
+ _useHear = kwargs .get ("is_deamon" , False )
404
437
return _useHear
405
438
406
439
def doStep (self , * args , ** kwargs ):
@@ -440,7 +473,8 @@ def setupArgs(cls, parser):
440
473
sub_parser = parser .add_parser (sub_tool , help = "..." )
441
474
type (TASK_OPTIONS [sub_tool ]).setupArgs (sub_parser )
442
475
443
- def useTool (self , tool , ** kwargs ):
476
+ @staticmethod
477
+ def useTool (tool , ** kwargs ):
444
478
"""Will Handle launching the actual task functions."""
445
479
theResult = None
446
480
cached_list = sorted (TASK_OPTIONS .keys ())
@@ -461,7 +495,7 @@ def doStep(self, *args):
461
495
__EXIT_MSG = (1 , "Unknown" )
462
496
try :
463
497
try :
464
- (argz , extra ) = type (self ).parseArgs (* args )
498
+ (argz , _ ) = type (self ).parseArgs (* args )
465
499
service_cmd = argz .cmd_tool
466
500
argz .__dict__ .__delitem__ ("""cmd_tool""" )
467
501
_TOOL_MSG = (self .useTool (service_cmd , ** argz .__dict__ ))
0 commit comments