Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: tools/binary_size/libsupersize/file_format.py

Issue 2813963002: //tools/binary_size: Consolidate most tools into "supersize" command (Closed)
Patch Set: Fix readme formatting. Make archive's --outoput-file a positional arg Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Deals with loading & saving .size files.""" 5 """Deals with loading & saving .size files."""
6 6
7 import cStringIO 7 import cStringIO
8 import calendar 8 import calendar
9 import collections 9 import collections
10 import datetime 10 import datetime
11 import gzip 11 import gzip
12 import json 12 import json
13 import models
14 import logging 13 import logging
15 import os 14 import os
16 import shutil 15 import shutil
17 16
17 import models
18
18 19
19 # File format version for .size files. 20 # File format version for .size files.
20 _SERIALIZATION_VERSION = 'Size File Format v1' 21 _SERIALIZATION_VERSION = 'Size File Format v1'
21 22
22 23
23 def _LogSize(file_obj, desc): 24 def _LogSize(file_obj, desc):
24 if not hasattr(file_obj, 'fileno'): 25 if not hasattr(file_obj, 'fileno'):
25 return 26 return
26 file_obj.flush() 27 file_obj.flush()
27 size = os.fstat(file_obj.fileno()).st_size 28 size = os.fstat(file_obj.fileno()).st_size
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 logging.debug('Serialization complete. Gzipping...') 167 logging.debug('Serialization complete. Gzipping...')
167 stringio.seek(0) 168 stringio.seek(0)
168 with gzip.open(path, 'wb') as f: 169 with gzip.open(path, 'wb') as f:
169 shutil.copyfileobj(stringio, f) 170 shutil.copyfileobj(stringio, f)
170 171
171 172
172 def LoadSizeInfo(path): 173 def LoadSizeInfo(path):
173 """Returns a SizeInfo loaded from |path|.""" 174 """Returns a SizeInfo loaded from |path|."""
174 with gzip.open(path) as f: 175 with gzip.open(path) as f:
175 return _LoadSizeInfoFromFile(f) 176 return _LoadSizeInfoFromFile(f)
OLDNEW
« no previous file with comments | « tools/binary_size/libsupersize/describe.py ('k') | tools/binary_size/libsupersize/function_signature.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698