예제 #1
0
def join_files_recursive(directory_path, file_exclusion):
    """
    Joins the files in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    """

    legacy.walk(directory_path, join_files_walker, (file_exclusion,))
예제 #2
0
def misc_recursive(directory_path, file_exclusion, configuration):
    """
    Runs the misc operations in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    :type configuration: Dictionary
    :param configuration: The configuration structure to be used
    for the execution of the misc operations
    """

    legacy.walk(directory_path, misc_walker, (file_exclusion, configuration))
예제 #3
0
def pysource_recursive(directory_path, file_exclusion, ignores = ()):
    """
    Normalizes pysource in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    :type ignores: Tuple
    :param ignores: A sequence of string values that define the
    various tests (in pep8) that are going to be ignored.
    """

    legacy.walk(directory_path, pysource_walker, (file_exclusion, ignores))
예제 #4
0
def pydev_recursive(directory_path, file_exclusion, fix = True):
    """
    Normalizes pydev in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    :type fix: bool
    :param fix: If any "fixable" error in the pydev project
    file should be automatically fixes using the known heuristics,
    this is a dangerous option as errors may be created.
    """

    legacy.walk(directory_path, pydev_walker, (file_exclusion, fix))
예제 #5
0
def jssource_recursive(directory_path, file_exclusion):
    """
    Normalizes jssource in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    """

    legacy.walk(directory_path, jssource_walker, (file_exclusion,))
    extra.shell_exec(
        "jshint",
        [directory_path, "--config", _config("jshint.json")],
        tester = ["jshint", "--version"]
    )
예제 #6
0
def cleanup_stylesheets_recursive(
    directory_path,
    windows_newline,
    fix_extra_newlines,
    property_order = [],
    rules_skip = [],
    file_extensions = None,
    file_exclusion = None
):
    """
    Cleans up stylesheets in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type windows_newline: bool
    :param windows_newline: If the windows newline should be used.
    :type fix_extra_newlines: bool
    :param fix_extra_newlines: If the extra newlines should be fixed.
    :type property_order: List
    :param property_order: The list with the explicit order of property names.
    :type rules_skip: List
    :param rules_skip: The list of specific rules to skip.
    :type file_extensions: List
    :param file_extensions: The list of file extensions to be used.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    """

    legacy.walk(
        directory_path,
        cleanup_stylesheets_walker,
        (
            windows_newline,
            fix_extra_newlines,
            property_order,
            rules_skip,
            file_extensions,
            file_exclusion
        )
    )
예제 #7
0
def convert_encoding_recursive(
    directory_path,
    source_encoding,
    target_encoding,
    windows_newline,
    replacements_list = None,
    file_extensions = None,
    file_exclusion = None
):
    """
    Converts the file encoding in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type source_encoding: String
    :param source_encoding: The source encoding from which the file is to be
    converted.
    :type target_encoding: String
    :param target_encoding: The target encoding to which the file is to be
    converted to.
    :type replacements_list: List
    :param replacements_list: The list of replacements to perform.
    :type file_extensions: List
    :param file_extensions: The list of file extensions to be used.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    """

    legacy.walk(
        directory_path,
        convert_encoding_walker,
        (
            source_encoding,
            target_encoding,
            windows_newline,
            replacements_list,
            file_extensions,
            file_exclusion
        )
    )
예제 #8
0
def remove_trailing_spaces_recursive(
    directory_path,
    tab_to_spaces,
    trailing_newlines,
    windows_newline,
    file_extensions = None,
    file_exclusion = None
):
    """
    Removes the trailing spaces in recursive mode.
    All the options are arguments to be passed to the
    walker function.

    :type directory_path: String
    :param directory_path: The path to the (entry point) directory.
    :type tab_to_spaces: bool
    :param tab_to_spaces: If the tab characters should be converted
    to spaces.
    :type trailing_newlines: bool
    :param trailing_newlines: If the trailing newline characters should be removed.
    :type windows_newline: bool
    :param windows_newline: If the windows newline should be used.
    :type file_extensions: List
    :param file_extensions: The list of file extensions to be used.
    :type file_exclusion: List
    :param file_exclusion: The list of file exclusion to be used.
    """

    legacy.walk(
        directory_path,
        remove_trailing_spaces_walker,
        (
            tab_to_spaces,
            trailing_newlines,
            windows_newline,
            file_extensions,
            file_exclusion
        )
    )
예제 #9
0
def build_sun(path):
    """
    Generates/builds a sun file for the provided repository
    path, the resulting file should be able to be distributed
    across nodes transparently.

    This building operation will start by processing the repo
    directory so that the files are ready for building.

    @type path: String
    @param path: The path to the repository directory to
    be used in the construction of the sun file.
    @rtype: String
    @return: The path of the sun file that has just been generated
    from the provided repository (ready for usage).
    """

    repo.process_repo(path)

    path = os.path.abspath(path)
    base = os.path.basename(path)
    base = base.rstrip(".git")
    tiberium_path = os.path.join(path, "tiberium")
    sun_path = os.path.join(tiberium_path, "%s.sun" % base)
    if os.path.exists(tiberium_path): os.path.exists(sun_path) and os.remove(sun_path)
    else: os.makedirs(tiberium_path)

    _tar = tarfile.TarFile(sun_path, "w")

    sun = dict(
        name = base,
        venv = repo.has_requirements(path)
    )

    buffer = legacy.StringIO()
    json.dump(sun, buffer)
    buffer_size = buffer.tell()
    buffer.seek(0)

    tar_info = tarfile.TarInfo("sun.json")
    tar_info.size = buffer_size
    _tar.addfile(tar_info, buffer)

    try:
        def add_sun(arg, dirname, names):
            if ".git" in names: names.remove(".git")
            if "tiberium" in names: names.remove("tiberium")

            for name in names:
                _path = os.path.join(dirname, name)
                if os.path.isdir(_path): continue
                relative_path = os.path.relpath(_path, path)
                _tar.add(_path, relative_path)

        legacy.walk(path, add_sun, None)
    finally:
        _tar.close()

    repo.cleanup_repo(path)

    return sun_path