Beispiel #1
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)
Beispiel #2
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))