Code Duplication    Length = 41-42 lines in 2 locations

org_fedora_oscap/service/kickstart.py 1 location

@@ 204-245 (lines=42) @@
201
202
            self.content_path = common.SSG_DIR + common.SSG_CONTENT
203
204
    def __str__(self):
205
        """Generate the kickstart representation.
206
207
        What should end up in the resulting kickstart file,
208
        i.e. string representation of the stored data.
209
210
        :return: a string
211
        """
212
        if not self.profile_id:
213
            return ""
214
215
        ret = "%%addon %s" % self.name
216
        ret += "\n%s" % key_value_pair("content-type", self.content_type)
217
218
        if self.content_url:
219
            ret += "\n%s" % key_value_pair("content-url", self.content_url)
220
221
        if self.datastream_id:
222
            ret += "\n%s" % key_value_pair("datastream-id", self.datastream_id)
223
224
        if self.xccdf_id:
225
            ret += "\n%s" % key_value_pair("xccdf-id", self.xccdf_id)
226
227
        if self.content_path and self.content_type != "scap-security-guide":
228
            ret += "\n%s" % key_value_pair("content-path", self.content_path)
229
230
        if self.cpe_path:
231
            ret += "\n%s" % key_value_pair("cpe-path", self.cpe_path)
232
233
        if self.tailoring_path:
234
            ret += "\n%s" % key_value_pair("tailoring-path", self.tailoring_path)
235
236
        ret += "\n%s" % key_value_pair("profile", self.profile_id)
237
238
        if self.fingerprint:
239
            ret += "\n%s" % key_value_pair("fingerprint", self.fingerprint)
240
241
        if self.certificates:
242
            ret += "\n%s" % key_value_pair("certificates", self.certificates)
243
244
        ret += "\n%end\n\n"
245
        return ret
246
247
248
class OSCAPKickstartSpecification(KickstartSpecification):

org_fedora_oscap/ks/oscap.py 1 location

@@ 104-144 (lines=41) @@
101
        self.rule_data = rule_handling.RuleData()
102
        self.dry_run = False
103
104
    def __str__(self):
105
        """
106
        What should end up in the resulting kickstart file, i.e. string
107
        representation of the stored data.
108
109
        """
110
111
        if self.dry_run or not self.profile_id:
112
            # the addon was run in the dry run mode, omit it from the kickstart
113
            return ""
114
115
        def key_value_pair(key, value, indent=4):
116
            return "%s%s = %s" % (indent * " ", key, value)
117
118
        ret = "%%addon %s" % self.name
119
        ret += "\n%s" % key_value_pair("content-type", self.content_type)
120
121
        if self.content_url:
122
            ret += "\n%s" % key_value_pair("content-url", self.content_url)
123
        if self.datastream_id:
124
            ret += "\n%s" % key_value_pair("datastream-id", self.datastream_id)
125
        if self.xccdf_id:
126
            ret += "\n%s" % key_value_pair("xccdf-id", self.xccdf_id)
127
        if self.content_path and self.content_type != "scap-security-guide":
128
            ret += "\n%s" % key_value_pair("content-path", self.content_path)
129
        if self.cpe_path:
130
            ret += "\n%s" % key_value_pair("cpe-path", self.cpe_path)
131
        if self.tailoring_path:
132
            ret += "\n%s" % key_value_pair("tailoring-path",
133
                                           self.tailoring_path)
134
135
        ret += "\n%s" % key_value_pair("profile", self.profile_id)
136
137
        if self.fingerprint:
138
            ret += "\n%s" % key_value_pair("fingerprint", self.fingerprint)
139
140
        if self.certificates:
141
            ret += "\n%s" % key_value_pair("certificates", self.certificates)
142
143
        ret += "\n%end\n\n"
144
        return ret
145
146
    def _parse_content_type(self, value):
147
        value_low = value.lower()