.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 291 of file weather.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 302 of file weather.py.

302 def __init__(self, value: float, unit: Units):
303 if unit not in self.units:
304 raise ValueError(f"invalid unit: {unit}")
305 # pylint: disable=invalid-name
306 self.si: float = convert_to_si(si_name=self.si_name, symbol=unit, value=value)
307

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

Member Function Documentation

◆ __str__()

searx.weather.Pressure.__str__ ( self)

Definition at line 308 of file weather.py.

308 def __str__(self):
309 return self.l10n()
310

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 314 of file weather.py.

320 ) -> str:
321 if isinstance(locale, GeoLocation):
322 locale = locale.locale()
323 elif locale is None:
324 locale = babel.Locale.parse(_get_sxng_locale_tag(), sep='-')
325
326 if unit is None: # unit by territory?
327 unit = "hPa"
328
329 val_str = babel.numbers.format_decimal(self.value(unit), locale=locale, format=num_pattern)
330 return template.format(value=val_str, unit=unit)
331
332

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 311 of file weather.py.

311 def value(self, unit: Units) -> float:
312 return convert_from_si(si_name=self.si_name, symbol=unit, value=self.si)
313

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 306 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 295 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 297 of file weather.py.

◆ units

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

Definition at line 300 of file weather.py.

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


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