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
9,001
encode_varint_unsigned
def encode_varint_unsigned(i, res): # https://en.wikipedia.org/wiki/LEB128 unsigned variant more = True startlen = len(res) if i < 0: raise ValueError("only positive numbers supported", i) while more: lowest7bits = i & 0b1111111 i >>= 7 if i == 0: more = F...
python
Tools/unicode/dawg.py
388
402
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,002
number_split_bits
def number_split_bits(x, n, acc=()): if n == 1: return x >> 1, x & 1 if n == 2: return x >> 2, (x >> 1) & 1, x & 1 assert 0, "implement me!"
python
Tools/unicode/dawg.py
404
409
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,003
decode_varint_unsigned
def decode_varint_unsigned(b, index=0): res = 0 shift = 0 while True: byte = b[index] res = res | ((byte & 0b1111111) << shift) index += 1 shift += 7 if not (byte & 0b10000000): return res, index
python
Tools/unicode/dawg.py
411
420
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,004
decode_node
def decode_node(packed, node): x, node = decode_varint_unsigned(packed, node) node_count, final = number_split_bits(x, 1) return node_count, final, node
python
Tools/unicode/dawg.py
422
425
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,005
decode_edge
def decode_edge(packed, edgeindex, prev_child_offset, offset): x, offset = decode_varint_unsigned(packed, offset) if x == 0 and edgeindex == 0: raise KeyError # trying to decode past a final node child_offset_difference, len1, last_edge = number_split_bits(x, 2) child_offset = prev_child_offset ...
python
Tools/unicode/dawg.py
427
437
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,006
_match_edge
def _match_edge(packed, s, size, node_offset, stringpos): if size > 1 and stringpos + size > len(s): # past the end of the string, can't match return False for i in range(size): if packed[node_offset + i] != s[stringpos + i]: # if a subsequent char of an edge doesn't match, t...
python
Tools/unicode/dawg.py
439
450
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,007
lookup
def lookup(packed, data, s): return data[_lookup(packed, s)]
python
Tools/unicode/dawg.py
452
453
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,008
_lookup
def _lookup(packed, s): stringpos = 0 node_offset = 0 skipped = 0 # keep track of number of final nodes that we skipped false = False while stringpos < len(s): #print(f"{node_offset=} {stringpos=}") _, final, edge_offset = decode_node(packed, node_offset) prev_child_offset =...
python
Tools/unicode/dawg.py
455
485
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,009
inverse_lookup
def inverse_lookup(packed, inverse, x): pos = inverse[x] return _inverse_lookup(packed, pos)
python
Tools/unicode/dawg.py
487
489
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,010
_inverse_lookup
def _inverse_lookup(packed, pos): result = bytearray() node_offset = 0 while 1: node_count, final, edge_offset = decode_node(packed, node_offset) if final: if pos == 0: return bytes(result) pos -= 1 prev_child_offset = edge_offset edgei...
python
Tools/unicode/dawg.py
491
519
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,011
build_compression_dawg
def build_compression_dawg(ucdata): d = Dawg() ucdata.sort() for name, value in ucdata: d.insert(name, value) packed, pos_to_code, reversedict = d.finish() print("size of dawg [KiB]", round(len(packed) / 1024, 2)) # check that lookup and inverse_lookup work correctly on the input data ...
python
Tools/unicode/dawg.py
522
533
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,012
parse_gb18030map
def parse_gb18030map(fo): m, gbuni = {}, {} for i in range(65536): if i < 0xd800 or i > 0xdfff: # exclude unicode surrogate area gbuni[i] = None for uni, native in re_gb18030ass.findall(fo.read()): uni = eval('0x'+uni) native = [eval('0x'+u) for u in native.split()] ...
python
Tools/unicode/genmap_schinese.py
37
52
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,013
main
def main(): print("Loading Mapping File...") gb2312map = open_mapping_file('python-mappings/GB2312.TXT', MAPPINGS_GB2312) cp936map = open_mapping_file('python-mappings/CP936.TXT', MAPPINGS_CP936) gb18030map = open_mapping_file('python-mappings/gb-18030-2000.xml', MAPPINGS_GB18030) gb18030decmap, gb...
python
Tools/unicode/genmap_schinese.py
54
145
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,014
bh2s
def bh2s(code): return ((code >> 8) - 0x87) * (0xfe - 0x40 + 1) + ((code & 0xff) - 0x40)
python
Tools/unicode/genmap_tchinese.py
26
27
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,015
split_bytes
def split_bytes(code): """Split 0xABCD into 0xAB, 0xCD""" return code >> 8, code & 0xff
python
Tools/unicode/genmap_tchinese.py
30
32
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,016
parse_hkscs_map
def parse_hkscs_map(fo): fo.seek(0, 0) table = [] for line in fo: line = line.split('#', 1)[0].strip() # We expect 4 columns in supported HKSCS files: # [1999]: unsupported # [2001]: unsupported # [2004]: Big-5; iso10646-1:1993; iso10646-1:2000; iso10646:2003+amd1 ...
python
Tools/unicode/genmap_tchinese.py
35
58
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,017
make_hkscs_map
def make_hkscs_map(table): decode_map = {} encode_map_bmp, encode_map_notbmp = {}, {} is_bmp_map = {} sequences = [] beginnings = {} single_cp_table = [] # Determine multi-codepoint sequences, and sequence beginnings that encode # multiple multibyte (i.e. Big-5) codes. for mbcode, cp...
python
Tools/unicode/genmap_tchinese.py
61
100
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,018
load_big5_map
def load_big5_map(): mapfile = open_mapping_file('python-mappings/BIG5.txt', MAPPINGS_BIG5) with mapfile: big5decmap = loadmap(mapfile) # big5 mapping fix: use the cp950 mapping for these characters as the file # provided by unicode.org doesn't define a mapping. See notes in BIG5.txt. # Sinc...
python
Tools/unicode/genmap_tchinese.py
103
134
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,019
load_cp950_map
def load_cp950_map(): mapfile = open_mapping_file('python-mappings/CP950.TXT', MAPPINGS_CP950) with mapfile: cp950decmap = loadmap(mapfile) cp950encmap = {} for c1, m in list(cp950decmap.items()): for c2, code in list(m.items()): cp950encmap.setdefault(code >> 8, {}) ...
python
Tools/unicode/genmap_tchinese.py
137
150
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,020
main_tw
def main_tw(): big5decmap, big5encmap = load_big5_map() cp950decmap, cp950encmap = load_cp950_map() # CP950 extends Big5, and the codec can use the Big5 lookup tables # for most entries. So the CP950 tables should only include entries # that are not in Big5: for c1, m in list(cp950encmap.items(...
python
Tools/unicode/genmap_tchinese.py
153
174
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,021
write_big5_maps
def write_big5_maps(fp, display_name, table_name, decode_map, encode_map): print(f'Generating {display_name} decode map...') writer = DecodeMapWriter(fp, table_name, decode_map) writer.update_decode_map(BIG5_C1, BIG5_C2) writer.generate() print(f'Generating {display_name} encode map...') writer ...
python
Tools/unicode/genmap_tchinese.py
177
184
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,022
__init__
def __init__(self, fp, prefix, isbmpmap): self.fp = fp self.prefix = prefix self.isbmpmap = isbmpmap self.filler = self.filler_class()
python
Tools/unicode/genmap_tchinese.py
190
194
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,023
fillhints
def fillhints(self, hintfrom, hintto): name = f'{self.prefix}_phint_{hintfrom}' self.fp.write(f'static const unsigned char {name}[] = {{\n') for msbcode in range(hintfrom, hintto+1, 8): v = 0 for c in range(msbcode, msbcode+8): v |= self.isbmpmap.get(c, 0)...
python
Tools/unicode/genmap_tchinese.py
196
205
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,024
main_hkscs
def main_hkscs(): filename = f'python-mappings/hkscs-{HKSCS_VERSION}-big5-iso.txt' with open_mapping_file(filename, MAPPINGS_HKSCS) as f: table = parse_hkscs_map(f) hkscsdecmap, hkscsencmap_bmp, hkscsencmap_nonbmp, isbmpmap = ( make_hkscs_map(table) ) with open('mappings_hk.h', 'w') ...
python
Tools/unicode/genmap_tchinese.py
208
234
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,025
loadmap_jisx0213
def loadmap_jisx0213(fo): decmap3, decmap4 = {}, {} # maps to BMP for level 3 and 4 decmap3_2, decmap4_2 = {}, {} # maps to U+2xxxx for level 3 and 4 decmap3_pair = {} # maps to BMP-pair for level 3 for line in fo: line = line.split('#', 1)[0].strip() if not line or len(line.split()) < 2...
python
Tools/unicode/genmap_japanese.py
30
72
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,026
main
def main(): jisx0208file = open_mapping_file('python-mappings/JIS0208.TXT', MAPPINGS_JIS0208) jisx0212file = open_mapping_file('python-mappings/JIS0212.TXT', MAPPINGS_JIS0212) cp932file = open_mapping_file('python-mappings/CP932.TXT', MAPPINGS_CP932) jisx0213file = open_mapping_file('python-mappings/jis...
python
Tools/unicode/genmap_japanese.py
75
248
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,027
__init__
def __init__(self, column=78): self.column = column self.buffered = [] self.cline = [] self.clen = 0 self.count = 0
python
Tools/unicode/genmap_support.py
10
15
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,028
write
def write(self, *data): for s in data: if len(s) > self.column: raise ValueError("token is too long") if len(s) + self.clen > self.column: self.flush() self.clen += len(s) self.cline.append(s) self.count += 1
python
Tools/unicode/genmap_support.py
17
25
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,029
flush
def flush(self): if not self.cline: return self.buffered.append(''.join(self.cline)) self.clen = 0 del self.cline[:]
python
Tools/unicode/genmap_support.py
27
32
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,030
printout
def printout(self, fp): self.flush() for l in self.buffered: fp.write(f'{l}\n') del self.buffered[:]
python
Tools/unicode/genmap_support.py
34
38
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,031
__len__
def __len__(self): return self.count
python
Tools/unicode/genmap_support.py
40
41
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,032
__init__
def __init__(self, fp, prefix, decode_map): self.fp = fp self.prefix = prefix self.decode_map = decode_map self.filler = self.filler_class()
python
Tools/unicode/genmap_support.py
47
51
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,033
update_decode_map
def update_decode_map(self, c1range, c2range, onlymask=(), wide=0): c2values = range(c2range[0], c2range[1] + 1) for c1 in range(c1range[0], c1range[1] + 1): if c1 not in self.decode_map or (onlymask and c1 not in onlymask): continue c2map = self.decode_map[c1] ...
python
Tools/unicode/genmap_support.py
53
73
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,034
generate
def generate(self, wide=False): if not wide: self.fp.write(f"static const ucs2_t __{self.prefix}_decmap[{len(self.filler)}] = {{\n") else: self.fp.write(f"static const Py_UCS4 __{self.prefix}_decmap[{len(self.filler)}] = {{\n") self.filler.printout(self.fp) self....
python
Tools/unicode/genmap_support.py
75
100
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,035
__init__
def __init__(self, fp, prefix, encode_map): self.fp = fp self.prefix = prefix self.encode_map = encode_map self.filler = self.filler_class()
python
Tools/unicode/genmap_support.py
108
112
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,036
generate
def generate(self): self.buildmap() self.printmap()
python
Tools/unicode/genmap_support.py
114
116
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,037
buildmap
def buildmap(self): for c1 in range(0, 256): if c1 not in self.encode_map: continue c2map = self.encode_map[c1] rc2values = [k for k in c2map.keys()] rc2values.sort() if not rc2values: continue c2map[self.pr...
python
Tools/unicode/genmap_support.py
118
141
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,038
write_nochar
def write_nochar(self): self.filler.write('N,')
python
Tools/unicode/genmap_support.py
143
144
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,039
write_multic
def write_multic(self, point): self.filler.write('M,')
python
Tools/unicode/genmap_support.py
146
147
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,040
write_char
def write_char(self, point): self.filler.write(str(point) + ',')
python
Tools/unicode/genmap_support.py
149
150
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,041
printmap
def printmap(self): self.fp.write(f"static const {self.elemtype} __{self.prefix}_encmap[{len(self.filler)}] = {{\n") self.filler.printout(self.fp) self.fp.write("};\n\n") self.fp.write(f"static const {self.indextype} {self.prefix}_encmap[256] = {{\n") for i in range(256): ...
python
Tools/unicode/genmap_support.py
152
168
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,042
open_mapping_file
def open_mapping_file(path, source): try: f = open(path) except IOError: raise SystemExit(f'{source} is needed') return f
python
Tools/unicode/genmap_support.py
171
176
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,043
print_autogen
def print_autogen(fo, source): fo.write(f'// AUTO-GENERATED FILE FROM {source}: DO NOT EDIT\n')
python
Tools/unicode/genmap_support.py
179
180
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,044
loadmap
def loadmap(fo, natcol=0, unicol=1, sbcs=0): print("Loading from", fo) fo.seek(0, 0) decmap = {} for line in fo: line = line.split('#', 1)[0].strip() if not line or len(line.split()) < 2: continue row = [eval(e) for e in line.split()] loc, uni = row[natcol], ...
python
Tools/unicode/genmap_support.py
183
198
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,045
gen_category
def gen_category(cats): for i in range(0, 0x110000): if unicodedata.category(chr(i)) in cats: yield(i)
python
Tools/unicode/mkstringprep.py
4
7
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,046
gen_bidirectional
def gen_bidirectional(cats): for i in range(0, 0x110000): if unicodedata.bidirectional(chr(i)) in cats: yield(i)
python
Tools/unicode/mkstringprep.py
9
12
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,047
compact_set
def compact_set(l): single = [] tuple = [] prev = None span = 0 for e in l: if prev is None: prev = e span = 0 continue if prev+span+1 != e: if span > 2: tuple.append((prev,prev+span+1)) else: ...
python
Tools/unicode/mkstringprep.py
14
46
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,048
map_table_b3
def map_table_b3(code): r = b3_exceptions.get(ord(code)) if r is not None: return r return code.lower()
python
Tools/unicode/mkstringprep.py
199
202
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,049
map_table_b2
def map_table_b2(a): al = map_table_b3(a) b = unicodedata.normalize("NFKC", al) bl = "".join([map_table_b3(ch) for ch in b]) c = unicodedata.normalize("NFKC", bl) if b != c: return c else: return al
python
Tools/unicode/mkstringprep.py
208
216
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,050
genwinmap
def genwinmap(codepage): MultiByteToWideChar = ctypes.windll.kernel32.MultiByteToWideChar MultiByteToWideChar.argtypes = [wintypes.UINT, wintypes.DWORD, wintypes.LPCSTR, ctypes.c_int, wintypes.LPWSTR, ctypes.c_int] MultiByteToWideChar.r...
python
Tools/unicode/genwincodec.py
11
41
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,051
genwincodec
def genwincodec(codepage): import platform map = genwinmap(codepage) encodingname = 'cp%d' % codepage code = codegen("", map, encodingname) # Replace first lines with our own docstring code = '''\ """Python Character Mapping Codec %s generated on Windows: %s with the command: python Tools/unic...
python
Tools/unicode/genwincodec.py
43
57
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,052
compare_codecs
def compare_codecs(encoding1, encoding2): print('Comparing encoding/decoding of %r and %r' % (encoding1, encoding2)) mismatch = 0 # Check encoding for i in range(sys.maxunicode+1): u = chr(i) try: c1 = u.encode(encoding1) except UnicodeError as reason: ...
python
Tools/unicode/comparecodecs.py
12
50
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,053
maketables
def maketables(trace=0): print("--- Reading", UNICODE_DATA % "", "...") unicode = UnicodeData(UNIDATA_VERSION) print(len(list(filter(None, unicode.table))), "characters") for version in old_versions: print("--- Reading", UNICODE_DATA % ("-"+version), "...") old_unicode = UnicodeData(...
python
Tools/unicode/makeunicodedata.py
117
133
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,054
makeunicodedata
def makeunicodedata(unicode, trace): # the default value of east_asian_width is "N", for unassigned code points # not mentioned in EastAsianWidth.txt # in addition there are some reserved but unassigned code points in CJK # ranges that are classified as "W". code points in private use areas # have ...
python
Tools/unicode/makeunicodedata.py
139
406
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,055
makeunicodetype
def makeunicodetype(unicode, trace): FILE = "Objects/unicodetype_db.h" print("--- Preparing", FILE, "...") # extract unicode types dummy = (0, 0, 0, 0, 0, 0) table = [dummy] cache = {dummy: 0} index = [0] * len(unicode.chars) numeric = {} spaces = [] linebreaks = [] extra_...
python
Tools/unicode/makeunicodedata.py
412
619
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,056
makeunicodename
def makeunicodename(unicode, trace): from dawg import build_compression_dawg FILE = "Modules/unicodename_db.h" print("--- Preparing", FILE, "...") # unicode name hash table # extract names data = [] for char in unicode.chars: record = unicode.table[char] if record: ...
python
Tools/unicode/makeunicodedata.py
625
699
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,057
merge_old_version
def merge_old_version(version, new, old): # Changes to exclusion file not implemented yet if old.exclusions != new.exclusions: raise NotImplementedError("exclusions differ") # In these change records, 0xFF means "no change" bidir_changes = [0xFF]*0x110000 category_changes = [0xFF]*0x110000 ...
python
Tools/unicode/makeunicodedata.py
702
792
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,058
open_data
def open_data(template, version): local = os.path.join(DATA_DIR, template % ('-'+version,)) if not os.path.exists(local): import urllib.request if version == '3.2.0': # irregular url structure url = ('https://www.unicode.org/Public/3.2-Update/'+template) % ('-'+version,) ...
python
Tools/unicode/makeunicodedata.py
797
812
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,059
expand_range
def expand_range(char_range: str) -> Iterator[int]: ''' Parses ranges of code points, as described in UAX #44: https://www.unicode.org/reports/tr44/#Code_Point_Ranges ''' if '..' in char_range: first, last = [int(c, 16) for c in char_range.split('..')] else: first = last = int(...
python
Tools/unicode/makeunicodedata.py
815
825
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,060
__init__
def __init__(self, template: str, version: str) -> None: self.template = template self.version = version
python
Tools/unicode/makeunicodedata.py
838
840
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,061
records
def records(self) -> Iterator[List[str]]: with open_data(self.template, self.version) as file: for line in file: line = line.split('#', 1)[0].strip() if not line: continue yield [field.strip() for field in line.split(';')]
python
Tools/unicode/makeunicodedata.py
842
848
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,062
__iter__
def __iter__(self) -> Iterator[List[str]]: return self.records()
python
Tools/unicode/makeunicodedata.py
850
851
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,063
expanded
def expanded(self) -> Iterator[Tuple[int, List[str]]]: for record in self.records(): char_range, rest = record[0], record[1:] for char in expand_range(char_range): yield char, rest
python
Tools/unicode/makeunicodedata.py
853
857
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,064
from_row
def from_row(row: List[str]) -> UcdRecord: return UcdRecord(*row, None, set(), 0)
python
Tools/unicode/makeunicodedata.py
895
896
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,065
__init__
def __init__(self, version, cjk_check=True): self.changed = [] table = [None] * 0x110000 for s in UcdFile(UNICODE_DATA, version): char = int(s[0], 16) table[char] = from_row(s) cjk_ranges_found = [] # expand first-last ranges field = None ...
python
Tools/unicode/makeunicodedata.py
908
1,068
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,066
uselatin1
def uselatin1(self): # restrict character range to ISO Latin 1 self.chars = list(range(256))
python
Tools/unicode/makeunicodedata.py
1,070
1,072
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,067
__init__
def __init__(self, name, data): self.name = name self.data = data
python
Tools/unicode/makeunicodedata.py
1,080
1,082
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,068
dump
def dump(self, file, trace=0): # write data to file, as a C array size = getsize(self.data) if trace: print(self.name+":", size*len(self.data), "bytes", file=sys.stderr) file.write("static const ") if size == 1: file.write("unsigned char") elif siz...
python
Tools/unicode/makeunicodedata.py
1,084
1,108
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,069
getsize
def getsize(data): # return smallest possible integer size for the given array maxdata = max(data) if maxdata < 256: return 1 elif maxdata < 65536: return 2 else: return 4
python
Tools/unicode/makeunicodedata.py
1,111
1,119
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,070
splitbins
def splitbins(t, trace=0): """t, trace=0 -> (t1, t2, shift). Split a table to save space. t is a sequence of ints. This function can be useful to save space if many of the ints are the same. t1 and t2 are lists of ints, and shift is an int, chosen to minimize the combined size of t1 and t2 (in C ...
python
Tools/unicode/makeunicodedata.py
1,122
1,181
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,071
dump
def dump(t1, t2, shift, bytes): print("%d+%d bins at shift %d; %d bytes" % ( len(t1), len(t2), shift, bytes), file=sys.stderr)
python
Tools/unicode/makeunicodedata.py
1,138
1,140
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,072
gencodecs
def gencodecs(prefix): for loc, encodings in codecs.items(): for enc in encodings: code = TEMPLATE.substitute(ENCODING=enc.upper(), encoding=enc.lower(), owner=loc) codecpath = os.path.join(prefix, enc + '....
python
Tools/unicode/gencjkcodecs.py
57
65
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,073
listcodecs
def listcodecs(dir): names = [] for filename in os.listdir(dir): if filename[-3:] != '.py': continue name = filename[:-3] # Check whether we've found a true codec try: codecs.lookup(name) except LookupError: # Codec not found ...
python
Tools/unicode/listcodecs.py
13
32
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,074
main
def main(): filenames, hashes, sizes = [], [], [] for file in sys.argv[1:]: if not os.path.isfile(file): continue with open(file, 'rb') as f: data = f.read() md5 = hashlib.md5() md5.update(data) filenames.append(os.path.split(file)[1]...
python
Tools/msi/generate_md5.py
5
22
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,075
make_id
def make_id(path): return re.sub( r'[^A-Za-z0-9_.]', lambda m: ID_CHAR_SUBS.get(m.group(0), '_'), str(path).rstrip('/\\'), flags=re.I )
python
Tools/msi/csv_to_wxs.py
33
39
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,076
main
def main(file_source, install_target): with open(file_source, 'r', newline='') as f: files = list(csv.reader(f)) assert len(files) == len(set(make_id(f[1]) for f in files)), "Duplicate file IDs exist" directories = defaultdict(set) cache_directories = defaultdict(set) groups = defaultdict(...
python
Tools/msi/csv_to_wxs.py
43
124
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,077
parse_emconfig
def parse_emconfig( emconfig: pathlib.Path = EM_CONFIG, ) -> Tuple[pathlib.Path, pathlib.Path]: """Parse EM_CONFIG file and lookup EMSCRIPTEN_ROOT and NODE_JS. The ".emscripten" config file is a Python snippet that uses "EM_CONFIG" environment variable. EMSCRIPTEN_ROOT is the "upstream/emscripten" ...
python
Tools/wasm/wasm_build.py
120
138
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,078
read_python_version
def read_python_version(configure: pathlib.Path = CONFIGURE) -> str: """Read PACKAGE_VERSION from configure script configure and configure.ac are the canonical source for major and minor version number. """ version_re = re.compile(r"^PACKAGE_VERSION='(\d\.\d+)'") with configure.open(encoding="u...
python
Tools/wasm/wasm_build.py
144
156
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,079
__init__
def __init__(self, info: str, text: str) -> None: self.info = info self.text = text
python
Tools/wasm/wasm_build.py
163
165
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,080
__str__
def __str__(self) -> str: return f"{type(self).__name__}: '{self.info}'\n{self.text}"
python
Tools/wasm/wasm_build.py
167
168
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,081
getenv
def getenv(self, profile: "BuildProfile") -> Dict[str, Any]: return self.environ.copy()
python
Tools/wasm/wasm_build.py
201
202
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,082
_check_clean_src
def _check_clean_src() -> None: candidates = [ SRCDIR / "Programs" / "python.o", SRCDIR / "Python" / "frozen_modules" / "importlib._bootstrap.h", ] for candidate in candidates: if candidate.exists(): raise DirtySourceDirectory(os.fspath(candidate), CLEAN_SRCDIR)
python
Tools/wasm/wasm_build.py
205
212
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,083
_check_native
def _check_native() -> None: if not any(shutil.which(cc) for cc in ["cc", "gcc", "clang"]): raise MissingDependency("cc", INSTALL_NATIVE) if not shutil.which("make"): raise MissingDependency("make", INSTALL_NATIVE) if sys.platform == "linux": # skip pkg-config check on macOS ...
python
Tools/wasm/wasm_build.py
215
230
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,084
_check_emscripten
def _check_emscripten() -> None: if EMSCRIPTEN_ROOT is _MISSING: raise MissingDependency("Emscripten SDK EM_CONFIG", INSTALL_EMSDK) # sanity check emconfigure = EMSCRIPTEN.configure_wrapper if emconfigure is not None and not emconfigure.exists(): raise MissingDependency(os.fspath(emconfi...
python
Tools/wasm/wasm_build.py
247
288
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,085
_check_wasi
def _check_wasi() -> None: wasm_ld = WASI_SDK_PATH / "bin" / "wasm-ld" if not wasm_ld.exists(): raise MissingDependency(os.fspath(wasm_ld), INSTALL_WASI_SDK) wasmtime = shutil.which("wasmtime") if wasmtime is None: raise MissingDependency("wasmtime", INSTALL_WASMTIME) _check_clean_sr...
python
Tools/wasm/wasm_build.py
309
316
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,086
platform
def platform(self) -> Platform: if self.is_emscripten: return EMSCRIPTEN elif self.is_wasi: return WASI else: return NATIVE
python
Tools/wasm/wasm_build.py
354
360
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,087
is_emscripten
def is_emscripten(self) -> bool: cls = type(self) return self in {cls.wasm32_emscripten, cls.wasm64_emscripten}
python
Tools/wasm/wasm_build.py
363
365
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,088
is_wasi
def is_wasi(self) -> bool: cls = type(self) return self in {cls.wasm32_wasi, cls.wasm64_wasi}
python
Tools/wasm/wasm_build.py
368
370
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,089
get_extra_paths
def get_extra_paths(self) -> Iterable[pathlib.PurePath]: """Host-specific os.environ["PATH"] entries. Emscripten's Node version 14.x works well for wasm32-emscripten. wasm64-emscripten requires more recent v8 version, e.g. node 16.x. Attempt to use system's node command. """ ...
python
Tools/wasm/wasm_build.py
372
386
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,090
emport_args
def emport_args(self) -> List[str]: """Host-specific port args (Emscripten).""" cls = type(self) if self is cls.wasm64_emscripten: return ["-sMEMORY64=1"] elif self is cls.wasm32_emscripten: return ["-sMEMORY64=0"] else: return []
python
Tools/wasm/wasm_build.py
389
397
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,091
embuilder_args
def embuilder_args(self) -> List[str]: """Host-specific embuilder args (Emscripten).""" cls = type(self) if self is cls.wasm64_emscripten: return ["--wasm64"] else: return []
python
Tools/wasm/wasm_build.py
400
406
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,092
is_browser
def is_browser(self) -> bool: cls = type(self) return self in {cls.browser, cls.browser_debug}
python
Tools/wasm/wasm_build.py
418
420
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,093
emport_args
def emport_args(self) -> List[str]: """Target-specific port args.""" cls = type(self) if self in {cls.browser_debug, cls.node_debug}: # some libs come in debug and non-debug builds return ["-O0"] else: return ["-O2"]
python
Tools/wasm/wasm_build.py
423
430
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,094
__bool__
def __bool__(self) -> bool: cls = type(self) return self in {cls.supported, cls.working}
python
Tools/wasm/wasm_build.py
439
441
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,095
is_browser
def is_browser(self) -> bool: """Is this a browser build?""" return self.target is not None and self.target.is_browser
python
Tools/wasm/wasm_build.py
455
457
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,096
builddir
def builddir(self) -> pathlib.Path: """Path to build directory""" return BUILDDIR / self.name
python
Tools/wasm/wasm_build.py
460
462
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,097
python_cmd
def python_cmd(self) -> pathlib.Path: """Path to python executable""" return self.builddir / self.host.platform.pythonexe
python
Tools/wasm/wasm_build.py
465
467
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,098
makefile
def makefile(self) -> pathlib.Path: """Path to Makefile""" return self.builddir / "Makefile"
python
Tools/wasm/wasm_build.py
470
472
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,099
configure_cmd
def configure_cmd(self) -> List[str]: """Generate configure command""" # use relative path, so WASI tests can find lib prefix. # pathlib.Path.relative_to() does not work here. configure = os.path.relpath(CONFIGURE, self.builddir) cmd = [configure, "-C"] platform = self.ho...
python
Tools/wasm/wasm_build.py
475
507
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,100
make_cmd
def make_cmd(self) -> List[str]: """Generate make command""" cmd = ["make"] platform = self.host.platform if platform.make_wrapper: cmd.insert(0, os.fspath(platform.make_wrapper)) return cmd
python
Tools/wasm/wasm_build.py
510
516
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }