mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Whitespace normalization, via reindent.py.
This commit is contained in:
parent
e6ddc8b20b
commit
182b5aca27
453 changed files with 31318 additions and 31452 deletions
|
@ -9,7 +9,7 @@ def write32(output, value):
|
|||
output.write(chr(value & 255)) ; value=value / 256
|
||||
output.write(chr(value & 255)) ; value=value / 256
|
||||
output.write(chr(value & 255))
|
||||
|
||||
|
||||
def read32(input):
|
||||
v=ord(input.read(1))
|
||||
v=v+ (ord(input.read(1))<<8 )
|
||||
|
@ -19,9 +19,9 @@ def read32(input):
|
|||
|
||||
import zlib, sys
|
||||
if len(sys.argv)!=2:
|
||||
print 'Usage: minigzip.py <filename>'
|
||||
print ' The file will be compressed or decompressed.'
|
||||
sys.exit(0)
|
||||
print 'Usage: minigzip.py <filename>'
|
||||
print ' The file will be compressed or decompressed.'
|
||||
sys.exit(0)
|
||||
|
||||
filename=sys.argv[1]
|
||||
compressing=1 ; outputname=filename+'.gz'
|
||||
|
@ -64,7 +64,7 @@ else:
|
|||
# extra flags, and OS byte.
|
||||
if flag & FEXTRA:
|
||||
# Read & discard the extra field, if present
|
||||
xlen=ord(input.read(1))
|
||||
xlen=ord(input.read(1))
|
||||
xlen=xlen+256*ord(input.read(1))
|
||||
input.read(xlen)
|
||||
if flag & FNAME:
|
||||
|
@ -92,11 +92,11 @@ else:
|
|||
decompdata=decompobj.flush()
|
||||
output.write(decompdata) ; length=length+len(decompdata)
|
||||
crcval=zlib.crc32(decompdata, crcval)
|
||||
|
||||
|
||||
# We've read to the end of the file, so we have to rewind in order
|
||||
# to reread the 8 bytes containing the CRC and the file size. The
|
||||
# decompressor is smart and knows when to stop, so feeding it
|
||||
# extra data is harmless.
|
||||
# extra data is harmless.
|
||||
input.seek(-8, 2)
|
||||
crc32=read32(input)
|
||||
isize=read32(input)
|
||||
|
@ -104,4 +104,3 @@ else:
|
|||
if isize!=length: print 'Incorrect length of data produced'
|
||||
|
||||
input.close() ; output.close()
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import zlib, sys
|
|||
if len(sys.argv)>1: filename=sys.argv[1]
|
||||
else: filename='zlibdemo.py'
|
||||
print 'Reading', filename
|
||||
f=open(filename, 'r') # Get the data to compress
|
||||
f=open(filename, 'r') # Get the data to compress
|
||||
s=f.read()
|
||||
f.close()
|
||||
|
||||
|
@ -24,7 +24,7 @@ decompressor=zlib.decompressobj()
|
|||
comptext=decomp=''
|
||||
for i in range(0, len(s), chunk):
|
||||
comptext=comptext+compressor.compress(s[i:i+chunk])
|
||||
comptext=comptext+compressor.flush() # Don't forget to call flush()!!
|
||||
comptext=comptext+compressor.flush() # Don't forget to call flush()!!
|
||||
|
||||
for i in range(0, len(comptext), chunk):
|
||||
decomp=decomp+decompressor.decompress(comptext[i:i+chunk])
|
||||
|
@ -33,4 +33,3 @@ decomp=decomp+decompressor.flush()
|
|||
print 'Progressive compression (level 9):'
|
||||
print ' Original:', len(s), 'Compressed:', len(comptext),
|
||||
print 'Uncompressed:', len(decomp)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue