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

Side by Side Diff: chrome/common/extensions/docs/server2/api_schema_graph.py

Issue 2738623003: Extensions: Fix DocServer assert failures. (Closed)
Patch Set: Nit. Created 3 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 json 5 import json
6 import logging 6 import logging
7 7
8 from api_models import GetNodeCategories 8 from api_models import GetNodeCategories
9 from collections import Iterable, Mapping 9 from collections import Iterable, Mapping
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 assert len(self._lookup_path) > 1, \ 73 assert len(self._lookup_path) > 1, \
74 'Tried to look up parent for the top-level node.' 74 'Tried to look up parent for the top-level node.'
75 75
76 # lookup_path[-1] is the name of the current node. If this lookup_path 76 # lookup_path[-1] is the name of the current node. If this lookup_path
77 # describes a regular node, then lookup_path[-2] will be a node category. 77 # describes a regular node, then lookup_path[-2] will be a node category.
78 # Otherwise, it's an event callback or a function parameter. 78 # Otherwise, it's an event callback or a function parameter.
79 if self._lookup_path[-2] not in GetNodeCategories(): 79 if self._lookup_path[-2] not in GetNodeCategories():
80 if self._lookup_path[-1] == 'callback': 80 if self._lookup_path[-1] == 'callback':
81 # This is an event callback, so lookup_path[-2] is the event 81 # This is an event callback, so lookup_path[-2] is the event
82 # node name, thus lookup_path[-3] must be 'events'. 82 # node name, thus lookup_path[-3] must be 'events'.
83 assert self._lookup_path[-3] == 'events' 83 assert self._lookup_path[-3] == 'events' , 'Invalid lookup path- %s' \
Devlin 2017/03/13 20:38:18 nitty nit: Let's separate the lines so the error s
karandeepb 2017/03/14 01:02:02 Done. Again is there a formatter commonly used for
Devlin 2017/03/14 01:12:05 No formatter I'm aware of. I think there are some
84 % (self._lookup_path)
84 return self._lookup_path[:-1] 85 return self._lookup_path[:-1]
85 # This is a function parameter. 86 # This is a function parameter.
86 assert self._lookup_path[-2] == 'parameters' 87 assert self._lookup_path[-2] == 'parameters'
87 return self._lookup_path[:-2] 88 return self._lookup_path[:-2]
88 # This is a regular node, so lookup_path[-2] should 89 # This is a regular node, so lookup_path[-2] should
89 # be a node category. 90 # be a node category.
90 self._AssertIsValidCategory(self._lookup_path[-2]) 91 self._AssertIsValidCategory(self._lookup_path[-2])
91 return self._lookup_path[:-2] 92 return self._lookup_path[:-2]
92 93
93 def _LookupNodeAvailability(self, lookup_path): 94 def _LookupNodeAvailability(self, lookup_path):
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 for path_piece in path: 374 for path_piece in path:
374 node = node.get(path_piece) 375 node = node.get(path_piece)
375 if node is None: 376 if node is None:
376 return LookupResult(found=False, annotation=None) 377 return LookupResult(found=False, annotation=None)
377 return LookupResult(found=True, annotation=node._annotation) 378 return LookupResult(found=True, annotation=node._annotation)
378 379
379 def IsEmpty(self): 380 def IsEmpty(self):
380 '''Checks for an empty schema graph. 381 '''Checks for an empty schema graph.
381 ''' 382 '''
382 return not self._graph 383 return not self._graph
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698