kopia lustrzana https://github.com/collective/icalendar
change some list and dict calls to list and dict literals
rodzic
2d62c56ab0
commit
c64db780f3
|
@ -20,7 +20,7 @@ Fixes:
|
|||
- Documentation fixes.
|
||||
[TomTry]
|
||||
|
||||
- Pep 8, UTF 8 headers.
|
||||
- Pep 8, UTF 8 headers, dict/list calls to literals.
|
||||
[thet]
|
||||
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ class Component(CaselessDict):
|
|||
super(Component, self).__init__(*args, **kwargs)
|
||||
# set parameters here for properties that use non-default values
|
||||
self.subcomponents = [] # Components can be nested.
|
||||
self.errors = list() # If we ignored exception(s) while
|
||||
# parsing a property, contains error strings
|
||||
self.errors = [] # If we ignored exception(s) while
|
||||
# parsing a property, contains error strings
|
||||
|
||||
# def is_compliant(self, name):
|
||||
# """Returns True is the given property name is compliant with the
|
||||
|
@ -553,8 +553,8 @@ class Timezone(Component):
|
|||
"""convert this VTIMEZONE component to a pytz.timezone object
|
||||
"""
|
||||
zone = str(self['TZID'])
|
||||
transitions = list()
|
||||
dst = dict()
|
||||
transitions = []
|
||||
dst = {}
|
||||
for component in self.walk():
|
||||
if type(component) == Timezone:
|
||||
continue
|
||||
|
@ -579,7 +579,7 @@ class Timezone(Component):
|
|||
# (utcoffset, dstoffset, name)
|
||||
# dstoffset = 0, if current transition is to standard time
|
||||
# = this_utcoffset - prev_standard_utcoffset, otherwise
|
||||
transition_info = list()
|
||||
transition_info = []
|
||||
for num, (transtime, osfrom, osto, name) in enumerate(transitions):
|
||||
dst_offset = False
|
||||
if not dst[name]:
|
||||
|
@ -599,10 +599,11 @@ class Timezone(Component):
|
|||
break
|
||||
transition_info.append((osto, dst_offset, name))
|
||||
|
||||
cls = type(zone, (DstTzInfo,), dict(
|
||||
zone=zone,
|
||||
_utc_transition_times=transition_times,
|
||||
_transition_info=transition_info))
|
||||
cls = type(zone, (DstTzInfo,), {
|
||||
'zone': zone,
|
||||
'_utc_transition_times': transition_times,
|
||||
'_transition_info': transition_info
|
||||
})
|
||||
|
||||
return cls()
|
||||
|
||||
|
|
|
@ -276,11 +276,11 @@ class vDDDTypes(object):
|
|||
if not isinstance(dt, (datetime, date, timedelta, time)):
|
||||
raise ValueError('You must use datetime, date, timedelta or time')
|
||||
if isinstance(dt, datetime):
|
||||
self.params = Parameters(dict(value='DATE-TIME'))
|
||||
self.params = Parameters({'value': 'DATE-TIME'})
|
||||
elif isinstance(dt, date):
|
||||
self.params = Parameters(dict(value='DATE'))
|
||||
self.params = Parameters({'value': 'DATE'})
|
||||
elif isinstance(dt, time):
|
||||
self.params = Parameters(dict(value='TIME'))
|
||||
self.params = Parameters({'value': 'TIME'})
|
||||
|
||||
if (isinstance(dt, datetime) or isinstance(dt, time))\
|
||||
and getattr(dt, 'tzinfo', False):
|
||||
|
@ -333,7 +333,7 @@ class vDate(object):
|
|||
if not isinstance(dt, date):
|
||||
raise ValueError('Value MUST be a date instance')
|
||||
self.dt = dt
|
||||
self.params = Parameters(dict(value='DATE'))
|
||||
self.params = Parameters({'value': 'DATE'})
|
||||
|
||||
def to_ical(self):
|
||||
s = "%04d%02d%02d" % (self.dt.year, self.dt.month, self.dt.day)
|
||||
|
@ -717,7 +717,7 @@ class vTime(object):
|
|||
self.dt = args[0]
|
||||
else:
|
||||
self.dt = time(*args)
|
||||
self.params = Parameters(dict(value='TIME'))
|
||||
self.params = Parameters({'value': 'TIME'})
|
||||
|
||||
def to_ical(self):
|
||||
return self.dt.strftime("%H%M%S")
|
||||
|
|
|
@ -161,8 +161,8 @@ class TestTimezoneCreation(unittest.TestCase):
|
|||
# for reasons (tm) the locally installed version of the time zone
|
||||
# database isn't always complete, therefore we only compare some
|
||||
# transition times
|
||||
ny_transition_times = list()
|
||||
ny_transition_info = list()
|
||||
ny_transition_times = []
|
||||
ny_transition_info = []
|
||||
for num, date in enumerate(pytz_new_york._utc_transition_times):
|
||||
if datetime.datetime(1967, 4, 30, 7, 0)\
|
||||
<= date <= datetime.datetime(2037, 11, 1, 6, 0):
|
||||
|
|
|
@ -41,8 +41,9 @@ class TestCaselessdict(unittest.TestCase):
|
|||
def test_caselessdict_canonsort_items(self):
|
||||
canonsort_items = icalendar.caselessdict.canonsort_items
|
||||
|
||||
d = dict(i=7, c='at', a=3.5, l=(2, 3), e=[4, 5], n=13, d={'x': 'y'},
|
||||
r=1.0)
|
||||
d = dict(
|
||||
i=7, c='at', a=3.5, l=(2, 3), e=[4, 5], n=13, d={'x': 'y'}, r=1.0
|
||||
)
|
||||
|
||||
out = canonsort_items(d)
|
||||
self.assertEqual(
|
||||
|
|
|
@ -258,7 +258,7 @@ class TestProp(unittest.TestCase):
|
|||
# Let's see how close we can get to one from the rfc:
|
||||
# FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30
|
||||
|
||||
r = dict(freq='yearly', interval=2)
|
||||
r = dict({'freq': 'yearly', 'interval': 2})
|
||||
r.update({
|
||||
'bymonth': 1,
|
||||
'byday': 'su',
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# we save all timezone with TZIDs unknow to the TZDB in here
|
||||
_timezone_cache = dict()
|
||||
_timezone_cache = {}
|
||||
|
|
Ładowanie…
Reference in New Issue