.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.weather.Pressure Class Reference

Public Member Functions

 __init__ (self, float value, Units unit)
 __str__ (self)
float value (self, Units unit)
str l10n (self, Units|None unit=None, babel.Locale|GeoLocation|None locale=None, str template="{value} {unit}", str num_pattern="#,##0")

Public Attributes

float si = convert_to_si(si_name=self.si_name, symbol=unit, value=value)

Static Public Attributes

str si_name = "Q44395"
 Units = typing.Literal["Pa", "hPa", "cm Hg", "bar"]
 units = list(typing.get_args(Units))

Detailed Description

Class for converting pressure units and for string representation of
measured values.

Definition at line 298 of file weather.py.

Constructor & Destructor Documentation

◆ __init__()

searx.weather.Pressure.__init__ ( self,
float value,
Units unit )

Definition at line 309 of file weather.py.

309 def __init__(self, value: float, unit: Units):
310 if unit not in self.units:
311 raise ValueError(f"invalid unit: {unit}")
312 # pylint: disable=invalid-name
313 self.si: float = convert_to_si(si_name=self.si_name, symbol=unit, value=value)
314

References units, and searx.weather.Temperature.units.

Member Function Documentation

◆ __str__()

searx.weather.Pressure.__str__ ( self)

Definition at line 315 of file weather.py.

315 def __str__(self):
316 return self.l10n()
317

References searx.weather.DateTime.l10n(), l10n(), and searx.weather.Temperature.l10n().

Here is the call graph for this function:

◆ l10n()

str searx.weather.Pressure.l10n ( self,
Units | None unit = None,
babel.Locale | GeoLocation | None locale = None,
str template = "{value} {unit}",
str num_pattern = "#,##0" )

Definition at line 321 of file weather.py.

327 ) -> str:
328 if isinstance(locale, GeoLocation):
329 locale = locale.locale()
330 elif locale is None:
331 locale = babel.Locale.parse(_get_sxng_locale_tag(), sep='-')
332
333 if unit is None: # unit by territory?
334 unit = "hPa"
335
336 val_str = babel.numbers.format_decimal(self.value(unit), locale=locale, format=num_pattern)
337 return template.format(value=val_str, unit=unit)
338
339
340@typing.final

References searx.weather._get_sxng_locale_tag(), searx.preferences.BooleanSetting.value, searx.preferences.EnumStringSetting.value, searx.preferences.MapSetting.value, searx.preferences.MultipleChoiceSetting.value, searx.preferences.SearchLanguageSetting.value, searx.preferences.Setting.value, value(), and searx.weather.Temperature.value().

Referenced by searx.weather.Compass.__str__(), __str__(), searx.weather.RelativeHumidity.__str__(), and searx.weather.WindSpeed.__str__().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ value()

float searx.weather.Pressure.value ( self,
Units unit )

Definition at line 318 of file weather.py.

318 def value(self, unit: Units) -> float:
319 return convert_from_si(si_name=self.si_name, symbol=unit, value=self.si)
320

References si, searx.weather.Temperature.si, si_name, and searx.weather.Temperature.si_name.

Referenced by searx.weather.Compass.l10n(), l10n(), searx.weather.RelativeHumidity.l10n(), and searx.weather.WindSpeed.l10n().

Here is the caller graph for this function:

Member Data Documentation

◆ si

float searx.weather.Pressure.si = convert_to_si(si_name=self.si_name, symbol=unit, value=value)

Definition at line 313 of file weather.py.

Referenced by value(), and searx.weather.WindSpeed.value().

◆ si_name

str searx.weather.Pressure.si_name = "Q44395"
static

Definition at line 302 of file weather.py.

Referenced by value(), and searx.weather.WindSpeed.value().

◆ Units

searx.weather.Pressure.Units = typing.Literal["Pa", "hPa", "cm Hg", "bar"]
static

Definition at line 304 of file weather.py.

◆ units

searx.weather.Pressure.units = list(typing.get_args(Units))
static

Definition at line 307 of file weather.py.

Referenced by __init__(), and searx.weather.WindSpeed.__init__().


The documentation for this class was generated from the following file:
  • /home/andrew/Documents/code/public/searxng/searx/weather.py