Skip to content

Commit e760262

Browse files
[MERGE]
* from PR #97 (HOTFIX-deps-style-update): [DOCUMENTATION] minor update for 'build' module license details (- WIP #96 & #80 -) [DOCUMENTATION] minor update for flake8 license details (- WIP #96 & #80 -) [DOCUMENTATION] minor update for tox license details (- WIP #96 & #80 -) * from PR #95 (pylint-linter-fixes): Update multicast/__main__.py as suggested [PATCH] Suppress pylint by fix or rule but suppress (- WIP #94 -) [STYLE] Minor updates to internal module structures to improve performance (- WIP #94 -) [STYLE] Minor updates to _sayStep core function (- WIP #94 -) [STYLE] possible fix for PYL-R0123 (- WIP #94 -) [STYLE] Suppress pylint by fix or rule but suppress (- WIP #94 -) [STYLE] attempt to improve code quality (- WIP #94 -)
2 parents 6b88bc3 + 00ede8d commit e760262

File tree

10 files changed

+171
-105
lines changed

10 files changed

+171
-105
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ignore_errors = True
3939
partial_branches =
4040
# Have to re-enable the standard pragma rules
4141
pragma: no branch
42+
skipcq: PYL-
4243
finally:
4344
@
4445
except unittest.SkipTest

multicast/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"""skt.endSocket""", """skt.endSocket.__func__""", """endSocket""",
2626
"""_BLANK""", """_MCAST_DEFAULT_PORT""", """_MCAST_DEFAULT_GROUP""",
2727
"""_MCAST_DEFAULT_TTL""", """mtool""", """recv""", """send""", """hear""",
28-
"""recv.McastRECV""", """send.McastSAY""", """hear.McastHEAR""", """hear.McastHEAR""",
28+
"""recv.McastRECV""", """send.McastSAY""", """hear.McastHEAR""",
2929
]
3030

31-
__package__ = """multicast"""
31+
__package__ = """multicast""" # skipcq: PYL-W0622
3232
"""The package of this program.
3333
3434
Minimal Acceptance Testing:
@@ -62,7 +62,7 @@
6262
"""
6363

6464

65-
__name__ = """multicast"""
65+
__name__ = """multicast""" # skipcq: PYL-W0622
6666
"""The name of this program.
6767
6868
Minimal Acceptance Testing:
@@ -79,7 +79,7 @@
7979
"""
8080

8181

82-
global __version__
82+
global __version__ # skipcq: PYL-W0604
8383

8484
__version__ = """1.5-rc"""
8585
"""The version of this program.
@@ -153,7 +153,7 @@
153153
"""
154154

155155

156-
global _MCAST_DEFAULT_PORT # noqa
156+
global _MCAST_DEFAULT_PORT # skipcq: PYL-W0604
157157

158158
_MCAST_DEFAULT_PORT = 59259
159159
"""
@@ -199,7 +199,7 @@
199199
200200
"""
201201

202-
global _MCAST_DEFAULT_GROUP # noqa
202+
global _MCAST_DEFAULT_GROUP # skipcq: PYL-W0604
203203

204204
_MCAST_DEFAULT_GROUP = """224.0.0.1"""
205205
"""Arbitrary group to use by default, though any mcst grp would work.
@@ -228,7 +228,7 @@
228228
"""
229229

230230

231-
global _MCAST_DEFAULT_TTL # noqa
231+
global _MCAST_DEFAULT_TTL # skipcq: PYL-W0604
232232

233233
_MCAST_DEFAULT_TTL = int(1)
234234
"""Arbitrary TTL time to live to use by default, though any small (1-126) TTL would work.
@@ -262,7 +262,7 @@
262262
"""
263263

264264

265-
global _BLANK # noqa
265+
global _BLANK # skipcq: PYL-W0604
266266

