Utilities for cece
Open and read a file, convert the contents to yaml, and close the file.
Parameters: path (string) – Path to the yaml file Returns: The parsed yaml file contents
natural_sort(lst, key=<function <lambda>>)¶
Sort a list in a natural way.
This works by splitting the key, which must be a string, into string and integer parts. The list of all of those parts is then used as a key for Python’s built in sort function.
- lst (list) – The list to sort
- key (function) – The key function to use
Safely make a directory by ensuring every parent directory is created.
Parameters: path (string) – The directory to create
Iterate over the sublists of the given list. Each sublist starts at the beginning of the given list, and is one item longer than the previous one.
[1, 2, 3, 4, 5]would yield:
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 3, 4, 5]
Parameters: lst (list) – The list to iterate Returns: An iterator over the sublists