| Total Complexity | 1 |
| Total Lines | 51 |
| Duplicated Lines | 31.37 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | import sys |
||
|
|
|||
| 2 | import os |
||
| 3 | import argparse |
||
| 4 | import getpass |
||
| 5 | import logging |
||
| 6 | |||
| 7 | logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | def DICOMMonitor(): |
||
| 12 | ''' |
||
| 13 | Monitor the DICOM folders of Orthanc output. |
||
| 14 | : |
||
| 15 | ''' |
||
| 16 | logger = logging.getLogger('DICOMMonitor') |
||
| 17 | |||
| 18 | default_locations = "example path" |
||
| 19 | default_monitoring_duration = 60 #seconds |
||
| 20 | default_DCMTK = "DCMTK path" |
||
| 21 | default_os = "ubuntu" |
||
| 22 | |||
| 23 | #Check for all the new batch if they contain any of the known existing DICOM string. |
||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | View Code Duplication | if __name__ == '__main__': |
|
| 36 | |||
| 37 | parser = argparse.ArgumentParser(description=__doc__) |
||
| 38 | parser.add_argument('-u', '--user', dest='email', type=str, help='Username/Email used for login') |
||
| 39 | parser.add_argument('-p', '--production', dest='production', action='store_true', help='Example of boolean arg') |
||
| 40 | parser.add_argument('-o', '--option', dest='option', type=str, help='Example of str arg') |
||
| 41 | |||
| 42 | parser.add_argument('file', metavar='file', type=str, help='Example of a positional argument') |
||
| 43 | |||
| 44 | args = parser.parse_args() |
||
| 45 | logger.info('--------------') |
||
| 46 | |||
| 47 | # Never ask for a password in command-line. Manually ask for it here |
||
| 48 | password = getpass.getpass() |
||
| 49 | |||
| 50 | logger.info('Hello World!') |
||
| 51 |
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.