Code Duplication    Length = 32-34 lines in 2 locations

org_fedora_oscap/ks/oscap.py 1 location

@@ 201-234 (lines=34) @@
198
    def _parse_certificates(self, value):
199
        self.certificates = value
200
201
    def handle_line(self, line):
202
        """
203
        The handle_line method that is called with every line from this addon's
204
        %addon section of the kickstart file.
205
206
        :param line: a single line from the %addon section
207
        :type line: str
208
209
        """
210
211
        actions = {"content-type": self._parse_content_type,
212
                   "content-url": self._parse_content_url,
213
                   "content-path": self._parse_content_path,
214
                   "datastream-id": self._parse_datastream_id,
215
                   "profile": self._parse_profile_id,
216
                   "xccdf-id": self._parse_xccdf_id,
217
                   "xccdf-path": self._parse_content_path,
218
                   "cpe-path": self._parse_cpe_path,
219
                   "tailoring-path": self._parse_tailoring_path,
220
                   "fingerprint": self._parse_fingerprint,
221
                   "certificates": self._parse_certificates,
222
                   }
223
224
        line = line.strip()
225
        (pre, sep, post) = line.partition("=")
226
        pre = pre.strip()
227
        post = post.strip()
228
        post = post.strip('"')
229
230
        try:
231
            actions[pre](post)
232
        except KeyError:
233
            msg = "Unknown item '%s' for %s addon" % (line, self.name)
234
            raise KickstartParseError(msg)
235
236
    def finalize(self):
237
        """

org_fedora_oscap/service/kickstart.py 1 location

@@ 74-105 (lines=32) @@
71
        """
72
        pass
73
74
    def handle_line(self, line, line_number=None):
75
        """Handle one line of the section.
76
77
        :param line: a line to parse
78
        :param line_number: a line number
79
        :raise: KickstartParseError for invalid lines
80
        """
81
        actions = {
82
            "content-type": self._parse_content_type,
83
            "content-url": self._parse_content_url,
84
            "content-path": self._parse_content_path,
85
            "datastream-id": self._parse_datastream_id,
86
            "profile": self._parse_profile_id,
87
            "xccdf-id": self._parse_xccdf_id,
88
            "xccdf-path": self._parse_content_path,
89
            "cpe-path": self._parse_cpe_path,
90
            "tailoring-path": self._parse_tailoring_path,
91
            "fingerprint": self._parse_fingerprint,
92
            "certificates": self._parse_certificates,
93
        }
94
95
        line = line.strip()
96
        (pre, sep, post) = line.partition("=")
97
        pre = pre.strip()
98
        post = post.strip()
99
        post = post.strip('"')
100
101
        try:
102
            actions[pre](post)
103
        except KeyError:
104
            msg = "Unknown item '%s' for %s addon" % (line, self.name)
105
            raise KickstartParseError(msg)
106
107
    def _parse_content_type(self, value):
108
        value_low = value.lower()