OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import copy | 5 import copy |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 from file_system import FileNotFoundError | |
10 import third_party.json_schema_compiler.json_parse as json_parse | 9 import third_party.json_schema_compiler.json_parse as json_parse |
11 import third_party.json_schema_compiler.model as model | 10 import third_party.json_schema_compiler.model as model |
12 import third_party.json_schema_compiler.idl_schema as idl_schema | 11 import third_party.json_schema_compiler.idl_schema as idl_schema |
13 import third_party.json_schema_compiler.idl_parser as idl_parser | 12 import third_party.json_schema_compiler.idl_parser as idl_parser |
14 | 13 |
15 # Increment this if the data model changes for APIDataSource. | 14 # Increment this if the data model changes for APIDataSource. |
16 # This would include changes to model.py in json_schema_compiler! | 15 # This would include changes to model.py in json_schema_compiler! |
17 _VERSION = 17 | 16 _VERSION = 17 |
18 | 17 |
19 def _RemoveNoDocs(item): | 18 def _RemoveNoDocs(item): |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 self._json_cache = json_cache | 374 self._json_cache = json_cache |
376 self._idl_cache = idl_cache | 375 self._idl_cache = idl_cache |
377 self._json_cache_no_refs = json_cache_no_refs | 376 self._json_cache_no_refs = json_cache_no_refs |
378 self._idl_cache_no_refs = idl_cache_no_refs | 377 self._idl_cache_no_refs = idl_cache_no_refs |
379 self._names_cache = names_cache | 378 self._names_cache = names_cache |
380 self._idl_names_cache = idl_names_cache | 379 self._idl_names_cache = idl_names_cache |
381 self._samples = samples | 380 self._samples = samples |
382 self._disable_refs = disable_refs | 381 self._disable_refs = disable_refs |
383 | 382 |
384 def _GetFeatureFile(self, filename): | 383 def _GetFeatureFile(self, filename): |
385 try: | 384 perms = self._permissions_cache.GetFromFile('%s/%s' % |
386 perms = self._permissions_cache.GetFromFile('%s/%s' % | 385 (self._base_path, filename)) |
387 (self._base_path, filename)) | 386 return dict((model.UnixName(k), v) for k, v in perms.iteritems()) |
388 return dict((model.UnixName(k), v) for k, v in perms.iteritems()) | |
389 except FileNotFoundError: | |
390 return {} | |
391 | 387 |
392 def _GetFeatureData(self, path): | 388 def _GetFeatureData(self, path): |
393 # Remove 'experimental_' from path name to match the keys in | 389 # Remove 'experimental_' from path name to match the keys in |
394 # _permissions_features.json. | 390 # _permissions_features.json. |
395 path = model.UnixName(path.replace('experimental_', '')) | 391 path = model.UnixName(path.replace('experimental_', '')) |
396 | 392 |
397 for filename in ['_permission_features.json', '_manifest_features.json']: | 393 for filename in ['_permission_features.json', '_manifest_features.json']: |
398 feature_data = self._GetFeatureFile(filename).get(path, None) | 394 feature_data = self._GetFeatureFile(filename).get(path, None) |
399 if feature_data is not None: | 395 if feature_data is not None: |
400 break | 396 break |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 if self._disable_refs: | 441 if self._disable_refs: |
446 cache, ext = ( | 442 cache, ext = ( |
447 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else | 443 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else |
448 (self._json_cache_no_refs, '.json')) | 444 (self._json_cache_no_refs, '.json')) |
449 else: | 445 else: |
450 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else | 446 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else |
451 (self._json_cache, '.json')) | 447 (self._json_cache, '.json')) |
452 return self._GenerateHandlebarContext( | 448 return self._GenerateHandlebarContext( |
453 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), | 449 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), |
454 path) | 450 path) |
OLD | NEW |