Code Duplication    Length = 15-21 lines in 2 locations

src/docmanager/action.py 2 locations

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