Exemple #1
0
def reporters_command(
        alias=False,  # Print detailed information about the specified reporter.
        simple=False,  # Only print report aliases, without other information.
):
    """
    List available reports which dexy can run.
    """
    if simple:
        for reporter in dexy.reporter.Reporter:
            print(reporter.alias)

    elif alias:
        nodoc_settings = (
            'aliases',
            'help',
        )

        reporter = dexy.reporter.Reporter.create_instance(alias)

        print_indented("%s Reporter" % reporter.__class__.__name__)
        print('')

        print_indented("settings:")
        print('')
        for name in sorted(reporter._instance_settings):
            if name in nodoc_settings:
                continue

            docs, default_value = reporter._instance_settings[name]
            print_indented(name, 2)
            print_rewrapped(docs, 4)
            print_indented("(default: %r)" % default_value, 4)
            print('')

        reporter.help()

        print('')

    else:
        FMT = "%-15s %-9s %s"

        print(FMT % ('alias', 'default', 'info'))
        for reporter in dexy.reporter.Reporter:
            help_text = reporter.setting('help').splitlines()[0]
            default_text = reporter.setting('default') and 'true' or 'false'
            print(FMT % (reporter.alias, default_text, help_text))
Exemple #2
0
def reporters_command(
        alias=False, # Print detailed information about the specified reporter.
        simple=False, # Only print report aliases, without other information.
        ):
    """
    List available reports which dexy can run.
    """
    if simple:
        for reporter in dexy.reporter.Reporter:
            print reporter.alias

    elif alias:
        nodoc_settings = ('aliases', 'help',)

        reporter = dexy.reporter.Reporter.create_instance(alias)

        print_indented("%s Reporter" % reporter.__class__.__name__)
        print ''

        print_indented("settings:")
        print ''
        for name in sorted(reporter._instance_settings):
            if name in nodoc_settings:
                continue

            docs, default_value = reporter._instance_settings[name]
            print_indented(name, 2)
            print_rewrapped(docs, 4)
            print_indented("(default: %r)" % default_value, 4)
            print ''

        reporter.help()

        print ''

    else:
        FMT = "%-15s %-9s %s"
    
        print FMT % ('alias', 'default', 'info')
        for reporter in dexy.reporter.Reporter:
            help_text = reporter.setting('help').splitlines()[0]
            default_text = reporter.setting('default') and 'true' or 'false'
            print FMT % (reporter.alias, default_text, help_text)
Exemple #3
0
def info_command(
        __cli_options=False,
        expr="", # An expression partially matching document name.
        key="", # The exact document key.
        ws=False, # Whether to print website reporter keys and values.
        **kwargs
        ):
    """
    Prints metadata about a dexy document.

    Dexy must have already run successfully.

    You can specify an exact document key or an expression which matches part
    of a document name/key. The `dexy grep` command is available to help you
    search for documents and print document contents.
    """
    artifactsdir = kwargs.get('artifactsdir', defaults['artifacts_dir'])
    wrapper = init_wrapper(locals())
    wrapper.setup_log()
    batch = Batch.load_most_recent(wrapper)
    wrapper.batch = batch

    if expr:
        print "search expr:", expr
        matches = sorted([data for data in batch if expr in data.key],
                key=attrgetter('key'))
    elif key:
        matches = sorted([data for data in batch if key == data.key],
                key=attrgetter('key'))
    else:
        raise dexy.exceptions.UserFeedback("Must specify either expr or key")

    for match in matches:
        print ""
        print "  Info for Document '%s'" % match.key
        print ""
        print "  document output data type:", match.alias
        print ""

        print_indented("settings:", 2)
        for k in sorted(match._instance_settings):
            if not k in ('aliases', 'help'):
                print_indented("%s: %s" % (k, match.setting(k)), 4)

        print ""
        print_indented("attributes:", 2)
        for fname in sorted(info_attrs):
            print_indented("%s: %s" % (fname, getattr(match, fname)), 4)
        print ""
    
        print_indented("methods:", 2)
        for fname in sorted(info_methods):
            print_indented("%s(): %s" % (fname, getattr(match, fname)()), 4)
        print ""

        if storage_methods:
            print_indented("storage methods:", 2)
            for fname in sorted(storage_methods):
                print_indented("%s(): %s" % (fname, getattr(match.storage, fname)), 4)
            print ''

        if ws:
            print_indented("website reporter methods:", 2)
            print ''
            reporter = dexy.reporter.Reporter.create_instance('ws')
            reporter.wrapper = wrapper
            reporter.setup_navobj()
            reporter.help(match)
            print ''
            print_indented("active template plugins are:", 2)
            print_indented(", ".join(reporter.setting('plugins')), 4)
            print ''


        else:
            print_indented("For website reporter tags, run this command with -ws option", 4)
            print ''


        print_rewrapped("""For more information about methods available on this
        data type run `dexy datas -alias %s`""" % match.alias)