Skip to content

Pylint linter fixes #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ignore_errors = True
partial_branches =
# Have to re-enable the standard pragma rules
pragma: no branch
skipcq: PYL-
finally:
@
except unittest.SkipTest
Expand Down
16 changes: 8 additions & 8 deletions multicast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"""skt.endSocket""", """skt.endSocket.__func__""", """endSocket""",
"""_BLANK""", """_MCAST_DEFAULT_PORT""", """_MCAST_DEFAULT_GROUP""",
"""_MCAST_DEFAULT_TTL""", """mtool""", """recv""", """send""", """hear""",
"""recv.McastRECV""", """send.McastSAY""", """hear.McastHEAR""", """hear.McastHEAR""",
"""recv.McastRECV""", """send.McastSAY""", """hear.McastHEAR""",
]

__package__ = """multicast"""
__package__ = """multicast""" # skipcq: PYL-W0622
"""The package of this program.

Minimal Acceptance Testing:
Expand Down Expand Up @@ -62,7 +62,7 @@
"""


__name__ = """multicast"""
__name__ = """multicast""" # skipcq: PYL-W0622
"""The name of this program.

Minimal Acceptance Testing:
Expand All @@ -79,7 +79,7 @@
"""


global __version__
global __version__ # skipcq: PYL-W0604

__version__ = """1.5-rc"""
"""The version of this program.
Expand Down Expand Up @@ -153,7 +153,7 @@
"""


global _MCAST_DEFAULT_PORT # noqa
global _MCAST_DEFAULT_PORT # skipcq: PYL-W0604

_MCAST_DEFAULT_PORT = 59259
"""
Expand Down Expand Up @@ -199,7 +199,7 @@

"""

global _MCAST_DEFAULT_GROUP # noqa
global _MCAST_DEFAULT_GROUP # skipcq: PYL-W0604

_MCAST_DEFAULT_GROUP = """224.0.0.1"""
"""Arbitrary group to use by default, though any mcst grp would work.
Expand Down Expand Up @@ -228,7 +228,7 @@
"""


global _MCAST_DEFAULT_TTL # noqa
global _MCAST_DEFAULT_TTL # skipcq: PYL-W0604

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


global _BLANK # noqa
global _BLANK # skipcq: PYL-W0604

_BLANK = str("""""")
"""Arbitrary blank string.
Expand Down
136 changes: 85 additions & 51 deletions multicast/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@

__all__ = [
"""__package__""", """__module__""", """__name__""", """__doc__""",
"""NoOp""", """McastNope""", """McastRecvHearDispatch""", """McastDispatch""", """main""",
"""McastNope""", """McastRecvHearDispatch""", """McastDispatch""", """main""",
]


__package__ = """multicast"""
__package__ = """multicast""" # skipcq: PYL-W0622


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


__file__ = """multicast/__main__.py"""
Expand All @@ -76,15 +76,15 @@


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


try:
if 'multicast.__version__' not in sys.modules:
from . import __version__ as __version__
from . import __version__ as __version__ # skipcq: PYL-C0414
else: # pragma: no branch
__version__ = sys.modules["""multicast.__version__"""]
except Exception as importErr:
Expand All @@ -94,7 +94,7 @@

try:
if 'multicast._MCAST_DEFAULT_PORT' not in sys.modules:
from . import _MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT
from . import _MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT # skipcq: PYL-C0414
else: # pragma: no branch
_MCAST_DEFAULT_PORT = sys.modules["""multicast._MCAST_DEFAULT_PORT"""]
except Exception as importErr:
Expand All @@ -104,7 +104,7 @@

try:
if 'multicast._MCAST_DEFAULT_GROUP' not in sys.modules:
from . import _MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP
from . import _MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP # skipcq: PYL-C0414
else: # pragma: no branch
_MCAST_DEFAULT_GROUP = sys.modules["""multicast._MCAST_DEFAULT_GROUP"""]
except Exception as importErr:
Expand All @@ -114,7 +114,7 @@

try:
if 'multicast.mtool' not in sys.modules:
from . import mtool as mtool
from . import mtool as mtool # skipcq: PYL-C0414
else: # pragma: no branch
mtool = sys.modules["""multicast.mtool"""]
except Exception as importErr:
Expand All @@ -124,7 +124,7 @@

try:
if 'multicast.recv' not in sys.modules:
from . import recv as recv
from . import recv as recv # skipcq: PYL-C0414
else: # pragma: no branch
recv = sys.modules["""multicast.recv"""]
except Exception as importErr:
Expand All @@ -134,7 +134,7 @@

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

try:
if 'multicast.hear' not in sys.modules:
from . import hear as hear
from . import hear as hear # skipcq: PYL-C0414
else: # pragma: no branch
hear = sys.modules["""multicast.hear"""]
except Exception as importErr:
del importErr
import multicast.hear as hear


def NoOp(*args, **kwargs):
"""Do Nothing.

