| Total Complexity | 2 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
|
|
|||
| 2 | import datetime |
||
| 3 | |||
| 4 | |||
| 5 | def cmp_to_key(mycmp): |
||
| 6 | """ |
||
| 7 | List sort related function |
||
| 8 | |||
| 9 | Convert a cmp= function into a key= function |
||
| 10 | """ |
||
| 11 | class K(object): |
||
| 12 | def __init__(self, obj, *args): |
||
| 13 | self.obj = obj |
||
| 14 | |||
| 15 | def __lt__(self, other): |
||
| 16 | return mycmp(self.obj, other.obj) < 0 |
||
| 17 | |||
| 18 | def __gt__(self, other): |
||
| 19 | return mycmp(self.obj, other.obj) > 0 |
||
| 20 | |||
| 21 | def __eq__(self, other): |
||
| 22 | return mycmp(self.obj, other.obj) == 0 |
||
| 23 | |||
| 24 | def __le__(self, other): |
||
| 25 | return mycmp(self.obj, other.obj) <= 0 |
||
| 26 | |||
| 27 | def __ge__(self, other): |
||
| 28 | return mycmp(self.obj, other.obj) >= 0 |
||
| 29 | |||
| 30 | def __ne__(self, other): |
||
| 31 | return mycmp(self.obj, other.obj) != 0 |
||
| 32 | |||
| 33 | return K |
||
| 34 | |||
| 35 | |||
| 36 | def current_date_for_filename() -> str: |
||
| 37 | """ |
||
| 38 | ISO8601 current date, adapted to be used in filename (for |
||
| 39 | webdav feature for example), with trouble-free characters. |
||
| 40 | :return: current date as string like "2018-03-19T15.49.27.246592" |
||
| 41 | """ |
||
| 42 | # INFO - G.M - 19-03-2018 - As ':' is in transform_to_bdd method in |
||
| 43 | # webdav utils, it may cause trouble. So, it should be replaced to |
||
| 44 | # a character which will not change in bdd. |
||
| 45 | return datetime.datetime.now().isoformat().replace(':', '.') |
||
| 46 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.