MCPcopy Index your code
hub / github.com/cirosantilli/linux-kernel-module-cheat / __init__

Method __init__

common.py:122–394  ·  view source on GitHub ↗

:ptype defaults: Dict[str,Any] :param defaults: override the default value of an argument

(self, *args, defaults=None, supported_archs=None, **kwargs)

Source from the content-addressed store, hash-verified

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='''\
147Run 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='''\
158CPU architecture to use. If given multiple times, run the action
159for each arch sequentially in that order. If one of them fails, stop running.
160Valid archs: {}
161'''.format(arches_string)
162 )
163 self.add_argument(
164 '--dry-run',
165 default=False,
166 help='''\
167Print the commands that would be run, but don't run them.
168
169We aim display every command that modifies the filesystem state, and generate
170Bash equivalents even for actions taken directly in Python without shelling out.
171
172mkdir are generally omitted since those are obvious
173'''
174 )
175 self.add_argument(
176 '--print-time', default=True,
177 help='''\
178Print how long it took to run the command at the end.
179Implied by --quiet.

Callers

nothing calls this directly

Calls 3

add_argumentMethod · 0.95
joinMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected