Esempio n. 1
0
def post_renderer(configurator):
    """
    """
    _update_package_configure_zcml(configurator)
    _update_behaviors_configure_zcml(configurator)
    git_commit(
        configurator,
        'Add behavior: {0}'.format(configurator.variables['behavior_name'], ),
    )
    behavior_name = '{0}.behaviors.{1}.{2}'.format(
        configurator.variables['package.dottedname'],
        configurator.variables['behavior_name_normalized'],
        configurator.variables['behavior_name_klass'],
    )
    behavior_name_short = '{0}.{1}'.format(
        configurator.variables['package.dottedname'],
        configurator.variables['behavior_name_normalized'],
    )
    echo(
        '===================================================\n'
        '=> Sucessfully added: {0} template.  \\o/ \n\n'.format(
            configurator.variables['template_id'], ),
        'info',
    )
    echo(
        'You can lookup your behavior by the name:\n "{0}"\n'
        'or by the shorter version:\n "{1}"\n'.format(
            behavior_name,
            behavior_name_short,
        ),
        'info',
    )
Esempio n. 2
0
def post_render(configurator, target_directory=None):
    mrbob_config = {}
    mrbob_config['author.name'] = \
        configurator.variables['configure_mrbob.author.name'].encode('utf-8')
    mrbob_config['author.email'] = \
        configurator.variables['configure_mrbob.author.email'].encode('utf-8')
    mrbob_config['author.github.user'] = \
        configurator.variables['configure_mrbob.author.github.user'].encode('utf-8')  # NOQA: E501
    if not configurator.variables['configure_mrbob.package.git.disabled']:
        mrbob_config['package.git.disabled'] = 'n'
        mrbob_config['package.git.init'] = \
            configurator.variables['configure_mrbob.package.git.init']
        mrbob_config['package.git.autocommit'] = \
            configurator.variables['configure_mrbob.package.git.autocommit']
    else:
        mrbob_config['package.git.disabled'] = 'y'
    mrbob_config['plone.version'] = \
        configurator.variables['configure_mrbob.plone.version'].encode('utf-8')
    if not target_directory:
        configurator.target_directory = home_path
        target_directory = configurator.target_directory
    generate_mrbob_ini(configurator, target_directory, mrbob_config)
    echo(
        u'\nMrbob\'s settings have been saved to {0}/.mrbob\n'.format(
            target_directory, ),
        msg_type='info',
    )
Esempio n. 3
0
def post_render(configurator, target_directory=None):
    mrbob_config = {}
    mrbob_config["author.name"] = safe_string(
        configurator.variables["configure_mrbob.author.name"])
    mrbob_config["author.email"] = safe_string(
        configurator.variables["configure_mrbob.author.email"])
    mrbob_config["author.github.user"] = safe_string(
        configurator.variables["configure_mrbob.author.github.user"])
    mrbob_config["package.venv.disabled"] = configurator.variables[
        "configure_mrbob.package.venv.disabled"]
    if not configurator.variables["configure_mrbob.package.git.disabled"]:
        mrbob_config["package.git.disabled"] = "n"
        mrbob_config["package.git.init"] = configurator.variables[
            "configure_mrbob.package.git.init"]
        mrbob_config["package.git.autocommit"] = configurator.variables[
            "configure_mrbob.package.git.autocommit"]
    else:
        mrbob_config["package.git.disabled"] = "y"
    mrbob_config["plone.version"] = safe_string(
        configurator.variables["configure_mrbob.plone.version"])
    if not target_directory:
        configurator.target_directory = home_path
        target_directory = configurator.target_directory
    generate_mrbob_ini(configurator, target_directory, mrbob_config)
    echo(
        u"\nMrbob's settings have been saved to {0}/.mrbob\n".format(
            target_directory),
        msg_type="info",
    )
Esempio n. 4
0
def post_renderer(configurator):
    """
    """
    _update_package_configure_zcml(configurator)
    _update_behaviors_configure_zcml(configurator)
    git_commit(
        configurator,
        'Add behavior: {0}'.format(
            configurator.variables['behavior_name'],
        ),
    )
    behavior_name = '{0}.behaviors.{1}.{2}'.format(
        configurator.variables['package.dottedname'],
        configurator.variables['behavior_name_normalized'],
        configurator.variables['behavior_name_klass'],
    )
    behavior_name_short = '{0}.{1}'.format(
        configurator.variables['package.dottedname'],
        configurator.variables['behavior_name_normalized'],
    )
    echo(
        '===================================================\n'
        '=> Sucessfully added: {0} template.  \\o/ \n\n'.format(
            configurator.variables['template_id'],
        ),
        'info',
    )
    echo(
        'You can lookup your behavior by the name:\n "{0}"\n'
        'or by the shorter version:\n "{1}"\n'.format(
            behavior_name,
            behavior_name_short,
        ),
        'info',
    )
Esempio n. 5
0
def prepare_renderer(configurator):
    echo('Using plone_theme template:', 'info')
    configurator = base_prepare_renderer(configurator)
    configurator.variables['template_id'] = 'theme'

    def normalize_theme_name(value):
        value = '-'.join(value.split('_'))
        value = '-'.join(value.split())
        return value

    configurator.variables['theme.normalized_name'] = normalize_theme_name(
        configurator.variables.get('theme.name'), ).lower()
Esempio n. 6
0
def prepare_renderer(configurator):
    echo("Using theme_barceloneta subtemplate:", "info")
    configurator = base_prepare_renderer(configurator)
    configurator.variables["template_id"] = "theme_barceloneta"

    def normalize_theme_name(value):
        value = "-".join(value.split("_"))
        value = "-".join(value.split())
        return value

    configurator.variables["theme.normalized_name"] = normalize_theme_name(
        configurator.variables.get("theme.name")
    ).lower()
Esempio n. 7
0
def prepare_renderer(configurator):
    echo('Using plone_theme template:', 'info')
    configurator = base_prepare_renderer(configurator)
    configurator.variables['template_id'] = 'theme'

    def normalize_theme_name(value):
        value = '-'.join(value.split('_'))
        value = '-'.join(value.split())
        return value
    configurator.variables['theme.normalized_name'] = normalize_theme_name(
        configurator.variables.get('theme.name'),
    ).lower()
    configurator.target_directory = configurator.variables['package_folder']
Esempio n. 8
0
def prepare_renderer(configurator):
    echo('Using theme_barceloneta subtemplate:', 'info')
    configurator = base_prepare_renderer(configurator)
    configurator.variables['template_id'] = 'theme_barceloneta'

    def normalize_theme_name(value):
        value = '-'.join(value.split('_'))
        value = '-'.join(value.split())
        return value

    configurator.variables['theme.normalized_name'] = normalize_theme_name(
        configurator.variables.get('theme.name'), ).lower()

    configurator.target_directory = configurator.variables['package_folder']
Esempio n. 9
0
def post_renderer(configurator):
    """"""
    _update_package_configure_zcml(configurator)
    _update_vocabularies_configure_zcml(configurator)
    git_commit(
        configurator,
        'Add vocabulary: {0}'.format(
            configurator.variables['vocabulary_name'], ),
    )
    registered_vocabulary = '{0}.{1}'.format(
        configurator.variables['package.dottedname'],
        configurator.variables['vocabulary_name_normalized'],
    )
    echo(
        '------------------------\nSucessfully added: {0} template.\n'.format(
            configurator.variables['template_id'], ), )
    echo(
        'You can lookup your vocabulary by the name: {0}\n'.format(
            registered_vocabulary, ),
        'info',
    )
Esempio n. 10
0
def _update_views_configure_zcml(configurator):
    file_name = u'configure.zcml'
    directory_path = configurator.variables['package_folder'] + '/views/'
    file_path = directory_path + file_name
    configure_example_file_path = configurator.variables[
        'package_folder'] + '/views/configure.zcml.example'  # NOQA: E501
    file_list = os.listdir(os.path.dirname(directory_path))
    if file_name not in file_list:
        os.rename(configure_example_file_path, file_path)

    match_str = '-*- extra stuff goes here -*-'

    if configurator.variables['view_template'] and configurator.variables[
            'view_python_class']:  # NOQA: E501
        insert_str = """
  <browser:page
    name="{0}"
    for="Products.CMFCore.interfaces.IFolderish"
    class=".{1}.{2}"
    template="{3}.pt"
    permission="zope2.View"
    />
""".format(
            configurator.variables['view_name'],
            configurator.variables['view_python_file_name'],
            configurator.variables['view_python_class_name'],
            configurator.variables['view_template_name'],
        )

    if configurator.variables['view_template'] and not configurator.variables[
            'view_python_class']:  # NOQA: E501
        insert_str = """
  <browser:page
    name="{0}"
    for="Products.CMFCore.interfaces.IFolderish"
    template="{1}.pt"
    permission="zope2.View"
    />
""".format(
            configurator.variables['view_name'],
            configurator.variables['view_template_name'],
        )

    if not configurator.variables['view_template'] and configurator.variables[
            'view_python_class']:  # NOQA: E501
        insert_str = """
  <browser:page
    name="{0}"
    for="Products.CMFCore.interfaces.IFolderish"
    class=".{1}.{2}"
    permission="zope2.View"
    />
""".format(
            configurator.variables['view_name'],
            configurator.variables['view_python_file_name'],
            configurator.variables['view_python_class_name'],
        )
    with open(file_path, 'r') as xml_file:
        parser = etree.XMLParser(remove_blank_text=True)
        tree = etree.parse(xml_file, parser)
        tree_root = tree.getroot()
        view_xpath = "./browser:page[@name='{0}']".format(
            configurator.variables['view_name'], )
        if len(tree_root.xpath(view_xpath, namespaces=ZCML_NAMESPACES)):
            echo(
                u'{0} already in configure.zcml, do you really want to add this config?'
                u'\n\n{1}\n [y/N]: '.format(
                    configurator.variables['view_name'],
                    insert_str,
                ),
                'info',
            )
            if configurator.bobconfig.get('non_interactive'):
                return
            choice = six.moves.input().lower()
            if choice != 'y':
                return

    update_file(configurator, file_path, match_str, insert_str)