diff options
author | Doug Hellmann <doug@doughellmann.com> | 2015-02-24 18:52:53 -0500 |
---|---|---|
committer | Doug Hellmann <doug@doughellmann.com> | 2015-02-24 19:02:12 -0500 |
commit | e1b0dca451f2a492f5761950077eb6e721b64f60 (patch) | |
tree | 76e423de3ed9371071de8ca791869d205cb8a496 | |
parent | 7312f510e0f0025b43fbde2ea899a258b994f741 (diff) | |
download | oslosphinx-e1b0dca451f2a492f5761950077eb6e721b64f60.tar.gz |
Speed up blueprint checking with naming convention2.5.0
If the blueprint file is named beginning with the name of a project,
look there for the blueprint first.
Change-Id: I49cf48ed001945670ab900fcc76cd4c2087ddbb7
-rw-r--r-- | oslosphinx/check_blueprints.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/oslosphinx/check_blueprints.py b/oslosphinx/check_blueprints.py index 56fb86d..e241edc 100644 --- a/oslosphinx/check_blueprints.py +++ b/oslosphinx/check_blueprints.py @@ -74,9 +74,13 @@ class BlueprintChecker(object): def blueprint_exists(self, project_name, bp_name): """Return boolean indicating whether the blueprint exists.""" + self.app.info('Checking for %s in %s' % (bp_name, project_name)) url = self.BP_URL_TEMPLATE % (project_name, bp_name) response = requests.get(url) - return response.status_code == 200 + if response.status_code == 200: + self.app.info('Found %s in %s' % (bp_name, project_name)) + return True + return False def check(self, bp_name): """Given one blueprint name, check to see if it is valid.""" @@ -84,10 +88,26 @@ class BlueprintChecker(object): return True self._load_project_settings() self.app.info('') # emit newline + candidate_project, dash, bp_name_to_find = bp_name.partition('-') + if candidate_project in self.project_names: + # First check the shortened name of the blueprint in the project. + if self.blueprint_exists(candidate_project, bp_name_to_find): + return + # Then check the full name of the blueprint in the project. + if self.blueprint_exists(candidate_project, bp_name): + return + self.app.info( + ('Blueprint name %r looks like it starts with a project ' + 'name, but %r was not found in project %r') % + (bp_name, bp_name_to_find, candidate_project) + ) + else: + self.app.info( + 'Blueprint checking is faster if the file names ' + 'start with the launchpad project name.' + ) for project_name in self.project_names: - self.app.info('Checking for %s in %s' % (bp_name, project_name)) if self.blueprint_exists(project_name, bp_name): - self.app.info('Found %s in %s' % (bp_name, project_name)) self._good_bps.add(bp_name) break else: |