Code Duplication    Length = 15-21 lines in 2 locations

src/docmanager/action.py 2 locations

@@ 306-326 (lines=21) @@
303
                except DMPropertyNotFound:
304
                    print("[{}] Property {} was not found in {}.".format(red(" error "), yellow(prop), f))
305
306
                    # we must substract 1 of "validfiles" since XML files are valid even
307
                    # if they don't have the given property.
308
                    validfiles -= 1
309
                    invalidfiles += 1
310
311
        print_stats(validfiles,invalidfiles)
312
313
314
    def get_attr(self, arguments):
315
        props = self.__args.properties
316
        attrs = self.__args.attributes
317
318
        data = dict(data=OrderedDict(),errors=None)
319
320
        for f in self.__files:
321
            data['data'][f] = self.__xml[f]["handler"].get_attr(props, attrs)
322
323
        return data
324
325
    def get(self, arguments):
326
        """Lists all properties
327
328
        :param list arguments:
329
        :return: [(FILENAME, {PROPERTIES}), ...]
@@ 262-276 (lines=15) @@
259
                    self.__xml[f]["handler"].write()
260
261
                    print("[{}] Set attributes for file {}.".format(green(" ok "), f))
262
                except DMPropertyNotFound:
263
                    print("[{}] Property {} was not found in {}.".format(red(" error "), yellow(prop), f))
264
265
                    # we must substract 1 of "validfiles" since XML files are valid even
266
                    # if they don't have the given property.
267
                    validfiles -= 1
268
                    invalidfiles += 1
269
270
        print_stats(validfiles, invalidfiles)
271
272
273
    def del_attr(self, arguments):
274
        prop = self.__args.property
275
        attrs = self.__args.attributes
276
277
        if not prop:
278
            log.error("You must specify a property with -p!")
279
            sys.exit(ReturnCodes.E_INVALID_ARGUMENTS)