mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Autocomplete, Fediverse, Geography, Poll: Run Black
This commit is contained in:
parent
5d8f59bf80
commit
d67fb2a8b2
@ -61,6 +61,7 @@ from . import config
|
|||||||
from . import plugin
|
from . import plugin
|
||||||
|
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
|
|
||||||
# In case we're being reloaded.
|
# In case we're being reloaded.
|
||||||
reload(config)
|
reload(config)
|
||||||
reload(plugin)
|
reload(plugin)
|
||||||
|
@ -53,6 +53,7 @@ from . import config
|
|||||||
from . import plugin
|
from . import plugin
|
||||||
|
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
|
|
||||||
# In case we're being reloaded.
|
# In case we're being reloaded.
|
||||||
reload(config)
|
reload(config)
|
||||||
reload(plugin)
|
reload(plugin)
|
||||||
|
@ -150,7 +150,8 @@ class Geography(callbacks.Plugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
offset_seconds = int(
|
offset_seconds = int(
|
||||||
datetime.datetime.now(tz=timezone).utcoffset().total_seconds())
|
datetime.datetime.now(tz=timezone).utcoffset().total_seconds()
|
||||||
|
)
|
||||||
offset = self._format_utc_offset(offset_seconds)
|
offset = self._format_utc_offset(offset_seconds)
|
||||||
|
|
||||||
# Extract a human-friendly name, depending on the type of
|
# Extract a human-friendly name, depending on the type of
|
||||||
|
@ -83,7 +83,7 @@ class GeographyTimezoneTestCase(PluginTestCase):
|
|||||||
with patch.object(wikidata, "timezone_from_uri", return_value=tz):
|
with patch.object(wikidata, "timezone_from_uri", return_value=tz):
|
||||||
self.assertRegexp(
|
self.assertRegexp(
|
||||||
"timezone Newfoundland",
|
"timezone Newfoundland",
|
||||||
r"Canada/Newfoundland \(currently UTC-[23]:30\)"
|
r"Canada/Newfoundland \(currently UTC-[23]:30\)",
|
||||||
)
|
)
|
||||||
|
|
||||||
tz = pytz.timezone("Asia/Kolkata")
|
tz = pytz.timezone("Asia/Kolkata")
|
||||||
@ -111,7 +111,7 @@ class GeographyTimezoneTestCase(PluginTestCase):
|
|||||||
with patch.object(wikidata, "timezone_from_uri", return_value=tz):
|
with patch.object(wikidata, "timezone_from_uri", return_value=tz):
|
||||||
self.assertRegexp(
|
self.assertRegexp(
|
||||||
"timezone Newfoundland",
|
"timezone Newfoundland",
|
||||||
r"Canada/Newfoundland \(currently UTC-[23]:30\)"
|
r"Canada/Newfoundland \(currently UTC-[23]:30\)",
|
||||||
)
|
)
|
||||||
|
|
||||||
tz = zoneinfo.ZoneInfo("Asia/Kolkata")
|
tz = zoneinfo.ZoneInfo("Asia/Kolkata")
|
||||||
@ -144,9 +144,7 @@ class GeographyTimezoneTestCase(PluginTestCase):
|
|||||||
self.assertRegexp(
|
self.assertRegexp(
|
||||||
"timezone Delhi", r"Asia/Kolkata \(currently UTC\+5:30\)"
|
"timezone Delhi", r"Asia/Kolkata \(currently UTC\+5:30\)"
|
||||||
)
|
)
|
||||||
self.assertRegexp(
|
self.assertRegexp("timezone Newfoundland", r"UTC-[23]:30")
|
||||||
"timezone Newfoundland", r"UTC-[23]:30"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class GeographyLocaltimeTestCase(PluginTestCase):
|
class GeographyLocaltimeTestCase(PluginTestCase):
|
||||||
|
@ -137,7 +137,9 @@ def timezone_from_uri(location_uri):
|
|||||||
"http://www.wikidata.org/entity/Q17272692", # IANA timezones first
|
"http://www.wikidata.org/entity/Q17272692", # IANA timezones first
|
||||||
"http://www.wikidata.org/entity/Q12143", # any timezone as a fallback
|
"http://www.wikidata.org/entity/Q12143", # any timezone as a fallback
|
||||||
]:
|
]:
|
||||||
data = _query_sparql(TIMEZONE_QUERY.substitute(subject=location_uri, tztype=tztype))
|
data = _query_sparql(
|
||||||
|
TIMEZONE_QUERY.substitute(subject=location_uri, tztype=tztype)
|
||||||
|
)
|
||||||
results = data["results"]["bindings"]
|
results = data["results"]["bindings"]
|
||||||
for result in results:
|
for result in results:
|
||||||
if "tzid" in result:
|
if "tzid" in result:
|
||||||
|
@ -53,6 +53,7 @@ from . import config
|
|||||||
from . import plugin
|
from . import plugin
|
||||||
|
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
|
|
||||||
# In case we're being reloaded.
|
# In case we're being reloaded.
|
||||||
reload(config)
|
reload(config)
|
||||||
reload(plugin)
|
reload(plugin)
|
||||||
|
Loading…
Reference in New Issue
Block a user