Check the meta file is valid
971638
public function isValidMetaFile()
	{
		if ( $this->metaFile ) return true;

		$metaFilePath = key( $this->contents ) . "/" . XBRL_TaxonomyPackage::metaFolderName . "/" . XBRL_TaxonomyPackage::taxonomyPackageFilename;

		try
		{
			// The XML should be valid
			$xml = $this->getFileAsXML( $metaFilePath );
			// Can't access the namespace of an element from SimpleXML so use the DOM version
			$dom = dom_import_simplexml( $xml );
			$namespace = $dom->namespaceURI;
			unset( $dom );

			// The root element should be taxonomyPackage
			if ( $xml->getName() != XBRL_TaxonomyPackage::rootElementNme )
			{
				throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", $ex->getMessage() );
			}

			$this->metaFile = $xml;

			// Now time to read elements and validate the document
			$xmlAttributes = $xml->attributes( 'xml', true );
			$lang = isset( $xmlAttributes['lang'] ) ? (string)$xmlAttributes['lang'] : '';

			foreach ( $xml->children( $namespace ) as $name => $element )
			{
				switch ( $name )
				{
					case 'name':
					case 'description':
					case 'publisher':

						$elementXmlAttributes = $element->attributes( 'xml', true );
						$elementLang = isset( $elementXmlAttributes['lang'] ) ? (string)$elementXmlAttributes['lang'] : $lang;

						if ( empty( $elementLang ) )
						{
							throw XBRL_TaxonomyPackageException::withError( "tpe:missingLanguageAttribute", "The language code must not be empty") ;
						}

						if ( isset( $this->$name[ $elementLang ] ) )
						{
							throw XBRL_TaxonomyPackageException::withError( "tpe:duplicateLanguagesForElement", "The language must be unique across all names");
						}

						$this->$name[ $elementLang ] = (string)$element;

						unset( $elementAttributes );
						break;

					case 'identifier':
					case 'version':
					case 'publisherURL':
					case 'publisherCountry':
					case 'publicationDate':
					case 'publisherCountry':

						// There should be only one instance
						if ( ! is_null( $this->$name ) )
						{
							throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", "The element '$name' must not be repeated");
						}

						// Check for a valid country code if relevant
						if ( $name == 'publisherCountry' && ( strlen( (string)$element ) != 2 || ! isset( self::$countries[ (string)$element ] ) ) )
						{
							throw XBRL_TaxonomyPackageException::withError( 'tpe:invalidMetaDataFile', "The contry code '$element' is not a valid 2-letter country code" );
						}

						$this->$name = (string)$element;
						break;

					case 'license':

						// There should be only one instance
						if ( ! is_null( $this->$name ) )
						{
							throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", "The element '$name' must not be repeated");
						}

						$elementAttributes = $xml->attributes();
						$licenseName = isset( $elementAttributes['name'] ) ? (string)$elementAttributes['name'] : '';
						if ( ! $licenseName ) continue;
						$href = isset( $elementAttributes['href'] ) ? (string)$elementAttributes['href'] : '';

						$this->$name['name'] = $licenseName;
						$this->$name['href'] = $href;

						unset( $licenseName );
						unset( $href );
						unset( $elementAttributes );
						break;

					case 'entryPoints':

						$elementXmlAttributes = $element->attributes( 'xml', true );
						$elementLang = isset( $elementXmlAttributes['lang'] ) ? (string)$elementXmlAttributes['lang'] : $lang;

						$entryPoints = array();

						foreach ( $element->children( $namespace ) as $entryPointName => $entryPoint )
						{
							$elementXmlAttributes = $entryPoint->attributes( 'xml', true );
							$elementLang2 = isset( $elementXmlAttributes['lang'] ) ? (string)$elementXmlAttributes['lang'] : $elementLang;

							$entryPoints[] = array();
							$index = count( $entryPoints ) - 1;

							foreach ( $entryPoint->children( $namespace ) as $elementName => $element )
							{
								switch ( $elementName )
								{
									case 'name':
									case 'description':

										$elementXmlAttributes = $element->attributes( 'xml', true );
										$elementLang3 = isset( $elementXmlAttributes['lang'] ) ? (string)$elementXmlAttributes['lang'] : $elementLang2;

										if ( empty( $elementLang3 ) )
										{
											throw XBRL_TaxonomyPackageException::withError( "tpe:missingLanguageAttribute", "The language code must not be empty") ;
										}

										if ( isset( $entryPoints[ $index ][ $elementName ][ $elementLang3 ] ) )
										{
											throw XBRL_TaxonomyPackageException::withError( "tpe:duplicateLanguagesForElement", "The language must be unique across all names");
										}

										$entryPoints[ $index ][ $elementName ][ $elementLang3 ] = (string)$element;

										unset( $elementXmlAttributes );
										break;

									case 'version':

										// There should be only one instance
										if ( isset( $entryPoints[ $index ][ $elementName ] ) )
										{
											throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", "The element '$elementName' must not be repeated");
										}

										$entryPoints[ $index ][ $elementName ] = (string)$element;
										break;

									case 'entryPointDocument':

										$elementAttributes = $element->attributes();
										if ( ! isset( $elementAttributes->href ) )
										{
											throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", "Missing the @href on element '$elementName'");
										}

										$href = (string)$elementAttributes->href;
										$entryPoints[ $index ][ $elementName ][] = $href;

										unset( $href );
										unset( $elementAttributes );
										break;

									case 'languages':

										foreach ( $element as $languageElement => $language )
										{
											$entryPoints[ $index ][ $elementName ][] = (string)$language;
										}
										unset( $languageElement );
										unset( $language );
										break;
								}
							}

							unset( $element );
							unset( $elementName );
						}


						$this->entryPoints = $entryPoints;

						unset( $entryPoints );
						unset( $entryPoint );
						unset( $entryPointName );

						break;

					default:

						// supersededTaxonomyPackages
						// versioningReports
						break;
				}
			}

			unset( $element );

		}
		catch ( XBRL_TaxonomyPackageException $ex )
		{
			throw $ex;
		}
		catch ( Exception $ex )
		{
			throw XBRL_TaxonomyPackageException::withError( "tpe:invalidMetaDataFile", $ex->getMessage() );
		}

		return true;
	}
