def Validate(self):
    """Check the source is well constructed."""

    if self.type == "COMMAND":
      # specifying command execution artifacts with multiple arguments as a
      # single string is a common mistake. For example the definition
      # cmd: "ls"
      # args: [-l -a]
      # will give you args as ["-l -a"] but that will not work (try ls "-l -a").
      args = self.attributes.GetItem("args")
      if args and len(args) == 1 and " " in args[0]:
        raise ArtifactDefinitionError(
            "Cannot specify a single argument containing a space: %s." % args)

    # Catch common mistake of path vs paths.
    if self.attributes.GetItem("paths"):
      if not isinstance(self.attributes.GetItem("paths"), list):
        raise ArtifactDefinitionError(
            "Arg 'paths' that is not a list.")

    if self.attributes.GetItem("path"):
      if not isinstance(self.attributes.GetItem("path"), basestring):
        raise ArtifactDefinitionError(
            "Arg 'path' is not a string.")

    # Check all returned types.
    if self.returned_types:
      for rdf_type in self.returned_types:
        if rdf_type not in rdfvalue.RDFValue.classes:
          raise ArtifactDefinitionError(
              "Invalid return type %s" % rdf_type)

    src_type = self.TYPE_MAP.get(str(self.type))
    if src_type is None:
      raise ArtifactDefinitionError(
          "Invalid type %s." % self.type)

    required_attributes = src_type.get("required_attributes", [])
    missing_attributes = set(
        required_attributes).difference(self.attributes.keys())
    if missing_attributes:
      raise ArtifactDefinitionError(
          missing_attributes % "Missing required attributes: %s.")
dataset/ETHPy150Open google/grr/grr/lib/artifact_registry.py/ArtifactSource.Validate/swapped operands of `%`