returns true iff the database is in the most recent format
974953
def parse_db(stream)
      case stream.gets.to_i
      when DB_FORMAT
        @meta   = Oj.load(stream.gets)
        @tables = Oj.load(stream.gets)
        return true
      when 3..4
        # Old format, so read the directories segment then rebuild
        add_paths(Oj.load(stream.gets))
        return false
      when 0..2
        # Old format (pre-json), so read the directories segment then rebuild
        len = stream.gets.to_i
        add_paths(Marshal.load(stream.read(len)))
        return false
      else
        raise UnknownDBFormatError
      end
    rescue Oj::ParseError
      stream.rewind
      raise unless stream.gets.to_i == DB_FORMAT
      # try reading as formated json, which is much slower, but it is sometimes
      # useful to be able to directly read your db
      objects = []
      Oj.load(stream) { |obj| objects << obj }
      @meta, @tables = objects
      return true
    end
1336685
def where_entry_last(query, ref):
    
    return orm.select(
        e for e in query
        if e.local_date < ref.local_date or
        (e.local_date == ref.local_date and
         e.id <= ref.id
         )
    )
479886
def clear_last_check(self):
        """"""
        with db.session.begin_nested():
            self.last_check = None
            self.last_check_at = datetime.utcnow()
        return self
86279
private boolean isTooOld(Date cacheDate) {
        Date now = new Date();
        return now.getTime() - cacheDate.getTime() > MAX_CACHE_TIME_MILLIS;
    }
1367876
public boolean hasNext() throws DBException
    {
        if (m_iCurrentRecord >= m_iRecordsAccessed)
            return true;
        Object record = this.next();
        if (record == null)
            return false;
        else
        {
            m_iRecordsAccessed--;   // Offically this record has not been accessed
            return true;
        }
    }
1171404
def query_recent(num=8, **kwargs):
        '''
        
        '''
        order_by_create = kwargs.get('order_by_create', False)
        kind = kwargs.get('kind', None)
        if order_by_create:
            if kind:
                recent_recs = TabPost.select().where(
                    (TabPost.kind == kind) & (TabPost.valid == 1)
                ).order_by(
                    TabPost.time_create.desc()
                ).limit(num)
            else:
                recent_recs = TabPost.select().where(
                    TabPost.valid == 1
                ).order_by(
                    TabPost.time_create.desc()
                ).limit(num)
        else:
            if kind:
                recent_recs = TabPost.select().where(
                    (TabPost.kind == kind) & (TabPost.valid == 1)
                ).order_by(
                    TabPost.time_update.desc()
                ).limit(num)
            else:
                recent_recs = TabPost.select().where(
                    TabPost.valid == 1
                ).order_by(
                    TabPost.time_update.desc()
                ).limit(num)
        return recent_recs
598782
@Override
	public boolean hasNext()
	{
		try {
			if (result != null && result.next()) {
				return true;
			}

			// Close old queries
			if (this.statement != null) {
				this.statement.close();
			}
			if (this.result != null) {
				this.result.close();
			}

			if (primaryKey <= endPK) { // TODO: <= ?
				return query();
			}

			return false;

		}
		catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}
754839
def old_items(mtime=(Time.now.to_i)-(172800))
      data = db.execute <<SQL
        SELECT * from artifacts where modified < #{mtime}
SQL
      data || []
    end
476884
def current?
      output_mapping.each do |file, format|
        return false if outofdate?(file, *dnote_session.files)
      end
      "DNotes are current (#{output})"
    end
322641
def previous(self):
        
        if self._order_by == 'oldest':
            return self.older
        if self._order_by == 'newest':
            return self.newer
        return None
697214
private boolean containsDate(String[] strs, int tolerance)
    {
        dfirst = -1;
        dlast = -1;
        int lastdw = -999;
        int lastnum = -999;
        int lastyear = -999;
        for (int i = 0; i < strs.length; i++)
        {
            if (isMonthName(strs[i]))
            {
                lastdw = i;
                if (lastdw - lastnum <= tolerance)
                    return true;
            }
            else if (isYear(strs[i]))
            {
                lastyear = i;
                if (lastyear - lastnum <= tolerance)
                    return true;
            }
            else if (isNum(strs[i]))
            {
                lastnum = i;
                if (lastnum - lastdw <= tolerance)
                    return true;
            }
        }
        return false;
    }
527224
def wasModified(self):
        
        self.filePath.restat()
        mtime = self.filePath.getmtime()
        if mtime >= self.lastModified:
            return True
        else:
            return False
96003
synchronized private boolean dumpAlgorithm(long currentTime) {
        boolean dumpTable = false;

        numberOfEntiesProcessed++; // Increment the number of entries updated in the table

        if ((lastTimeOfDump == Long.MIN_VALUE) // Note we check this since if currentTime is zero or more, the line below will be false due to arthimetic overflow
            || (currentTime - lastTimeOfDump > highWaterTime)) {
            // Dump the content of the hash regardless of the
            // number of entries which have been seen.
            dumpTable = true;
        } else {
            if ((numberOfEntiesProcessed > normalDumpThreshold) &&
                (currentTime - lastTimeOfDump > lowWaterTime)) {
                dumpTable = true;
            }
        }

        if (dumpTable == true) {
            lastTimeOfDump = currentTime;
            numberOfEntiesProcessed = 0;
        }
        return dumpTable;
    }
261910
public function IsToday()
    {
        return $this->Format(self::ISO_DATE) === DBDatetime::now()->Format(self::ISO_DATE);
    }
589723
def most_recent(self):
        
        if not self.instance:
            raise TypeError(
                "Can't use most_recent() without a {} instance.".format(
                    self.model._meta.object_name
                )
            )
        tmp = []
        excluded_fields = getattr(self.model, "_history_excluded_fields", [])

        for field in self.instance._meta.fields:
            if field.name in excluded_fields:
                continue
            if isinstance(field, models.ForeignKey):
                tmp.append(field.name + "_id")
            else:
                tmp.append(field.name)
        fields = tuple(tmp)
        try:
            values = self.get_queryset().values_list(*fields)[0]
        except IndexError:
            raise self.instance.DoesNotExist(
                "%s has no historical record." % self.instance._meta.object_name
            )
        return self.instance.__class__(*values)
594844
def is_processed(self, db_versions):
        
        return self.number in (v.number for v in db_versions if v.date_done)
179728
def last_update_time(self) -> float:
        """"""
        stdout = self.stdout_interceptor
        stderr = self.stderr_interceptor

        return max([
            self._last_update_time,
            stdout.last_write_time if stdout else 0,
            stderr.last_write_time if stderr else 0,
        ])