.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.favicons.cache.FaviconCacheStats Class Reference

Public Member Functions

FaviconCacheStats __sub__ (self, other)
 
 report (self, str fmt="{descr}: {val}\n")
 

Static Public Attributes

int favicons = None
 
int bytes = None
 
int domains = None
 
int resolvers = None
 
tuple field_descr
 

Private Attributes

 __class__
 

Detailed Description

Dataclass wich provides information on the status of the cache.

Definition at line 142 of file cache.py.

Member Function Documentation

◆ __sub__()

FaviconCacheStats searx.favicons.cache.FaviconCacheStats.__sub__ ( self,
other )

Definition at line 157 of file cache.py.

157 def __sub__(self, other) -> FaviconCacheStats:
158 if not isinstance(other, self.__class__):
159 raise TypeError(f"unsupported operand type(s) for +: '{self.__class__}' and '{type(other)}'")
160 kwargs = {}
161 for field, _, _ in self.field_descr:
162 self_val, other_val = getattr(self, field), getattr(other, field)
163 if None in (self_val, other_val):
164 continue
165 if isinstance(self_val, int):
166 kwargs[field] = self_val - other_val
167 else:
168 kwargs[field] = self_val
169 return self.__class__(**kwargs)
170

◆ report()

searx.favicons.cache.FaviconCacheStats.report ( self,
str fmt = "{descr}: {val}\n" )

Definition at line 171 of file cache.py.

171 def report(self, fmt: str = "{descr}: {val}\n"):
172 s = []
173 for field, descr, cast in self.field_descr:
174 val = getattr(self, field)
175 if val is None:
176 val = "--"
177 else:
178 val = cast(val)
179 s.append(fmt.format(descr=descr, val=val))
180 return "".join(s)
181
182

References searx.favicons.cache.FaviconCacheStats.field_descr.

Member Data Documentation

◆ __class__

searx.favicons.cache.FaviconCacheStats.__class__
private

Definition at line 158 of file cache.py.

Referenced by searx.sqlitedb.SQLiteAppl.connect().

◆ bytes

int searx.favicons.cache.FaviconCacheStats.bytes = None
static

Definition at line 146 of file cache.py.

◆ domains

int searx.favicons.cache.FaviconCacheStats.domains = None
static

Definition at line 147 of file cache.py.

◆ favicons

int searx.favicons.cache.FaviconCacheStats.favicons = None
static

Definition at line 145 of file cache.py.

◆ field_descr

searx.favicons.cache.FaviconCacheStats.field_descr
static
Initial value:
= (
("favicons", "number of favicons in cache", humanize_number),
("bytes", "total size (approx. bytes) of cache", humanize_bytes),
("domains", "total number of domains in cache", humanize_number),
("resolvers", "number of resolvers", str),
)

Definition at line 150 of file cache.py.

Referenced by searx.favicons.cache.FaviconCacheStats.report().

◆ resolvers

int searx.favicons.cache.FaviconCacheStats.resolvers = None
static

Definition at line 148 of file cache.py.


The documentation for this class was generated from the following file: