Ejemplo n.º 1
0
def main(cmd_args=None):
    """The main entry point for running the Markdoc CLI."""

    if cmd_args is not None:
        args = parser.parse_args(cmd_args)
    else:
        args = parser.parse_args()

    if args.command != 'init':
        try:
            args.config = os.path.abspath(args.config)

            if os.path.isdir(args.config):
                config = Config.for_directory(args.config)
            elif os.path.isfile(args.config):
                config = Config.for_file(args.config)
            else:
                raise ConfigNotFound("Couldn't locate Markdoc config.")
        except ConfigNotFound as exc:
            parser.error(str(exc))
    else:
        config = None

    logging.getLogger('markdoc').setLevel(getattr(logging, args.log_level))

    command = getattr(commands, args.command.replace('-', '_'))
    return command(config, args)
Ejemplo n.º 2
0
def get_temporary_config():
    """
    Return a temporary Markdoc configuration.
    
    The contents of the wiki will be copied from the example Markdoc wiki. After
    you're done with this, you should call `clean_temporary_config()` on the
    config object.
    """

    own_config_dir = p.join(p.dirname(p.abspath(__file__)), 'example') + p.sep
    temp_config_dir = p.join(tempfile.mkdtemp(), 'example')
    shutil.copytree(own_config_dir, temp_config_dir)
    return Config.for_directory(temp_config_dir)
Ejemplo n.º 3
0
def get_temporary_config():
    
    """
    Return a temporary Markdoc configuration.
    
    The contents of the wiki will be copied from the example Markdoc wiki. After
    you're done with this, you should call `clean_temporary_config()` on the
    config object.
    """
    
    own_config_dir = p.join(p.dirname(p.abspath(__file__)), 'example') + p.sep
    temp_config_dir = p.join(tempfile.mkdtemp(), 'example')
    shutil.copytree(own_config_dir, temp_config_dir)
    return Config.for_directory(temp_config_dir)
Ejemplo n.º 4
0
def main(cmd_args=None):
    """The main entry point for running the Markdoc CLI."""
    
    if cmd_args is not None:
        args = parser.parse_args(cmd_args)
    else:
        args = parser.parse_args()
    
    if args.command != 'init':
        try:
            args.config = os.path.abspath(args.config)
            
            if os.path.isdir(args.config):
                config = Config.for_directory(args.config)
            elif os.path.isfile(args.config):
                config = Config.for_file(args.config)
            else:
                raise ConfigNotFound("Couldn't locate Markdoc config.")
        except ConfigNotFound, exc:
            parser.error(str(exc))
Ejemplo n.º 5
0
def main(cmd_args=None):
    """The main entry point for running the Markdoc CLI."""

    if cmd_args is not None:
        args = parser.parse_args(cmd_args)
    else:
        args = parser.parse_args()

    if args.command != 'init':
        try:
            args.config = os.path.abspath(args.config)

            if os.path.isdir(args.config):
                config = Config.for_directory(args.config)
            elif os.path.isfile(args.config):
                config = Config.for_file(args.config)
            else:
                raise ConfigNotFound("Couldn't locate Markdoc config.")
        except ConfigNotFound, exc:
            parser.error(str(exc))