Contextually change the working directory to do thy bidding. Then gets back to the original location.
- swh.core.utils.grouper(iterable, n)
- Collect data into fixed-length size iterables. The last block might
contain less elements as it will hold only the remaining number of elements.
The invariant here is that the number of elements in the input iterable and the sum of the number of elements of all iterables generated from this function should be equal.
iterable (Iterable) – an iterable
n (int) – size of block to slice the iterable into
fixed-length blocks as iterables. As mentioned, the last iterable might be less populated.
Encode an unicode string containing x<hex> backslash escapes
Decode a bytestring as utf-8, escaping the bytes of invalid utf-8 sequences as x<hex value>. We also escape NUL bytes as they are invalid in JSON strings.
- swh.core.utils.commonname(path0, path1, as_str=False)
Compute the commonname between the path0 and path1.
Simple function to sort filenames of the form:
where nn is a number according to the numbers.
Typically used to sort sql/nn-swh-xxx.sql files.