JIP utilities and helper functions
Make sure source is a list, else wrap it, and return a flat list.
Parameters: | source – source list |
---|---|
Returns: | flat list |
Ignores given set of exception in a with context. For example:
with ignore(Exception):
...
This will ignore all Exceptions raised within the with block.
Parameters: | exceptions – list of exception classes that will be ignored |
---|
Generator function to iterates a directory recursively and yields all files.
Parameters: |
|
---|
Takse a string and parses a memory pattern. The supported suffixes are G M or K both upper and lower case.
Parameters: | mem – the memory string |
---|---|
Returns: | memory in megabyte |
Parse time string and returns time in minutes.
The string can be either a number, which is the time in minutes, or of the form:
<int>d<int>h<int>m<int>s
where any part can be left out, but the order matters.
Examples:
- 30:
- returns 30 minutes
- 1h:
- returns 60 minutes
- 2h30m:
- return 150 minutes
In addition, you can use a colon separated format that is either:
HH:MM
or
HH:MM:SS
Parameters: | time (string) – time string |
---|---|
Returns: | time in minutes |
Return type: | integer |
Raises: | ValueError in case the time could not be parsed |
Replace all occurencens of ‘old’ with ‘new’ starting at the right hand side of the string. If occurences is specified, the number of replacements is limited to occurences.
Parameters: |
|
---|