Check whether a script is valid

        See MANAGESIEVE specifications, section 2.12

        :param name: script's content
        :rtype: boolean
188060
def checkscript(self, content):
        
        if "VERSION" not in self.__capabilities:
            raise NotImplementedError(
                "server does not support CHECKSCRIPT command")
        content = tools.to_bytes(content)
        content = tools.to_bytes("{%d+}" % len(content)) + CRLF + content
        code, data = self.__send_command("CHECKSCRIPT", [content])
        if code == "OK":
            return True
        return False
1252972
def is_valid(self, context):
        
        if self.requires:
            for r in self.requires:
                if not r in context.executed_actions:
                    raise RequirementMissingError("Action '%s' requires '%s'" % (self.name, r))
        return True
563131
def havespace(self, scriptname, scriptsize):
        
        code, data = self.__send_command(
            "HAVESPACE", [scriptname.encode("utf-8"), scriptsize])
        if code == "OK":
            return True
        return False
99053
def script_exists(self, digest, *digests):
        """"""
        return self.execute(b'SCRIPT', b'EXISTS', digest, *digests)
1099524
function handleScriptValidation(url) {
        if (!url) {
          return;
        }
        url = url.split('#')[0];
        var scripts = document.getElementsByTagName('script');
        for (var i = scripts.length; i--;) {
          if (scripts[i].src === url) {
            return true;
          }
        }
        return false;
      }
1334134
def check_valid(self, get_params):
        
        if self.commands._if:
            return self.commands._if.check_valid(get_params)
355382
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlCapacity == null) {
			this.sarlCapacity = SarlFactory.eINSTANCE.createSarlCapacity();
			script.getXtendTypes().add(this.sarlCapacity);
			this.sarlCapacity.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlCapacity.setName(name);
			}
		}
	}
8978
def evaluate(self, script):
        
        if WEBENGINE:
            return self.dom.runJavaScript("{}".format(script))
        else:
            return self.dom.evaluateJavaScript("{}".format(script))
113703
def isgood(name):
    
    if not isbad(name):
        if name.endswith('.py') or name.endswith('.json') or name.endswith('.tar'):
            return True
    return False
1131432
private boolean ensureAntScriptFileIsValid(File antScriptFile) {
		if (antScriptFile.exists() && antScriptFile.isDirectory() && fAntScriptNamesCombo.getText().length() > 0) {
			setErrorMessage(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationIsDir);
			fAntScriptNamesCombo.setFocus();
			return false;
		}
		if (antScriptFile.exists()) {
			if (!antScriptFile.canWrite()) {
				setErrorMessage(FatJarPackagerMessages.FatJarPackageWizardPage_error_antScriptLocationUnwritable);
				fAntScriptNamesCombo.setFocus();
				return false;
			}
		}
		return true;
	}
779270
def _generate_validation_scripts(self):
        

        id_script_list_validation_fields = (
            AccessibleFormImplementation.ID_SCRIPT_LIST_VALIDATION_FIELDS
        )
        local = self.parser.find('head,body').first_result()
        if local is not None:
            if (
                self.parser.find(
                    '#'
                    + AccessibleEventImplementation.ID_SCRIPT_COMMON_FUNCTIONS
                ).first_result() is None
            ):
                common_functions_file = open(
                    os.path.join(
                        os.path.dirname(os.path.dirname(os.path.dirname(
                            os.path.realpath(__file__)
                        ))),
                        'js',
                        'common.js'
                    ),
                    'r'
                )
                common_functions_content = common_functions_file.read()
                common_functions_file.close()

                common_functions_script = self.parser.create_element('script')
                common_functions_script.set_attribute(
                    'id',
                    AccessibleEventImplementation.ID_SCRIPT_COMMON_FUNCTIONS
                )
                common_functions_script.set_attribute(
                    'type',
                    'text/javascript'
                )
                common_functions_script.append_text(common_functions_content)
                local.prepend_element(common_functions_script)

            self.script_list_fields_with_validation = self.parser.find(
                '#'
                + id_script_list_validation_fields
            ).first_result()
            if self.script_list_fields_with_validation is None:
                script_list_file = open(
                    os.path.join(
                        os.path.dirname(os.path.dirname(os.path.dirname(
                            os.path.realpath(__file__)
                        ))),
                        'js',
                        'scriptlist_validation_fields.js'
                    ),
                    'r'
                )
                script_list_content = script_list_file.read()
                script_list_file.close()

                self.script_list_fields_with_validation = (
                    self.parser.create_element('script')
                )
                self.script_list_fields_with_validation.set_attribute(
                    'id',
                    id_script_list_validation_fields
                )
                self.script_list_fields_with_validation.set_attribute(
                    'type',
                    'text/javascript'
                )
                self.script_list_fields_with_validation.append_text(
                    script_list_content
                )
                local.append_element(self.script_list_fields_with_validation)
            if (
                self.parser.find(
                    '#'
                    + AccessibleFormImplementation.ID_SCRIPT_EXECUTE_VALIDATION
                ).first_result() is None
            ):
                script_function_file = open(
                    os.path.join(
                        os.path.dirname(os.path.dirname(os.path.dirname(
                            os.path.realpath(__file__)
                        ))),
                        'js',
                        'validation.js'
                    ),
                    'r'
                )
                script_function_content = script_function_file.read()
                script_function_file.close()

                script_function = self.parser.create_element('script')
                script_function.set_attribute(
                    'id',
                    AccessibleFormImplementation.ID_SCRIPT_EXECUTE_VALIDATION
                )
                script_function.set_attribute('type', 'text/javascript')
                script_function.append_text(script_function_content)
                self.parser.find('body').first_result().append_element(
                    script_function
                )
        self.scripts_added = True
889887
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlBehavior == null) {
			this.sarlBehavior = SarlFactory.eINSTANCE.createSarlBehavior();
			script.getXtendTypes().add(this.sarlBehavior);
			this.sarlBehavior.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlBehavior.setName(name);
			}
		}
	}
703944
def isValidSemver(version):
    """"""
    if version and isinstance(version, string_types):
        try:
            semver.parse(version)
        except (TypeError,ValueError):
            return False
        else:
            return True
    return False
464949
def validate_name(name)
      return if name =~ /\A[a-z0-9]+[-\/][a-z][a-z0-9_]*\Z/i

      namespace, modname = name.split(/[-\/]/, 2)
      modname = :namespace_missing if namespace == ''

      err = case modname
      when nil, '', :namespace_missing
        _("the field must be a namespaced module name")
      when /[^a-z0-9_]/i
        _("the module name contains non-alphanumeric (or underscore) characters")
      when /^[^a-z]/i
        _("the module name must begin with a letter")
      else
        _("the namespace contains non-alphanumeric characters")
      end

      raise ArgumentError, _("Invalid 'name' field in metadata.json: %{err}") % { err: err }
    end
1034235
function hasModule (name) {
    // throw error on invalid name
    requireValidName(name)
    // check if module exists
    return defined(immutable.modules[name]) ? true : false
}
409548
def check(cls, config, strict=False):  # type: (dict, bool) -> Dict[str, List[str]]
        
        result = {"errors": [], "warnings": []}
        # Schema validation errors
        validation_errors = validate_object(config, "poetry-schema")

        result["errors"] += validation_errors

        if strict:
            # If strict, check the file more thoroughly

            # Checking license
            license = config.get("license")
            if license:
                try:
                    license_by_id(license)
                except ValueError:
                    result["errors"].append("{} is not a valid license".format(license))

            if "dependencies" in config:
                python_versions = config["dependencies"]["python"]
                if python_versions == "*":
                    result["warnings"].append(
                        "A wildcard Python dependency is ambiguous. "
                        "Consider specifying a more explicit one."
                    )

            # Checking for scripts with extras
            if "scripts" in config:
                scripts = config["scripts"]
                for name, script in scripts.items():
                    if not isinstance(script, dict):
                        continue

                    extras = script["extras"]
                    for extra in extras:
                        if extra not in config["extras"]:
                            result["errors"].append(
                                'Script "{}" requires extra "{}" which is not defined.'.format(
                                    name, extra
                                )
                            )

        return result
1010207
public static boolean valueIsScript(String propertyName) {
      return (getInstance().properties.containsKey(propertyName) && getInstance().properties.get(propertyName)
                                                                                            .startsWith(
                                                                                               SCRIPT_PROPERTY));
   }