def _get_plugin_name():
    """Return a new plugin name."""
    # Clear the screen
    clear_screen()

    # Ask for a valid plugin name
    name = input(
        'What is the name of the plugin that should be created?\n\n')

    # Is the plugin name invalid?
    if not name.replace('_', '').isalnum():

        # Try to get a new plugin name
        return _ask_retry(
            'Invalid characters used in plugin name "{name}".\n'
            'Only alpha-numeric and underscores allowed.'.format(
                name=name,
            )
        )

    # Does the plugin already exist?
    if name in plugin_list:

        # Try to get a new plugin name
        return _ask_retry(
            'Plugin name "{name}" already exists.'.format(name=name)
        )

    # Return the plugin name
    return name
def _get_plugin_name():
    """Return a new plugin name."""
    # Clear the screen
    clear_screen()

    # Ask for a valid plugin name
    name = input('What is the name of the plugin that should be created?\n\n')

    # Is the plugin name invalid?
    if not name.replace('_', '').isalnum():

        # Try to get a new plugin name
        return _ask_retry('Invalid characters used in plugin name "{name}".\n'
                          'Only alpha-numeric and underscores allowed.'.format(
                              name=name, ))

    # Does the plugin already exist?
    if name in plugin_list:

        # Try to get a new plugin name
        return _ask_retry(
            'Plugin name "{name}" already exists.'.format(name=name))

    # Return the plugin name
    return name
def _get_directory(name):
    """Return whether or not to create the given directory."""
    # Clear the screen
    clear_screen()

    # Get whether the directory should be added
    value = input('Do you want to include a {name} directory?\n\n'
                  '\t(1) Yes\n\t(2) No\n\n'.format(name=name, )).lower()

    # Was the given value invalid?
    if value not in _boolean_values:

        # Try again
        return _get_directory(name)

    # Return the value
    return _boolean_values[value]
def _get_directory_or_file(name):
    """Return whether to create the given directory or file."""
    # Clear the screen
    clear_screen()

    # Get whether to add a directory, file, or neither
    value = input(
        'Do you want to include a {name} file, directory, or neither?\n\n'
        '\t(1) File\n\t(2) Directory\n\t(3) Neither\n\n'.format(name=name, ))

    # Was the given value invalid?
    if value not in _directory_or_file:

        # Try again
        _get_directory_or_file(name)

    # Return the value
    return _directory_or_file[value]
def _get_directory_or_file(name):
    """Return whether to create the given directory or file."""
    # Clear the screen
    clear_screen()

    # Get whether to add a directory, file, or neither
    value = input(
        'Do you want to include a {name} file, directory, or neither?\n\n'
        '\t(1) File\n\t(2) Directory\n\t(3) Neither\n\n'.format(
            name=name,
        )
    )

    # Was the given value invalid?
    if value not in _directory_or_file:

        # Try again
        _get_directory_or_file(name)

    # Return the value
    return _directory_or_file[value]
def _get_directory(name):
    """Return whether or not to create the given directory."""
    # Clear the screen
    clear_screen()

    # Get whether the directory should be added
    value = input(
        'Do you want to include a {name} directory?\n\n'
        '\t(1) Yes\n\t(2) No\n\n'.format(
            name=name,
        )
    ).lower()

    # Was the given value invalid?
    if value not in _boolean_values:

        # Try again
        return _get_directory(name)

    # Return the value
    return _boolean_values[value]
def _ask_retry(reason):
    """Ask if another plugin name should be given."""
    # Clear the screen
    clear_screen()

    # Get whether to retry or not
    value = input(reason + '\n\n' + 'Do you want to try again?\n\n' +
                  '\t(1) Yes\n\t(2) No\n\n').lower()

    # Was the retry value invalid?
    if value not in _boolean_values:

        # Try again
        return _ask_retry(reason)

    # Was Yes selected?
    if _boolean_values[value]:

        # Try to get another plugin name
        return _get_plugin_name()

    # Simply return None to not get a plugin name
    return None
def _ask_retry(reason):
    """Ask if another plugin name should be given."""
    # Clear the screen
    clear_screen()

    # Get whether to retry or not
    value = input(
        reason + '\n\n' + 'Do you want to try again?\n\n' +
        '\t(1) Yes\n\t(2) No\n\n').lower()

    # Was the retry value invalid?
    if value not in _boolean_values:

        # Try again
        return _ask_retry(reason)

    # Was Yes selected?
    if _boolean_values[value]:

        # Try to get another plugin name
        return _get_plugin_name()

    # Simply return None to not get a plugin name
    return None
Exemple #9
0
    link_source_python(game_name)


# =============================================================================
# >> CALL MAIN FUNCTION
# =============================================================================
if __name__ == '__main__':

    # Get the game to link
    _game_name = get_game()

    # Was a valid game chosen?
    if _game_name is not None:

        # Clear the screen
        clear_screen()

        # Was ALL selected?
        if _game_name == 'ALL':

            # Loop through each game
            for _game_name in supported_games:

                # Link the game
                link_game(_game_name)

        # Otherwise
        else:

            # Link the game
            link_game(_game_name)
        link_file(src, dest)


# =============================================================================
# >> CALL MAIN FUNCTION
# =============================================================================
if __name__ == '__main__':

    # Get the plugin to link
    _plugin_name = get_plugin('link')

    # Was a valid plugin chosen?
    if _plugin_name is not None:

        # Clear the screen
        clear_screen()

        # Was ALL chosen?
        if _plugin_name == 'ALL':

            # Loop through all plugins
            for _plugin_name in plugin_list:

                # Check the current plugin
                link_plugin(_plugin_name)

        # Was a valid plugin chosen?
        else:

            # Check the chosen plugin
            link_plugin(_plugin_name)