pyp.utils package

Submodules

pyp.utils.core module

cat(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

flatten(iterable, /)[source]

Alternative chain() constructor taking a single iterable argument that evaluates lazily.

get_project_root()pathlib.Path[source]
get_relative_path(path: Union[str, pathlib.Path])pathlib.Path[source]

Returns Path relative to src/ folder.

get_src_path()pathlib.Path[source]

Returns Path of the src/ folder.

has_files(basename, trailers, suffix=False)[source]
makedirs_list(paths)[source]
movie2regex(pattern, filename='*')[source]

Translate the pattern in movie_pattern to RegEx, used to search corresponding frame files

TILTSERIES -> name of the tiltseries SCANORD -> scanning order (i.e. 000, 001, 002, …) ANGLE -> tilt angles (i.e. -0.0, 10, 0.5, …)

Parameters
  • pattern (str) – Pattern of filename

  • filename (str) – Name of the tilt-series

Returns

RegEx

Return type

str

Create a symlink pointing to target from location. :param target: The target of the symlink (the file/directory that is pointed to) :param destination: The location of the symlink itself.

pyp.utils.timer module

Timer module adapted from Real Python.

class Timer(name: Union[str, NoneType] = None, text: str = 'Elapsed time: {}', logger: Union[Callable[[str], NoneType], NoneType] = <built-in function print>)[source]

Bases: contextlib.ContextDecorator

logger()[source]

print(value, …, sep=’ ‘, end=’n’, file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.

name: Optional[str] = None[source]
start()[source]

Start a new timer

stop()[source]

Stop the timer, and report the elapsed time

text: str = 'Elapsed time: {}'[source]
timers: ClassVar[Dict[str, Dict[str, str]]] = {}[source]
exception TimerError[source]

Bases: Exception

A custom exception used to report errors in the use of Timer class.

Module contents

cat(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

flatten(iterable, /)[source]

Alternative chain() constructor taking a single iterable argument that evaluates lazily.