Code Duplication    Length = 22-23 lines in 2 locations

gmp/xml.py 2 locations

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