844568
def check_meta(cls, dap):
        ''''''
        problems = list()

        # Check for non array-like metadata
        for datatype in (Dap._required_meta | Dap._optional_meta) - Dap._array_meta:
            if not dap._isvalid(datatype):
                msg = datatype + ' is not valid (or required and unspecified)'
                problems.append(DapProblem(msg))

        # Check for the array-like metadata
        for datatype in Dap._array_meta:
            ok, bads = dap._arevalid(datatype)
            if not ok:
                if not bads:
                    msg = datatype + ' is not a valid non-empty list'
                    problems.append(DapProblem(msg))
                else:
                    for bad in bads:
                        msg = bad + ' in ' + datatype + ' is not valid or is a duplicate'
                        problems.append(DapProblem(msg))

        # Check that there is no unknown metadata
        leftovers = set(dap.meta.keys()) - (Dap._required_meta | Dap._optional_meta)
        if leftovers:
            msg = 'Unknown metadata: ' + str(leftovers)
            problems.append(DapProblem(msg))

        # Check that package_name is not longer than 200 characters
        if len(dap.meta.get('package_name', '')) > 200:
            msg = 'Package name is too long. It must not exceed 200 characters.'
            problems.append(DapProblem(msg))

        return problems
248602
def check(self, strict=False):
        """"""
        self.set_metadata_version()

        # XXX should check the versions (if the file was loaded)
        missing, warnings = [], []

        for attr in ('Name', 'Version'):  # required by PEP 345
            if attr not in self:
                missing.append(attr)

        if strict and missing != []:
            msg = 'missing required metadata: %s' % ', '.join(missing)
            raise MetadataMissingError(msg)

        for attr in ('Home-page', 'Author'):
            if attr not in self:
                missing.append(attr)

        # checking metadata 1.2 (XXX needs to check 1.1, 1.0)
        if self['Metadata-Version'] != '1.2':
            return missing, warnings

        scheme = get_scheme(self.scheme)

        def are_valid_constraints(value):
            for v in value:
                if not scheme.is_valid_matcher(v.split(';')[0]):
                    return False
            return True

        for fields, controller in ((_PREDICATE_FIELDS, are_valid_constraints),
                                   (_VERSIONS_FIELDS,
                                    scheme.is_valid_constraint_list),
                                   (_VERSION_FIELDS,
                                    scheme.is_valid_version)):
            for field in fields:
                value = self.get(field, None)
                if value is not None and not controller(value):
                    warnings.append('Wrong value for %r: %s' % (field, value))

        return missing, warnings
127291
def valid_hook(hook_file, hook_name):
    
    filename = os.path.basename(hook_file)
    basename = os.path.splitext(filename)[0]

    matching_hook = basename == hook_name
    supported_hook = basename in _HOOKS
    backup_file = filename.endswith('~')

    return matching_hook and supported_hook and not backup_file
