id
int64
1
6.07M
name
stringlengths
1
295
code
stringlengths
12
426k
language
stringclasses
1 value
source_file
stringlengths
5
202
start_line
int64
1
158k
end_line
int64
1
158k
repo
dict
8,701
_parse_capi
def _parse_capi(lines, filename): if isinstance(lines, str): lines = lines.splitlines() prev = None for lno, line in enumerate(lines, 1): parsed, prev = CAPIItem.from_line(line, filename, lno, prev) if parsed: yield parsed if prev: parsed, prev = CAPIItem.from...
python
Tools/c-analyzer/cpython/_capi.py
315
331
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,702
iter_capi
def iter_capi(filenames=None): for filename in iter_header_files(filenames): with open(filename) as infile: for item in _parse_capi(infile, filename): yield item
python
Tools/c-analyzer/cpython/_capi.py
334
338
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,703
resolve_filter
def resolve_filter(ignored): if not ignored: return None ignored = set(_resolve_ignored(ignored)) def filter(item, *, log=None): if item.name not in ignored: return True if log is not None: log(f'ignored {item.name!r}') return False return filter
python
Tools/c-analyzer/cpython/_capi.py
341
351
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,704
filter
def filter(item, *, log=None): if item.name not in ignored: return True if log is not None: log(f'ignored {item.name!r}') return False
python
Tools/c-analyzer/cpython/_capi.py
345
350
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,705
_resolve_ignored
def _resolve_ignored(ignored): if isinstance(ignored, str): ignored = [ignored] for raw in ignored: if isinstance(raw, str): if raw.startswith('|'): yield raw[1:] elif raw.startswith('<') and raw.endswith('>'): filename = raw[1:-1] ...
python
Tools/c-analyzer/cpython/_capi.py
354
384
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,706
_collate
def _collate(items, groupby, includeempty): groupby = _parse_groupby(groupby)[0] maxfilename = maxname = maxkind = maxlevel = 0 collated = {} groups = GROUPINGS[groupby] for group in groups: collated[group] = [] for item in items: key = getattr(item, groupby) collated[k...
python
Tools/c-analyzer/cpython/_capi.py
387
411
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,707
_get_sortkey
def _get_sortkey(sort, _groupby, _columns): if sort is True or sort is None: # For now: def sortkey(item): return ( item.level == 'private', LEVELS.index(item.level), KINDS.index(item.kind), os.path.dirname(item.file), ...
python
Tools/c-analyzer/cpython/_capi.py
414
437
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,708
sortkey
def sortkey(item): return ( item.level == 'private', LEVELS.index(item.level), KINDS.index(item.kind), os.path.dirname(item.file), os.path.basename(item.file), item.name, )
python
Tools/c-analyzer/cpython/_capi.py
417
425
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,709
resolve_format
def resolve_format(format): if not format: return 'table' elif isinstance(format, str) and format in _FORMATS: return format else: return resolve_columns(format)
python
Tools/c-analyzer/cpython/_capi.py
460
466
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,710
get_renderer
def get_renderer(format): format = resolve_format(format) if isinstance(format, str): try: return _FORMATS[format] except KeyError: raise ValueError(f'unsupported format {format!r}') else: def render(items, **kwargs): return render_table(items, col...
python
Tools/c-analyzer/cpython/_capi.py
469
479
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,711
render
def render(items, **kwargs): return render_table(items, columns=format, **kwargs)
python
Tools/c-analyzer/cpython/_capi.py
477
478
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,712
render_table
def render_table(items, *, columns=None, groupby='kind', sort=True, showempty=False, verbose=False, ): if groupby is None: groupby = 'kind' if showempty is None: showempty = False if groupb...
python
Tools/c-analyzer/cpython/_capi.py
482
570
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,713
get_extra
def get_extra(item): return {extra: getattr(item, extra) for extra in ('kind', 'level')}
python
Tools/c-analyzer/cpython/_capi.py
510
512
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,714
get_extra
def get_extra(item): return {extra: getattr(item, extra) for extra in extras}
python
Tools/c-analyzer/cpython/_capi.py
517
519
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,715
get_extra
def get_extra(item): return {m: m if getattr(item, extra) == markers[extra][m] else '' for m in markers[extra]}
python
Tools/c-analyzer/cpython/_capi.py
523
525
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,716
render_full
def render_full(items, *, groupby='kind', sort=None, showempty=None, verbose=False, ): if groupby is None: groupby = 'kind' if showempty is None: showempty = False if sort: sortkey = _get_sortkey(sort, g...
python
Tools/c-analyzer/cpython/_capi.py
573
606
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,717
_render_item_full
def _render_item_full(item, groupby, verbose): yield item.name yield f' {"filename:":10} {item.relfile}' for extra in ('kind', 'level'): yield f' {extra+":":10} {getattr(item, extra)}' if verbose: print(' ---------------------------------------') for lno, line in enumerate(ite...
python
Tools/c-analyzer/cpython/_capi.py
609
618
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,718
render_summary
def render_summary(items, *, groupby='kind', sort=None, showempty=None, verbose=False, ): if groupby is None: groupby = 'kind' summary = summarize( items, groupby=groupby, includeempty=...
python
Tools/c-analyzer/cpython/_capi.py
621
652
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,719
_resolve_filenames
def _resolve_filenames(filenames): if filenames: resolved = (_files.resolve_filename(f) for f in filenames) else: resolved = _files.iter_filenames() return resolved
python
Tools/c-analyzer/cpython/__main__.py
61
66
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,720
fmt_summary
def fmt_summary(analysis): # XXX Support sorting and grouping. supported = [] unsupported = [] for item in analysis: if item.supported: supported.append(item) else: unsupported.append(item) total = 0 def section(name, groupitems): nonlocal total ...
python
Tools/c-analyzer/cpython/__main__.py
72
107
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,721
section
def section(name, groupitems): nonlocal total items, render = c_analyzer.build_section(name, groupitems, relroot=REPO_ROOT) yield from render() total += len(items)
python
Tools/c-analyzer/cpython/__main__.py
83
88
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,722
_cli_parse
def _cli_parse(parser): process_output = c_parser.add_output_cli(parser) process_kind = add_kind_filtering_cli(parser) process_preprocessor = c_parser.add_preprocessor_cli( parser, get_preprocessor=_parser.get_preprocessor, ) process_files = add_files_cli(parser, **FILES_KWARGS) ...
python
Tools/c-analyzer/cpython/__main__.py
123
136
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,723
cmd_parse
def cmd_parse(filenames=None, **kwargs): filenames = _resolve_filenames(filenames) if 'get_file_preprocessor' not in kwargs: kwargs['get_file_preprocessor'] = _parser.get_preprocessor() c_parser.cmd_parse( filenames, relroot=REPO_ROOT, file_maxsizes=_parser.MAX_SIZES, ...
python
Tools/c-analyzer/cpython/__main__.py
139
148
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,724
_cli_check
def _cli_check(parser, **kwargs): return c_analyzer._cli_check(parser, CHECKS, **kwargs, **FILES_KWARGS)
python
Tools/c-analyzer/cpython/__main__.py
151
152
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,725
cmd_check
def cmd_check(filenames=None, **kwargs): filenames = _resolve_filenames(filenames) kwargs['get_file_preprocessor'] = _parser.get_preprocessor(log_err=print) try: c_analyzer.cmd_check( filenames, relroot=REPO_ROOT, _analyze=_analyzer.analyze, _CHECKS=CH...
python
Tools/c-analyzer/cpython/__main__.py
155
177
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,726
cmd_analyze
def cmd_analyze(filenames=None, **kwargs): formats = dict(c_analyzer.FORMATS) formats['summary'] = fmt_summary filenames = _resolve_filenames(filenames) kwargs['get_file_preprocessor'] = _parser.get_preprocessor(log_err=print) c_analyzer.cmd_analyze( filenames, relroot=REPO_ROOT, ...
python
Tools/c-analyzer/cpython/__main__.py
180
192
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,727
_cli_data
def _cli_data(parser): filenames = False known = True return c_analyzer._cli_data(parser, filenames, known)
python
Tools/c-analyzer/cpython/__main__.py
195
198
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,728
cmd_data
def cmd_data(datacmd, **kwargs): formats = dict(c_analyzer.FORMATS) formats['summary'] = fmt_summary filenames = (file for file in _resolve_filenames(None) if file not in _parser.EXCLUDED) kwargs['get_file_preprocessor'] = _parser.get_preprocessor(log_err=print) if ...
python
Tools/c-analyzer/cpython/__main__.py
201
254
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,729
analyze
def analyze(files, **kwargs): decls = [] for decl in _analyzer.iter_decls(files, **kwargs): if not KIND.is_type_decl(decl.kind): continue if not decl.filename.endswith('.h'): if decl.shortkey not in _analyzer.KNOWN_IN_DOT_C:...
python
Tools/c-analyzer/cpython/__main__.py
225
239
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,730
analyze
def analyze(files, **kwargs): return _analyzer.iter_decls(files, **kwargs)
python
Tools/c-analyzer/cpython/__main__.py
242
243
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,731
_cli_capi
def _cli_capi(parser): parser.add_argument('--levels', action='append', metavar='LEVEL[,...]') parser.add_argument(f'--public', dest='levels', action='append_const', const='public') parser.add_argument(f'--no-public', dest='levels', action='append_const', cons...
python
Tools/c-analyzer/cpython/__main__.py
257
331
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,732
process_levels
def process_levels(args, *, argv=None): levels = [] for raw in args.levels or (): for level in raw.replace(',', ' ').strip().split(): if level == 'public': levels.append('stable') levels.append('cpython') elif level == '...
python
Tools/c-analyzer/cpython/__main__.py
266
280
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,733
process_kinds
def process_kinds(args, *, argv=None): kinds = [] for raw in args.kinds or (): for kind in raw.replace(',', ' ').strip().split(): if kind in _capi.KINDS: kinds.append(kind) else: parser.error(f'expected KIND to be one of...
python
Tools/c-analyzer/cpython/__main__.py
286
294
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,734
process_format
def process_format(args, *, argv=None): orig = args.format args.format = _capi.resolve_format(args.format) if isinstance(args.format, str): if args.format not in _capi._FORMATS: parser.error(f'unsupported format {orig!r}')
python
Tools/c-analyzer/cpython/__main__.py
302
307
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,735
process_ignored
def process_ignored(args, *, argv=None): ignored = [] for raw in args.ignored or (): ignored.extend(raw.replace(',', ' ').strip().split()) args.ignored = ignored or None
python
Tools/c-analyzer/cpython/__main__.py
316
320
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,736
cmd_capi
def cmd_capi(filenames=None, *, levels=None, kinds=None, groupby='kind', format='table', showempty=None, ignored=None, track_progress=None, verbosity=VERBOSITY, **kwargs ): render = _cap...
python
Tools/c-analyzer/cpython/__main__.py
334
369
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,737
_cli_builtin_types
def _cli_builtin_types(parser): parser.add_argument('--format', dest='fmt', default='table') # parser.add_argument('--summary', dest='format', # action='store_const', const='summary') def process_format(args, *, argv=None): orig = args.fmt args.fmt = _builtin_types.reso...
python
Tools/c-analyzer/cpython/__main__.py
372
391
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,738
process_format
def process_format(args, *, argv=None): orig = args.fmt args.fmt = _builtin_types.resolve_format(args.fmt) if isinstance(args.fmt, str): if args.fmt not in _builtin_types._FORMATS: parser.error(f'unsupported format {orig!r}')
python
Tools/c-analyzer/cpython/__main__.py
376
381
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,739
process_modules
def process_modules(args, *, argv=None): pass
python
Tools/c-analyzer/cpython/__main__.py
385
386
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,740
cmd_builtin_types
def cmd_builtin_types(fmt, *, showmodules=False, verbosity=VERBOSITY, ): render = _builtin_types.get_renderer(fmt) types = _builtin_types.iter_builtin_types() match = _builtin_types.resolve_matcher(showmodules) if match: types = (...
python
Tools/c-analyzer/cpython/__main__.py
394
410
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,741
parse_args
def parse_args(argv=sys.argv[1:], prog=None, *, subset=None): import argparse parser = argparse.ArgumentParser( prog=prog or get_prog(), ) # if subset == 'check' or subset == ['check']: # if checks is not None: # commands = dict(COMMANDS) # commands['check'] = list(c...
python
Tools/c-analyzer/cpython/__main__.py
453
490
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,742
main
def main(cmd, cmd_kwargs): try: run_cmd = COMMANDS[cmd][-1] except KeyError: raise ValueError(f'unsupported cmd {cmd!r}') run_cmd(**cmd_kwargs)
python
Tools/c-analyzer/cpython/__main__.py
493
498
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,743
configure_logger
def configure_logger(logger, verbosity=VERBOSITY, *, logfile=None, maxlevel=logging.CRITICAL, ): level = max(1, # 0 disables it, so we use the next lowest. min(maxlevel, maxlevel - verbosity * 10)) logger.setLeve...
python
Tools/c-analyzer/c_common/logging.py
12
38
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,744
hide_emit_errors
def hide_emit_errors(): """Ignore errors while emitting log entries. Rather than printing a message describing the error, we show nothing. """ # For now we simply ignore all exceptions. If we wanted to ignore # specific ones (e.g. BrokenPipeError) then we would need to use # a Handler subclass...
python
Tools/c-analyzer/c_common/logging.py
41
53
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,745
restore
def restore(): logging.raiseExceptions = orig
python
Tools/c-analyzer/c_common/logging.py
51
52
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,746
__init__
def __init__(self, verbosity=VERBOSITY): self.verbosity = verbosity
python
Tools/c-analyzer/c_common/logging.py
57
58
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,747
info
def info(self, *args, **kwargs): if self.verbosity < 3: return print(*args, **kwargs)
python
Tools/c-analyzer/c_common/logging.py
60
63
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,748
__init__
def __init__(self, label): self._label = label
python
Tools/c-analyzer/c_common/misc.py
4
5
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,749
__repr__
def __repr__(self): return f'<{self._label}>'
python
Tools/c-analyzer/c_common/misc.py
6
7
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,750
get_prog
def get_prog(spec=None, *, absolute=False, allowsuffix=True): if spec is None: _, spec = _find_script() # This is more natural for prog than __file__ would be. filename = sys.argv[0] elif isinstance(spec, str): filename = os.path.normpath(spec) spec = None else: ...
python
Tools/c-analyzer/c_common/scriptutil.py
15
47
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,751
_find_script
def _find_script(): frame = sys._getframe(2) while frame.f_globals['__name__'] != '__main__': frame = frame.f_back # This should match sys.argv[0]. filename = frame.f_globals['__file__'] # This will be None if -m wasn't used.. spec = frame.f_globals['__spec__'] return filename, spec
python
Tools/c-analyzer/c_common/scriptutil.py
50
59
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,752
is_installed
def is_installed(filename, *, allowsuffix=True): if not allowsuffix and filename.endswith('.py'): return False filename = os.path.abspath(os.path.normalize(filename)) found = shutil.which(os.path.basename(filename)) if not found: return False if found != filename: return Fals...
python
Tools/c-analyzer/c_common/scriptutil.py
62
71
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,753
is_standalone
def is_standalone(filename): filename = os.path.abspath(os.path.normalize(filename)) return _is_standalone(filename)
python
Tools/c-analyzer/c_common/scriptutil.py
74
76
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,754
_is_standalone
def _is_standalone(filename): return fsutil.is_executable(filename)
python
Tools/c-analyzer/c_common/scriptutil.py
79
80
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,755
configure_logger
def configure_logger(verbosity, logger=None, **kwargs): if logger is None: # Configure the root logger. logger = logging.getLogger() loggingutil.configure_logger(logger, verbosity, **kwargs)
python
Tools/c-analyzer/c_common/scriptutil.py
95
99
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,756
__init__
def __init__(self, values, possible): self.values = tuple(values) self.possible = tuple(possible) super().__init__(f'unsupported selections {self.unique}')
python
Tools/c-analyzer/c_common/scriptutil.py
106
109
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,757
unique
def unique(self): return tuple(sorted(set(self.values)))
python
Tools/c-analyzer/c_common/scriptutil.py
112
113
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,758
normalize_selection
def normalize_selection(selected: str, *, possible=None): if selected in (None, True, False): return selected elif isinstance(selected, str): selected = [selected] elif not selected: return () unsupported = [] _selected = set() for item in selected: if not item: ...
python
Tools/c-analyzer/c_common/scriptutil.py
116
140
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,759
__new__
def __new__(cls, *args, **kwargs): return super().__new__(cls, (args, kwargs))
python
Tools/c-analyzer/c_common/scriptutil.py
147
148
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,760
__repr__
def __repr__(self): args, kwargs = self args = [repr(arg) for arg in args] for name, value in kwargs.items(): args.append(f'{name}={value!r}') return f'{type(self).__name__}({", ".join(args)})'
python
Tools/c-analyzer/c_common/scriptutil.py
150
155
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,761
__call__
def __call__(self, parser, *, _noop=(lambda a: None)): self.apply(parser) return _noop
python
Tools/c-analyzer/c_common/scriptutil.py
157
159
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,762
apply
def apply(self, parser): args, kwargs = self parser.add_argument(*args, **kwargs)
python
Tools/c-analyzer/c_common/scriptutil.py
161
163
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,763
apply_cli_argspecs
def apply_cli_argspecs(parser, specs): processors = [] for spec in specs: if callable(spec): procs = spec(parser) _add_procs(processors, procs) else: args, kwargs = spec parser.add_argument(args, kwargs) return processors
python
Tools/c-analyzer/c_common/scriptutil.py
166
175
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,764
_add_procs
def _add_procs(flattened, procs): # XXX Fail on non-empty, non-callable procs? if not procs: return if callable(procs): flattened.append(procs) else: #processors.extend(p for p in procs if callable(p)) for proc in procs: _add_procs(flattened, proc)
python
Tools/c-analyzer/c_common/scriptutil.py
178
187
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,765
add_verbosity_cli
def add_verbosity_cli(parser): parser.add_argument('-q', '--quiet', action='count', default=0) parser.add_argument('-v', '--verbose', action='count', default=0) def process_args(args, *, argv=None): ns = vars(args) key = 'verbosity' if key in ns: parser.error(f'duplicate...
python
Tools/c-analyzer/c_common/scriptutil.py
190
201
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,766
process_args
def process_args(args, *, argv=None): ns = vars(args) key = 'verbosity' if key in ns: parser.error(f'duplicate arg {key!r}') ns[key] = max(0, VERBOSITY + ns.pop('verbose') - ns.pop('quiet')) return key
python
Tools/c-analyzer/c_common/scriptutil.py
194
200
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,767
add_traceback_cli
def add_traceback_cli(parser): parser.add_argument('--traceback', '--tb', action='store_true', default=TRACEBACK) parser.add_argument('--no-traceback', '--no-tb', dest='traceback', action='store_const', const=False) def process_args(args, *, argv=None): ...
python
Tools/c-analyzer/c_common/scriptutil.py
204
243
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,768
process_args
def process_args(args, *, argv=None): ns = vars(args) key = 'traceback_cm' if key in ns: parser.error(f'duplicate arg {key!r}') showtb = ns.pop('traceback') @contextlib.contextmanager def traceback_cm(): restore = loggingutil.hide_emit_errors() ...
python
Tools/c-analyzer/c_common/scriptutil.py
210
242
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,769
traceback_cm
def traceback_cm(): restore = loggingutil.hide_emit_errors() try: yield except BrokenPipeError: # It was piped to "head" or something similar. pass except NotImplementedError: raise # re-raise ex...
python
Tools/c-analyzer/c_common/scriptutil.py
218
240
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,770
add_sepval_cli
def add_sepval_cli(parser, opt, dest, choices, *, sep=',', **kwargs): # if opt is True: # parser.add_argument(f'--{dest}', action='append', **kwargs) # elif isinstance(opt, str) and opt.startswith('-'): # parser.add_argument(opt, dest=dest, action='append', **kwargs) # else: # arg = dest i...
python
Tools/c-analyzer/c_common/scriptutil.py
246
277
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,771
process_args
def process_args(args, *, argv=None): ns = vars(args) # XXX Use normalize_selection()? if isinstance(ns[dest], str): ns[dest] = [ns[dest]] selections = [] for many in ns[dest] or (): for value in many.split(sep): if value not in choices: ...
python
Tools/c-analyzer/c_common/scriptutil.py
264
276
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,772
add_files_cli
def add_files_cli(parser, *, excluded=None, nargs=None): process_files = add_file_filtering_cli(parser, excluded=excluded) parser.add_argument('filenames', nargs=nargs or '+', metavar='FILENAME') return [ process_files, ]
python
Tools/c-analyzer/c_common/scriptutil.py
280
285
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,773
add_file_filtering_cli
def add_file_filtering_cli(parser, *, excluded=None): parser.add_argument('--start') parser.add_argument('--include', action='append') parser.add_argument('--exclude', action='append') excluded = tuple(excluded or ()) def process_args(args, *, argv=None): ns = vars(args) key = 'ite...
python
Tools/c-analyzer/c_common/scriptutil.py
288
312
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,774
process_args
def process_args(args, *, argv=None): ns = vars(args) key = 'iter_filenames' if key in ns: parser.error(f'duplicate arg {key!r}') _include = tuple(ns.pop('include') or ()) _exclude = excluded + tuple(ns.pop('exclude') or ()) kwargs = dict( start=n...
python
Tools/c-analyzer/c_common/scriptutil.py
295
311
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,775
process_filenames
def process_filenames(filenames, relroot=None): return fsutil.process_filenames(filenames, relroot=relroot, **kwargs)
python
Tools/c-analyzer/c_common/scriptutil.py
309
310
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,776
_parse_files
def _parse_files(filenames): for filename, _ in strutil.parse_entries(filenames): yield filename.strip()
python
Tools/c-analyzer/c_common/scriptutil.py
315
317
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,777
add_progress_cli
def add_progress_cli(parser, *, threshold=VERBOSITY, **kwargs): parser.add_argument('--progress', dest='track_progress', action='store_const', const=True) parser.add_argument('--no-progress', dest='track_progress', action='store_false') parser.set_defaults(track_progress=True) def process_args(args, *,...
python
Tools/c-analyzer/c_common/scriptutil.py
320
333
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,778
process_args
def process_args(args, *, argv=None): if args.track_progress: ns = vars(args) verbosity = ns.get('verbosity', VERBOSITY) if verbosity <= threshold: args.track_progress = track_progress_compact else: args.track_progress = track_progr...
python
Tools/c-analyzer/c_common/scriptutil.py
325
332
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,779
add_failure_filtering_cli
def add_failure_filtering_cli(parser, pool, *, default=False): parser.add_argument('--fail', action='append', metavar=f'"{{all|{"|".join(sorted(pool))}}},..."') parser.add_argument('--no-fail', dest='fail', action='store_const', const=()) def process_args(args, *, argv=None): ...
python
Tools/c-analyzer/c_common/scriptutil.py
336
367
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,780
process_args
def process_args(args, *, argv=None): ns = vars(args) fail = ns.pop('fail') try: fail = normalize_selection(fail, possible=pool) except UnsupportedSelectionError as exc: parser.error(f'invalid --fail values: {", ".join(exc.unique)}') else: if ...
python
Tools/c-analyzer/c_common/scriptutil.py
341
366
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,781
ignore_exc
def ignore_exc(_exc): return False
python
Tools/c-analyzer/c_common/scriptutil.py
354
355
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,782
ignore_exc
def ignore_exc(_exc): return True
python
Tools/c-analyzer/c_common/scriptutil.py
357
358
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,783
ignore_exc
def ignore_exc(exc): for err in fail: if type(exc) == pool[err]: return False else: return True
python
Tools/c-analyzer/c_common/scriptutil.py
360
365
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,784
add_kind_filtering_cli
def add_kind_filtering_cli(parser, *, default=None): parser.add_argument('--kinds', action='append') def process_args(args, *, argv=None): ns = vars(args) kinds = [] for kind in ns.pop('kinds') or default or (): kinds.extend(kind.strip().replace(',', ' ').split()) ...
python
Tools/c-analyzer/c_common/scriptutil.py
370
404
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,785
process_args
def process_args(args, *, argv=None): ns = vars(args) kinds = [] for kind in ns.pop('kinds') or default or (): kinds.extend(kind.strip().replace(',', ' ').split()) if not kinds: match_kind = (lambda k: True) else: included = set() ...
python
Tools/c-analyzer/c_common/scriptutil.py
373
403
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,786
match_kind
def match_kind(kind, *, _excluded=excluded): return kind not in _excluded
python
Tools/c-analyzer/c_common/scriptutil.py
398
399
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,787
match_kind
def match_kind(kind, *, _included=included): return kind in _included
python
Tools/c-analyzer/c_common/scriptutil.py
401
402
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,788
add_commands_cli
def add_commands_cli(parser, commands, *, commonspecs=COMMON_CLI, subset=None): arg_processors = {} if isinstance(subset, str): cmdname = subset try: _, argspecs, _ = commands[cmdname] except KeyError: raise ValueError(f'unsupported subset {subset!r}') par...
python
Tools/c-analyzer/c_common/scriptutil.py
414
450
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,789
_add_cmd_cli
def _add_cmd_cli(parser, commonspecs, argspecs): processors = [] argspecs = list(commonspecs or ()) + list(argspecs or ()) for argspec in argspecs: if callable(argspec): procs = argspec(parser) _add_procs(processors, procs) else: if not argspec: ...
python
Tools/c-analyzer/c_common/scriptutil.py
453
475
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,790
_flatten_processors
def _flatten_processors(processors): for proc in processors: if proc is None: continue if callable(proc): yield proc else: yield from _flatten_processors(proc)
python
Tools/c-analyzer/c_common/scriptutil.py
478
485
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,791
process_args
def process_args(args, argv, processors, *, keys=None): processors = _flatten_processors(processors) ns = vars(args) extracted = {} if keys is None: for process_args in processors: for key in process_args(args, argv=argv): extracted[key] = ns.pop(key) else: ...
python
Tools/c-analyzer/c_common/scriptutil.py
488
509
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,792
process_args_by_key
def process_args_by_key(args, argv, processors, keys): extracted = process_args(args, argv, processors, keys=keys) return [extracted[key] for key in keys]
python
Tools/c-analyzer/c_common/scriptutil.py
512
514
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,793
set_command
def set_command(name, add_cli): """A decorator factory to set CLI info.""" def decorator(func): if hasattr(func, '__cli__'): raise Exception(f'already set') func.__cli__ = (name, add_cli) return func return decorator
python
Tools/c-analyzer/c_common/scriptutil.py
520
527
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,794
decorator
def decorator(func): if hasattr(func, '__cli__'): raise Exception(f'already set') func.__cli__ = (name, add_cli) return func
python
Tools/c-analyzer/c_common/scriptutil.py
522
526
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,795
filter_filenames
def filter_filenames(filenames, process_filenames=None, relroot=fsutil.USE_CWD): # We expect each filename to be a normalized, absolute path. for filename, _, check, _ in _iter_filenames(filenames, process_filenames, relroot): if (reason := check()): logger.debug(f'{filename}: {reason}') ...
python
Tools/c-analyzer/c_common/scriptutil.py
533
539
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,796
main_for_filenames
def main_for_filenames(filenames, process_filenames=None, relroot=fsutil.USE_CWD): filenames, relroot = fsutil.fix_filenames(filenames, relroot=relroot) for filename, relfile, check, show in _iter_filenames(filenames, process_filenames, relroot): if show: print() print(relfile) ...
python
Tools/c-analyzer/c_common/scriptutil.py
542
552
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,797
_iter_filenames
def _iter_filenames(filenames, process, relroot): if process is None: yield from fsutil.process_filenames(filenames, relroot=relroot) return onempty = Exception('no filenames provided') items = process(filenames, relroot=relroot) items, peeked = iterutil.peek_and_iter(items) if not ...
python
Tools/c-analyzer/c_common/scriptutil.py
555
575
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,798
track_progress_compact
def track_progress_compact(items, *, groups=5, **mark_kwargs): last = os.linesep marks = iter_marks(groups=groups, **mark_kwargs) for item in items: last = next(marks) print(last, end='', flush=True) yield item if not last.endswith(os.linesep): print()
python
Tools/c-analyzer/c_common/scriptutil.py
578
586
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,799
track_progress_flat
def track_progress_flat(items, fmt='<{}>'): for item in items: print(fmt.format(item), flush=True) yield item
python
Tools/c-analyzer/c_common/scriptutil.py
589
592
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,800
iter_marks
def iter_marks(mark='.', *, group=5, groups=2, lines=_NOT_SET, sep=' '): mark = mark or '' group = group if group and group > 1 else 1 groups = groups if groups and groups > 1 else 1 sep = f'{mark}{sep}' if sep else mark end = f'{mark}{os.linesep}' div = os.linesep perline = group * groups ...
python
Tools/c-analyzer/c_common/scriptutil.py
595
627
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }