|
29 | 29 | # default interval in seconds |
30 | 30 | DEFAULT_INTERVAL = 60.0 |
31 | 31 |
|
| 32 | +# used in migrate method per default - empty dictionary means no deployment |
| 33 | +DEFAULT_CONFIG = { |
| 34 | + 'deploy': { |
| 35 | + 'interval': dict() |
| 36 | + } |
| 37 | +} |
| 38 | + |
32 | 39 |
|
33 | 40 | def _migrate_int_to_float(value: object) -> Mapping[str, object]: |
34 | 41 | """ |
35 | 42 | migrate from integer interval to float interval |
36 | 43 | """ |
37 | 44 |
|
38 | 45 | # debugging - might become an option later |
39 | | - #with open('/tmp/debug-migrate_int_to_float.txt', 'a') as debug_file: |
| 46 | + # with open('/tmp/debug-migrate_int_to_float.txt', 'a') as debug_file: |
40 | 47 | # debug_file.write(f'value: {value}\n') |
41 | 48 |
|
42 | 49 | if value is not None: |
43 | 50 | if value.get('deploy'): |
44 | | - if value['deploy'].get('interval'): |
45 | | - return { |
46 | | - 'deploy': { |
47 | | - 'interval': float(value['deploy']['interval']) |
| 51 | + if isinstance(value['deploy'], dict): |
| 52 | + if value['deploy'].get('interval'): |
| 53 | + return { |
| 54 | + 'deploy': { |
| 55 | + 'interval': float(value['deploy']['interval']) |
| 56 | + } |
48 | 57 | } |
49 | | - } |
50 | | - else: |
51 | | - return { |
52 | | - 'deploy': { |
53 | | - 'interval': dict() |
| 58 | + # backward compatiblility with tuple |
| 59 | + elif isinstance(value['deploy'], tuple): |
| 60 | + if len(value['deploy']) == 2: |
| 61 | + return { |
| 62 | + 'deploy': { |
| 63 | + 'interval': float(value['deploy'][1]) |
| 64 | + } |
54 | 65 | } |
55 | | - } |
| 66 | + else: |
| 67 | + return DEFAULT_CONFIG |
| 68 | + else: |
| 69 | + return DEFAULT_CONFIG |
56 | 70 | # backward compatibility - migrate from interval to deploy |
57 | 71 | elif value.get('interval'): |
58 | 72 | return { |
59 | 73 | 'deploy': { |
60 | 74 | 'interval': float(value['interval']) |
61 | 75 | } |
62 | 76 | } |
63 | | - # backward compatibility |
64 | | - elif value.get('nointerval'): |
65 | | - return { |
66 | | - 'deploy': { |
67 | | - 'interval': dict() |
68 | | - } |
69 | | - } |
70 | | - else: |
71 | | - return value |
| 77 | + # if no other case matches just give back empty default config |
| 78 | + return DEFAULT_CONFIG |
72 | 79 | else: |
73 | 80 | # empty dictionary means no deployment |
74 | 81 | return dict() |
|
0 commit comments