267267
_BLANK = str("""""")
268268
"""Arbitrary blank string.

multicast/__main__.py

Lines changed: 85 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@
5959

6060
__all__ = [
6161
"""__package__""", """__module__""", """__name__""", """__doc__""",
62-
"""NoOp""", """McastNope""", """McastRecvHearDispatch""", """McastDispatch""", """main""",
62+
"""McastNope""", """McastRecvHearDispatch""", """McastDispatch""", """main""",
6363
]
6464

6565

66-
__package__ = """multicast"""
66+
__package__ = """multicast""" # skipcq: PYL-W0622
6767

6868

69-
__module__ = """multicast.__main__"""
69+
__module__ = """multicast.__main__""" # skipcq: PYL-W0622
7070

7171

7272
__file__ = """multicast/__main__.py"""
@@ -76,15 +76,15 @@
7676

7777

7878
try:
79-
from . import sys as sys
79+
from . import sys as sys # skipcq: PYL-C0414
8080
except Exception:
8181
# Throw more relevant Error
8282
raise ImportError(str("[CWE-440] Error Importing Python"))
8383

8484

8585
try:
8686
if 'multicast.__version__' not in sys.modules:
87-
from . import __version__ as __version__
87+
from . import __version__ as __version__ # skipcq: PYL-C0414
8888
else: # pragma: no branch
8989
__version__ = sys.modules["""multicast.__version__"""]
9090
except Exception as importErr:
@@ -94,7 +94,7 @@
9494

9595
try:
9696
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
9898
else: # pragma: no branch
9999
_MCAST_DEFAULT_PORT = sys.modules["""multicast._MCAST_DEFAULT_PORT"""]
100100
except Exception as importErr:
@@ -104,7 +104,7 @@
104104

105105
try:
106106
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
108108
else: # pragma: no branch
109109
_MCAST_DEFAULT_GROUP = sys.modules["""multicast._MCAST_DEFAULT_GROUP"""]
110110
except Exception as importErr:
@@ -114,7 +114,7 @@
114114

115115
try:
116116
if 'multicast.mtool' not in sys.modules:
117-
from . import mtool as mtool
117+
from . import mtool as mtool # skipcq: PYL-C0414
118118
else: # pragma: no branch
119119
mtool = sys.modules["""multicast.mtool"""]
120120
except Exception as importErr:
@@ -124,7 +124,7 @@
124124

125125
try:
126126
if 'multicast.recv' not in sys.modules:
127-
from . import recv as recv
127+
from . import recv as recv # skipcq: PYL-C0414
128128
else: # pragma: no branch
129129
recv = sys.modules["""multicast.recv"""]
130130
except Exception as importErr:
@@ -134,7 +134,7 @@
134134

135135
try:
136136
if 'multicast.send' not in sys.modules:
137-
from . import send as send
137+
from . import send as send # skipcq: PYL-C0414
138138
else: # pragma: no branch
139139
send = sys.modules["""multicast.send"""]
140140
except Exception as importErr:
@@ -144,49 +144,17 @@
144144

145145
try:
146146
if 'multicast.hear' not in sys.modules:
147-
from . import hear as hear
147+
from . import hear as hear # skipcq: PYL-C0414
148148
else: # pragma: no branch
149149
hear = sys.modules["""multicast.hear"""]
150150
except Exception as importErr:
151151
del importErr
152152
import multicast.hear as hear
153153

154154

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-
188155
class McastNope(mtool):
189156
"""
157+
The trivial implementation of mtool.
190158
191159
Testing:
192160
@@ -251,8 +219,44 @@ class McastNope(mtool):
251219
def setupArgs(cls, parser):
252220
pass
253221

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+
254258
def doStep(self, *args, **kwargs):
255-
return NoOp(*args, **kwargs)
259+
return self.NoOp(*args, **kwargs)
256260

257261

258262
class McastRecvHearDispatch(mtool):
@@ -326,7 +330,7 @@ class McastRecvHearDispatch(mtool):
326330

