# HG changeset patch # User osimons # Date 1274430208 0 # Node ID fcdc7fa56b1f260e79b1a12bcd0ae8aba591fb2b # Parent 031ce03d2baf04be7996c06c29bb374f98aa78a6 Support `resource_exists()` as new API feature called by Trac attachment code follwing trac:changeset:9724. diff --git a/bitten/main.py b/bitten/main.py --- a/bitten/main.py +++ b/bitten/main.py @@ -152,6 +152,16 @@ self.log.error("Unknown build/config resource.id: %s" % resource.id) return 'Unknown Build or Config' + def resource_exists(self, resource): + config_name, build_id = self._parse_resource(resource.id) + if build_id: + build = Build.fetch(self.env, build_id) + return build and build.exists or False + elif config_name: + config = BuildConfig.fetch(self.env, config_name) + return config and config.exists or False + return False + def _parse_resource(self, resource_id): """ Returns a (config_name, build_id) tuple. """ r = resource_id.split('/', 1)