| 42 | |
| 43 | |
| 44 | class ArgsParser(ArgumentParser): |
| 45 | def __init__(self): |
| 46 | super(ArgsParser, self).__init__(formatter_class=RawDescriptionHelpFormatter) |
| 47 | self.add_argument("-c", "--config", help="configuration file to use") |
| 48 | self.add_argument("-o", "--opt", nargs="+", help="set configuration options") |
| 49 | self.add_argument( |
| 50 | "-p", |
| 51 | "--profiler_options", |
| 52 | type=str, |
| 53 | default=None, |
| 54 | help="The option of profiler, which should be in format " |
| 55 | '"key1=value1;key2=value2;key3=value3".', |
| 56 | ) |
| 57 | |
| 58 | def parse_args(self, argv=None): |
| 59 | args = super(ArgsParser, self).parse_args(argv) |
| 60 | assert args.config is not None, "Please specify --config=configure_file_path." |
| 61 | args.opt = self._parse_opt(args.opt) |
| 62 | return args |
| 63 | |
| 64 | def _parse_opt(self, opts): |
| 65 | config = {} |
| 66 | if not opts: |
| 67 | return config |
| 68 | for s in opts: |
| 69 | s = s.strip() |
| 70 | k, v = s.split("=") |
| 71 | config[k] = yaml.load(v, Loader=yaml.SafeLoader) |
| 72 | return config |
| 73 | |
| 74 | |
| 75 | def load_config(file_path): |
no outgoing calls
no test coverage detected
searching dependent graphs…