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,601
run_cmd
def run_cmd(argv, *, #capture_output=True, stdout=subprocess.PIPE, #stderr=subprocess.STDOUT, stderr=subprocess.PIPE, text=True, check=True, **kwargs ): if isinstance(stderr, str) and stderr.lower() == 'stdout': ...
python
Tools/c-analyzer/c_parser/preprocessor/common.py
27
50
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,602
preprocess
def preprocess(tool, filename, cwd=None, **kwargs): argv = _build_argv(tool, filename, **kwargs) logger.debug(' '.join(shlex.quote(v) for v in argv)) # Make sure the OS is supported for this file. if (_expected := is_os_mismatch(filename)): error = None raise OSMismatchError(filename, _...
python
Tools/c-analyzer/c_parser/preprocessor/common.py
53
68
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,603
_build_argv
def _build_argv( tool, filename, incldirs=None, includes=None, macros=None, preargs=None, postargs=None, executable=None, compiler=None, ): if includes: includes = tuple(f'-include{i}' for i in includes) postargs = (includes + postargs) if postargs else includes ...
python
Tools/c-analyzer/c_parser/preprocessor/common.py
71
104
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,604
_spawn
def _spawn(_argv): nonlocal argv argv = _argv
python
Tools/c-analyzer/c_parser/preprocessor/common.py
93
95
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,605
converted_error
def converted_error(tool, argv, filename): try: yield except subprocess.CalledProcessError as exc: convert_error( tool, argv, filename, exc.stderr, exc.returncode, )
python
Tools/c-analyzer/c_parser/preprocessor/common.py
108
118
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,606
convert_error
def convert_error(tool, argv, filename, stderr, rc): error = (stderr.splitlines()[0], rc) if (_expected := is_os_mismatch(filename, stderr)): logger.info(stderr.strip()) raise OSMismatchError(filename, _expected, argv, error, tool) elif (_missing := is_missing_dep(stderr)): logger.in...
python
Tools/c-analyzer/c_parser/preprocessor/common.py
121
139
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,607
is_os_mismatch
def is_os_mismatch(filename, errtext=None): # See: https://docs.python.org/3/library/sys.html#sys.platform actual = sys.platform if actual == 'unknown': raise NotImplementedError if errtext is not None: if (missing := is_missing_dep(errtext)): matching = get_matching_oses(mi...
python
Tools/c-analyzer/c_parser/preprocessor/common.py
142
153
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,608
get_matching_oses
def get_matching_oses(missing, filename): # OSX if 'darwin' in filename or 'osx' in filename: return ('darwin',) elif missing == 'SystemConfiguration/SystemConfiguration.h': return ('darwin',) # Windows elif missing in ('windows.h', 'winsock2.h'): return ('win32',) # ot...
python
Tools/c-analyzer/c_parser/preprocessor/common.py
156
177
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,609
is_missing_dep
def is_missing_dep(errtext): if 'No such file or directory' in errtext: missing = errtext.split(': No such file or directory')[0].split()[-1] return missing return False
python
Tools/c-analyzer/c_parser/preprocessor/common.py
180
184
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,610
preprocess
def preprocess(filename, incldirs=None, includes=None, macros=None, samefiles=None, cwd=None, ): if not cwd or not os.path.isabs(cwd): cwd = os.path.abspath(cwd or '.') filename = _normpath(filename, cwd) post...
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
69
99
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,611
_iter_lines
def _iter_lines(text, reqfile, samefiles, cwd, raw=False): lines = iter(text.splitlines()) # The first line is special. # The next two lines are consistent. firstlines = [ f'# 0 "{reqfile}"', '# 0 "<built-in>"', '# 0 "<command-line>"', ] if text.startswith('# 1 '): ...
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
102
144
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,612
_iter_top_include_lines
def _iter_top_include_lines(lines, topfile, cwd, filter_reqfile, make_info, raw): partial = 0 # depth files = [topfile] # We start at 1 in case there are source lines (including blank onces) # before the first marker line. Also, we already verifi...
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
147
205
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,613
_parse_marker_line
def _parse_marker_line(line, reqfile=None): m = LINE_MARKER_RE.match(line) if not m: return None, None, None lno, origfile, flags = m.groups() lno = int(lno) assert origfile not in META_FILES, (line,) assert lno > 0, (line, lno) flags = set(int(f) for f in flags.split()) if flags els...
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
208
233
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,614
_strip_directives
def _strip_directives(line, partial=0): # We assume there are no string literals with parens in directive bodies. while partial > 0: if not (m := re.match(r'[^{}]*([()])', line)): return None, partial delim, = m.groups() partial += 1 if delim == '(' else -1 # opened/closed ...
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
236
258
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,615
_filter_reqfile
def _filter_reqfile(current, reqfile, samefiles): if current == reqfile: return True if current == '<stdin>': return True if current in samefiles: return True return False
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
261
268
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,616
_normpath
def _normpath(filename, cwd): assert cwd return os.path.normpath(os.path.join(cwd, filename))
python
Tools/c-analyzer/c_parser/preprocessor/gcc.py
271
273
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,617
_as_tuple
def _as_tuple(items): if isinstance(items, str): return tuple(items.strip().replace(',', ' ').split()) elif items: return tuple(items) else: return ()
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
7
13
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,618
_msg
def _msg(cls, filename, reason, **ignored): msg = 'failure while preprocessing' if reason: msg = f'{msg} ({reason})' return msg
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
20
24
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,619
__init__
def __init__(self, filename, preprocessor=None, reason=None): if isinstance(reason, str): reason = reason.strip() self.filename = filename self.preprocessor = preprocessor or None self.reason = str(reason) if reason else None msg = self._msg(**vars(self)) ms...
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
26
38
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,620
_msg
def _msg(cls, error, **ignored): msg = 'preprocessor command failed' if error: msg = f'{msg} {error}' return msg
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
45
49
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,621
__init__
def __init__(self, filename, argv, error=None, preprocessor=None): exitcode = -1 if isinstance(error, tuple): if len(error) == 2: error, exitcode = error else: error = str(error) if isinstance(error, str): error = error.strip() ...
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
51
66
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,622
_msg
def _msg(cls, error, **ignored): return f'#error directive hit ({error})'
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
73
74
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,623
__init__
def __init__(self, filename, argv, error, *args, **kwargs): super().__init__(filename, argv, error, *args, **kwargs)
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
76
77
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,624
_msg
def _msg(cls, missing, **ignored): msg = 'preprocessing failed due to missing dependencies' if missing: msg = f'{msg} ({", ".join(missing)})' return msg
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
84
88
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,625
__init__
def __init__(self, filename, missing=None, *args, **kwargs): self.missing = _as_tuple(missing) or None super().__init__(filename, *args, **kwargs)
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
90
93
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,626
_msg
def _msg(cls, expected, **ignored): return f'OS is {OS} but expected {expected or "???"}'
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
100
101
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,627
__init__
def __init__(self, filename, expected=None, *args, **kwargs): if isinstance(expected, str): expected = expected.strip() self.actual = OS self.expected = expected if expected else None super().__init__(filename, None, *args, **kwargs)
python
Tools/c-analyzer/c_parser/preprocessor/errors.py
103
110
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,628
add_common_cli
def add_common_cli(parser, *, get_preprocessor=_get_preprocessor): parser.add_argument('--macros', action='append') parser.add_argument('--incldirs', action='append') parser.add_argument('--same', action='append') process_fail_arg = add_failure_filtering_cli(parser, FAIL) def process_args(args, *, ...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
36
56
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,629
process_args
def process_args(args, *, argv): ns = vars(args) process_fail_arg(args, argv=argv) ignore_exc = ns.pop('ignore_exc') # We later pass ignore_exc to _get_preprocessor(). args.get_file_preprocessor = get_preprocessor( file_macros=ns.pop('macros'), file_incl...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
42
55
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,630
_iter_preprocessed
def _iter_preprocessed(filename, *, get_preprocessor, match_kind=None, pure=False, ): preprocess = get_preprocessor(filename) for line in preprocess(tool=not pure) or (): if match_kind is not None and not match_k...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
59
68
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,631
_cli_preprocess
def _cli_preprocess(parser, excluded=None, **prepr_kwargs): parser.add_argument('--pure', action='store_true') parser.add_argument('--no-pure', dest='pure', action='store_const', const=False) process_kinds = add_kind_filtering_cli(parser) process_common = add_common_cli(parser, **prepr_kwargs) parse...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
74
86
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,632
cmd_preprocess
def cmd_preprocess(filenames, *, raw=False, iter_filenames=None, **kwargs ): if 'get_file_preprocessor' not in kwargs: kwargs['get_file_preprocessor'] = _get_preprocessor() if raw: def show_file(filename, lines): ...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
89
116
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,633
show_file
def show_file(filename, lines): for line in lines: print(line) #print(line.raw)
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
97
100
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,634
show_file
def show_file(filename, lines): for line in lines: linefile = '' if line.filename != filename: linefile = f' ({line.filename})' text = line.data if line.kind == 'comment': text = '/* ' + line.data.splitli...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
102
111
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,635
_cli_data
def _cli_data(parser): ... return None
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
119
122
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,636
cmd_data
def cmd_data(filenames, **kwargs ): # XXX raise NotImplementedError
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
125
129
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,637
parse_args
def parse_args(argv=sys.argv[1:], prog=sys.argv[0], *, subset='preprocess', excluded=None, **prepr_kwargs ): import argparse parser = argparse.ArgumentParser( prog=prog or get_prog(), ) processors = add_commands_cli( parser, ...
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
149
181
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,638
main
def main(cmd, cmd_kwargs): try: run_cmd = COMMANDS[cmd][0] except KeyError: raise ValueError(f'unsupported cmd {cmd!r}') run_cmd(**cmd_kwargs)
python
Tools/c-analyzer/c_parser/preprocessor/__main__.py
184
189
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,639
_parse_line
def _parse_line(line): m = re.match(REGEX, line) if not m: return None (static, extern, capi, name, def_, decl, excname, ) = m.groups() if def_: isdecl = False if extern or capi: raise NotImplementedError(line) kind = 'static' if static els...
python
Tools/c-analyzer/cpython/_builtin_types.py
66
94
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,640
from_line
def from_line(cls, line, filename, lno): # This is similar to ._capi.CAPIItem.from_line(). parsed = _parse_line(line) if not parsed: return None name, isdecl, kind = parsed if not isdecl: return None return cls.from_parsed(name, kind, filename, lno...
python
Tools/c-analyzer/cpython/_builtin_types.py
107
115
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,641
from_parsed
def from_parsed(cls, name, kind, filename, lno): if not kind: kind = 'forward' return cls.from_values(filename, lno, name, kind)
python
Tools/c-analyzer/cpython/_builtin_types.py
118
121
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,642
from_values
def from_values(cls, filename, lno, name, kind): if kind not in cls.KINDS: raise ValueError(f'unsupported kind {kind!r}') self = cls(filename, lno, name, kind) if self.kind not in ('extern', 'capi') and self.api: raise NotImplementedError(self) elif self.kind == '...
python
Tools/c-analyzer/cpython/_builtin_types.py
124
132
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,643
relfile
def relfile(self): return self.file[len(REPO_ROOT) + 1:]
python
Tools/c-analyzer/cpython/_builtin_types.py
135
136
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,644
api
def api(self): return self.relfile.startswith(CAPI_PREFIX)
python
Tools/c-analyzer/cpython/_builtin_types.py
139
140
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,645
internal
def internal(self): return self.relfile.startswith(INTERNAL_PREFIX)
python
Tools/c-analyzer/cpython/_builtin_types.py
143
144
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,646
private
def private(self): if not self.name.startswith('_'): return False return self.api and not self.internal
python
Tools/c-analyzer/cpython/_builtin_types.py
147
150
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,647
public
def public(self): if self.kind != 'capi': return False return not self.internal and not self.private
python
Tools/c-analyzer/cpython/_builtin_types.py
153
156
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,648
from_line
def from_line(cls, line, filename, lno, *, decls=None): parsed = _parse_line(line) if not parsed: return None name, isdecl, kind = parsed if isdecl: return None return cls.from_parsed(name, kind, filename, lno, decls=decls)
python
Tools/c-analyzer/cpython/_builtin_types.py
162
169
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,649
from_parsed
def from_parsed(cls, name, kind, filename, lno, *, decls=None): if not kind: static = False elif kind == 'static': static = True else: raise NotImplementedError((filename, line, kind)) decl = decls.get(name) if decls else None return cls(filena...
python
Tools/c-analyzer/cpython/_builtin_types.py
172
180
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,650
relfile
def relfile(self): return self.file[len(REPO_ROOT) + 1:]
python
Tools/c-analyzer/cpython/_builtin_types.py
183
184
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,651
exported
def exported(self): return not self.static
python
Tools/c-analyzer/cpython/_builtin_types.py
187
188
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,652
api
def api(self): if not self.decl: return False return self.decl.api
python
Tools/c-analyzer/cpython/_builtin_types.py
191
194
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,653
internal
def internal(self): if not self.decl: return False return self.decl.internal
python
Tools/c-analyzer/cpython/_builtin_types.py
197
200
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,654
private
def private(self): if not self.decl: return False return self.decl.private
python
Tools/c-analyzer/cpython/_builtin_types.py
203
206
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,655
public
def public(self): if not self.decl: return False return self.decl.public
python
Tools/c-analyzer/cpython/_builtin_types.py
209
212
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,656
inmodule
def inmodule(self): return self.relfile.startswith('Modules' + os.path.sep)
python
Tools/c-analyzer/cpython/_builtin_types.py
215
216
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,657
render_rowvalues
def render_rowvalues(self, kinds): row = { 'name': self.name, **{k: '' for k in kinds}, 'filename': f'{self.relfile}:{self.lno}', } if self.static: kind = 'static' else: if self.internal: kind = 'internal' ...
python
Tools/c-analyzer/cpython/_builtin_types.py
218
237
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,658
_ensure_decl
def _ensure_decl(decl, decls): prev = decls.get(decl.name) if prev: if decl.kind == 'forward': return None if prev.kind != 'forward': if decl.kind == prev.kind and decl.file == prev.file: assert decl.lno != prev.lno, (decl, prev) return Non...
python
Tools/c-analyzer/cpython/_builtin_types.py
240
250
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,659
iter_builtin_types
def iter_builtin_types(filenames=None): decls = {} seen = set() for filename in iter_header_files(): seen.add(filename) with open(filename) as infile: for lno, line in enumerate(infile, 1): decl = BuiltinTypeDecl.from_line(line, filename, lno) if n...
python
Tools/c-analyzer/cpython/_builtin_types.py
253
297
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,660
resolve_matcher
def resolve_matcher(showmodules=False): def match(info, *, log=None): if not info.inmodule: return True if log is not None: log(f'ignored {info.name!r}') return False return match
python
Tools/c-analyzer/cpython/_builtin_types.py
300
307
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,661
match
def match(info, *, log=None): if not info.inmodule: return True if log is not None: log(f'ignored {info.name!r}') return False
python
Tools/c-analyzer/cpython/_builtin_types.py
301
306
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,662
resolve_format
def resolve_format(fmt): if not fmt: return 'table' elif isinstance(fmt, str) and fmt in _FORMATS: return fmt else: raise NotImplementedError(fmt)
python
Tools/c-analyzer/cpython/_builtin_types.py
313
319
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,663
get_renderer
def get_renderer(fmt): fmt = resolve_format(fmt) if isinstance(fmt, str): try: return _FORMATS[fmt] except KeyError: raise ValueError(f'unsupported format {fmt!r}') else: raise NotImplementedError(fmt)
python
Tools/c-analyzer/cpython/_builtin_types.py
322
330
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,664
render_table
def render_table(types): types = sorted(types, key=(lambda t: t.name)) colspecs = tables.resolve_columns( 'name:<33 static:^ global:^ internal:^ private:^ public:^ filename:<30') header, div, rowfmt = tables.build_table(colspecs) leader = ' ' * sum(c.width+2 for c in colspecs[:3]) + ' ' ...
python
Tools/c-analyzer/cpython/_builtin_types.py
333
354
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,665
render_repr
def render_repr(types): for t in types: yield repr(t)
python
Tools/c-analyzer/cpython/_builtin_types.py
357
359
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,666
read_known
def read_known(): if not _KNOWN: # Cache a copy the first time. extracols = None # XXX #extracols = ['unsupported'] known = _datafiles.read_known(KNOWN_FILE, extracols, REPO_ROOT) # For now we ignore known.values() (i.e. "extra"). types, _ = _datafiles.analyze_known(...
python
Tools/c-analyzer/cpython/_analyzer.py
101
113
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,667
write_known
def write_known(): raise NotImplementedError datafiles.write_known(decls, IGNORED_FILE, ['unsupported'], relroot=REPO_ROOT)
python
Tools/c-analyzer/cpython/_analyzer.py
116
118
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,668
read_ignored
def read_ignored(): if not _IGNORED: _IGNORED.update(_datafiles.read_ignored(IGNORED_FILE, relroot=REPO_ROOT)) _IGNORED.update(_datafiles.read_ignored(NEED_FIX_FILE, relroot=REPO_ROOT)) return dict(_IGNORED)
python
Tools/c-analyzer/cpython/_analyzer.py
121
125
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,669
write_ignored
def write_ignored(): raise NotImplementedError _datafiles.write_ignored(variables, IGNORED_FILE, relroot=REPO_ROOT)
python
Tools/c-analyzer/cpython/_analyzer.py
128
130
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,670
analyze
def analyze(filenames, *, skip_objects=False, **kwargs ): if skip_objects: # XXX Set up a filter. raise NotImplementedError known = read_known() decls = iter_decls(filenames) results = _c_analyzer.analyze_decls( decls, known, ...
python
Tools/c-analyzer/cpython/_analyzer.py
133
151
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,671
iter_decls
def iter_decls(filenames, **kwargs): decls = _c_analyzer.iter_decls( filenames, # We ignore functions (and statements). kinds=KINDS, parse_files=_parser.parse_files, **kwargs ) for decl in decls: if not decl.data: # Ignore forward declarations. ...
python
Tools/c-analyzer/cpython/_analyzer.py
154
166
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,672
analyze_resolved
def analyze_resolved(resolved, decl, types, knowntypes, extra=None): if decl.kind not in KINDS: # Skip it! return None typedeps = resolved if typedeps is _info.UNKNOWN: if decl.kind in (KIND.STRUCT, KIND.UNION): typedeps = [typedeps] * len(decl.members) else: ...
python
Tools/c-analyzer/cpython/_analyzer.py
169
190
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,673
_check_unsupported
def _check_unsupported(decl, typedeps, types, knowntypes): if typedeps is None: raise NotImplementedError(decl) if decl.kind in (KIND.STRUCT, KIND.UNION): return _check_members(decl, typedeps, types, knowntypes) elif decl.kind is KIND.ENUM: if typedeps: raise NotImplemen...
python
Tools/c-analyzer/cpython/_analyzer.py
193
204
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,674
_check_members
def _check_members(decl, typedeps, types, knowntypes): if isinstance(typedeps, TypeDeclaration): raise NotImplementedError((decl, typedeps)) #members = decl.members or () # A forward decl has no members. members = decl.members if not members: # A forward decl has no members, but that s...
python
Tools/c-analyzer/cpython/_analyzer.py
207
228
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,675
_check_typedep
def _check_typedep(decl, typedecl, types, knowntypes): if not isinstance(typedecl, TypeDeclaration): if hasattr(type(typedecl), '__len__'): if len(typedecl) == 1: typedecl, = typedecl if typedecl is None: # XXX Fail? return 'typespec (missing)' elif typede...
python
Tools/c-analyzer/cpython/_analyzer.py
231
263
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,676
_is_kwlist
def _is_kwlist(decl): # keywords for PyArg_ParseTupleAndKeywords() # "static char *name[]" -> "static const char * const name[]" # XXX These should be made const. for relpath, name in _KWLIST_VARIANTS: if decl.name == name: if relpath == '*': break assert ...
python
Tools/c-analyzer/cpython/_analyzer.py
266
281
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,677
_has_other_supported_type
def _has_other_supported_type(decl): if hasattr(decl, 'file') and decl.file.filename.endswith('.c.h'): assert 'clinic' in decl.file.filename, (decl,) if decl.name == '_kwtuple': return True vartype = str(decl.vartype).split() if vartype[0] == 'struct': vartype = vartype[1...
python
Tools/c-analyzer/cpython/_analyzer.py
284
293
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,678
_check_vartype
def _check_vartype(decl, typedecl, types, knowntypes): """Return failure reason.""" checked = _check_typespec(decl, typedecl, types, knowntypes) if checked: return checked if is_immutable(decl.vartype): return None if is_fixed_type(decl.vartype): return FIXED_TYPE return ...
python
Tools/c-analyzer/cpython/_analyzer.py
296
305
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,679
_check_typespec
def _check_typespec(decl, typedecl, types, knowntypes): typespec = decl.vartype.typespec if typedecl is not None: found = types.get(typedecl) if found is None: found = knowntypes.get(typedecl) if found is not None: _, extra = found if extra is None: ...
python
Tools/c-analyzer/cpython/_analyzer.py
308
331
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,680
is_target
def is_target(cls, raw): if not super().is_target(raw): return False if raw.kind not in KINDS: return False return True
python
Tools/c-analyzer/cpython/_analyzer.py
337
342
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,681
__init__
def __init__(self, item, typedecl=None, *, unsupported=None, **extra): if 'unsupported' in extra: raise NotImplementedError((item, typedecl, unsupported, extra)) if not unsupported: unsupported = None elif isinstance(unsupported, (str, TypeDeclaration)): unsup...
python
Tools/c-analyzer/cpython/_analyzer.py
351
371
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,682
render
def render(self, fmt='line', *, itemonly=False): if fmt == 'raw': yield repr(self) return rendered = super().render(fmt, itemonly=itemonly) # XXX ??? #if itemonly: # yield from rendered supported = self.supported if fmt in ('line', 'brie...
python
Tools/c-analyzer/cpython/_analyzer.py
373
396
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,683
build_item
def build_item(cls, info, result=None): if not isinstance(info, Declaration) or info.kind not in KINDS: raise NotImplementedError((info, result)) return super().build_item(info, result)
python
Tools/c-analyzer/cpython/_analyzer.py
403
406
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,684
check_globals
def check_globals(analysis): # yield (data, failure) ignored = read_ignored() for item in analysis: if item.kind != KIND.VARIABLE: continue if item.supported: continue if item.id in ignored: continue reason = item.unsupported if not...
python
Tools/c-analyzer/cpython/_analyzer.py
409
426
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,685
resolve_filename
def resolve_filename(filename): orig = filename filename = os.path.normcase(os.path.normpath(filename)) if os.path.isabs(filename): if os.path.relpath(filename, REPO_ROOT).startswith('.'): raise Exception(f'{orig!r} is outside the repo ({REPO_ROOT})') return filename else: ...
python
Tools/c-analyzer/cpython/_files.py
29
37
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,686
iter_filenames
def iter_filenames(*, search=False): if search: yield from iter_files_by_suffix(INCLUDE_DIRS, ('.h',)) yield from iter_files_by_suffix(SOURCE_DIRS, ('.c',)) else: globs = (os.path.join(REPO_ROOT, file) for file in GLOBS) yield from expand_filenames(globs)
python
Tools/c-analyzer/cpython/_files.py
40
46
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,687
iter_header_files
def iter_header_files(filenames=None, *, levels=None): if not filenames: if levels: levels = set(levels) if 'private' in levels: levels.add('stable') levels.add('cpython') for level, glob in LEVEL_GLOBS.items(): if level in ...
python
Tools/c-analyzer/cpython/_files.py
49
72
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,688
_abs
def _abs(relfile): return os.path.join(REPO_ROOT, relfile)
python
Tools/c-analyzer/cpython/_parser.py
17
18
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,689
clean_lines
def clean_lines(text): """Clear out comments, blank lines, and leading/trailing whitespace.""" lines = (line.strip() for line in text.splitlines()) lines = (line.partition('#')[0].rstrip() for line in lines if line and not line.startswith('#')) glob_all = f'{GLOB_ALL} ' lin...
python
Tools/c-analyzer/cpython/_parser.py
21
30
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,690
get_preprocessor
def get_preprocessor(*, file_macros=None, file_includes=None, file_incldirs=None, file_same=None, **kwargs ): macros = tuple(MACROS) if file_macros: macros += tuple(file_macros) ...
python
Tools/c-analyzer/cpython/_parser.py
352
377
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,691
parse_file
def parse_file(filename, *, match_kind=None, ignore_exc=None, log_err=None, ): get_file_preprocessor = get_preprocessor( ignore_exc=ignore_exc, log_err=log_err, ) yield from _parse_file( filename, match_kind=match_ki...
python
Tools/c-analyzer/cpython/_parser.py
380
394
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,692
parse_files
def parse_files(filenames=None, *, match_kind=None, ignore_exc=None, log_err=None, get_file_preprocessor=None, **file_kwargs ): if get_file_preprocessor is None: get_file_preprocessor = get_preprocessor( ...
python
Tools/c-analyzer/cpython/_parser.py
397
415
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,693
_parse_line
def _parse_line(line, prev=None): last = line if prev: if not prev.endswith(os.linesep): prev += os.linesep line = prev + line m = CAPI_RE.match(line) if not m: if not prev and line.startswith('static inline '): return line # the new "prev" #if 'P...
python
Tools/c-analyzer/cpython/_capi.py
113
148
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,694
_get_level
def _get_level(filename, name, *, _cpython=INCLUDE_CPYTHON + os.path.sep, _internal=INCLUDE_INTERNAL + os.path.sep, ): if filename.startswith(_internal): return 'internal' elif name.startswith('_'): return 'private' elif os.path.dirname(filename) ...
python
Tools/c-analyzer/cpython/_capi.py
158
172
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,695
from_line
def from_line(cls, line, filename, lno, prev=None): parsed = _parse_line(line, prev) if not parsed: return None, None if isinstance(parsed, str): # incomplete return None, parsed name, kind = parsed level = _get_level(filename, name) se...
python
Tools/c-analyzer/cpython/_capi.py
184
198
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,696
relfile
def relfile(self): return self.file[len(REPO_ROOT) + 1:]
python
Tools/c-analyzer/cpython/_capi.py
201
202
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,697
text
def text(self): try: return self._text except AttributeError: # XXX Actually ready the text from disk?. self._text = [] if self.kind == 'data': self._text = [ f'PyAPI_DATA(...) {self.name}', ] ...
python
Tools/c-analyzer/cpython/_capi.py
205
235
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,698
_parse_groupby
def _parse_groupby(raw): if not raw: raw = 'kind' if isinstance(raw, str): groupby = raw.replace(',', ' ').strip().split() else: raise NotImplementedError if not all(v in GROUPINGS for v in groupby): raise ValueError(f'invalid groupby value {raw!r}') return groupby
python
Tools/c-analyzer/cpython/_capi.py
238
249
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,699
_resolve_full_groupby
def _resolve_full_groupby(groupby): if isinstance(groupby, str): groupby = [groupby] groupings = [] for grouping in groupby + list(GROUPINGS): if grouping not in groupings: groupings.append(grouping) return groupings
python
Tools/c-analyzer/cpython/_capi.py
252
259
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,700
summarize
def summarize(items, *, groupby='kind', includeempty=True, minimize=None): if minimize is None: if includeempty is None: minimize = True includeempty = False else: minimize = includeempty elif includeempty is None: includeempty = minimize elif mini...
python
Tools/c-analyzer/cpython/_capi.py
262
312
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }