parse out the type and name from the resource

@param string $resource_base_path
@param string $resource_name
@param string $resource_type
@param string $resource_name
@return boolean
515324
function _parse_resource_name(&$params)
	{

		// split tpl_path by the first colon
		$_resource_name_parts = explode(':', $params['resource_name'], 2);

		if (count($_resource_name_parts) == 1) {
			// no resource type given
			$params['resource_type'] = $this->default_resource_type;
			$params['resource_name'] = $_resource_name_parts[0];
		} else {
			if(strlen($_resource_name_parts[0]) == 1) {
				// 1 char is not resource type, but part of filepath
				$params['resource_type'] = $this->default_resource_type;
				$params['resource_name'] = $params['resource_name'];
			} else {
				$params['resource_type'] = $_resource_name_parts[0];
				$params['resource_name'] = $_resource_name_parts[1];
			}
		}

		if ($params['resource_type'] == 'file') {
			if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
				// relative pathname to $params['resource_base_path']
				// use the first directory where the file is found
				foreach ((array)$params['resource_base_path'] as $_curr_path) {
					$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
					if (file_exists($_fullpath) && is_file($_fullpath)) {
						$params['resource_name'] = $_fullpath;
						return true;
					}
					// didn't find the file, try include_path
					$_params = array('file_path' => $_fullpath);
					require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
					if(smarty_core_get_include_path($_params, $this)) {
						$params['resource_name'] = $_params['new_file_path'];
						return true;
					}
				}
				return false;
			} else {
				/* absolute path */
				return file_exists($params['resource_name']);
			}
		} elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
			$_params = array('type' => $params['resource_type']);
			require_once(SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
			smarty_core_load_resource_plugin($_params, $this);
		}

		return true;
	}
649475
def is_resource_class_collection_attribute(rc, attr_name):
    
    attr = get_resource_class_attribute(rc, attr_name)
    return attr.kind == RESOURCE_ATTRIBUTE_KINDS.COLLECTION
681368
def resource_info(self, resource_name, extended=True):
        

        if extended:
            ret, err = self.visalib.parse_resource_extended(self.session, resource_name)
        else:
            ret, err = self.visalib.parse_resource(self.session, resource_name)

        return ret
873796
public function getFieldNameByBaseType($base_type)
    {
        $this->getTableInfo();
        $field = null;
        if (isset($this['fields'])) {
            if (isset($this['fields'][$base_type])) {
                $field = $base_type;
            }
            foreach ($this['fields'] as $v) {
                if (isset($v['base_type']) && $v['base_type'] == $base_type) {
                    $field = $v['field_name'];
                    break;
                }
            }
        }
        
        return $field;
    }
1014225
public function checkResourceTypes(array $resourceTypes)
    {
        $validTypes = [];
        $unknownTypes = [];

        foreach ($resourceTypes as $type) {
            //@todo write findByNames method.
            $rt = $this->resourceTypeRepo->findOneBy(['name' => $type['name']]);
            if (null === $rt) {
                $unknownTypes[] = $type['name'];
            } else {
                $validTypes[] = $rt;
            }
        }

        if (count($unknownTypes) > 0) {
            $content = 'The resource type(s) ';
            foreach ($unknownTypes as $unknown) {
                $content .= "{$unknown}, ";
            }
            $content .= 'were not found';

            throw new ResourceTypeNotFoundException($content);
        }

        return $validTypes;
    }
1187274
private function replaceTypes($raml, $types, $path, $name, $parentKey = null)
    {
        if (\strpos($path, '/') !== 0 || !\is_array($raml)) {
            return $raml;
        }

        $newArray = [];

        foreach ($raml as $key => $value) {
            if ($key === 'type' && \strpos($parentKey, '/') === 0) {
                $type = [];

                $typeVariables = ['resourcePath' => $path, 'resourcePathName' => $name];

                if (\is_array($value)) {
                    $typeVariables = \array_merge($typeVariables, \current($value));
                    $typeName = \key($value);
                    $type = $this->applyVariables($typeVariables, $types[$typeName]);
                } elseif (isset($types[$value])) {
                    $type = $this->applyVariables($typeVariables, $types[$value]);
                }

                $newArray = \array_replace_recursive($newArray, $this->replaceTypes($type, $types, $path, $name, $key));
            } else {
                $newName = $name;
                if (\strpos($key, '/') === 0 && !\preg_match('/^\/\{.+\}$/', $key)) {
                    $newName = (isset($value['displayName'])) ? $value['displayName'] : \substr($key, 1);
                }
                $newValue = $this->replaceTypes($value, $types, $path, $newName, $key);

                $newArray[$key] = isset($newArray[$key]) && \is_array($newArray[$key]) ? \array_replace_recursive($newArray[$key], $newValue) : $newValue;
            }
        }

        return $newArray;
    }
39844
public function addResource($resource, string $type = 'file'): void
    {
        if (is_array($resource)) {
            $this->addResourceArray($resource);
            return;
        }

        if (is_string($resource)) {
            switch ($type) {
                case 'json':
                    $this->addResourceString($resource);
                    break;
                case 'file':
                    $this->addResourceFile($resource);
                    break;
                default:
                    throw new \InvalidArgumentException("Invalid resource type");
            }
        }
    }
