Code Duplication    Length = 22-23 lines in 2 locations

gmp/xml.py 2 locations

@@ 1274-1296 (lines=23) @@
1271
1272
        return etree.tostring(xmlRoot).decode('utf-8')
1273
1274
    def modify_role_command(self, role_id, kwargs):
1275
        if not role_id:
1276
            raise ValueError('modify_role requires a role_id element')
1277
1278
        xmlRoot = etree.Element('modify_role',
1279
                                role_id=role_id)
1280
1281
        comment = kwargs.get('comment', '')
1282
        if comment:
1283
            _xmlComment = etree.SubElement(xmlRoot, 'comment')
1284
            _xmlComment.text = comment
1285
1286
        name = kwargs.get('name', '')
1287
        if name:
1288
            _xmlName = etree.SubElement(xmlRoot, 'name')
1289
            _xmlName.text = name
1290
1291
        users = kwargs.get('users', '')
1292
        if users:
1293
            _xmlUser = etree.SubElement(xmlRoot, 'users')
1294
            _xmlUser.text = users
1295
1296
        return etree.tostring(xmlRoot).decode('utf-8')
1297
1298
    def modify_scanner_command(self, scanner_id, host, port, scanner_type,
1299
                               kwargs):
@@ 1065-1086 (lines=22) @@
1062
1063
        return etree.tostring(xmlRoot).decode('utf-8')
1064
1065
    def modify_group_command(self, group_id, kwargs):
1066
        if not group_id:
1067
            raise ValueError('modify_group requires a group_id attribute')
1068
1069
        xmlRoot = etree.Element('modify_group', group_id=group_id)
1070
1071
        comment = kwargs.get('comment', '')
1072
        if comment:
1073
            _xmlComment = etree.SubElement(xmlRoot, 'comment')
1074
            _xmlComment.text = comment
1075
1076
        name = kwargs.get('name', '')
1077
        if name:
1078
            _xmlName = etree.SubElement(xmlRoot, 'name')
1079
            _xmlName.text = name
1080
1081
        users = kwargs.get('users', '')
1082
        if users:
1083
            _xmlUser = etree.SubElement(xmlRoot, 'users')
1084
            _xmlUser.text = users
1085
1086
        return etree.tostring(xmlRoot).decode('utf-8')
1087
1088
    def modify_note_command(self, note_id, text, kwargs):
1089
        if not note_id: