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

Unified Diff: scripts/common/archive_utils.py

Issue 2402423002: Enable saving the same file in multiple archives (Closed)
Patch Set: Remove accidental commit Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/common/archive_utils_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/common/archive_utils.py
diff --git a/scripts/common/archive_utils.py b/scripts/common/archive_utils.py
index a2fa1d858c90b1da55b309ed23b369078736ca09..86e7302b9fd1bb80ecb04869f609845e0eb161ed 100644
--- a/scripts/common/archive_utils.py
+++ b/scripts/common/archive_utils.py
@@ -78,33 +78,33 @@ class FilesCfgParser(object):
self._buildtype = buildtype
self._arch = arch
self._files_cfg = self._ParseFilesCfg(files_file)
- self.files_dict = self._FilterFilesCfg()
+ self._files_list = self._FilterFilesCfg()
def _SetArch(self, value):
- """Set build arch and reset files_dict to reflect new build criteria."""
+ """Set build arch and reset files_list to reflect new build criteria."""
self._arch = value
- self.files_dict.clear()
- self.files_dict.update(self._FilterFilesCfg())
+ del self._files_list[:]
+ self._files_list.extend(self._FilterFilesCfg())
arch = property(fset=_SetArch)
def _SetBuildType(self, value):
- """Set build type and reset files_dict to reflect new build criteria."""
+ """Set build type and reset files_list to reflect new build criteria."""
self._buildtype = value
- self.files_dict.clear()
- self.files_dict.update(self._FilterFilesCfg())
+ del self._files_list[:]
+ self._files_list.extend(self._FilterFilesCfg())
buildtype = property(fset=_SetBuildType)
def _FilterFilesCfg(self):
- """Return a dict of file items that match the current build criteria."""
- files_dict = {}
+ """Return a list of file items that match the current build criteria."""
+ files_list = []
for fileobj in self._files_cfg:
if self._buildtype not in fileobj['buildtype']:
continue
if not fileobj.get('arch') or self._arch in fileobj['arch']:
- files_dict[fileobj['filename']] = fileobj
- return files_dict
+ files_list.append(fileobj)
+ return files_list
@staticmethod
def _ParseFilesCfg(files_file):
@@ -133,19 +133,24 @@ class FilesCfgParser(object):
def IsOptional(self, filename):
"""Determine if the given filename is marked optional for this config."""
- return (self.files_dict.get(filename) and self._buildtype in
- self.files_dict[filename].get('optional', []))
+ has_file = False
+ for fileobj in self._files_list:
+ if fileobj['filename'] == filename:
+ has_file = True
+ if self._buildtype not in fileobj['optional']:
+ return False
+ return has_file
Michael Moss 2016/10/11 18:23:32 Maybe simplify slightly by getting rid of the 'has
Michael Moss 2016/10/11 18:47:06 Ugh, my logic was backwards, ignore. We want it to
def ParseGroup(self, filegroup):
"""Return the list of filenames in the given group (e.g. "symbols")."""
- return [fileobj['filename'] for fileobj in self.files_dict.itervalues()
+ return [fileobj['filename'] for fileobj in self._files_list
if (fileobj.get('filegroup') and filegroup in fileobj.get('filegroup'))
]
def ParseArchiveLists(self):
"""Generate a dict of all the file items in all archives."""
archive_lists = {}
- for fileobj in self.files_dict.itervalues():
+ for fileobj in self._files_list:
if fileobj.get('archive'):
archive_lists.setdefault(fileobj['archive'], []).append(fileobj)
return archive_lists
@@ -157,14 +162,13 @@ class FilesCfgParser(object):
filegroup (i.e. legacy entries from before the filegroup field was added.)
"""
files_list = [
- fileobj['filename'] for fileobj in self.files_dict.itervalues()
+ fileobj['filename'] for fileobj in self._files_list
if (not fileobj.get('archive') and
(not fileobj.get('filegroup') or 'default' in
fileobj.get('filegroup')))
]
return files_list
-
Michael Moss 2016/10/11 18:23:32 Nit: Keep 2 lines before top-level functions/class
chenwilliam 2016/10/11 19:08:15 Done.
def ParseFilesList(files_file, buildtype, arch):
"""DEPRECATED: Determine the list of archive files for a given release.
« no previous file with comments | « no previous file | scripts/common/archive_utils_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698