aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/parsers.rst1
-rw-r--r--sos/cleaner/parsers/__init__.py51
2 files changed, 38 insertions, 14 deletions
diff --git a/docs/parsers.rst b/docs/parsers.rst
index 4d8e2656..7b15ca25 100644
--- a/docs/parsers.rst
+++ b/docs/parsers.rst
@@ -4,5 +4,4 @@
.. automodule:: sos.cleaner.parsers
:noindex:
:members:
- :undoc-members:
:show-inheritance:
diff --git a/sos/cleaner/parsers/__init__.py b/sos/cleaner/parsers/__init__.py
index 248e353c..dd0451df 100644
--- a/sos/cleaner/parsers/__init__.py
+++ b/sos/cleaner/parsers/__init__.py
@@ -21,18 +21,28 @@ class SoSCleanerParser():
Ideally a new parser subclass will only need to set the class level attrs
in order to be fully functional.
- :attr name str: The parser name, used in logging errors
-
- :attr regex_patterns list: A list of regex patterns to iterate
- over for every line processed
- :attr mapping SoSMap: A SoSMap used by the parser to store
- and obfuscate pattern matches
- :attr map_file_key str: The key in the map_file to read when
- loading previous obfuscation matches
- :attr prep_map_file str: Filename to attempt to read from an
- archive to pre-seed the map with
- matches. E.G. ip_addr for loading IP
- addresses into the SoSIPMap.
+ :param conf_file: The configuration file to read from
+ :type conf_file: ``str``
+
+ :cvar name: The parser name, used in logging errors
+ :vartype name: ``str``
+
+ :cvar regex_patterns: A list of regex patterns to iterate over for every
+ line processed
+ :vartype regex_patterns: ``list``
+
+ :cvar mapping: Used by the parser to store and obfuscate matches
+ :vartype mapping: ``SoSMap()``
+
+
+ :cvar map_file_key: The key in the ``map_file`` to read when loading
+ previous obfuscation matches
+ :vartype map_file_key: ``str``
+
+
+ :cvar prep_map_file: File to read from an archive to pre-seed the map with
+ matches. E.G. ip_addr for loading IP addresses
+ :vartype prep_map_fie: ``str``
"""
name = 'Undefined Parser'
@@ -58,6 +68,12 @@ class SoSCleanerParser():
def parse_line(self, line):
"""This will be called for every line in every file we process, so that
every parser has a chance to scrub everything.
+
+ :param line: The line to parse for possible matches for obfuscation
+ :type line: ``str``
+
+ :returns: The obfsucated line, and the number of changes made
+ :rtype: ``tuple``, ``(str, int))``
"""
count = 0
for skip_pattern in self.skip_line_patterns:
@@ -79,6 +95,12 @@ class SoSCleanerParser():
Rather than try to regex match the string_data, just use the builtin
checks for substrings matching known obfuscated keys
+
+ :param string_data: The line to be parsed
+ :type string_data: ``str``
+
+ :returns: The obfuscated line
+ :rtype: ``str``
"""
for key, val in self.mapping.dataset.items():
if key in string_data:
@@ -86,6 +108,9 @@ class SoSCleanerParser():
return string_data
def get_map_contents(self):
- """Return the contents of the mapping used by the parser
+ """Get the contents of the mapping used by the parser
+
+ :returns: All matches and their obfuscate counterparts
+ :rtype: ``dict``
"""
return self.mapping.dataset