Пример #1
0
def init():
    """
    Initialize a new python project with default files.  Default values from herring.conf and directory name.
    """
    defaults = _project_defaults()

    if Project.prompt:
        defaults['name'] = prompt("Enter the project's name:", defaults['name'])
        defaults['package'] = prompt("Enter the project's package:", defaults['package'])
        defaults['author'] = prompt("Enter the project's author:", defaults['author'])
        defaults['author_email'] = prompt("Enter the project's author's email:", defaults['author_email'])
        defaults['description'] = prompt("Enter the project's description:", defaults['description'])

    # print("defaults:\n{defaults}".format(defaults=pformat(defaults)))

    if Project.use_templates:

        template = Template()

        for template_dir in [os.path.abspath(os.path.join(herringlib, 'herringlib', 'templates'))
                             for herringlib in HerringFile.herringlib_paths]:

            info("template directory: %s" % template_dir)
            # noinspection PyArgumentEqualDefault
            template.generate(template_dir, defaults, overwrite=False)
Пример #2
0
def update():
    """
    Regenerate files (except herringfile) from current templates.
    Delete the file(s) you want to update, then run this task.
    """
    defaults = _project_defaults()

    template = Template()

    for template_dir in [os.path.abspath(os.path.join(herringlib, 'herringlib', 'templates'))
                         for herringlib in HerringFile.herringlib_paths]:

        info("template directory: %s" % template_dir)
        # noinspection PyArgumentEqualDefault
        template.generate(template_dir, defaults, overwrite=False)