Renamed get_month_text() to _get_month_text(), and get_date_text() to _get_date_text() to change them to private in Period.Parser.

This commit is contained in:
依瑪貓 2020-08-03 21:19:47 +08:00
parent c3240b27e7
commit cd6cd51444

View File

@ -437,7 +437,7 @@ class Period:
self.invalid_period() self.invalid_period()
return return
self.end = self.get_month_last_day(self.start) self.end = self.get_month_last_day(self.start)
self.description = self.get_month_text(year, month) self.description = self._get_month_text(year, month)
return return
# From a specific month # From a specific month
m = re.match("^([0-9]{4})-([0-9]{2})-$", spec) m = re.match("^([0-9]{4})-([0-9]{2})-$", spec)
@ -452,7 +452,7 @@ class Period:
self.end = self.get_month_last_day( self.end = self.get_month_last_day(
timezone.localdate()) timezone.localdate())
self.description = gettext( self.description = gettext(
"Since %s") % self.get_month_text(year, month) "Since %s") % self._get_month_text(year, month)
return return
# Until a specific month # Until a specific month
m = re.match("^-([0-9]{4})-([0-9]{2})$", spec) m = re.match("^-([0-9]{4})-([0-9]{2})$", spec)
@ -467,7 +467,7 @@ class Period:
self.start = datetime.date(2000, 1, 1) self.start = datetime.date(2000, 1, 1)
self.end = self.get_month_last_day(until_month) self.end = self.get_month_last_day(until_month)
self.description = gettext( self.description = gettext(
"Until %s") % self.get_month_text(year, month) "Until %s") % self._get_month_text(year, month)
return return
# A specific year # A specific year
m = re.match("^([0-9]{4})$", spec) m = re.match("^([0-9]{4})$", spec)
@ -526,7 +526,7 @@ class Period:
self.invalid_period() self.invalid_period()
return return
self.end = self.start self.end = self.start
self.description = self.get_date_text(self.start) self.description = self._get_date_text(self.start)
return return
# A specific date period # A specific date period
m = re.match(("^([0-9]{4})-([0-9]{2})-([0-9]{2})" m = re.match(("^([0-9]{4})-([0-9]{2})-([0-9]{2})"
@ -574,7 +574,7 @@ class Period:
# At the same day # At the same day
else: else:
self.spec = dateformat.format(self.start, "Y-m-d") self.spec = dateformat.format(self.start, "Y-m-d")
self.description = self.get_date_text(self.start) self.description = self._get_date_text(self.start)
return return
# Until a specific day # Until a specific day
m = re.match("^-([0-9]{4})-([0-9]{2})-([0-9]{2})$", spec) m = re.match("^-([0-9]{4})-([0-9]{2})-([0-9]{2})$", spec)
@ -589,7 +589,7 @@ class Period:
return return
self.start = datetime.date(2000, 1, 1) self.start = datetime.date(2000, 1, 1)
self.description = gettext( self.description = gettext(
"Until %s") % self.get_date_text(self.end) "Until %s") % self._get_date_text(self.end)
return return
# Wrong period format # Wrong period format
self.invalid_period() self.invalid_period()
@ -628,7 +628,7 @@ class Period:
next_year, next_month, 1) - datetime.timedelta(days=1) next_year, next_month, 1) - datetime.timedelta(days=1)
@staticmethod @staticmethod
def get_month_text(year, month): def _get_month_text(year, month):
"""Returns the text description of a month. """Returns the text description of a month.
Args: Args:
@ -652,7 +652,7 @@ class Period:
return "%d/%d" % (year, month) return "%d/%d" % (year, month)
@staticmethod @staticmethod
def get_date_text(day): def _get_date_text(day):
"""Returns the text description of a day. """Returns the text description of a day.
Args: Args: