pimlico.utils.core module

pimlico.utils.core.import_member(path)[source]

Import a class, function, or other module member by its fully-qualified Python name.

Parameters:path – path to member, including full package path and class/function/etc name
Returns:cls
pimlico.utils.core.infinite_cycle(iterable)[source]
pimlico.utils.core.is_identifier(ident)[source]

Determines if string is valid Python identifier.

pimlico.utils.core.multiwith(*args, **kwds)[source]

Taken from contextlib’s nested(). We need the variable number of context managers that this function allows.

pimlico.utils.core.remove_duplicates(lst, key=<function <lambda>>)[source]

Remove duplicate values from a list, keeping just the first one, using a particular key function to compare them.

pimlico.utils.core.split_seq(seq, separator, ignore_empty_final=False)[source]

Iterate over a sequence and group its values into lists, separated in the original sequence by the given value. If on is callable, it is called on each element to test whether it is a separator. Otherwise, elements that are equal to on a treated as separators.

Parameters:
  • seq – sequence to divide up
  • separator – separator or separator test function
  • ignore_empty_final – by default, if there’s a separator at the end, the last sequence yielded is empty. If ignore_empty_final=True, in this case the last empty sequence is dropped
Returns:

iterator over subsequences

pimlico.utils.core.split_seq_after(seq, separator)[source]

Somewhat like split_seq, but starts a new subsequence after each separator, without removing the separators. Each subsequence therefore ends with a separator, except the last one if there’s no separator at the end.

Parameters:
  • seq – sequence to divide up
  • separator – separator or separator test function
Returns:

iterator over subsequences