:ptype defaults: Dict[str,Any] :param defaults: override the default value of an argument
(self, *args, defaults=None, supported_archs=None, **kwargs)
| 120 | * some common flags, e.g.: --arch, --dry-run, --quiet, --verbose |
| 121 | ''' |
| 122 | def __init__(self, *args, defaults=None, supported_archs=None, **kwargs): |
| 123 | ''' |
| 124 | :ptype defaults: Dict[str,Any] |
| 125 | :param defaults: override the default value of an argument |
| 126 | ''' |
| 127 | kwargs['config_file'] = consts['config_file'] |
| 128 | kwargs['extra_config_params'] = os.path.basename(inspect.getfile(self.__class__)) |
| 129 | if defaults is None: |
| 130 | defaults = {} |
| 131 | self._defaults = defaults |
| 132 | self._is_common = True |
| 133 | self._common_args = set() |
| 134 | super().__init__(*args, **kwargs) |
| 135 | self.supported_archs = supported_archs |
| 136 | |
| 137 | # Args for all scripts. |
| 138 | arches = consts['arch_short_to_long_dict'] |
| 139 | arches_string = [] |
| 140 | for arch_short in arches: |
| 141 | arch_long = arches[arch_short] |
| 142 | arches_string.append('{} ({})'.format(arch_long, arch_short)) |
| 143 | arches_string = ', '.join(arches_string) |
| 144 | self.add_argument( |
| 145 | '-A', '--all-archs', default=False, |
| 146 | help='''\ |
| 147 | Run action for all supported --archs archs. Ignore --archs. |
| 148 | '''.format(arches_string) |
| 149 | ) |
| 150 | self.add_argument( |
| 151 | '-a', |
| 152 | '--arch', |
| 153 | action='append', |
| 154 | choices=consts['arch_choices'], |
| 155 | default=[consts['default_arch']], |
| 156 | dest='archs', |
| 157 | help='''\ |
| 158 | CPU architecture to use. If given multiple times, run the action |
| 159 | for each arch sequentially in that order. If one of them fails, stop running. |
| 160 | Valid archs: {} |
| 161 | '''.format(arches_string) |
| 162 | ) |
| 163 | self.add_argument( |
| 164 | '--dry-run', |
| 165 | default=False, |
| 166 | help='''\ |
| 167 | Print the commands that would be run, but don't run them. |
| 168 | |
| 169 | We aim display every command that modifies the filesystem state, and generate |
| 170 | Bash equivalents even for actions taken directly in Python without shelling out. |
| 171 | |
| 172 | mkdir are generally omitted since those are obvious |
| 173 | ''' |
| 174 | ) |
| 175 | self.add_argument( |
| 176 | '--print-time', default=True, |
| 177 | help='''\ |
| 178 | Print how long it took to run the command at the end. |
| 179 | Implied by --quiet. |
nothing calls this directly
no test coverage detected