The meaning of Nothing. This function should be self-explanitory;
it does 'no operation' i.e. nothing.

Minimal Acceptance Testing:

First setup test fixtures by importing multicast.

>>> import multicast.__main__
>>>

Testcase 0: multicast.__main__ should have a doctests.

>>> import multicast.__main__
>>> multicast.__main__.__module__ is not None
True
>>>

Testcase 1: multicast.NoOp should return None.

>>> import multicast.__main__
>>> multicast.__main__.NoOp() is None
True
>>> multicast.__main__.NoOp() is not None
False
>>>

"""
return None # noqa


class McastNope(mtool):
"""
The trivial implementation of mtool.

Testing:

Expand Down Expand Up @@ -251,8 +219,44 @@ class McastNope(mtool):
def setupArgs(cls, parser):
pass

@staticmethod
def NoOp(*args, **kwargs):
"""Do Nothing.

The meaning of Nothing. This function should be self-explanitory;
it does 'no operation' i.e. nothing.

Minimal Acceptance Testing:

First setup test fixtures by importing multicast.

>>> import multicast.__main__
>>>

Testcase 0: multicast.__main__ should have a McastNope class.

>>> import multicast.__main__
>>> multicast.__main__.McastNope is not None
True
>>>

Testcase 1: multicast.NoOp should return None.

>>> import multicast.__main__
>>> multicast.__main__.McastNope.NoOp() is None
True
>>> multicast.__main__.McastNope.NoOp() is not None
False
>>>
>>> multicast.__main__.McastNope.NoOp("Junk")
None
>>>

"""
return None # noqa

def doStep(self, *args, **kwargs):
return NoOp(*args, **kwargs)
return self.NoOp(*args, **kwargs)


class McastRecvHearDispatch(mtool):
Expand Down Expand Up @@ -326,7 +330,7 @@ class McastRecvHearDispatch(mtool):

@classmethod
def setupArgs(cls, parser):
"""Will attempt add send args.
"""Will attempt to add send args.

Testing:

Expand Down Expand Up @@ -375,8 +379,36 @@ def setupArgs(cls, parser):
>>> multicast.__main__.McastRecvHearDispatch.setupArgs(parser=tst_fxtr_args)
>>>

Testcase 3: setupArgs should return None untouched.
A: Test that the multicast component is initialized.
B: Test that the __main__ component is initialized.
C: Test that the McastRecvHearDispatch class is initialized.
D: Test that the McastRecvHearDispatch.setupArgs() function yields None.

>>> multicast.__main__ is not None
True
>>> multicast.__main__.McastRecvHearDispatch is not None
True
>>> multicast.__main__.McastRecvHearDispatch.setupArgs is not None
True
>>> tst_fxtr_N = None
>>> test_fixture = multicast.__main__.McastRecvHearDispatch.setupArgs(tst_fxtr_N)
>>> test_fixture is not None
False
>>> type(test_fixture) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
<...None...>
>>> tst_fxtr_N == test_fixture
True
>>> tst_fxtr_N is None
True
>>>
>>> test_fixture is None
True
>>>


