peltak.core.fs

peltak.core.fs.collect_files(files)[source]

Collect files using the given configuration.

Return type

List[str]

peltak.core.fs.filtered_walk(path, include=None, exclude=None)[source]

Walk recursively starting at path excluding files matching exclude

Parameters
  • path (str) – A starting path. This has to be an existing directory.

  • include (Optional[List[str]]) – A white list of glob patterns. If given, only files that match those globs will be yielded (filtered by exclude).

  • exclude (Optional[List[str]]) – A list of glob string patterns to test against. If the file/path matches any of those patters, it will be filtered out.

Return type

Iterator[str]

Returns

A generator yielding all the files that do not match any pattern in exclude.

peltak.core.fs.match_globs(path, patterns)[source]

Test whether the given path matches any patterns in patterns

Parameters
  • path (str) – A file path to test for matches.

  • patterns (list[str]) – A list of glob string patterns to test against. If path matches any of those patters, it will return True.

Returns

True if the path matches any pattern in patterns.

Return type

bool

peltak.core.fs.search_globs(path, patterns)[source]

Test whether the given path contains any patterns in patterns

Parameters
  • path (str) – A file path to test for matches.

  • patterns (list[str]) – A list of glob string patterns to test against. If path matches any of those patters, it will return True.

Returns

True if the path matches any pattern in patterns.

Return type

bool

peltak.core.fs.wrap_paths(paths)[source]

Put quotes around all paths and join them with space in-between.

Return type

str

peltak.core.fs.write_file(path, content, mode='w')[source]

–pretend aware file writing.

You can always write files manually but you should always handle the –pretend case.

Parameters
  • path (str) –

  • content (str) –

  • mode (str) –

Return type

None