Code Duplication    Length = 36-38 lines in 2 locations

doorstop/cli/commands.py 2 locations

@@ 524-561 (lines=38) @@
521
    return True
522
523
                                                                           # add 28.11.2019 /11.12.2019 added findRef
524
def run_valMatrix(args, cwd, error, catch=True):
525
    """
526
    Process arguments and run the `doorstop valMatrix` subcommand added by Peter Bauer.
527
528
    :param args: Namespace of CLI arguments
529
    :param cwd: current working directory
530
    :param error: function to call for CLI errors
531
    :param catch: catch and log :class:`~doorstop.common.DoorstopError`
532
            
533
    """
534
    
535
    # Get document or tree
536
    with utilities.capture(catch=catch) as success:
537
538
        
539
        tree = _get_tree(args, cwd, load='all')
540
        if not args.prefix == 'all':
541
             document = tree.find_document(args.prefix)
542
543
    if not success:
544
        return False
545
546
547
    if args.path:
548
        if args.prefix == 'all':
549
            msg = "publishing tree to '{}'...".format(args.path)
550
            utilities.show(msg, flush=True)
551
            valMatrix.publish_Matrix(tree, args.path)
552
        else:
553
            msg = "publishing document to '{}'...".format(args.path)
554
            utilities.show(msg, flush=True)
555
            valMatrix.publish_Matrix(document, args.path)
556
557
    else:
558
        
559
        error('There must be a tree or documetn like object given to the command!')
560
561
    return True
562
563
564
@@ 566-601 (lines=36) @@
563
564
565
566
def run_verMatrix(args, cwd, error, catch=True):
567
    """
568
    Process arguments and run the `doorstop verMatrix` subcommand added by Peter Bauer.
569
570
    :param args: Namespace of CLI arguments
571
    :param cwd: current working directory
572
    :param error: function to call for CLI errors
573
    :param catch: catch and log :class:`~doorstop.common.DoorstopError`
574
            
575
    """
576
  
577
    # Get document or tree
578
    with utilities.capture(catch=catch) as success:
579
580
       
581
        tree = _get_tree(args, cwd, load='all')
582
        if not args.prefix == 'all':
583
             document = tree.find_document(args.prefix)
584
585
    if not success:
586
        return False
587
588
    if args.path:
589
        if args.prefix == 'all':
590
            msg = "publishing tree to '{}'...".format(args.path)
591
            utilities.show(msg, flush=True)
592
            verMatrix.publish_Matrix(tree, args.path)
593
        else:
594
            msg = "publishing document to '{}'...".format(args.path)
595
            utilities.show(msg, flush=True)
596
            verMatrix.publish_Matrix(document, args.path)
597
598
    else:  
599
        error('There must be a tree or documetn like object given to the command!')
600
601
    return True
602
603
604