"""
if parser is not None:
if parser is not None: # pragma: no branch
parser.add_argument("""--port""", type=int, default=_MCAST_DEFAULT_PORT)
__tmp_help = """local interface to use for listening to multicast data; """
__tmp_help += """if unspecified, any one interface may be chosen."""
Expand All @@ -399,8 +431,9 @@ def setupArgs(cls, parser):
help="""multicast groups (ip addrs) to listen to join."""
)

def _help_deamon_dispatch(self, *args, **kwargs):
_useHear = False if "is_deamon" not in kwargs.keys() else kwargs["is_deamon"]
@staticmethod
def _help_deamon_dispatch(*args, **kwargs):
_useHear = kwargs.get("is_deamon", False)
return _useHear

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

def useTool(self, tool, **kwargs):
@staticmethod
def useTool(tool, **kwargs):
"""Will Handle launching the actual task functions."""
theResult = None
cached_list = sorted(TASK_OPTIONS.keys())
Expand All @@ -461,7 +495,7 @@ def doStep(self, *args):
__EXIT_MSG = (1, "Unknown")
try:
try:
(argz, extra) = type(self).parseArgs(*args)
(argz, _) = type(self).parseArgs(*args)
service_cmd = argz.cmd_tool
argz.__dict__.__delitem__("""cmd_tool""")
_TOOL_MSG = (self.useTool(service_cmd, **argz.__dict__))
Expand Down
24 changes: 12 additions & 12 deletions multicast/hear.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"""


__package__ = """multicast"""
__package__ = """multicast""" # skipcq: PYL-W0622
"""Names the package of this program.

Minimal Acceptance Testing:
Expand Down Expand Up @@ -139,7 +139,7 @@
"""Names the file of this component."""


__name__ = """multicast.hear"""
__name__ = """multicast.hear""" # skipcq: PYL-W0622
"""Names this component.

Minimal Acceptance Testing:
Expand All @@ -162,24 +162,24 @@
try:
import sys
if 'multicast' not in sys.modules:
from . import multicast as multicast
from . import multicast as multicast # skipcq: PYL-C0414
else: # pragma: no branch
multicast = sys.modules["""multicast"""]
_BLANK = multicast._BLANK
from . import recv as recv
from . import send as send
from . import recv as recv # skipcq: PYL-C0414
from . import send as send # skipcq: PYL-C0414
except Exception as importErr:
del importErr
import multicast as multicast
import multicast as multicast # skipcq: PYL-C0414


try:
import socketserver
from socketserver import threading as threading
from multicast import argparse as argparse
from multicast import unicodedata as unicodedata
from multicast import socket as socket
from multicast import struct as struct
from socketserver import threading as threading # skipcq: PYL-C0414
from multicast import argparse as argparse # skipcq: PYL-C0414
from multicast import unicodedata as unicodedata # skipcq: PYL-C0414
from multicast import socket as socket # skipcq: PYL-C0414
from multicast import struct as struct # skipcq: PYL-C0414
depends = [
unicodedata, socket, struct, argparse
]
Expand Down Expand Up @@ -382,7 +382,7 @@ def setupArgs(cls, parser):
pass

def doStep(self, *args, **kwargs):
# _is_std = False if "is_std" not in kwargs.keys() else kwargs["is_std"]
# _is_std = False if "is_std" not in kwargs else kwargs["is_std"]
HOST = kwargs.get("group", multicast._MCAST_DEFAULT_GROUP)
PORT = kwargs.get("port", multicast._MCAST_DEFAULT_PORT)
with McastServer((HOST, PORT), HearUDPHandler) as server:
Expand Down
Loading
Loading