MCPcopy Index your code
hub / github.com/python/cpython / dump

Method dump

Tools/unicode/makeunicodedata.py:1259–1283  ·  view source on GitHub ↗
(self, file, trace=0)

Source from the content-addressed store, hash-verified

1257 self.data = data
1258
1259 def dump(self, file, trace=0):
1260 # write data to file, as a C array
1261 size = getsize(self.data)
1262 if trace:
1263 print(self.name+":", size*len(self.data), "bytes", file=sys.stderr)
1264 file.write("static const ")
1265 if size == 1:
1266 file.write("unsigned char")
1267 elif size == 2:
1268 file.write("unsigned short")
1269 else:
1270 file.write("unsigned int")
1271 file.write(" " + self.name + "[] = {\n")
1272 if self.data:
1273 s = " "
1274 for item in self.data:
1275 i = str(item) + ", "
1276 if len(s) + len(i) > 78:
1277 file.write(s.rstrip() + "\n")
1278 s = " " + i
1279 else:
1280 s = s + i
1281 if s.strip():
1282 file.write(s.rstrip() + "\n")
1283 file.write("};\n\n")
1284
1285
1286def getsize(data):

Callers 4

marshalmapFunction · 0.45
makeunicodedataFunction · 0.45
makeunicodetypeFunction · 0.45
makeunicodenameFunction · 0.45

Calls 5

strFunction · 0.85
getsizeFunction · 0.70
writeMethod · 0.45
rstripMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected