def Create(self, urn, aff4_type, mode="w", token=None, age=NEWEST_TIME,
             ignore_cache=False, force_new_version=True,
             object_exists=False, mutation_pool=None, transaction=None):
    if mode not in ["w", "r", "rw"]:
      raise AttributeError("Invalid mode %s" % mode)

    if token is None:
      token = data_store.default_token

    if urn is not None:
      urn = rdfvalue.RDFURN(urn)

    if "r" in mode:
      # Check to see if an object already exists.
      try:
        existing = self.Open(
            urn, mode=mode, token=token, age=age,
            ignore_cache=ignore_cache, transaction=transaction)

        result = existing.Upgrade(aff4_type)

        # We can't pass aff4_type into the Open call since it will raise with a
        # type mismatch. We set it like this so BadGetAttributeError checking
        # works.
        if aff4_type:
          result.aff4_type = aff4_type

        if force_new_version and existing.Get(result.Schema.TYPE) != aff4_type:
          result.ForceNewVersion()
        return result
      except IOError:
        pass

    # Object does not exist, just make it.
    cls = AFF4Object.classes[str(aff4_type)]
    result = cls(urn, mode=mode, token=token, age=age, aff4_type=aff4_type,
                 object_exists=object_exists, mutation_pool=mutation_pool,
                 transaction=transaction)
    result.Initialize()
    if force_new_version:
      result.ForceNewVersion()

    return result
Creates the urn if it does not already exist, otherwise opens it.
dataset/ETHPy150Open google/grr/grr/lib/aff4.py/Factory.Create