本文整理汇总了Python中twistedcaldav.timezones.TimezoneCache类的典型用法代码示例。如果您正苦于以下问题:Python TimezoneCache类的具体用法?Python TimezoneCache怎么用?Python TimezoneCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimezoneCache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_calendar_query_bogus_timezone_id
def test_calendar_query_bogus_timezone_id(self):
"""
Partial retrieval of events by time range.
(CalDAV-access-09, section 7.6.1)
"""
TimezoneCache.create()
self.addCleanup(TimezoneCache.clear)
calendar_properties = (
davxml.GETETag(),
caldavxml.CalendarData(),
)
query_timerange = caldavxml.TimeRange(
start="%04d1001T000000Z" % (DateTime.getToday().getYear(),),
end="%04d1101T000000Z" % (DateTime.getToday().getYear(),),
)
query = caldavxml.CalendarQuery(
davxml.PropertyContainer(*calendar_properties),
caldavxml.Filter(
caldavxml.ComponentFilter(
caldavxml.ComponentFilter(
query_timerange,
name="VEVENT",
),
name="VCALENDAR",
),
),
caldavxml.TimeZoneID.fromString("bogus"),
)
result = yield self.calendar_query(query, got_xml=None, expected_code=responsecode.FORBIDDEN)
self.assertTrue("valid-timezone" in result)
开发者ID:eventable,项目名称:CalendarServer,代码行数:34,代码来源:test_calendarquery.py
示例2: test_copyPackage_Concurrency
def test_copyPackage_Concurrency(self):
"""
Test that concurrent copying of the tz package works.
"""
self.patch(config, "UsePackageTimezones", False)
TimezoneCache.clear()
ex = [None, None]
def _try(n):
try:
TimezoneCache.create()
except:
f = Failure()
ex[n] = str(f)
t1 = threading.Thread(target=_try, args=(0,))
t2 = threading.Thread(target=_try, args=(1,))
t1.start()
t2.start()
t1.join()
t2.join()
self.assertTrue(ex[0] is None, msg=ex[0])
self.assertTrue(ex[1] is None, msg=ex[1])
self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:28,代码来源:test_timezones.py
示例3: __init__
def __init__(self, store, options, output, reactor, config):
super(PodMigrationService, self).__init__(store)
self.options = options
self.output = output
self.reactor = reactor
self.config = config
TimezoneCache.create()
开发者ID:eventable,项目名称:CalendarServer,代码行数:7,代码来源:pod_migration.py
示例4: __init__
def __init__(self, store, options, reactor, config):
super(ImporterService, self).__init__(store)
self.options = options
self.reactor = reactor
self.config = config
self._directory = self.store.directoryService()
TimezoneCache.create()
开发者ID:eventable,项目名称:CalendarServer,代码行数:8,代码来源:importer.py
示例5: _calendarTimezoneUpgrade_setup
def _calendarTimezoneUpgrade_setup(self):
TimezoneCache.create()
self.addCleanup(TimezoneCache.clear)
tz1 = Component(None, pycalendar=readVTZ("Etc/GMT+1"))
tz2 = Component(None, pycalendar=readVTZ("Etc/GMT+2"))
tz3 = Component(None, pycalendar=readVTZ("Etc/GMT+3"))
# Share user01 calendar with user03
calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
home3 = yield self.homeUnderTest(name="user03")
shared_name = yield calendar.shareWith(home3, _BIND_MODE_WRITE)
user_details = (
("user01", "calendar_1", tz1),
("user02", "calendar_1", tz2),
("user03", "calendar_1", None),
("user03", shared_name, tz3),
)
# Set dead properties on calendars
for user, calname, tz in user_details:
calendar = (yield self.calendarUnderTest(name=calname, home=user))
if tz:
calendar.properties()[PropertyName.fromElement(caldavxml.CalendarTimeZone)] = caldavxml.CalendarTimeZone.fromString(str(tz))
# Force data version to previous
home = (yield self.homeUnderTest(name=user))
ch = home._homeSchema
yield Update(
{ch.DATAVERSION: 4},
Where=ch.RESOURCE_ID == home._resourceID,
).on(self.transactionUnderTest())
yield self.commit()
for user, calname, tz in user_details:
calendar = (yield self.calendarUnderTest(name=calname, home=user))
self.assertEqual(calendar.getTimezone(), None)
self.assertEqual(PropertyName.fromElement(caldavxml.CalendarTimeZone) in calendar.properties(), tz is not None)
yield self.commit()
# Create "fake" entry for non-existent share
txn = self.transactionUnderTest()
calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
rp = schema.RESOURCE_PROPERTY
yield Insert(
{
rp.RESOURCE_ID: calendar._resourceID,
rp.NAME: PropertyName.fromElement(caldavxml.CalendarTimeZone).toString(),
rp.VALUE: caldavxml.CalendarTimeZone.fromString(str(tz3)).toxml(),
rp.VIEWER_UID: "user04",
}
).on(txn)
yield self.commit()
returnValue(user_details)
开发者ID:eventable,项目名称:CalendarServer,代码行数:58,代码来源:test_upgrade_from_4_to_5.py
示例6: testRead
def testRead(self):
xmlfile = self.mktemp()
db1 = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db1.createNewDatabase()
self.assertTrue(os.path.exists(xmlfile))
db2 = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db2.readDatabase()
self.assertEqual(db1.dtstamp, db2.dtstamp)
self.assertEqual(len(db1.timezones), len(db2.timezones))
开发者ID:eventable,项目名称:CalendarServer,代码行数:11,代码来源:test_timezonestdservice.py
示例7: test_truncatedDec
def test_truncatedDec(self):
"""
Properties in components
"""
TimezoneCache.create("")
TimezoneCache.clear()
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:12,代码来源:test_timezones.py
示例8: test_truncatedApr
def test_truncatedApr(self):
"""
Custom VTZ with truncated standard time - 2006. Daylight 2007 OK.
"""
TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:13,代码来源:test_timezones.py
示例9: test_truncatedDec
def test_truncatedDec(self):
"""
Custom VTZ valid from 2007. Daylight 2007 OK.
"""
TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:13,代码来源:test_timezones.py
示例10: test_truncatedApr
def test_truncatedApr(self):
"""
Properties in components
"""
TimezoneCache.create("")
TimezoneCache.clear()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:13,代码来源:test_timezones.py
示例11: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
Properties in components
"""
oldtzid = getTzid("America/New_York")
try:
registerTzid("America/New_York", None)
tzcache = TimezoneCache()
tzcache.register()
self.doTest(
"TruncatedApr01.ics",
datetime.datetime(2007, 04, 01, 16, 0, 0, tzinfo=utc),
datetime.datetime(2007, 04, 01, 17, 0, 0, tzinfo=utc),
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:14,代码来源:test_timezones.py
示例12: __init__
def __init__(self, records, populator, parameters, reactor, server,
principalPathTemplate, serializationPath, workerIndex=0, workerCount=1):
self._records = records
self.populator = populator
self.reactor = reactor
self.server = server
self.principalPathTemplate = principalPathTemplate
self.serializationPath = serializationPath
self._pop = self.populator.populate(parameters)
self._user = 0
self._stopped = False
self.workerIndex = workerIndex
self.workerCount = workerCount
self.clients = []
TimezoneCache.create()
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:16,代码来源:population.py
示例13: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
Properties in components
"""
TimezoneCache.create()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True)),
)
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:16,代码来源:test_timezones.py
示例14: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
VTZ loaded from std timezone DB. 2007 OK.
"""
TimezoneCache.create()
self.doTest(
"TruncatedApr01.ics",
PyCalendarDateTime(2007, 04, 01, 16, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True)),
)
self.doTest(
"TruncatedDec10.ics",
PyCalendarDateTime(2007, 12, 10, 17, 0, 0, PyCalendarTimezone(utc=True)),
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:17,代码来源:test_timezones.py
示例15: test_truncatedAprThenDecOK
def test_truncatedAprThenDecOK(self):
"""
VTZ loaded from std timezone DB. 2007 OK.
"""
TimezoneCache.create()
self.doTest(
"TruncatedApr01.ics",
DateTime(2007, 04, 01, 16, 0, 0, Timezone.UTCTimezone),
DateTime(2007, 04, 01, 17, 0, 0, Timezone.UTCTimezone),
)
self.doTest(
"TruncatedDec10.ics",
DateTime(2007, 12, 10, 17, 0, 0, Timezone.UTCTimezone),
DateTime(2007, 12, 10, 18, 0, 0, Timezone.UTCTimezone),
)
开发者ID:eventable,项目名称:CalendarServer,代码行数:17,代码来源:test_timezones.py
示例16: test_not_in_cache
def test_not_in_cache(self):
TimezoneCache.create()
data = """BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:US-Eastern
LAST-MODIFIED:19870101T000000Z
BEGIN:STANDARD
DTSTART:19671029T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:Eastern Standard Time (US & Canada)
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19870405T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:Eastern Daylight Time (US & Canada)
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:12345-67890
DTSTART;TZID="US-Eastern":20071225T000000
DTEND;TZID="US-Eastern":20071225T010000
ATTENDEE:mailto:[email protected]
ATTENDEE:mailto:[email protected]
END:VEVENT
END:VCALENDAR
"""
calendar = Component.fromString(data)
if calendar.name() != "VCALENDAR":
self.fail("Calendar is not a VCALENDAR")
instances = calendar.expandTimeRanges(PyCalendarDateTime(2100, 1, 1))
for key in instances:
instance = instances[key]
start = instance.start
end = instance.end
self.assertEqual(start, PyCalendarDateTime(2007, 12, 25, 05, 0, 0, PyCalendarTimezone(utc=True)))
self.assertEqual(end, PyCalendarDateTime(2007, 12, 25, 06, 0, 0, PyCalendarTimezone(utc=True)))
break
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:45,代码来源:test_timezones.py
示例17: testGetNone
def testGetNone(self):
xmlfile = self.mktemp()
db = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db.createNewDatabase()
self.assertTrue(os.path.exists(xmlfile))
tz = db.getTimezone("Bogus")
self.assertEqual(tz, None)
开发者ID:eventable,项目名称:CalendarServer,代码行数:9,代码来源:test_timezonestdservice.py
示例18: testListChangedSince
def testListChangedSince(self):
xmlfile = self.mktemp()
db = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db.createNewDatabase()
self.assertTrue(os.path.exists(xmlfile))
tzids = set([tz.tzid for tz in db.listTimezones(db.dtstamp)])
self.assertTrue(len(tzids) == 0)
开发者ID:eventable,项目名称:CalendarServer,代码行数:9,代码来源:test_timezonestdservice.py
示例19: test_truncatedDecThenApr
def test_truncatedDecThenApr(self):
"""
Custom VTZ valid from 2007 loaded first. Daylight 2007 OK.
"""
TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
"TruncatedDec10.ics",
DateTime(2007, 12, 10, 17, 0, 0, Timezone(utc=True)),
DateTime(2007, 12, 10, 18, 0, 0, Timezone(utc=True))
)
self.doTest(
"TruncatedApr01.ics",
DateTime(2007, 04, 01, 16, 0, 0, Timezone(utc=True)),
DateTime(2007, 04, 01, 17, 0, 0, Timezone(utc=True))
)
开发者ID:nunb,项目名称:calendarserver,代码行数:18,代码来源:test_timezones.py
示例20: testCreate
def testCreate(self):
xmlfile = self.mktemp()
db = PrimaryTimezoneDatabase(TimezoneCache.getDBPath(), xmlfile)
db.createNewDatabase()
self.assertTrue(os.path.exists(xmlfile))
self.assertTrue(db.dtstamp is not None)
self.assertTrue(len(db.timezones) > 0)
开发者ID:eventable,项目名称:CalendarServer,代码行数:9,代码来源:test_timezonestdservice.py
注:本文中的twistedcaldav.timezones.TimezoneCache类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论