327331
@classmethod
328332
def setupArgs(cls, parser):
329-
"""Will attempt add send args.
333+
"""Will attempt to add send args.
330334
331335
Testing:
332336
@@ -375,8 +379,36 @@ def setupArgs(cls, parser):
375379
>>> multicast.__main__.McastRecvHearDispatch.setupArgs(parser=tst_fxtr_args)
376380
>>>
377381
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+
378410
"""
379-
if parser is not None:
411+
if parser is not None: # pragma: no branch
380412
parser.add_argument("""--port""", type=int, default=_MCAST_DEFAULT_PORT)
381413
__tmp_help = """local interface to use for listening to multicast data; """
382414
__tmp_help += """if unspecified, any one interface may be chosen."""
@@ -399,8 +431,9 @@ def setupArgs(cls, parser):
399431
help="""multicast groups (ip addrs) to listen to join."""
400432
)
401433

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)
404437
return _useHear
405438

406439
def doStep(self, *args, **kwargs):
@@ -440,7 +473,8 @@ def setupArgs(cls, parser):
440473
sub_parser = parser.add_parser(sub_tool, help="...")
441474
type(TASK_OPTIONS[sub_tool]).setupArgs(sub_parser)
442475

443-
def useTool(self, tool, **kwargs):
476+
@staticmethod
477+
def useTool(tool, **kwargs):
444478
"""Will Handle launching the actual task functions."""
445479
theResult = None
446480
cached_list = sorted(TASK_OPTIONS.keys())
@@ -461,7 +495,7 @@ def doStep(self, *args):
461495
__EXIT_MSG = (1, "Unknown")
462496
try:
463497
try:
464-
(argz, extra) = type(self).parseArgs(*args)
498+
(argz, _) = type(self).parseArgs(*args)
465499
service_cmd = argz.cmd_tool
466500
argz.__dict__.__delitem__("""cmd_tool""")
467501
_TOOL_MSG = (self.useTool(service_cmd, **argz.__dict__))

multicast/hear.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"""
9191

9292

93-
__package__ = """multicast"""
93+
__package__ = """multicast""" # skipcq: PYL-W0622
9494
"""Names the package of this program.
9595
9696
Minimal Acceptance Testing:
@@ -139,7 +139,7 @@
139139
"""Names the file of this component."""
140140

141141

142-
__name__ = """multicast.hear"""
142+
__name__ = """multicast.hear""" # skipcq: PYL-W0622
143143
"""Names this component.
144144
145145
Minimal Acceptance Testing:
@@ -162,24 +162,24 @@
162162
try:
163163
import sys
164164
if 'multicast' not in sys.modules:
165-
from . import multicast as multicast
165+
from . import multicast as multicast # skipcq: PYL-C0414
166166
else: # pragma: no branch
167167
multicast = sys.modules["""multicast"""]
168168
_BLANK = multicast._BLANK
169-
from . import recv as recv
170-
from . import send as send
169+
from . import recv as recv # skipcq: PYL-C0414
170+
from . import send as send # skipcq: PYL-C0414
171171
except Exception as importErr:
172172
del importErr
173-
import multicast as multicast
173+
import multicast as multicast # skipcq: PYL-C0414
174174

175175

176176
try:
177177
import socketserver
178-
from socketserver import threading as threading
179-
from multicast import argparse as argparse
180-
from multicast import unicodedata as unicodedata
181-
from multicast import socket as socket
182-
from multicast import struct as struct
178+
from socketserver import threading as threading # skipcq: PYL-C0414
179+
from multicast import argparse as argparse # skipcq: PYL-C0414
180+
from multicast import unicodedata as unicodedata # skipcq: PYL-C0414
181+
from multicast import socket as socket # skipcq: PYL-C0414
182+
from multicast import struct as struct # skipcq: PYL-C0414
183183
depends = [
184184
unicodedata, socket, struct, argparse
185185
]
@@ -382,7 +382,7 @@ def setupArgs(cls, parser):
382382
pass
383383

384384
def doStep(self, *args, **kwargs):
385-
# _is_std = False if "is_std" not in kwargs.keys() else kwargs["is_std"]
385+
# _is_std = False if "is_std" not in kwargs else kwargs["is_std"]
386386
HOST = kwargs.get("group", multicast._MCAST_DEFAULT_GROUP)
387387
PORT = kwargs.get("port", multicast._MCAST_DEFAULT_PORT)
388388
with McastServer((HOST, PORT), HearUDPHandler) as server:

0 commit comments

Comments
 (0)