| Conditions | 8 |
| Total Lines | 52 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | #!/usr/bin/env python3 |
||
| 60 | def remove_target_database_dump(): |
||
| 61 | """ |
||
| 62 | Removing the target database dump files |
||
| 63 | :return: |
||
| 64 | """ |
||
| 65 | _file_path = helper.get_dump_dir(mode.Client.TARGET) + database_utility.database_dump_file_name |
||
| 66 | |||
| 67 | # |
||
| 68 | # Move dump to specified directory |
||
| 69 | # |
||
| 70 | if system.config['keep_dump']: |
||
| 71 | helper.create_local_temporary_data_dir() |
||
| 72 | _keep_dump_path = system.default_local_sync_path + database_utility.database_dump_file_name |
||
| 73 | mode.run_command( |
||
| 74 | helper.get_command('target', |
||
| 75 | 'cp') + ' ' + _file_path + ' ' + _keep_dump_path, |
||
| 76 | mode.Client.TARGET |
||
| 77 | ) |
||
| 78 | output.message( |
||
| 79 | output.Subject.INFO, |
||
| 80 | f'Database dump file is saved to: {_keep_dump_path}', |
||
| 81 | True, |
||
| 82 | True |
||
| 83 | ) |
||
| 84 | |||
| 85 | # |
||
| 86 | # Clean up |
||
| 87 | # |
||
| 88 | if not mode.is_dump() and not mode.is_import(): |
||
| 89 | output.message( |
||
| 90 | output.Subject.TARGET, |
||
| 91 | 'Cleaning up', |
||
| 92 | True |
||
| 93 | ) |
||
| 94 | |||
| 95 | if system.config['dry_run']: |
||
| 96 | return |
||
| 97 | |||
| 98 | if mode.is_target_remote(): |
||
| 99 | mode.run_command( |
||
| 100 | helper.get_command(mode.Client.TARGET, 'rm') + ' ' + _file_path, |
||
| 101 | mode.Client.TARGET |
||
| 102 | ) |
||
| 103 | mode.run_command( |
||
| 104 | helper.get_command(mode.Client.TARGET, 'rm') + ' ' + _file_path + '.tar.gz', |
||
| 105 | mode.Client.TARGET |
||
| 106 | ) |
||
| 107 | else: |
||
| 108 | if os.path.isfile(_file_path): |
||
| 109 | os.remove(_file_path) |
||
| 110 | if os.path.isfile(f'{_file_path}.tar.gz'): |
||
| 111 | os.remove(f'{_file_path}.tar.gz') |
||
| 112 | |||
| 124 |