Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tearDown(self):
if self.__old_pdtlocale_fr is not None: # restore the locale
pdt.pdtLocales['fr_FR'] = self.__old_pdtlocale_fr
super(TestDayOffsets, self).tearDown()
def setUp(self):
pdt.pdtLocales['en_us'] = pdtLocale_en # override for the test
self.ptc = pdt.Constants('en_us', usePyICU=False)
self.cal = pdt.Calendar(self.ptc)
(self.yr, self.mth, self.dy, self.hr,
self.mn, self.sec, self.wd, self.yd, self.isdst) = time.localtime()
def setUp(self):
super(TestDayOffsets, self).setUp()
self.__old_pdtlocale_fr = pdt.pdtLocales.get('fr_FR') # save for later
pdt.pdtLocales['fr_FR'] = pdtLocale_fr # override for the test
self.ptc = pdt.Constants('fr_FR', usePyICU=False)
self.cal = pdt.Calendar(self.ptc)
import datetime
import parsedatetime as pdt
from dateutil.relativedelta import relativedelta
from .formats import plural, human_join
from discord.ext import commands
import re
# Monkey patch mins and secs into the units
units = pdt.pdtLocales['en_US'].units
units['minutes'].append('mins')
units['seconds'].append('secs')
class ShortTime:
compiled = re.compile("""(?:(?P[0-9])(?:years?|y))? # e.g. 2y
(?:(?P[0-9]{1,2})(?:months?|mo))? # e.g. 2months
(?:(?P[0-9]{1,4})(?:weeks?|w))? # e.g. 10w
(?:(?P[0-9]{1,5})(?:days?|d))? # e.g. 14d
(?:(?P[0-9]{1,5})(?:hours?|h))? # e.g. 12h
(?:(?P[0-9]{1,5})(?:minutes?|m))? # e.g. 10m
(?:(?P[0-9]{1,5})(?:seconds?|s))? # e.g. 15s
""", re.VERBOSE)
def __init__(self, argument, *, now=None):
match = self.compiled.fullmatch(argument)
if match is None or not match.group(0):