| Total Complexity | 1 |
| Total Lines | 43 |
| Duplicated Lines | 37.21 % |
| 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 ServerResponse(InstitutionID, protocolName): |
||
| 12 | logger = logging.getLogger('LORISServerResponse') |
||
| 13 | |||
| 14 | #Resolved protocolname to CNBPID pattern. |
||
| 15 | |||
| 16 | |||
| 17 | #if "protocol" |
||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | View Code Duplication | if __name__ == '__main__': |
|
|
|
|||
| 28 | |||
| 29 | parser = argparse.ArgumentParser(description=__doc__) |
||
| 30 | parser.add_argument('-u', '--user', dest='email', type=str, help='Username/Email used for login') |
||
| 31 | parser.add_argument('-p', '--production', dest='production', action='store_true', help='Example of boolean arg') |
||
| 32 | parser.add_argument('-o', '--option', dest='option', type=str, help='Example of str arg') |
||
| 33 | |||
| 34 | parser.add_argument('file', metavar='file', type=str, help='Example of a positional argument') |
||
| 35 | |||
| 36 | args = parser.parse_args() |
||
| 37 | logger.info('--------------') |
||
| 38 | |||
| 39 | # Never ask for a password in command-line. Manually ask for it here |
||
| 40 | password = getpass.getpass() |
||
| 41 | |||
| 42 | logger.info('Hello World!') |
||
| 43 |