Returns the asset based on specified version/range whose attributes match the custom attribute
Override to apply additional or non-standard conditions.
183114
protected KieBase getKnowledgeBase(String name, String assetVersion, String modifier) throws ActivityException {
        Map<String,String> customAttrs = null;
        KnowledgeBaseAsset kbrs;
        if (assetVersion == null)
            kbrs = DroolsKnowledgeBaseCache.getKnowledgeBaseAsset(name, modifier, customAttrs, getClassLoader());
        else
            kbrs = DroolsKnowledgeBaseCache.getKnowledgeBaseAsset(new AssetVersionSpec(name, assetVersion), modifier, customAttrs, getClassLoader());

        if (kbrs == null) {
            return null;
        }
        else {
            super.loginfo("Using Knowledge Base: " + kbrs.getAsset().getLabel());

            String versionLabelVarName = getAttributeValue(RULE_VERSION_VAR);
            if (versionLabelVarName != null)
                setParameterValue(versionLabelVarName, kbrs.getAsset().getLabel());
            return kbrs.getKnowledgeBase();
        }
    }
1225238
def use_comparative_asset_view(self):
        """"""
        self._object_views['asset'] = COMPARATIVE
        # self._get_provider_session('asset_lookup_session') # To make sure the session is tracked
        for session in self._get_provider_sessions():
            try:
                session.use_comparative_asset_view()
            except AttributeError:
                pass
764388
def asset(self, id):
        
        data = None
        if int(id) > 0:
            url = self._build_url('releases', 'assets', str(id),
                                  base_url=self._api)
            data = self._json(self._get(url, headers=Release.CUSTOM_HEADERS),
                              200)
        return Asset(data, self) if data else None
1184620
def _check_ver_range(self, version, ver_range):
        

        lower, upper, lower_inc, upper_inc = ver_range

        #If the range extends over everything, we automatically match
        if lower is None and upper is None:
            return True

        if lower is not None:
            if lower_inc and version < lower:
                return False
            elif not lower_inc and version <= lower:
                return False

        if upper is not None:
            if upper_inc and version > upper:
                return False
            elif not upper_inc and version >= upper:
                return False

        # Prereleases have special matching requirements
        if version.is_prerelease:
            # Prereleases cannot match ranges that are not defined as prereleases
            if (lower is None or not lower.is_prerelease) and (upper is None or not upper.is_prerelease):
                return False

            # Prereleases without the same major.minor.patch as a range end point cannot match
            if (lower is not None and version.release_tuple != lower.release_tuple) and \
               (upper is not None and version.release_tuple != upper.release_tuple):
                return False

        return True
504133
def get_version_by_value(context, value):
  
  versions = get_versions(context)
  for version in versions:
    if version.value == value:
      return version
  fail("Didn't find a matching version for: "
       "{}:{} in env/service: {}/{}".format(
          context.key, value,
          context.env, context.service_name))
69902
def select_version(self, version_range):
        
        row = -1
        version = None
        for i, package in self.packages.iteritems():
            if package.version in version_range \
                    and (version is None or version < package.version):
                version = package.version
                row = i

        self.clearSelection()
        if row != -1:
            self.selectRow(row)
        return version
854636
def get_asset_location(element, attr):
    
    asset_location = re.match(r'^/?(static)?/?(.*)', element[attr],
                              re.IGNORECASE)

    # replace relative links i.e (../../static)
    asset_location = asset_location.group(2).replace('../', '')

    return asset_location
128103
def lookup_facade(name, version):
    
    for _version in range(int(version), 0, -1):
        try:
            facade = getattr(CLIENTS[str(_version)], name)
            return facade
        except (KeyError, AttributeError):
            continue
    else:
        raise ImportError("No supported version for facade: "
                          "{}".format(name))
701500
def find(self, asset_id, query=None, **kwargs):
        

        if query is None:
            query = {}

        normalize_select(query)

        return super(AssetsProxy, self).find(asset_id, query=query, **kwargs)
498869
public MatchResult matches(ProductDefinition def) {
        Collection<AppliesToFilterInfo> atfiList = _asset.getWlpInformation().getAppliesToFilterInfo();
        if (atfiList == null || atfiList.isEmpty()) {
            return MatchResult.NOT_APPLICABLE;
        }
        MatchResult matchResult = MatchResult.MATCHED;
        for (AppliesToFilterInfo atfi : atfiList) {
            if (!!!atfi.getProductId().equals(def.getId())) {
                // This one isn't applicable, maybe the next one is
                matchResult = MatchResult.NOT_APPLICABLE;
                continue;
            } else {
                if (def.getVersion() != null && !def.getVersion().isEmpty()) {

                    Version checkVersion = new Version(def.getVersion());
                    VersionRange vr = FilterVersion.getFilterRange(atfi.getMinVersion(), atfi.getMaxVersion());

                    if (!vr.includes(checkVersion)) {
                        return MatchResult.INVALID_VERSION;
                    }
                }

                if (atfi.getRawEditions() != null && !!!atfi.getRawEditions().isEmpty() && !!!atfi.getRawEditions().contains(def.getEdition())) {
                    return MatchResult.INVALID_EDITION;
                }

                if (atfi.getInstallType() != null && !!!atfi.getInstallType().equals(def.getInstallType())) {
                    return MatchResult.INVALID_INSTALL_TYPE;
                }

                // Got here so this must have been a match, only need one of the array to match, not all
                return MatchResult.MATCHED;
            }
        }
        return matchResult;
    }
334240
def get_asset(self, name, **kwargs):
        
        if len(name.split(".")) == 3:
            return self.get_objects([name], **kwargs)[0]
        else:
            return self.lookup_asset_symbols([name], **kwargs)[0]
169272
private VersionControl getAssetVersionControl() throws IOException, DataAccessException {
        VersionControl vc = getVersionControl();
        if (vc == null)
            vc = DataAccess.getAssetVersionControl(assetRoot);
        return vc;
    }
355269
protected static function getUrlFileDependencyVersion(AssetTypeInterface $assetType, $url, $version)
    {
        if ('#' !== $version) {
            return substr($version, 1);
        }

        if (preg_match('/(\d+)(\.\d+)(\.\d+)?(\.\d+)?/', $url, $match)) {
            return $assetType->getVersionConverter()->convertVersion($match[0]);
        }

        return '0.0.0.0';
    }
701711
def select(self, versions):
        """"""
        options = list(self.filter(versions))
        if options:
            return max(options)
        return None
1283226
def _index_range(self, version, symbol, from_version=None, **kwargs):
        
        from_index = None
        if from_version:
            from_index = from_version['up_to']
        return from_index, None
42845
private function get_assets_version( $append_version, $q = 'v' ) {
		if ( ! $append_version ) {
			return '';
		}
		$append = trim( $this->apply_filters( 'assets_version' ) );
		if ( $append !== '' ) {
			if ( $q ) {
				return '?' . $q . '=' . $append;
			}

			return '?' . $append;
		}

		return '';
	}
133913
def _get_version(name, results):
    '''
    
    '''
    for line in salt.utils.itertools.split(results, '\n'):
        if not line:
            continue
        try:
            pkgname, pkgver = line.rsplit('-', 1)
        except ValueError:
            continue
        if pkgname == name:
            return pkgver
    return None