From 05e874d67f9fd0f215741f0b8aba9d44be49d1fb Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Sat, 23 Mar 2024 02:29:18 +0330 Subject: [PATCH] rename natz/ -> mytz/ --- {natz => mytz}/LICENSE | 0 {natz => mytz}/__init__.py | 0 {natz => mytz}/tree/__init__.py | 0 {natz => mytz}/tree/tree_unix.py | 0 {natz => mytz}/tree/tree_win.py | 0 {natz => mytz}/tree/zone_tree.json | 0 plugins/pray_times_files/pray_times.py | 4 ++-- scal3/event_lib.py | 12 ++++++------ scal3/locale_man.py | 6 +++--- scal3/time_utils.py | 12 ++++++------ scal3/ui_gtk/event/bulk_edit.py | 6 +++--- scal3/ui_gtk/event/bulk_save_timezone.py | 4 ++-- scal3/ui_gtk/mywidgets/tz_combo.py | 2 +- scripts/load-zoneinfo-tree.py | 2 +- 14 files changed, 24 insertions(+), 24 deletions(-) rename {natz => mytz}/LICENSE (100%) rename {natz => mytz}/__init__.py (100%) rename {natz => mytz}/tree/__init__.py (100%) rename {natz => mytz}/tree/tree_unix.py (100%) rename {natz => mytz}/tree/tree_win.py (100%) rename {natz => mytz}/tree/zone_tree.json (100%) diff --git a/natz/LICENSE b/mytz/LICENSE similarity index 100% rename from natz/LICENSE rename to mytz/LICENSE diff --git a/natz/__init__.py b/mytz/__init__.py similarity index 100% rename from natz/__init__.py rename to mytz/__init__.py diff --git a/natz/tree/__init__.py b/mytz/tree/__init__.py similarity index 100% rename from natz/tree/__init__.py rename to mytz/tree/__init__.py diff --git a/natz/tree/tree_unix.py b/mytz/tree/tree_unix.py similarity index 100% rename from natz/tree/tree_unix.py rename to mytz/tree/tree_unix.py diff --git a/natz/tree/tree_win.py b/mytz/tree/tree_win.py similarity index 100% rename from natz/tree/tree_win.py rename to mytz/tree/tree_win.py diff --git a/natz/tree/zone_tree.json b/mytz/tree/zone_tree.json similarity index 100% rename from natz/tree/zone_tree.json rename to mytz/tree/zone_tree.json diff --git a/plugins/pray_times_files/pray_times.py b/plugins/pray_times_files/pray_times.py index 3ce3a0b37..b86724b0d 100644 --- a/plugins/pray_times_files/pray_times.py +++ b/plugins/pray_times_files/pray_times.py @@ -42,7 +42,7 @@ # if "gtk" in sys.modules: from pray_times_gtk import TextPluginUI, showDisclaimer -import natz +import mytz from scal3 import logger from scal3.cal_types import hijri from scal3.cal_types.gregorian import to_jd as gregorian_to_jd @@ -68,7 +68,7 @@ # ---------------------------------------------------- -localTz = natz.gettz() +localTz = mytz.gettz() timeDescByName = dict(timeNames) diff --git a/scal3/event_lib.py b/scal3/event_lib.py index cb3b5ade0..c3c85a5ba 100644 --- a/scal3/event_lib.py +++ b/scal3/event_lib.py @@ -38,7 +38,7 @@ from cachetools import LRUCache -import natz +import mytz from scal3 import core, ics, locale_man from scal3.cal_types import ( GREGORIAN, @@ -2030,8 +2030,8 @@ def copySomeRuleTypesFrom( def getTimeZoneObj(self): if self.timeZoneEnable and self.timeZone: - # natz.gettz does not raise exception, returns None if invalid - tz = natz.gettz(self.timeZone) + # mytz.gettz does not raise exception, returns None if invalid + tz = mytz.gettz(self.timeZone) if tz: return tz return locale_man.localTz @@ -2318,7 +2318,7 @@ def getDescription(self): def getTextParts(self, showDesc=True): summary = self.getSummary() # -- - if self.timeZoneEnable and self.timeZone and natz.gettz(self.timeZone) is None: + if self.timeZoneEnable and self.timeZone and mytz.gettz(self.timeZone) is None: invalidTZ = _("Invalid Time Zone: {timeZoneName}").format( timeZoneName=self.timeZone, ) @@ -4102,7 +4102,7 @@ def getSubclass(cls, _type: str) -> "type[EventGroup]": def getTimeZoneObj(self) -> "datetime.tzinfo": if self.timeZoneEnable and self.timeZone: - tz = natz.gettz(self.timeZone) + tz = mytz.gettz(self.timeZone) if tz: return tz return locale_man.localTz @@ -5609,7 +5609,7 @@ def updateOccurrence(self) -> None: return # ---- try: - utc = natz.gettz("UTC") + utc = mytz.gettz("UTC") self.vcsMinJd = getJdFromEpoch(mod.getFirstCommitEpoch(self), tz=utc) self.vcsMaxJd = getJdFromEpoch(mod.getLastCommitEpoch(self), tz=utc) + 1 except Exception: diff --git a/scal3/locale_man.py b/scal3/locale_man.py index f69356948..995e6827b 100644 --- a/scal3/locale_man.py +++ b/scal3/locale_man.py @@ -35,7 +35,7 @@ splitext, ) -import natz +import mytz from scal3.cal_types import calTypes from scal3.json_utils import ( jsonToData, @@ -53,9 +53,9 @@ # ---------------------------------------------------------- -natz.defaultTZ = natz.UTC +mytz.defaultTZ = mytz.UTC -localTz = natz.gettz() +localTz = mytz.gettz() localTzStr = str(localTz) # ---------------------------------------------------------- diff --git a/scal3/time_utils.py b/scal3/time_utils.py index db8a9fafe..74d91d977 100644 --- a/scal3/time_utils.py +++ b/scal3/time_utils.py @@ -22,7 +22,7 @@ from datetime import datetime from time import time as now -import natz +import mytz from scal3.cal_types.gregorian import J1970, J0001_epoch from scal3.cal_types.gregorian import jd_to as jd_to_g from scal3.utils import ifloor @@ -30,7 +30,7 @@ # getEpochFromJd(gregorian.to_jd(10000, 1, 1)) G10000_epoch = 253402300800 -TZ: "typing.TypeAlias" = "natz.TimeZone | None" +TZ: "typing.TypeAlias" = "mytz.TimeZone | None" # jd is the integer value of Chreonological Julian Day, # which is specific to time zone @@ -98,7 +98,7 @@ def getUtcOffsetByEpoch(epoch: int, tz: TZ = None) -> int: if epoch >= G10000_epoch: return 0 if not tz: - tz = natz.gettz() + tz = mytz.gettz() try: dt = datetime.fromtimestamp(epoch) # noqa: DTZ006 except ValueError as e: @@ -113,7 +113,7 @@ def getUtcOffsetByGDate(year: int, month: int, day: int, tz: TZ = None) -> int: if year >= 10000: return 0 if not tz: - tz = natz.gettz() + tz = mytz.gettz() try: dt = datetime(year, month, day) except ValueError as e: @@ -124,7 +124,7 @@ def getUtcOffsetByGDate(year: int, month: int, day: int, tz: TZ = None) -> int: def getUtcOffsetByJd(jd: int, tz: TZ = None) -> int: if not tz: - tz = natz.gettz() + tz = mytz.gettz() tzStr = str(tz) # utcOffsetByJdCache: {tzStr => {jd => utcOffset}} if jd >= J1970: @@ -334,7 +334,7 @@ def clockWaitMilliseconds() -> int: def jsonTimeFromEpoch(epoch: int) -> str: - tm = datetime.fromtimestamp(epoch, tz=natz.UTC) + tm = datetime.fromtimestamp(epoch, tz=mytz.UTC) # Python's `datetime` does not support "%:z" format ("+03:30") # so we have to set `tz` to None return tm.strftime("%Y-%m-%dT%H:%M:%SZ") diff --git a/scal3/ui_gtk/event/bulk_edit.py b/scal3/ui_gtk/event/bulk_edit.py index cde99c7ad..ccc4ab966 100644 --- a/scal3/ui_gtk/event/bulk_edit.py +++ b/scal3/ui_gtk/event/bulk_edit.py @@ -2,7 +2,7 @@ log = logger.get() -import natz +import mytz from scal3.locale_man import tr as _ from scal3.ui_gtk import HBox, VBox, gtk, pack from scal3.ui_gtk.mywidgets import TextFrame @@ -188,8 +188,8 @@ def doAction(self): chType = self.timeZoneChangeCombo.get_active() timeZone = self.timeZoneInput.get_text() if chType != 0: - # natz.gettz does not raise exception, returns None if invalid - if natz.gettz(timeZone): + # mytz.gettz does not raise exception, returns None if invalid + if mytz.gettz(timeZone): for event in container: if not (chType == 2 and event.timeZone): event.timeZone = timeZone diff --git a/scal3/ui_gtk/event/bulk_save_timezone.py b/scal3/ui_gtk/event/bulk_save_timezone.py index 993e843e1..b94afba6e 100644 --- a/scal3/ui_gtk/event/bulk_save_timezone.py +++ b/scal3/ui_gtk/event/bulk_save_timezone.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License along # with this program. If not, see . -import natz +import mytz from scal3 import ui from scal3.locale_man import tr as _ from scal3.ui_gtk import HBox, gtk, pack @@ -84,7 +84,7 @@ def onResponse(self, _dialog, responseId): if responseId == gtk.ResponseType.OK: timeZone = self.timeZoneInput.get_text() try: - natz.gettz(timeZone) + mytz.gettz(timeZone) except Exception as e: self.errorLabel.set_text( _("Time zone is invalid") + "\n" + str(e), diff --git a/scal3/ui_gtk/mywidgets/tz_combo.py b/scal3/ui_gtk/mywidgets/tz_combo.py index dcfee8e26..40c678a04 100644 --- a/scal3/ui_gtk/mywidgets/tz_combo.py +++ b/scal3/ui_gtk/mywidgets/tz_combo.py @@ -5,7 +5,7 @@ class TimeZoneComboBoxEntry(gtk.Box): def __init__(self): - from natz.tree import getZoneInfoTree + from mytz.tree import getZoneInfoTree gtk.Box.__init__(self, orientation=gtk.Orientation.HORIZONTAL) model = gtk.TreeStore(str, bool) diff --git a/scripts/load-zoneinfo-tree.py b/scripts/load-zoneinfo-tree.py index c5c364682..c80bac00d 100755 --- a/scripts/load-zoneinfo-tree.py +++ b/scripts/load-zoneinfo-tree.py @@ -12,7 +12,7 @@ def dataToPrettyJson(data): if __name__ == "__main__": - from natz.tree import getZoneInfoTree + from mytz.tree import getZoneInfoTree zoneTree = getZoneInfoTree(["usr", "share", "zoneinfo"]) # open("data/zoneinfo-tree.json", "w").write(