Fetch a title, if it exists. Create it if it doesn't.

        Returns a tuple with the object first, and then a boolean that
        indicates whether or not the object was created fresh. True means it's
        brand new.
185913
def get_or_create_by_title(self, title):
        
        try:
            obj = self.get_by_title(title)
            created = False
        except DoesNotExistError:
            obj = self.create(title=title)
            created = True
        return obj, created
48603
def get_or_new_child(self, term, value=False, **kwargs):
        

        pt, rt = self.split_term(term)

        term = self.record_term + '.' + rt

        c = self.find_first(rt)

        if c is None:
            tc = self.doc.get_term_class(term.lower())
            c = tc(term, value, parent=self, doc=self.doc, section=self.section).new_children(**kwargs)
            assert not c.term_is("Datafile.Section"), (self, c)
            self.children.append(c)

        else:
            if value is not False:
                c.value = value

            for k, v in kwargs.items():
                c.get_or_new_child(k, v)

        # Check that the term was inserted and can be found.
        assert self.find_first(rt)
        assert self.find_first(rt) == c

        return c
104010
def created(self):
        ''
        return dateutil.parser.parse(str(self.f.currentRevision.created))
1156693
def set_title(self, title = None):
        

        if title is None or type(title) is not str:
            raise KPError("Need a new title.")
        else:
            self.title = title
            self.last_mod = datetime.now().replace(microsecond=0)
            return True
419419
def _fetch_new(&client_block)
      if (@never_block || (_total_current_size < @max_size))
        if client_block.arity == 0
          nc = yield
        else
          nc = yield @sessions_key
        end
        HotTub.logger.info "[HotTub] Adding client: #{nc.class.name} to #{@name}." if HotTub.log_trace?
        nc
      end
    end
483215
def _get_or_create(cls, model_class, *args, **kwargs):
        """"""
        manager = cls._get_manager(model_class)

        assert 'defaults' not in cls._meta.django_get_or_create, (
            "'defaults' is a reserved keyword for get_or_create "
            "(in %s._meta.django_get_or_create=%r)"
            % (cls, cls._meta.django_get_or_create))

        key_fields = {}
        for field in cls._meta.django_get_or_create:
            if field not in kwargs:
                raise errors.FactoryError(
                    "django_get_or_create - "
                    "Unable to find initialization value for '%s' in factory %s" %
                    (field, cls.__name__))
            key_fields[field] = kwargs.pop(field)
        key_fields['defaults'] = kwargs

        try:
            instance, _created = manager.get_or_create(*args, **key_fields)
        except IntegrityError:
            try:
                instance = manager.get(**cls._original_params)
            except manager.model.DoesNotExist:
                raise ValueError(
                    "django_get_or_create - Unable to create a new object "
                    "due an IntegrityError raised based on "
                    "your model's uniqueness constraints. "
                    "DoesNotExist: Unable to find an existing object based on "
                    "the fields specified in your factory instance.")

        return instance
151288
def get_or_create(cls, **kwargs):
    

    try:
        obj = cls.objects.get(**kwargs)
        created = False
    except cls.DoesNotExist:
        obj = cls(**kwargs)
        created = True
        calculate_hash(obj)
        obj.save()

    return (obj, created)
412627
def _get_full_title(self):
        """"""
        if len(self.arguments) > 0:  # a title was passed
            if 'title_from_content' in self.options:
                self.log.warning(
                    'Needs: need "{}" has :title_from_content: set, '
                    'but a title was provided. (see file {})'
                        .format(self.arguments[0], self.docname)
                )
            return self.arguments[0]
        elif self.title_from_content:
            first_sentence = ' '.join(self.content).split('.', 1)[0]
            if not first_sentence:
                raise NeedsInvalidException(':title_from_content: set, but '
                                            'no content provided. '
                                            '(Line {} of file {}'
                                            .format(self.lineno, self.docname))
            return first_sentence
        else:
            return ''
1017433
async def get_or_create(self, model_, defaults=None, **kwargs):
        
        try:
            return (await self.get(model_, **kwargs)), False
        except model_.DoesNotExist:
            data = defaults or {}
            data.update({k: v for k, v in kwargs.items() if '__' not in k})
            return (await self.create(model_, **data)), True
1248393
def _pretty_title_or_id(context, obj, empty_value=_marker):
    
    # if safe_hasattr(obj, 'aq_explicit'):
    #    obj = obj.aq_explicit
    #title = getattr(obj, 'Title', None)
    title = None
    if base_hasattr(obj, 'Title'):
        title = getattr(obj, 'Title', None)
    if safe_callable(title):
        title = title()
    if title:
        return title
    item_id = getattr(obj, 'getId', None)
    if safe_callable(item_id):
        item_id = item_id()
    if item_id and not isIDAutoGenerated(context, item_id):
        return item_id
    if empty_value is _marker:
        empty_value = getEmptyTitle(context)
    return empty_value
667409
def refresh!
      raise UnknownObject, self.name unless self.exists?
      h = Rudy::Metadata.get self.name
      return false if h.nil? || h.empty?
      obj = self.from_hash(h)
      obj.postprocess
      obj
    end
1166308
def _get_title(self, prop, main_infos, info_dict):
        
        result = main_infos.get('label')
        if result is None:
            result = info_dict.get('colanderalchemy', {}).get('title')
        if result is None:
            result = prop.key
        return result
260442
def new(self, verbose=False):
        

        response=api(url=self.__url+"/new", verbose=verbose)
        return response
625447
def fetchone(self):
        
        self._assert_valid_result_set()
        result = self.result_set.fetch_row()
        if len(result) == 0:
            return None
        else:
            return result
204451
def get_content_title(self, obj):
        """"""
        return Content.objects.get(id=obj.content.id).title
506630
def fetchone(self):
        
        self._check_executed()
        fut = self._loop.create_future()

        if self._rows is None or self._rownumber >= len(self._rows):
            fut.set_result(None)
            return fut
        result = self._rows[self._rownumber]
        self._rownumber += 1

        fut = self._loop.create_future()
        fut.set_result(result)
        return fut
179389
def get_or_create(cls, **kwargs):
		

		try:
			return Plan.objects.get(id=kwargs["id"]), False
		except Plan.DoesNotExist:
			return cls.create(**kwargs), True