934244
function checkMetaRules(nodePaths, includeChildren, callback) {
            var parameters = {
                command: CONSTANTS.SERVER_WORKER_REQUESTS.CHECK_CONSTRAINTS,
                checkType: 'META', //TODO this should come from a constant
                includeChildren: includeChildren,
                nodePaths: nodePaths,
                commitHash: state.commitHash,
                projectId: state.project.projectId
            };

            storage.simpleRequest(parameters, function (err, result) {
                if (err) {
                    logger.error(err);
                }

                if (result) {
                    client.dispatchEvent(client.CONSTANTS.META_RULES_RESULT, result);
                } else {
                    client.notifyUser({
                        severity: 'error',
                        message: 'Evaluating Meta rules failed with error.'
                    });
                }

                if (callback) {
                    callback(err, result);
                }
            });
        }
1294934
def _eval_meta_as_summary(meta):
    """"""

    if meta == '':
        return False
    if len(meta)>500:
        return False
    if 'login' in meta.lower():
        return False
    return True
652690
public function check()
    {
        $origStage = Versioned::get_reading_mode();
        Versioned::set_reading_mode(Versioned::LIVE);

        $files = $this->getFiles();
        if ($files) {
            $fileTypeValidateFunc = $this->fileTypeValidateFunc;
            if (method_exists($this, $fileTypeValidateFunc)) {
                $invalidFiles = [];
                $validFiles = [];

                foreach ($files as $file) {
                    if ($this->$fileTypeValidateFunc($file)) {
                        $validFiles[] = $file;
                    } else {
                        $invalidFiles[] = $file;
                    }
                }

                // If at least one file was valid, count as passed
                if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) {
                    $validFileList = PHP_EOL;
                    foreach ($validFiles as $vf) {
                        $validFileList .= $vf . PHP_EOL;
                    }
                    if ($fileTypeValidateFunc == 'noVidation') {
                        $checkReturn = [
                            EnvironmentCheck::OK,
                            sprintf('At least these file(s) accessible: %s', $validFileList)
                        ];
                    } else {
                        $checkReturn = [
                            EnvironmentCheck::OK,
                            sprintf(
                                'At least these file(s) passed file type validate function "%s": %s',
                                $fileTypeValidateFunc,
                                $validFileList
                            )
                        ];
                    }
                } else {
                    if (count($invalidFiles) == 0) {
                        $checkReturn = [EnvironmentCheck::OK, 'All files valideted'];
                    } else {
                        $invalidFileList = PHP_EOL;
                        foreach ($invalidFiles as $vf) {
                            $invalidFileList .= $vf . PHP_EOL;
                        }

                        if ($fileTypeValidateFunc == 'noVidation') {
                            $checkReturn = [
                                EnvironmentCheck::ERROR,
                                sprintf('File(s) not accessible: %s', $invalidFileList)
                            ];
                        } else {
                            $checkReturn = [
                                EnvironmentCheck::ERROR,
                                sprintf(
                                    'File(s) not passing the file type validate function "%s": %s',
                                    $fileTypeValidateFunc,
                                    $invalidFileList
                                )
                            ];
                        }
                    }
                }
            } else {
                $checkReturn =  array(
                    EnvironmentCheck::ERROR,
                    sprintf("Invalid file type validation method name passed: %s ", $fileTypeValidateFunc)
                );
            }
        } else {
            $checkReturn = array(
                EnvironmentCheck::ERROR,
                sprintf("No files accessible at path %s", $this->path)
            );
        }

        Versioned::set_reading_mode($origStage);

        return $checkReturn;
    }
1019351
def validate(config):
    """"""
    with open(config) as fh:
        content = fh.read()

    try:
        data = yaml.safe_load(content)
    except Exception:
        log.error("config file: %s is not valid yaml", config)
        raise

    try:
        jsonschema.validate(data, CONFIG_SCHEMA)
    except Exception:
        log.error("config file: %s is not valid", config)
        raise

    log.info("config file valid, accounts:%d", len(data['accounts']))
    return data
345923
def verify(path):
        """"""
        valid = False
        try:
            h5 = h5py.File(path, mode="r")
        except (OSError, IsADirectoryError):
            pass
        else:
            if ("file_format" in h5.attrs and
                h5.attrs["file_format"].lower() == "hyperspy" and
                    "Experiments" in h5):
                valid = True
        return valid
127853
function invalid(data, meta, thing) {
	if (data === undefined && meta.required)
		return true;

	let type = meta.type;
	
	// missing type accepts anything
	if (type === undefined)
		return false;
		
	// application defined type?
	
	if (thing.model.types && thing.model.types.hasOwnProperty(type))
		return invalid(data, thing.model.types[type], thing);
		
	if (typeof (meta.enum) === 'array') {
		list = meta.enum;
		
		for (let i = 0; i < list.length; ++i ) {
			if (data === list[i])
				return false;
		}
		
		return true;
	}
	
	if (type === 'null' && data !== null)
		return true;
		
	if (type === 'const' && data !== meta.const)
		return true;
	
	if (type === 'boolean')
		return !(data === true || data === false);
		
	if (type === 'string') {
		if (typeof data !== 'string')
			return true;
			
		if (meta.regex) {
			const regex = new RegExp(meta.regex);
			return ! regex.test(data);
		}
		
		return false;
	}
		
	if (type === 'number' || type === 'integer') {		
		if (typeof data !== 'number')
			return true;
			
		if (type === 'integer' && !Number.isInteger(data))
			return true;
						
		if (meta.minimum !== undefined && data < meta.minimum)
			return true;
			
		if (meta.maximum !== undefined && data > meta.maximum)
			return true;
			
		return false;
	}
	
	// arrays and objects are more complicated
	// is it acceptable for data to be null when expecting an array?
	
	if (type === 'array') {
		if (!Array.isArray(data))
			return true;
			
		let length = data.length;
		
		if (meta.minItems !== undefined && length < meta.minItems)
			return true;
			
		if (meta.maxItems !== undefined && length > meta.maxItems)
			return true;
			
		let items = meta.items;
		
		if (items !== undefined) {
			for (let i = 0; i < length; ++i) {
				if (!invalid(data[i], meta, thing))
					return true;
			}
		}
		
		return false;
	}
	
	// is it acceptable for data to be null when expecting an object?
	
	if (type === 'object') {
		if (data === null || typeof data !== 'object' || Array.isArray(data))
			return true;
		let properties = meta.properties;
			
		for (name in data) {
			if (data.hasOwnProperty(name)) {
				if (!properties.hasOwnProperty(name))
					return true;
					
				if (invalid(data[name], properties[name], thing)) {
					return true;
				}
			}
		}
		
		let required = meta.required;
		
		if (required === undefined)
			return false;
			
		// we need to check for missing required properties
		
		for (let i = 0; i < required.length; ++i) {
			if (!data.hasOwnProperty(required[i]))
				return true;
		}
			
		return false;
	}
	
	return true;
}
637530
def check_meta(meta):
    
    if not isinstance(meta, dict):
        raise ValueError("bad metadata - not a dictionary")
    if not isinstance(meta.get("announce"), basestring):
        raise ValueError("bad announce URL - not a string")
    check_info(meta.get("info"))

    return meta
427182
def check(ctx, meta_model_file, model_file, ignore_case):
    
    debug = ctx.obj['debug']
    check_model(meta_model_file, model_file, debug, ignore_case)
660502
def is_valid_file(parser,arg):
	""""""
	if not os.path.exists(arg):
       		parser.error("File %s not found"%arg)
	else:
	       	return arg
503034
def _validate_config(config_path):
    '''
    
    '''
    log.debug('Checking configuration file: %s', config_path)

    if not os.path.isfile(config_path):
        message = 'Unable to get configuration file: {}'.format(config_path)
        log.error(message)
        raise SaltInvocationError(message)
    log.debug('Found configuration file: %s', config_path)
362663
protected function validateMetaTitle()
    {
        $field = 'meta_title';
        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            $this->unsetSubmitted($field);
            return true;
        }

        if (mb_strlen($value) > 60) {
            $this->setErrorLengthRange($field, $this->translation->text('Meta title'), 0, 60);
            return false;
        }

        return true;
    }
1075133
def _check_if_downloaded(self):
        
        if not os.path.isfile(self.path + self.file_name):
            print("")
            self.msg.template(78)
            print("| Download '{0}' file [ {1}FAILED{2} ]".format(
                self.file_name, self.meta.color["RED"],
                self.meta.color["ENDC"]))
            self.msg.template(78)
            print("")
            if not self.msg.answer() in ["y", "Y"]:
                raise SystemExit()
133202
def valid?
      return false if @id.nil?
      return false if @name.nil?
      return false if @name !~ Regexp.new(/^(?!(.*[\\\"\\*\\\\\\>\\<\\?\/\\:\\|]+.*)|(.*[\\.]?.*[\\.]+$)|(.*[ ]+$))/)
      return false if @node_type.nil?
      return false if @is_folder.nil?
      return false if @is_file.nil?
      return false if @modified_at.nil?
      return false if @modified_by_user.nil?
      return false if @created_at.nil?
      return false if @created_by_user.nil?
      return true
    end