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,801
unrepr
def unrepr(value): raise NotImplementedError
python
Tools/c-analyzer/c_common/strutil.py
7
8
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,802
parse_entries
def parse_entries(entries, *, ignoresep=None): for entry in entries: if ignoresep and ignoresep in entry: subentries = [entry] else: subentries = entry.strip().replace(',', ' ').split() for item in subentries: if item.startswith('+'): filen...
python
Tools/c-analyzer/c_common/strutil.py
11
34
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,803
_iter_significant_lines
def _iter_significant_lines(lines): for line in lines: line = line.partition('#')[0] if not line.strip(): continue yield line
python
Tools/c-analyzer/c_common/strutil.py
37
42
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,804
create_backup
def create_backup(old, backup=None): if isinstance(old, str): filename = old else: filename = getattr(old, 'name', None) if not filename: return None if not backup or backup is True: backup = f'{filename}.bak' try: shutil.copyfile(filename, backup) except ...
python
Tools/c-analyzer/c_common/fsutil.py
17
32
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,805
fix_filename
def fix_filename(filename, relroot=USE_CWD, *, fixroot=True, _badprefix=f'..{os.path.sep}', ): """Return a normalized, absolute-path copy of the given filename.""" if not relroot or relroot is USE_CWD: return os.path.abspath(filename) if fixroot: ...
python
Tools/c-analyzer/c_common/fsutil.py
38
47
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,806
_fix_filename
def _fix_filename(filename, relroot, *, _badprefix=f'..{os.path.sep}', ): orig = filename # First we normalize. filename = os.path.normpath(filename) if filename.startswith(_badprefix): raise ValueError(f'bad filename {orig!r} (resolves beyond relative root')...
python
Tools/c-analyzer/c_common/fsutil.py
50
68
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,807
fix_filenames
def fix_filenames(filenames, relroot=USE_CWD): if not relroot or relroot is USE_CWD: filenames = (os.path.abspath(v) for v in filenames) else: relroot = os.path.abspath(relroot) filenames = (_fix_filename(v, relroot) for v in filenames) return filenames, relroot
python
Tools/c-analyzer/c_common/fsutil.py
71
77
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,808
format_filename
def format_filename(filename, relroot=USE_CWD, *, fixroot=True, normalize=True, _badprefix=f'..{os.path.sep}', ): """Return a consistent relative-path representation of the filename.""" orig = filename if normalize: file...
python
Tools/c-analyzer/c_common/fsutil.py
80
104
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,809
match_path_tail
def match_path_tail(path1, path2): """Return True if one path ends the other.""" if path1 == path2: return True if os.path.isabs(path1): if os.path.isabs(path2): return False return _match_tail(path1, path2) elif os.path.isabs(path2): return _match_tail(path2,...
python
Tools/c-analyzer/c_common/fsutil.py
107
118
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,810
_match_tail
def _match_tail(path, tail): assert not os.path.isabs(tail), repr(tail) return path.endswith(os.path.sep + tail)
python
Tools/c-analyzer/c_common/fsutil.py
121
123
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,811
match_glob
def match_glob(filename, pattern): if fnmatch.fnmatch(filename, pattern): return True # fnmatch doesn't handle ** quite right. It will not match the # following: # # ('x/spam.py', 'x/**/*.py') # ('spam.py', '**/*.py') # # though it *will* match the following: # # ('x...
python
Tools/c-analyzer/c_common/fsutil.py
129
148
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,812
process_filenames
def process_filenames(filenames, *, start=None, include=None, exclude=None, relroot=USE_CWD, ): if relroot and relroot is not USE_CWD: relroot = os.path.abspath(relroot) if start: start ...
python
Tools/c-analyzer/c_common/fsutil.py
151
173
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,813
expand_filenames
def expand_filenames(filenames): for filename in filenames: # XXX Do we need to use glob.escape (a la commit 9355868458, GH-20994)? if '**/' in filename: yield from glob.glob(filename.replace('**/', '')) yield from glob.glob(filename)
python
Tools/c-analyzer/c_common/fsutil.py
176
181
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,814
_get_check
def _get_check(filename, start, include, exclude): if start and filename != start: return (lambda: '<skipped>'), start else: def check(): if _is_excluded(filename, exclude, include): return '<excluded>' return None return check, None
python
Tools/c-analyzer/c_common/fsutil.py
184
192
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,815
check
def check(): if _is_excluded(filename, exclude, include): return '<excluded>' return None
python
Tools/c-analyzer/c_common/fsutil.py
188
191
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,816
_is_excluded
def _is_excluded(filename, exclude, include): if include: for included in include: if match_glob(filename, included): return False return True elif exclude: for excluded in exclude: if match_glob(filename, excluded): return True ...
python
Tools/c-analyzer/c_common/fsutil.py
195
207
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,817
_walk_tree
def _walk_tree(root, *, _walk=os.walk, ): # A wrapper around os.walk that resolves the filenames. for parent, _, names in _walk(root): for name in names: yield os.path.join(parent, name)
python
Tools/c-analyzer/c_common/fsutil.py
210
216
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,818
walk_tree
def walk_tree(root, *, suffix=None, walk=_walk_tree, ): """Yield each file in the tree under the given directory name. If "suffix" is provided then only files with that suffix will be included. """ if suffix and not isinstance(suffix, str): raise Va...
python
Tools/c-analyzer/c_common/fsutil.py
219
234
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,819
glob_tree
def glob_tree(root, *, suffix=None, _glob=glob.iglob, ): """Yield each file in the tree under the given directory name. If "suffix" is provided then only files with that suffix will be included. """ suffix = suffix or '' if not isinstance(suffix, str): ...
python
Tools/c-analyzer/c_common/fsutil.py
237
253
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,820
iter_files
def iter_files(root, suffix=None, relparent=None, *, get_files=os.walk, _glob=glob_tree, _walk=walk_tree, ): """Yield each file in the tree under the given directory name. If "root" is a non-string iterable then do the same for each of those trees...
python
Tools/c-analyzer/c_common/fsutil.py
256
301
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,821
iter_files_by_suffix
def iter_files_by_suffix(root, suffixes, relparent=None, *, walk=walk_tree, _iter_files=iter_files, ): """Yield each file in the tree that has the given suffixes. Unlike iter_files(), the results are in the original suffix order. ""...
python
Tools/c-analyzer/c_common/fsutil.py
304
316
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,822
is_readable
def is_readable(file, *, user=None, check=False): filename, st, mode = _get_file_info(file) if check: try: okay = _check_file(filename, S_IRANY) except NotImplementedError: okay = NotImplemented if okay is not NotImplemented: return okay # Fall...
python
Tools/c-analyzer/c_common/fsutil.py
329
339
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,823
is_writable
def is_writable(file, *, user=None, check=False): filename, st, mode = _get_file_info(file) if check: try: okay = _check_file(filename, S_IWANY) except NotImplementedError: okay = NotImplemented if okay is not NotImplemented: return okay # Fall...
python
Tools/c-analyzer/c_common/fsutil.py
342
352
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,824
is_executable
def is_executable(file, *, user=None, check=False): filename, st, mode = _get_file_info(file) if check: try: okay = _check_file(filename, S_IXANY) except NotImplementedError: okay = NotImplemented if okay is not NotImplemented: return okay # Fa...
python
Tools/c-analyzer/c_common/fsutil.py
355
365
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,825
_get_file_info
def _get_file_info(file): filename = st = mode = None if isinstance(file, int): mode = file elif isinstance(file, os.stat_result): st = file else: if isinstance(file, str): filename = file elif hasattr(file, 'name') and os.path.exists(file.name): f...
python
Tools/c-analyzer/c_common/fsutil.py
368
382
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,826
_check_file
def _check_file(filename, check): if not isinstance(filename, str): raise Exception(f'filename required to check file, got {filename}') if check & S_IRANY: flags = os.O_RDONLY elif check & S_IWANY: flags = os.O_WRONLY elif check & S_IXANY: # We can worry about S_IXANY lat...
python
Tools/c-analyzer/c_common/fsutil.py
385
405
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,827
_get_user_info
def _get_user_info(user): import pwd username = uid = gid = groups = None if user is None: uid = os.geteuid() #username = os.getlogin() username = pwd.getpwuid(uid)[0] gid = os.getgid() groups = os.getgroups() else: if isinstance(user, int): ui...
python
Tools/c-analyzer/c_common/fsutil.py
408
430
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,828
_check_mode
def _check_mode(st, mode, check, user): orig = check _, uid, gid, groups = _get_user_info(user) if check & S_IRANY: check -= S_IRANY matched = False if mode & stat.S_IRUSR: if st.st_uid == uid: matched = True if mode & stat.S_IRGRP: if ...
python
Tools/c-analyzer/c_common/fsutil.py
433
477
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,829
parse_markers
def parse_markers(markers, default=None): if markers is NOT_SET: return default if not markers: return None if type(markers) is not str: return markers if markers == markers[0] * len(markers): return [markers] return list(markers)
python
Tools/c-analyzer/c_common/tables.py
13
22
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,830
fix_row
def fix_row(row, **markers): if isinstance(row, str): raise NotImplementedError(row) empty = parse_markers(markers.pop('empty', ('-',))) unknown = parse_markers(markers.pop('unknown', ('???',))) row = (val if val else None for val in row) if not empty: if unknown: row = (...
python
Tools/c-analyzer/c_common/tables.py
25
39
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,831
_fix_read_default
def _fix_read_default(row): for value in row: yield value.strip()
python
Tools/c-analyzer/c_common/tables.py
42
44
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,832
_fix_write_default
def _fix_write_default(row, empty=''): for value in row: yield empty if value is None else str(value)
python
Tools/c-analyzer/c_common/tables.py
47
49
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,833
_normalize_fix_read
def _normalize_fix_read(fix): if fix is None: fix = '' if callable(fix): def fix_row(row): values = fix(row) return _fix_read_default(values) elif isinstance(fix, str): def fix_row(row): values = _fix_read_default(row) return (None if v...
python
Tools/c-analyzer/c_common/tables.py
52
66
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,834
fix_row
def fix_row(row): values = fix(row) return _fix_read_default(values)
python
Tools/c-analyzer/c_common/tables.py
56
58
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,835
fix_row
def fix_row(row): values = _fix_read_default(row) return (None if v == fix else v for v in values)
python
Tools/c-analyzer/c_common/tables.py
60
63
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,836
_normalize_fix_write
def _normalize_fix_write(fix, empty=''): if fix is None: fix = empty if callable(fix): def fix_row(row): values = fix(row) return _fix_write_default(values, empty) elif isinstance(fix, str): def fix_row(row): return _fix_write_default(row, fix) ...
python
Tools/c-analyzer/c_common/tables.py
69
81
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,837
fix_row
def fix_row(row): values = fix(row) return _fix_write_default(values, empty)
python
Tools/c-analyzer/c_common/tables.py
73
75
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,838
fix_row
def fix_row(row): return _fix_write_default(row, fix)
python
Tools/c-analyzer/c_common/tables.py
77
78
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,839
read_table
def read_table(infile, header, *, sep='\t', fix=None, _open=open, _get_reader=csv.reader, ): """Yield each row of the given ???-separated (e.g. tab) file.""" if isinstance(infile, str): with _open(infile, newline='') as infile: ...
python
Tools/c-analyzer/c_common/tables.py
84
116
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,840
write_table
def write_table(outfile, header, rows, *, sep='\t', fix=None, backup=True, _open=open, _get_writer=csv.writer, ): """Write each of the rows to the given ???-separated (e.g. tab) file.""" if backup: fsutil.cre...
python
Tools/c-analyzer/c_common/tables.py
119
150
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,841
parse_table
def parse_table(entries, sep, header=None, rawsep=None, *, default=NOT_SET, strict=True, ): header, sep = _normalize_table_file_props(header, sep) if not sep: raise ValueError('missing "sep"') ncols = None if header: if strict: ...
python
Tools/c-analyzer/c_common/tables.py
153
183
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,842
parse_row
def parse_row(line, sep, *, ncols=None, default=NOT_SET): if not sep: raise ValueError('missing "sep"') return _parse_row(line, sep, ncols, default)
python
Tools/c-analyzer/c_common/tables.py
186
189
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,843
_parse_row
def _parse_row(line, sep, ncols, default): row = tuple(v.strip() for v in line.split(sep)) if (ncols or 0) > 0: diff = ncols - len(row) if diff: if default is NOT_SET or diff < 0: raise Exception(f'bad row (expected {ncols} columns, got {row!r})') row += (...
python
Tools/c-analyzer/c_common/tables.py
192
200
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,844
_normalize_table_file_props
def _normalize_table_file_props(header, sep): if not header: return None, sep if not isinstance(header, str): if not sep: raise NotImplementedError(header) header = sep.join(header) elif not sep: for sep in ('\t', ',', ' '): if sep in header: ...
python
Tools/c-analyzer/c_common/tables.py
203
217
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,845
resolve_columns
def resolve_columns(specs): if isinstance(specs, str): specs = specs.replace(',', ' ').strip().split() resolved = [] for raw in specs: column = ColumnSpec.from_raw(raw) resolved.append(column) return resolved
python
Tools/c-analyzer/c_common/tables.py
226
233
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,846
build_table
def build_table(specs, *, sep=' ', defaultwidth=None): columns = resolve_columns(specs) return _build_table(columns, sep=sep, defaultwidth=defaultwidth)
python
Tools/c-analyzer/c_common/tables.py
236
238
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,847
from_raw
def from_raw(cls, raw): if not raw: raise ValueError('missing column spec') elif isinstance(raw, cls): return raw if isinstance(raw, str): *values, _ = cls._parse(raw) else: *values, _ = cls._normalize(raw) if values is None: ...
python
Tools/c-analyzer/c_common/tables.py
276
288
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,848
parse
def parse(cls, specstr): parsed = cls._parse(specstr) if not parsed: return None *values, _ = parsed return cls(*values)
python
Tools/c-analyzer/c_common/tables.py
291
296
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,849
_parse
def _parse(cls, specstr): m = cls.REGEX.match(specstr) if not m: return None (label, field, align, width1, width2, fmt, ) = m.groups() if not label: label = field if fmt: assert not align and not width1, (specstr,) ...
python
Tools/c-analyzer/c_common/tables.py
299
328
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,850
_normalize
def _normalize(cls, spec): if len(spec) == 1: raw, = spec raise NotImplementedError return _resolve_column(raw) if len(spec) == 4: label, field, width, fmt = spec if width: if not fmt: fmt = str(width) ...
python
Tools/c-analyzer/c_common/tables.py
331
366
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,851
width
def width(self): if not self.fmt: return None parsed = _parse_fmt(self.fmt) if not parsed: return None width, _ = parsed return width
python
Tools/c-analyzer/c_common/tables.py
369
376
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,852
resolve_width
def resolve_width(self, default=None): return _resolve_width(self.width, self.fmt, self.label, default)
python
Tools/c-analyzer/c_common/tables.py
378
379
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,853
_parse_fmt
def _parse_fmt(fmt): if fmt.startswith(tuple('<^>')): align = fmt[0] width = fmt[1:] if width.isdigit(): return int(width), align elif fmt.isdigit(): return int(fmt), '<' return None
python
Tools/c-analyzer/c_common/tables.py
382
390
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,854
_resolve_width
def _resolve_width(width, fmt, label, default): if width: if not isinstance(width, int): raise NotImplementedError return width elif fmt: parsed = _parse_fmt(fmt) if parsed: width, _ = parsed if width: return width if not d...
python
Tools/c-analyzer/c_common/tables.py
393
412
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,855
_build_table
def _build_table(columns, *, sep=' ', defaultwidth=None): header = [] div = [] rowfmt = [] for spec in columns: width = spec.resolve_width(defaultwidth) colfmt = spec.fmt colfmt = f':{spec.fmt}' if spec.fmt else f':{width}' header.append(f' {{:^{width}}} '.format(spec.la...
python
Tools/c-analyzer/c_common/tables.py
415
431
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,856
peek_and_iter
def peek_and_iter(items): if not items: return None, None items = iter(items) try: peeked = next(items) except StopIteration: return None, None def chain(): yield peeked yield from items return chain(), peeked
python
Tools/c-analyzer/c_common/iterutil.py
1
12
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,857
chain
def chain(): yield peeked yield from items
python
Tools/c-analyzer/c_common/iterutil.py
9
11
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,858
iter_many
def iter_many(items, onempty=None): if not items: if onempty is None: return if not callable(onempty): raise onEmpty items = onempty(items) yield from iter_many(items, onempty=None) return items = iter(items) try: first = next(items) ...
python
Tools/c-analyzer/c_common/iterutil.py
15
44
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,859
__init__
def __init__(self, initial=_NOT_SET, *, default=_NOT_SET, readonly=False, ): self.initial = initial self.default = default self.readonly = readonly # The instance cache is not inherently tied to the normal # lifetime of the inst...
python
Tools/c-analyzer/c_common/clsutil.py
14
30
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,860
__set_name__
def __set_name__(self, cls, name): if self.name is not None: raise TypeError('already used') self.name = name try: slotnames = cls.__slot_names__ except AttributeError: slotnames = cls.__slot_names__ = [] slotnames.append(name) self._en...
python
Tools/c-analyzer/c_common/clsutil.py
32
41
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,861
__get__
def __get__(self, obj, cls): if obj is None: # called on the class return self try: value = self.instances[id(obj)] except KeyError: if self.initial is _NOT_SET: value = self.default else: value = self.initial ...
python
Tools/c-analyzer/c_common/clsutil.py
43
57
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,862
__set__
def __set__(self, obj, value): if self.readonly: raise AttributeError(f'{self.name} is readonly') # XXX Optionally coerce? self.instances[id(obj)] = value
python
Tools/c-analyzer/c_common/clsutil.py
59
63
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,863
__delete__
def __delete__(self, obj): if self.readonly: raise AttributeError(f'{self.name} is readonly') self.instances[id(obj)] = self.default # XXX refleak?
python
Tools/c-analyzer/c_common/clsutil.py
65
68
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,864
_ensure___del__
def _ensure___del__(self, cls, slotnames): # See the comment in __init__(). try: old___del__ = cls.__del__ except AttributeError: old___del__ = (lambda s: None) else: if getattr(old___del__, '_slotted', False): return def __del__(_sel...
python
Tools/c-analyzer/c_common/clsutil.py
70
84
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,865
__del__
def __del__(_self): for name in slotnames: delattr(_self, name) old___del__(_self)
python
Tools/c-analyzer/c_common/clsutil.py
79
82
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,866
set
def set(self, obj, value): """Update the cached value for an object. This works even if the descriptor is read-only. This is particularly useful when initializing the object (e.g. in its __new__ or __init__). """ self.instances[id(obj)] = value
python
Tools/c-analyzer/c_common/clsutil.py
86
93
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,867
__init__
def __init__(self, value): self.value = value self.getter = classmethod(value).__get__ self.name = None
python
Tools/c-analyzer/c_common/clsutil.py
103
106
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,868
__set_name__
def __set_name__(self, cls, name): if self.name is not None: raise TypeError('already used') self.name = name
python
Tools/c-analyzer/c_common/clsutil.py
108
111
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,869
__get__
def __get__(self, obj, cls): if obj is not None: raise AttributeError(self.name) # called on the class return self.getter(None, cls)
python
Tools/c-analyzer/c_common/clsutil.py
113
117
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,870
analyze
def analyze(filenmes, **kwargs): results = iter_analysis_results(filenames, **kwargs) return Analysis.from_results(results)
python
Tools/c-analyzer/c_analyzer/__init__.py
20
22
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,871
iter_analysis_results
def iter_analysis_results(filenmes, *, known=None, **kwargs ): decls = iter_decls(filenames, **kwargs) yield from analyze_decls(decls, known)
python
Tools/c-analyzer/c_analyzer/__init__.py
25
30
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,872
iter_decls
def iter_decls(filenames, *, kinds=None, parse_files=_parse_files, **kwargs ): kinds = KIND.DECLS if kinds is None else (KIND.DECLS & set(kinds)) parse_files = parse_files or _parse_files parsed = parse_files(filenames, **kwargs) parsed = filt...
python
Tools/c-analyzer/c_analyzer/__init__.py
33
44
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,873
analyze_decls
def analyze_decls(decls, known, *, analyze_resolved=None, handle_unresolved=True, relroot=None, ): knowntypes, knowntypespecs = _datafiles.get_known( known, handle_unresolved=handle_unresolved, analyze_resolved=analyze_r...
python
Tools/c-analyzer/c_analyzer/__init__.py
47
86
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,874
analyze_decl
def analyze_decl(decl): return _analyze.analyze_decl( decl, typespecs, knowntypespecs, types, knowntypes, analyze_resolved=analyze_resolved, )
python
Tools/c-analyzer/c_analyzer/__init__.py
65
73
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,875
check_all
def check_all(analysis, checks, *, failfast=False): for check in checks or (): for data, failure in check(analysis): if failure is None: continue yield data, failure if failfast: yield None, None break else: ...
python
Tools/c-analyzer/c_analyzer/__init__.py
92
105
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,876
__init__
def __init__(self, name): super().__init__(None, name, None, None, _shortkey=name)
python
Tools/c-analyzer/c_analyzer/info.py
23
24
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,877
is_target
def is_target(cls, raw): if isinstance(raw, HighlevelParsedItem): return True else: return False
python
Tools/c-analyzer/c_analyzer/info.py
31
35
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,878
from_raw
def from_raw(cls, raw, **extra): if isinstance(raw, cls): if extra: # XXX ? raise NotImplementedError((raw, extra)) #return cls(raw.item, raw.typedecl, **raw._extra, **extra) else: return info elif cls.is_target(raw)...
python
Tools/c-analyzer/c_analyzer/info.py
38
49
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,879
from_resolved
def from_resolved(cls, item, resolved, **extra): if isinstance(resolved, TypeDeclaration): return cls(item, typedecl=resolved, **extra) else: typedeps, extra = cls._parse_raw_resolved(item, resolved, extra) if item.kind is KIND.ENUM: if typedeps: ...
python
Tools/c-analyzer/c_analyzer/info.py
52
62
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,880
_parse_raw_resolved
def _parse_raw_resolved(cls, item, resolved, extra_extra): if resolved in (UNKNOWN, IGNORED): return resolved, None try: typedeps, extra = resolved except (TypeError, ValueError): typedeps = extra = None if extra: # The resolved data takes ...
python
Tools/c-analyzer/c_analyzer/info.py
65
85
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,881
__init__
def __init__(self, item, typedecl=None, **extra): assert item is not None self.item = item if typedecl in (UNKNOWN, IGNORED): pass elif item.kind is KIND.STRUCT or item.kind is KIND.UNION: if isinstance(typedecl, TypeDeclaration): raise NotImplemen...
python
Tools/c-analyzer/c_analyzer/info.py
87
110
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,882
_validate
def _validate(self): item = self.item extra = self._extra # Check item. if not isinstance(item, HighlevelParsedItem): raise ValueError(f'"item" must be a high-level parsed item, got {item!r}') # Check extra. for key, value in extra.items(): if key....
python
Tools/c-analyzer/c_analyzer/info.py
112
123
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,883
__repr__
def __repr__(self): kwargs = [ f'item={self.item!r}', f'typedecl={self.typedecl!r}', *(f'{k}={v!r}' for k, v in self._extra.items()) ] return f'{type(self).__name__}({", ".join(kwargs)})'
python
Tools/c-analyzer/c_analyzer/info.py
125
131
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,884
__str__
def __str__(self): try: return self._str except AttributeError: self._str, = self.render('line') return self._str
python
Tools/c-analyzer/c_analyzer/info.py
133
138
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,885
__hash__
def __hash__(self): return hash(self.item)
python
Tools/c-analyzer/c_analyzer/info.py
140
141
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,886
__eq__
def __eq__(self, other): if isinstance(other, Analyzed): return self.item == other.item elif isinstance(other, HighlevelParsedItem): return self.item == other elif type(other) is tuple: return self.item == other else: return NotImplemented
python
Tools/c-analyzer/c_analyzer/info.py
143
151
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,887
__gt__
def __gt__(self, other): if isinstance(other, Analyzed): return self.item > other.item elif isinstance(other, HighlevelParsedItem): return self.item > other elif type(other) is tuple: return self.item > other else: return NotImplemented
python
Tools/c-analyzer/c_analyzer/info.py
153
161
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,888
__dir__
def __dir__(self): names = set(super().__dir__()) names.update(self._extra) names.remove('_locked') return sorted(names)
python
Tools/c-analyzer/c_analyzer/info.py
163
167
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,889
__getattr__
def __getattr__(self, name): if name.startswith('_'): raise AttributeError(name) # The item takes precedence over the extra data (except if callable). try: value = getattr(self.item, name) if callable(value): raise AttributeError(name) ...
python
Tools/c-analyzer/c_analyzer/info.py
169
188
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,890
__setattr__
def __setattr__(self, name, value): if self._locked and name != '_str': raise AttributeError(f'readonly ({name})') super().__setattr__(name, value)
python
Tools/c-analyzer/c_analyzer/info.py
190
193
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,891
__delattr__
def __delattr__(self, name): if self._locked: raise AttributeError(f'readonly ({name})') super().__delattr__(name)
python
Tools/c-analyzer/c_analyzer/info.py
195
198
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,892
decl
def decl(self): if not isinstance(self.item, Declaration): raise AttributeError('decl') return self.item
python
Tools/c-analyzer/c_analyzer/info.py
201
204
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,893
signature
def signature(self): # XXX vartype... ...
python
Tools/c-analyzer/c_analyzer/info.py
207
209
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,894
istype
def istype(self): return is_type_decl(self.item.kind)
python
Tools/c-analyzer/c_analyzer/info.py
212
213
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,895
is_known
def is_known(self): if self.typedecl in (UNKNOWN, IGNORED): return False elif isinstance(self.typedecl, TypeDeclaration): return True else: return UNKNOWN not in self.typedecl
python
Tools/c-analyzer/c_analyzer/info.py
216
222
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,896
fix_filename
def fix_filename(self, relroot=fsutil.USE_CWD, **kwargs): self.item.fix_filename(relroot, **kwargs) return self
python
Tools/c-analyzer/c_analyzer/info.py
224
226
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,897
as_rowdata
def as_rowdata(self, columns=None): # XXX finish! return self.item.as_rowdata(columns)
python
Tools/c-analyzer/c_analyzer/info.py
228
230
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,898
render_rowdata
def render_rowdata(self, columns=None): # XXX finish! return self.item.render_rowdata(columns)
python
Tools/c-analyzer/c_analyzer/info.py
232
234
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,899
render
def render(self, fmt='line', *, itemonly=False): if fmt == 'raw': yield repr(self) return rendered = self.item.render(fmt) if itemonly or not self._extra: yield from rendered return extra = self._render_extra(fmt) if not extra: ...
python
Tools/c-analyzer/c_analyzer/info.py
236
258
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,900
_render_extra
def _render_extra(self, fmt): if fmt in ('brief', 'line'): yield str(self._extra) else: raise NotImplementedError(fmt)
python
Tools/c-analyzer/c_analyzer/info.py
260
264
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }