trigger 2.2.3__tar.gz → 2.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. {trigger-2.2.3/trigger.egg-info → trigger-2.2.5}/PKG-INFO +1 -1
  2. {trigger-2.2.3 → trigger-2.2.5}/pyproject.toml +6 -58
  3. {trigger-2.2.3 → trigger-2.2.5}/tests/test_acl.py +4 -9
  4. {trigger-2.2.3 → trigger-2.2.5}/tests/test_acl_queue.py +1 -1
  5. {trigger-2.2.3 → trigger-2.2.5}/tests/test_changemgmt.py +0 -7
  6. {trigger-2.2.3 → trigger-2.2.5}/tests/test_except.py +1 -1
  7. {trigger-2.2.3 → trigger-2.2.5}/tests/test_netdevices.py +0 -5
  8. {trigger-2.2.3 → trigger-2.2.5}/tests/test_scripts.py +0 -5
  9. {trigger-2.2.3 → trigger-2.2.5}/tests/test_tacacsrc.py +26 -7
  10. {trigger-2.2.3 → trigger-2.2.5}/tests/test_templates.py +3 -3
  11. {trigger-2.2.3 → trigger-2.2.5}/tests/test_twister.py +2 -2
  12. {trigger-2.2.3 → trigger-2.2.5}/tests/test_twister2.py +0 -6
  13. {trigger-2.2.3 → trigger-2.2.5}/trigger/__init__.py +2 -0
  14. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/__init__.py +2 -9
  15. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/autoacl.py +3 -9
  16. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/db.py +8 -13
  17. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/dicts.py +2 -8
  18. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/grammar.py +20 -25
  19. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/ios.py +45 -52
  20. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/junos.py +76 -77
  21. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/models.py +1 -1
  22. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/parser.py +41 -40
  23. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/queue.py +2 -9
  24. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/support.py +142 -152
  25. {trigger-2.2.3 → trigger-2.2.5}/trigger/acl/tools.py +58 -61
  26. trigger-2.2.5/trigger/bin/__init__.py +1 -0
  27. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/acl.py +33 -11
  28. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/acl_script.py +8 -12
  29. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/aclconv.py +2 -4
  30. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/check_access.py +4 -6
  31. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/check_syntax.py +3 -5
  32. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/fe.py +5 -8
  33. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/find_access.py +9 -11
  34. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/gnng.py +5 -8
  35. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/gong.py +3 -5
  36. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/load_acl.py +27 -29
  37. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/load_config.py +1 -1
  38. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/netdev.py +5 -6
  39. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/optimizer.py +24 -24
  40. {trigger-2.2.3 → trigger-2.2.5}/trigger/bin/run_cmds.py +1 -1
  41. {trigger-2.2.3 → trigger-2.2.5}/trigger/changemgmt/__init__.py +25 -30
  42. {trigger-2.2.3 → trigger-2.2.5}/trigger/changemgmt/bounce.py +1 -9
  43. {trigger-2.2.3 → trigger-2.2.5}/trigger/cmds.py +40 -46
  44. {trigger-2.2.3 → trigger-2.2.5}/trigger/conf/__init__.py +6 -10
  45. {trigger-2.2.3 → trigger-2.2.5}/trigger/conf/global_settings.py +7 -4
  46. {trigger-2.2.3 → trigger-2.2.5}/trigger/contrib/__init__.py +1 -1
  47. {trigger-2.2.3 → trigger-2.2.5}/trigger/exceptions.py +15 -22
  48. {trigger-2.2.3 → trigger-2.2.5}/trigger/gorc.py +4 -4
  49. {trigger-2.2.3 → trigger-2.2.5}/trigger/netdevices/__init__.py +67 -67
  50. {trigger-2.2.3 → trigger-2.2.5}/trigger/netdevices/loader.py +9 -7
  51. {trigger-2.2.3 → trigger-2.2.5}/trigger/netscreen.py +98 -94
  52. {trigger-2.2.3 → trigger-2.2.5}/trigger/rancid.py +10 -16
  53. {trigger-2.2.3 → trigger-2.2.5}/trigger/tacacsrc.py +35 -38
  54. {trigger-2.2.3 → trigger-2.2.5}/trigger/twister.py +74 -79
  55. {trigger-2.2.3 → trigger-2.2.5}/trigger/twister2.py +38 -38
  56. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/__init__.py +3 -8
  57. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/cli.py +14 -19
  58. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/importlib.py +1 -1
  59. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/network.py +6 -6
  60. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/rcs.py +10 -15
  61. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/templates.py +7 -15
  62. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/url.py +1 -7
  63. {trigger-2.2.3 → trigger-2.2.5}/trigger/utils/xmltodict.py +5 -9
  64. {trigger-2.2.3 → trigger-2.2.5/trigger.egg-info}/PKG-INFO +1 -1
  65. {trigger-2.2.3 → trigger-2.2.5}/twisted/plugins/trigger_xmlrpc.py +0 -2
  66. trigger-2.2.3/trigger/bin/__init__.py +0 -0
  67. {trigger-2.2.3 → trigger-2.2.5}/AUTHORS.md +0 -0
  68. {trigger-2.2.3 → trigger-2.2.5}/LICENSE.md +0 -0
  69. {trigger-2.2.3 → trigger-2.2.5}/README.md +0 -0
  70. {trigger-2.2.3 → trigger-2.2.5}/setup.cfg +0 -0
  71. {trigger-2.2.3 → trigger-2.2.5}/tests/test_acl_db.py +0 -0
  72. {trigger-2.2.3 → trigger-2.2.5}/tests/test_utils.py +0 -0
  73. {trigger-2.2.3 → trigger-2.2.5}/trigger/packages/__init__.py +0 -0
  74. {trigger-2.2.3 → trigger-2.2.5}/trigger/packages/peewee.py +0 -0
  75. {trigger-2.2.3 → trigger-2.2.5}/trigger.egg-info/SOURCES.txt +0 -0
  76. {trigger-2.2.3 → trigger-2.2.5}/trigger.egg-info/dependency_links.txt +0 -0
  77. {trigger-2.2.3 → trigger-2.2.5}/trigger.egg-info/entry_points.txt +0 -0
  78. {trigger-2.2.3 → trigger-2.2.5}/trigger.egg-info/requires.txt +0 -0
  79. {trigger-2.2.3 → trigger-2.2.5}/trigger.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trigger
3
- Version: 2.2.3
3
+ Version: 2.2.5
4
4
  Summary: Network automation toolkit for managing network devices
5
5
  Author-email: Jathan McCollum <jathan@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "trigger"
7
- version = "2.2.3"
7
+ version = "2.2.5"
8
8
  description = "Network automation toolkit for managing network devices"
9
9
  readme = "README.md"
10
10
  license = "BSD-3-Clause"
@@ -110,69 +110,15 @@ select = [
110
110
  "UP", # pyupgrade - Python 3 modernization
111
111
  "W", # pycodestyle warnings
112
112
  ]
113
+ extend-select = [
114
+ "D401", # non-imperative-mood (not in google convention, enabled explicitly)
115
+ ]
113
116
  ignore = [
114
117
  # --- Formatter conflicts ---
115
118
  "COM812", # trailing-comma-missing (handled by ruff formatter)
116
119
 
117
120
  # --- Kept from v2.0.0 baseline ---
118
- "E402", # module-import-not-at-top-of-file
119
121
  "E501", # line-too-long (handled by formatter)
120
- "E721", # type-comparison (existing code style)
121
- "E722", # bare-except (intentional in many places)
122
- "E741", # ambiguous-variable-name (existing code style)
123
- "F401", # unused-import (may be used dynamically)
124
- "F402", # import-shadowed-by-loop-var
125
- "F403", # undefined-local-with-import-star
126
- "F405", # undefined-local-with-import-star-usage
127
- "F523", # string-dot-format-extra-positional-arguments
128
- "F811", # redefined-while-unused
129
- "F821", # undefined-name
130
- "UP031", # printf-string-formatting
131
-
132
- # --- Bugbear exceptions ---
133
- "B016", # raise-literal (used intentionally in tests)
134
- "B018", # useless-expression (test assertions)
135
-
136
- # --- Pre-commit specific ignores ---
137
- "PLW1641", # __hash__ implementation (false positive, requires __eq__ impl)
138
- "PT028", # pytest parameter defaults (false positive, not pytest functions)
139
-
140
- # --- Docstring exceptions (not enforcing coverage/style) ---
141
- "D100", # undocumented-public-module
142
- "D101", # undocumented-public-class
143
- "D102", # undocumented-public-method
144
- "D103", # undocumented-public-function
145
- "D104", # undocumented-public-package
146
- "D105", # undocumented-magic-method
147
- "D107", # undocumented-public-init
148
- "D200", # unnecessary-multiline-docstring
149
- "D205", # missing-blank-line-after-summary
150
- "D401", # non-imperative-mood
151
- "D402", # signature-in-docstring
152
- "D404", # docstring-starts-with-this
153
-
154
- # --- Complexity (deep refactoring territory) ---
155
- "PLR0911", # too-many-return-statements
156
- "PLR0912", # too-many-branches
157
- "PLR0913", # too-many-arguments
158
- "PLR0915", # too-many-statements
159
- "PLR2004", # magic-value-comparison
160
- "PLW0603", # global-statement (parser pattern)
161
-
162
- # --- Security false positives for network toolkit ---
163
- "S101", # assert (used in tests)
164
- "S105", # hardcoded-password-string (false positives)
165
- "S110", # try-except-pass
166
- "S112", # try-except-continue
167
- "S314", # suspicious-xml-element-tree-usage
168
- "S603", # subprocess-without-shell-equals-true
169
- "S605", # start-process-with-a-shell (fix manually)
170
- "S606", # start-process-with-no-shell
171
- "S608", # hardcoded-sql-expression
172
-
173
- # --- Other ---
174
- "RUF012", # mutable-class-default (too many in device metadata)
175
- "SLF001", # private-member-access (common in Twisted patterns)
176
122
  ]
177
123
 
178
124
  [tool.ruff.lint.pydocstyle]
@@ -237,6 +183,8 @@ minor_tags = ["feat"]
237
183
  patch_tags = ["fix", "perf"]
238
184
 
239
185
  [tool.semantic_release.changelog]
186
+
187
+ [tool.semantic_release.changelog.default_templates]
240
188
  changelog_file = "CHANGELOG.md"
241
189
 
242
190
  [tool.semantic_release.branches.main]
@@ -1,10 +1,5 @@
1
1
  #!/usr/bin/python
2
2
 
3
- __author__ = "Jathan McCollum, Michael Shields"
4
- __maintainer__ = "Jathan McCollum"
5
- __copyright__ = "Copyright 2005-2011 AOL Inc.; 2013 Salesforce.com"
6
- __version__ = "2.0"
7
-
8
3
  import contextlib
9
4
  import unittest
10
5
  from io import StringIO
@@ -72,7 +67,7 @@ class CheckRangeList(unittest.TestCase):
72
67
  """Check RangeList behavior as a container type."""
73
68
  r = acl.RangeList([1, (3, 6)])
74
69
  self.assertTrue(1 in r)
75
- self.assertTrue(5 in r)
70
+ self.assertTrue(5 in r) # noqa: PLR2004
76
71
  self.assertTrue(0 not in r)
77
72
  r = acl.RangeList([acl.TIP("10/8"), acl.TIP("172.16/12")])
78
73
  self.assertTrue(acl.TIP("10.1.1.1") in r)
@@ -695,7 +690,7 @@ class CheckMiscIOS(unittest.TestCase):
695
690
  # Python 3: map() returns an iterator, convert to list for comparison
696
691
  self.assertEqual(
697
692
  t.output_ios(),
698
- list(map(lambda x: "permit icmp any any %d" % x, types)),
693
+ list(map(lambda x: "permit icmp any any %d" % x, types)), # noqa: UP031
699
694
  )
700
695
 
701
696
  def testCounterSuppression(self):
@@ -748,8 +743,8 @@ class CheckTriggerIP(unittest.TestCase):
748
743
  # Until we fix inactive testing, this is legit
749
744
  self.assertTrue(obj in self.test_net)
750
745
 
751
- def testInactive(self):
752
- """Test an inactive IP object"""
746
+ def testInactiveAndNegated(self):
747
+ """Test an inactive and negated IP object"""
753
748
  test = "inactive: 1.2.3.4/32 except"
754
749
  obj = acl.TIP(test)
755
750
  self.assertEqual(str(obj), test)
@@ -6,7 +6,7 @@ Test the functionality of `~trigger.acl.queue` (aka task queue)
6
6
  Only tests SQLite for now.
7
7
  """
8
8
 
9
- import os
9
+ import os # noqa: F401
10
10
  import tempfile
11
11
  from pathlib import Path
12
12
 
@@ -4,13 +4,6 @@
4
4
  Tests for bounce windows and the stuff that goes with them.
5
5
  """
6
6
 
7
- __author__ = "Jathan McCollum, Michael Shields"
8
- __maintainer__ = "Jathan McCollum"
9
- __email__ = "jmccollum@salesforce.com"
10
- __copyright__ = "Copyright 2013 Salesforce.com"
11
- __version__ = "2.0"
12
-
13
-
14
7
  # Make sure we load the mock redis library
15
8
  from utils import mock_redis
16
9
 
@@ -1,5 +1,5 @@
1
1
  # a test for except processing
2
- import os
2
+ import os # noqa: F401
3
3
  import sys
4
4
  from pathlib import Path
5
5
 
@@ -7,11 +7,6 @@ This uses the mockups of netdevices.xml, acls.db, and autoacls.py in
7
7
  tests/data.
8
8
  """
9
9
 
10
- __author__ = "Jathan McCollum, Michael Shields"
11
- __maintainer__ = "Jathan McCollum"
12
- __copyright__ = "Copyright 2005-2011 AOL Inc.; 2013 Salesforce.com"
13
- __version__ = "2.0"
14
-
15
10
  import unittest
16
11
 
17
12
  # Make sure we load the mock redis library
@@ -2,11 +2,6 @@
2
2
 
3
3
  # tests/scripts.py
4
4
 
5
- __author__ = "Michael Shields"
6
- __maintainer__ = "Jathan McCollum"
7
- __copyright__ = "Copyright 2005-2011 AOL Inc."
8
- __version__ = "1.1"
9
-
10
5
  import os
11
6
  import subprocess
12
7
  import unittest
@@ -1,11 +1,5 @@
1
1
  #!/usr/bin/env python
2
2
 
3
- __author__ = "Jathan McCollum, Michael Shields"
4
- __maintainer__ = "Jathan McCollum"
5
- __copyright__ = "Copyright 2005-2011 AOL Inc.; 2013 Salesforce.com"
6
- __version__ = "2.0.1"
7
-
8
-
9
3
  import os
10
4
  import tempfile
11
5
  import unittest
@@ -13,7 +7,7 @@ from pathlib import Path
13
7
  from unittest.mock import patch
14
8
 
15
9
  from trigger.conf import settings
16
- from trigger.tacacsrc import Credentials, Tacacsrc
10
+ from trigger.tacacsrc import Credentials, Tacacsrc, convert_tacacsrc
17
11
 
18
12
  # Constants
19
13
  aol = Credentials("jschmoe", "abc123", "aol")
@@ -147,6 +141,31 @@ class TacacsrcTest(unittest.TestCase):
147
141
  new_perms = self._get_perms(fname)
148
142
  self.assertNotEqual(new_perms, RIGHT_PERMS)
149
143
 
144
+ def test_convert_tacacsrc(self):
145
+ """Test that convert_tacacsrc reads old creds and writes via GPG."""
146
+ captured = {}
147
+
148
+ def spy_encrypt_and_write(self):
149
+ captured["creds"] = dict(self.creds)
150
+ captured["use_gpg"] = self.use_gpg
151
+ captured["file_name"] = self.file_name
152
+
153
+ with (
154
+ patch("trigger.tacacsrc.Tacacsrc", MockTacacsrc),
155
+ patch.object(MockTacacsrc, "_encrypt_and_write", spy_encrypt_and_write),
156
+ patch.object(MockTacacsrc, "_update_perms"),
157
+ ):
158
+ convert_tacacsrc()
159
+
160
+ # GPG write path should have been reached
161
+ self.assertIn("creds", captured)
162
+ # All original credentials should be preserved
163
+ for name, value in ALL_CREDS:
164
+ self.assertEqual(captured["creds"][name], value)
165
+ # Should be in GPG mode targeting the .gpg file
166
+ self.assertTrue(captured["use_gpg"])
167
+ self.assertEqual(captured["file_name"], settings.TACACSRC + ".gpg")
168
+
150
169
 
151
170
  if __name__ == "__main__":
152
171
  unittest.main()
@@ -3,7 +3,7 @@ from io import StringIO
3
3
 
4
4
  from trigger.cmds import Commando
5
5
  from trigger.netdevices import NetDevices
6
- from trigger.utils.templates import *
6
+ from trigger.utils.templates import * # noqa: F403
7
7
 
8
8
  # Constants
9
9
  DEVICE_NAME = "test1-abc.net.aol.com"
@@ -112,12 +112,12 @@ class CheckTemplates(unittest.TestCase):
112
112
 
113
113
  def testTemplatePath(self):
114
114
  """Test that template path is correct."""
115
- t_path = get_template_path("show clock", dev_type="cisco_ios")
115
+ t_path = get_template_path("show clock", dev_type="cisco_ios") # noqa: F405
116
116
  self.assertTrue("vendor/ntc_templates/cisco_ios_show_clock.template" in t_path)
117
117
 
118
118
  def testGetTextFsmObject(self):
119
119
  """Test that we get structured data back from cli output."""
120
- data = get_textfsm_object(self.re_table, cli_data)
120
+ data = get_textfsm_object(self.re_table, cli_data) # noqa: F405
121
121
  self.assertTrue(isinstance(data, dict))
122
122
  keys = ["dayweek", "time", "timezone", "year", "day", "month"]
123
123
  # Python 3: dict.has_key() removed, use 'in' operator
@@ -160,7 +160,7 @@ class TestPromptMatchStart:
160
160
  m = pat.search(buffer)
161
161
  assert m is not None
162
162
  # The \n is at index 6, prompt starts at index 7
163
- assert prompt_match_start(m) == 7
163
+ assert prompt_match_start(m) == 7 # noqa: PLR2004
164
164
 
165
165
  def test_match_after_crlf(self):
166
166
  """Match after \\r\\n skips both characters."""
@@ -169,7 +169,7 @@ class TestPromptMatchStart:
169
169
  m = pat.search(buffer)
170
170
  assert m is not None
171
171
  # \r at 6, \n at 7, prompt starts at 8
172
- assert prompt_match_start(m) == 8
172
+ assert prompt_match_start(m) == 8 # noqa: PLR2004
173
173
 
174
174
 
175
175
  # =============================================================================
@@ -7,10 +7,4 @@ This uses the mockups of netdevices.xml in
7
7
  tests/data.
8
8
  """
9
9
 
10
- __author__ = "Thomas Cuthbert, Jathan McCollum"
11
- __maintainer__ = "Jathan McCollum"
12
- __copyright__ = "Copyright 2005-2011 AOL Inc.; 2013 Salesforce.com.; 2016 Dropbox"
13
- __version__ = "1.0"
14
-
15
-
16
10
  # TODO: see http://twistedmatrix.com/trac/wiki/TwistedTrial
@@ -1,3 +1,5 @@
1
+ """Trigger: Network automation toolkit for managing network devices."""
2
+
1
3
  from importlib.metadata import PackageNotFoundError, version
2
4
 
3
5
  try:
@@ -6,13 +6,6 @@ ACL and return an ACL object that can be easily translated to any supported
6
6
  vendor syntax.
7
7
  """
8
8
 
9
- __author__ = "Jathan McCollum"
10
- __author__ = "Jathan McCollum, Mike Biancaniello, Mike Harding"
11
- __maintainer__ = "Jathan McCollum"
12
- __email__ = "jathanism@aol.com"
13
- __copyright__ = "Copyright 2010-2012, AOL Inc."
14
- __version__ = (0, 1)
15
-
16
9
  import os
17
10
 
18
11
  from trigger.conf import settings
@@ -21,11 +14,11 @@ __all__ = ["acl_exists", "parser"]
21
14
 
22
15
  # Parser
23
16
  from . import parser
24
- from .parser import *
17
+ from .parser import * # noqa: F403
25
18
 
26
19
  __all__.extend(parser.__all__)
27
20
 
28
21
 
29
22
  # Functions
30
- def acl_exists(name):
23
+ def acl_exists(name): # noqa: D103
31
24
  return os.access(settings.FIREWALL_DIR + "/acl." + name, os.R_OK)
@@ -1,4 +1,4 @@
1
- """This module controls when ACLs get auto-applied to network devices,
1
+ """Controls when ACLs get auto-applied to network devices,
2
2
  in addition to what is specified in acls.db.
3
3
 
4
4
  This is primarily used by :class:`~trigger.acl.db.AclsDB` to populate the
@@ -14,12 +14,7 @@ devices out of the Trigger packaging.
14
14
 
15
15
  If you do not specify a location for ``AUTOACL_FILE`` or the module cannot be
16
16
  loaded, then a default :func:`autoacl()` function ill be used.
17
- """
18
-
19
- __author__ = "Jathan McCollum, Eileen Tschetter"
20
- __maintainer__ = "Jathan McCollum"
21
- __email__ = "jathan.mccollum@teamaol.com"
22
- __copyright__ = "Copyright 2010-2012, AOL Inc."
17
+ """ # noqa: D205
23
18
 
24
19
  import warnings
25
20
 
@@ -32,7 +27,6 @@ __all__ = ("autoacl",)
32
27
 
33
28
  module_path = settings.AUTOACL_FILE
34
29
 
35
-
36
30
  # In either case we're exporting a single name: autoacl().
37
31
  try:
38
32
  # Placeholder for the custom autoacl module that will provide the autoacl()
@@ -64,5 +58,5 @@ except ImportError:
64
58
 
65
59
  NOTE: If the default function is returned it does nothing with the
66
60
  arguments and always returns an empty set.
67
- """
61
+ """ # noqa: D205
68
62
  return set()
@@ -16,12 +16,7 @@ set(['juniper-router.policer', 'juniper-router-protect'])
16
16
  {'all': set(['abc123', 'juniper-router-protect', 'juniper-router.policer']),
17
17
  'explicit': set(['abc123']),
18
18
  'implicit': set(['juniper-router-protect', 'juniper-router.policer'])}
19
- """
20
-
21
- __author__ = "Jathan McCollum"
22
- __maintainer__ = "Jathan McCollum"
23
- __email__ = "jathan@gmail.com"
24
- __copyright__ = "Copyright 2010-2012, AOL Inc.; 2013 Salesforce.com"
19
+ """ # noqa: D205
25
20
 
26
21
  from collections import defaultdict
27
22
  from pathlib import Path
@@ -63,7 +58,7 @@ class AclsDB:
63
58
  add/remove operations are for explicit associations only.
64
59
  """
65
60
 
66
- def __init__(self):
61
+ def __init__(self): # noqa: D107
67
62
  self.redis = r
68
63
  log.msg("ACLs database client initialized")
69
64
 
@@ -111,7 +106,7 @@ class AclsDB:
111
106
  'testgreenj', 'testops_blockmj']),
112
107
  'explicit': set(['test-bluej', 'testgreenj', 'testops_blockmj']),
113
108
  'implicit': set(['115j', 'protectRE', 'protectRE.policer'])}
114
- """
109
+ """ # noqa: D401, D205
115
110
  acls = {}
116
111
 
117
112
  # Explicit (we want to make sure the key exists before we try to assign
@@ -142,7 +137,7 @@ class AclsDB:
142
137
  set(['testops_blockmj', 'test-bluej', 'testgreenj'])
143
138
  >>> a.get_acl_set(dev, 'implicit')
144
139
  set(['protectRE', 'protectRE.policer', '115j'])
145
- """
140
+ """ # noqa: D205
146
141
  acls_dict = self.get_acl_dict(device)
147
142
  ACL_SETS = acls_dict.keys()
148
143
  if DEBUG:
@@ -180,7 +175,7 @@ def populate_explicit_acls(aclsdb_file):
180
175
 
181
176
 
182
177
  def backup_explicit_acls():
183
- """Dumps acls:explicit:* to csv."""
178
+ """Dumps acls:explicit:* to csv.""" # noqa: D401
184
179
  import csv
185
180
 
186
181
  out = csv.writer(Path(ACLSDB_BACKUP).open("w")) # noqa: SIM115
@@ -212,7 +207,7 @@ def get_all_acls(nd=None):
212
207
  >>> all_acls = get_all_acls()
213
208
  >>> all_acls['abc123']
214
209
  set([<NetDevice: test1-abc.net.aol.com>, <NetDevice: fw1-xyz.net.aol.com>])
215
- """
210
+ """ # noqa: D401, D205
216
211
  nd = nd or get_netdevices()
217
212
  all_acls = defaultdict(set)
218
213
  for device in nd.all():
@@ -224,7 +219,7 @@ def get_all_acls(nd=None):
224
219
  def get_bulk_acls(nd=None):
225
220
  """Returns a set of acls with an applied count over
226
221
  settings.AUTOLOAD_BULK_THRESH.
227
- """
222
+ """ # noqa: D401, D205
228
223
  nd = nd or get_netdevices()
229
224
  all_acls = get_all_acls()
230
225
  return set(
@@ -269,7 +264,7 @@ def get_matching_acls(wanted, exact=True, match_acl=True, match_device=False, nd
269
264
  >>> adb.get_matching_acls(['test1-abc'], match_device=True, exact=False)
270
265
  [('test1-abc.net.aol.com', ['abc123', 'juniper-router-protect',
271
266
  'juniper-router.policer'])]
272
- """
267
+ """ # noqa: D205
273
268
  found = []
274
269
  wanted_set = set(wanted)
275
270
 
@@ -1,4 +1,4 @@
1
- """This code is originally from parser.py. It contains all the simple data definitions in
1
+ """Originally from parser.py. Contains all the simple data definitions in
2
2
  form of dictionaries and lists and such. This file is not meant to by used by itself.
3
3
  Imported into support.py.
4
4
 
@@ -21,13 +21,7 @@ Variables defined:
21
21
  tcp_flag_names
22
22
  tcp_flag_specials
23
23
  tcp_flag_rev
24
- """
25
-
26
- __author__ = "Jathan McCollum, Mike Biancaniello, Michael Harding, Michael Shields"
27
- __editor__ = "Joseph Malone"
28
- __maintainer__ = "Jathan McCollum"
29
- __email__ = "jathanism@aol.com"
30
- __copyright__ = "Copyright 2006-2013, AOL Inc.; 2013 Saleforce.com"
24
+ """ # noqa: D205
31
25
 
32
26
  adrsbk = {"svc": {"group": {}, "book": {}}, "addr": {"group": {}, "book": {}}}
33
27
 
@@ -1,4 +1,4 @@
1
- """This code is originally from parser.py. This is the basic grammar and rules
1
+ """Originally from parser.py. Provides the basic grammar and rules
2
2
  from which the other specific grammars are built. This file is not meant to by used by itself.
3
3
  Imported into the specific grammar files.
4
4
 
@@ -10,15 +10,9 @@ Imported into the specific grammar files.
10
10
  literals
11
11
  update
12
12
  dict_sum
13
- """
13
+ """ # noqa: D205
14
14
 
15
- __author__ = "Jathan McCollum, Mike Biancaniello, Michael Harding, Michael Shields"
16
- __editor__ = "Joseph Malone"
17
- __maintainer__ = "Jathan McCollum"
18
- __email__ = "jathanism@aol.com"
19
- __copyright__ = "Copyright 2006-2013, AOL Inc.; 2013 Saleforce.com"
20
-
21
- from .support import *
15
+ from .support import * # noqa: F403
22
16
 
23
17
  # Each production can be any of:
24
18
  # 1. string
@@ -37,7 +31,7 @@ def S(prod):
37
31
  performing modifiers.
38
32
 
39
33
  :param prod: The parser product.
40
- """
34
+ """ # noqa: D205
41
35
  subtagged.add(prod)
42
36
  return prod
43
37
 
@@ -46,22 +40,23 @@ def literals(d):
46
40
  """Longest match of all the strings that are keys of 'd'."""
47
41
  keys = [str(key) for key in d]
48
42
  keys.sort(key=lambda x: -len(x)) # Sort by length descending
49
- return " / ".join(['"%s"' % key for key in keys])
43
+ return " / ".join([f'"{key}"' for key in keys])
50
44
 
51
45
 
52
- def update(d, **kwargs):
46
+ def update(d, **kwargs): # noqa: D103
53
47
  # Check for duplicate subterms, which is legal but too confusing to be
54
48
  # allowed at AOL. For example, a Juniper term can have two different
55
49
  # 'destination-address' clauses, which means that the first will be
56
50
  # ignored. This led to an outage on 2006-10-11.
57
51
  for key in kwargs:
58
52
  if key in d:
59
- raise exceptions.ParseError("duplicate %s" % key)
53
+ msg = f"duplicate {key}"
54
+ raise exceptions.ParseError(msg) # noqa: F405
60
55
  d.update(kwargs)
61
56
  return d
62
57
 
63
58
 
64
- def dict_sum(dlist):
59
+ def dict_sum(dlist): # noqa: D103
65
60
  dsum = {}
66
61
  for d in dlist:
67
62
  for k, v in d.items():
@@ -91,20 +86,20 @@ rules = {
91
86
  "anychar": "[ a-zA-Z0-9.$:()&,/'_-]",
92
87
  "hex": "[0-9a-fA-F]+",
93
88
  "ipchars": "[0-9a-fA-F:.]+",
94
- "ipv4": ('digits, (".", digits)*', TIP),
95
- "ipaddr": ("ipchars", TIP),
89
+ "ipv4": ('digits, (".", digits)*', TIP), # noqa: F405
90
+ "ipaddr": ("ipchars", TIP), # noqa: F405
96
91
  "cidr": (
97
92
  '("inactive:", ws+)?, (ipaddr / ipv4), "/", digits, (ws+, "except")?',
98
- TIP,
93
+ TIP, # noqa: F405
99
94
  ),
100
95
  "macaddr": 'hex, (":", hex)+',
101
- "protocol": (literals(Protocol.name2num) + " / digits", do_protocol_lookup),
102
- "tcp": ('"tcp" / "6"', Protocol("tcp")),
103
- "udp": ('"udp" / "17"', Protocol("udp")),
104
- "icmp": ('"icmp" / "1"', Protocol("icmp")),
105
- "icmp_type": (literals(icmp_types) + " / digits", do_icmp_type_lookup),
106
- "icmp_code": (literals(icmp_codes) + " / digits", do_icmp_code_lookup),
107
- "port": (literals(ports) + " / digits", do_port_lookup),
108
- "dscp": (literals(dscp_names) + " / digits", do_dscp_lookup),
96
+ "protocol": (literals(Protocol.name2num) + " / digits", do_protocol_lookup), # noqa: F405
97
+ "tcp": ('"tcp" / "6"', Protocol("tcp")), # noqa: F405
98
+ "udp": ('"udp" / "17"', Protocol("udp")), # noqa: F405
99
+ "icmp": ('"icmp" / "1"', Protocol("icmp")), # noqa: F405
100
+ "icmp_type": (literals(icmp_types) + " / digits", do_icmp_type_lookup), # noqa: F405
101
+ "icmp_code": (literals(icmp_codes) + " / digits", do_icmp_code_lookup), # noqa: F405
102
+ "port": (literals(ports) + " / digits", do_port_lookup), # noqa: F405
103
+ "dscp": (literals(dscp_names) + " / digits", do_dscp_lookup), # noqa: F405
109
104
  "root": "ws?, junos_raw_acl / junos_replace_family_acl / junos_replace_acl / junos_replace_policers / ios_acl, ws?",
110
105
  }