Codebase list oslo-sphinx / e1b0dca
Speed up blueprint checking with naming convention If the blueprint file is named beginning with the name of a project, look there for the blueprint first. Change-Id: I49cf48ed001945670ab900fcc76cd4c2087ddbb7 Doug Hellmann 9 years ago
1 changed file(s) with 23 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7373
7474 def blueprint_exists(self, project_name, bp_name):
7575 """Return boolean indicating whether the blueprint exists."""
76 self.app.info('Checking for %s in %s' % (bp_name, project_name))
7677 url = self.BP_URL_TEMPLATE % (project_name, bp_name)
7778 response = requests.get(url)
78 return response.status_code == 200
79 if response.status_code == 200:
80 self.app.info('Found %s in %s' % (bp_name, project_name))
81 return True
82 return False
7983
8084 def check(self, bp_name):
8185 """Given one blueprint name, check to see if it is valid."""
8387 return True
8488 self._load_project_settings()
8589 self.app.info('') # emit newline
90 candidate_project, dash, bp_name_to_find = bp_name.partition('-')
91 if candidate_project in self.project_names:
92 # First check the shortened name of the blueprint in the project.
93 if self.blueprint_exists(candidate_project, bp_name_to_find):
94 return
95 # Then check the full name of the blueprint in the project.
96 if self.blueprint_exists(candidate_project, bp_name):
97 return
98 self.app.info(
99 ('Blueprint name %r looks like it starts with a project '
100 'name, but %r was not found in project %r') %
101 (bp_name, bp_name_to_find, candidate_project)
102 )
103 else:
104 self.app.info(
105 'Blueprint checking is faster if the file names '
106 'start with the launchpad project name.'
107 )
86108 for project_name in self.project_names:
87 self.app.info('Checking for %s in %s' % (bp_name, project_name))
88109 if self.blueprint_exists(project_name, bp_name):
89 self.app.info('Found %s in %s' % (bp_name, project_name))
90110 self._good_bps.add(bp_name)
91111 break
92112 else: