Code Duplication    Length = 22-23 lines in 2 locations

gmp/xml.py 2 locations

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