From 6f820fa0be879083af7df877c8f725796ccd937e Mon Sep 17 00:00:00 2001 From: mpenning Date: Mon, 11 Dec 2023 15:20:37 -0600 Subject: [PATCH] Fix SonarCloud bugs --- CHANGES.md | 6 ++++++ ciscoconfparse2/ccp_abc.py | 5 ++--- ciscoconfparse2/ciscoconfparse2.py | 11 +++-------- pyproject.toml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4b80f8d..d848fa0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,12 @@ - Summary: - Insert something here +## Version: 0.1.7 + +- Released: 2023-12-11 +- Summary: + - Fix SonarCloud bugs + ## Version: 0.1.6 - Released: 2023-12-11 diff --git a/ciscoconfparse2/ccp_abc.py b/ciscoconfparse2/ccp_abc.py index 21e8556..ea8126b 100644 --- a/ciscoconfparse2/ccp_abc.py +++ b/ciscoconfparse2/ccp_abc.py @@ -453,8 +453,7 @@ def as_diff_dict(self): # # Sometimes brace escaping is not required... we need better fencing # around safe_escape_curly_braces() - if False: - newtext = self.safe_escape_curly_braces(newtext) + newtext = self.safe_escape_curly_braces(newtext) # Remove all double-spacing, except for the indent spaces... self.line_id = self.calculate_line_id() @@ -1356,7 +1355,7 @@ def re_sub(self, regex, replacergx, re_flags=None): self.text = text_after_replace - if text_before_replace != text_after_replace: + if self.confobj and text_before_replace != text_after_replace: # Substitute the modified object back into # the UserList... self.confobj[idx] = self diff --git a/ciscoconfparse2/ciscoconfparse2.py b/ciscoconfparse2/ciscoconfparse2.py index ac48937..961d488 100644 --- a/ciscoconfparse2/ciscoconfparse2.py +++ b/ciscoconfparse2/ciscoconfparse2.py @@ -822,7 +822,6 @@ def __delitem__(self, ii): # This method is on ConfigList() @logger.catch(reraise=True) def __add__(self, other): - raise NotImplementedError() if isinstance(other, ConfigList): return self.__class__(self.data + other._list) elif isinstance(other, type(self.data)): @@ -832,7 +831,6 @@ def __add__(self, other): # This method is on ConfigList() @logger.catch(reraise=True) def __radd__(self, other): - raise NotImplementedError() if isinstance(other, ConfigList): return self.__class__(other.data + self.data) elif isinstance(other, type(self.data)): @@ -842,7 +840,6 @@ def __radd__(self, other): # This method is on ConfigList() @logger.catch(reraise=True) def __iadd__(self, other): - raise NotImplementedError() if isinstance(other, ConfigList): self.data += other.data elif isinstance(other, type(self.data)): @@ -859,7 +856,6 @@ def __iadd__(self, other): # This method is on ConfigList() @logger.catch(reraise=True) def __mul__(self, val): - raise NotImplementedError() return self.__class__(self.data * val) __rmul__ = __mul__ @@ -867,7 +863,6 @@ def __mul__(self, val): # This method is on ConfigList() @logger.catch(reraise=True) def __imul__(self, val): - raise NotImplementedError() self.data *= val return self @@ -1340,13 +1335,13 @@ def insert(self, ii, val): if isinstance(val, str): if self.factory: obj = config_line_factory( - text=val, + line=val, syntax=self.syntax, ) elif self.factory is False: obj = CFGLINE[self.syntax]( - text=val, + line=val, ) else: @@ -3728,7 +3723,7 @@ def decrypt(self, ep=""): return dp -#@logger.catch(reraise=True) +@logger.catch(reraise=True) def config_line_factory(all_lines=None, line=None, comment_delimiters=None, syntax="ios", debug=0): """A factory method to assign a custom BaseCfgLine() subclass based on `all_lines`, `line`, `comment_delimiters`, and `syntax` parameters.""" # Complicted & Buggy diff --git a/pyproject.toml b/pyproject.toml index 60641bb..5452709 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ requires-python = ">=3.8.0" [tool.poetry] name = "ciscoconfparse2" -version = "0.1.6" +version = "0.1.7" description = "Parse, Audit, Query, Build, and Modify Cisco IOS-style and JunOS-style configs" license = "GPL-3.0-only" authors = [