Path helper module

class rebasehelper.helpers.path_helper.PathHelper[source]

Class for performing path related tasks.

static file_available(filename)[source]

Checks if the given file exists.

Parameters:

filename (str) – Path to the file.

Returns:

Whether the file exists.

Return type:

bool

static find_all_files(top_path, pattern)[source]

Recursively searches for all files matching the given pattern.

Parameters:
  • top_path (str) – Directory where to start the search.

  • pattern (str) – Filename pattern.

Returns:

List containing absolute paths to all found files.

Return type:

list

static find_all_files_current_dir(top_path, pattern)[source]

Searches for all files that match the given pattern inside a directory.

Parameters:
  • top_path (str) – Directory where to start the search.

  • pattern (str) – Filename pattern.

Returns:

List containing absolute paths to all found files.

Return type:

list

static find_first_dir_with_file(top_path, pattern)[source]

Recursively searches for a directory containing a file that matches the given pattern.

Parameters:
  • top_path (str) – Directory where to start the search.

  • pattern (str) – Filename pattern.

Returns:

Full path to the directory containing the first occurence of the searched file. None if there is no file matching the pattern.

Return type:

str

static find_first_file(top_path, pattern, recursion_level=None)[source]

Recursively searches for a file that matches the given pattern.

Parameters:
  • top_path (str) – Directory where to start the search.

  • pattern (str) – Filename pattern.

  • recursion_level (int) – How deep in the directory tree the search can go.

Returns:

Path to the file matching the pattern or None if there is no file matching the pattern.

Return type:

str

static get_temp_dir()[source]

Creates a new temporary directory.

Returns:

Path to the created directory.

Return type:

str