779431
def resource_type(resource)
      raise_unless_xpath!(resource)
      type = resource.xpath("string(command/ident/@value)")
      if type.empty?
        raise ArgumentError, "Provided AST node is not a resource"
      end
      type
    end
562697
public function load($resource, $type = null) 
    {
        $path = $this->locator->locate($resource);
        
        if (!stream_is_local($path)) {
            throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path));
        }

        if (!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
        }

        $result = parse_ini_file($path, true);
        
        if (false === $result || array() === $result) {
            throw new \InvalidArgumentException(sprintf('The "%s" file is not valid.', $path));
        }
        
        return $result;
    }
618873
public function deserialize($data, Resource $resource = null)
    {
        if (empty($resource)) {
            $resource = new Resource();
        }
        if (isset($data['resourceType']) && isset($data['resourceType']['name'])) {
            $resourceType = $this->resourceTypeRepo->findOneBy(['name' => $data['resourceType']['name']]);
            $resource->setResourceType($resourceType);
        }
        if (isset($data['name'])) {
            $resource->setName($data['name']);
        }
        if (isset($data['maxTimeReservation'])) {
            $resource->setMaxTimeReservation($data['maxTimeReservation']);
        }
        if (isset($data['description'])) {
            $resource->setDescription($data['description']);
        }
        if (isset($data['localization'])) {
            $resource->setLocalisation($data['localization']);
        }
        if (isset($data['quantity'])) {
            $resource->setQuantity($data['quantity']);
        }
        if (isset($data['color'])) {
            $resource->setColor($data['color']);
        }
        if (isset($data['organizations'])) {
            $this->deserializeOrganizations($resource, $data['organizations']);
        }

        return $resource;
    }
138452
public function load($resource, $type = null)
    {
        if (! is_file($resource)) {
            throw new InvalidArgumentException(sprintf('File "%s" is not a regular file.', $resource));
        }

        /* Checking file readability before hand to ensure getting its contents never fail. */
        if (! is_readable($resource)) {
            throw new InvalidArgumentException(sprintf('File "%s" is not readable.', $resource));
        }

        /* Explicitly reading file's content, because support for passing file names is deprecated since Symfony 2.8. */
        $content = file_get_contents($resource);
        $parsedYaml = Yaml::parse($content);

        if (! is_array($parsedYaml)) {
            throw new InvalidArgumentException(sprintf('Could not parse Yaml of file "%s"', $resource));
        }

        return $parsedYaml;
    }
852387
def validate_resource_uri(self, path):
        """"""
        if self._base_uri not in path:
            logger.exception('Get by uri : unrecognized uri: (%s)' % path)
            raise exceptions.HPOneViewUnknownType(UNRECOGNIZED_URI)
138196
public function visitResourceType(ResourceType $type)
    {
        $attributes = '';
        if (null !== $type->ofType()) {
            $attributes =
                sprintf('{ofType:%s}', var_export($type->ofType(), true));
        }

        return 'resource' . $attributes;
    }
1008085
def _parse_resource(resource):
        
        resource = resource.strip() if resource else resource
        if resource in {ME_RESOURCE, USERS_RESOURCE}:
            return resource
        elif '@' in resource and not resource.startswith(USERS_RESOURCE):
            # when for example accessing a shared mailbox the
            # resource is set to the email address. we have to prefix
            # the email with the resource 'users/' so --> 'users/email_address'
            return '{}/{}'.format(USERS_RESOURCE, resource)
        else:
            return resource
205840
def _ParseSourceType(self, source):
    """"""
    type_name = rdf_artifacts.ArtifactSource.SourceType
    switch = {
        type_name.COMMAND: self._ProcessCommandSource,
        type_name.DIRECTORY: self._ProcessFileSource,
        type_name.FILE: self._ProcessFileSource,
        type_name.GREP: self._ProcessGrepSource,
        type_name.REGISTRY_KEY: self._ProcessRegistryKeySource,
        type_name.REGISTRY_VALUE: self._ProcessRegistryValueSource,
        type_name.WMI: self._ProcessWmiSource,
        type_name.ARTIFACT_FILES: self._ProcessArtifactFilesSource,
        type_name.GRR_CLIENT_ACTION: self._ProcessClientActionSource
    }
    source_type = source.base_source.type

    try:
      source_type_action = switch[source_type]
    except KeyError:
      raise ValueError("Incorrect source type: %s" % source_type)

    for res in source_type_action(source):
      yield res
422006
def is_resource_class_terminal_attribute(rc, attr_name):
    
    attr = get_resource_class_attribute(rc, attr_name)
    return attr.kind == RESOURCE_ATTRIBUTE_KINDS.TERMINAL
947966
public function parse($resource) {

        $result = array();
        $fieldcnt = mysqli_num_fields($resource);


        $fields_transform = array();

        for($i=0;$i<$fieldcnt;$i++) {
            $finfo = mysqli_fetch_field_direct($resource, $i);

            if(isset(self::$mysqli_type[$finfo->type])) {
                $fields_transform[$finfo->name] = self::$mysqli_to_php[self::$mysqli_type[$finfo->type]];
            }
        }

        while($row = mysqli_fetch_assoc($resource)) {
            foreach($fields_transform as $fieldname => $fieldtype) {
               settype($row[$fieldname], $fieldtype);
            }
            $result[] = $row;
        }
        return $result;
    }