[CalendarServer-changes] [14699] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Apr 23 10:51:44 PDT 2015
Revision: 14699
http://trac.calendarserver.org//changeset/14699
Author: cdaboo at apple.com
Date: 2015-04-23 10:51:44 -0700 (Thu, 23 Apr 2015)
Log Message:
-----------
Fix docstrs and change method names.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/dateops.py
CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py
Modified: CalendarServer/trunk/twistedcaldav/dateops.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/dateops.py 2015-04-23 17:29:31 UTC (rev 14698)
+++ CalendarServer/trunk/twistedcaldav/dateops.py 2015-04-23 17:51:44 UTC (rev 14699)
@@ -319,39 +319,44 @@
-def pickledFromPyCalendar(dt):
+def tupleFromDateTime(dt):
"""
- Parse an SQL formated timestamp into a DateTime
- @param ts: the SQL timestamp
- @type ts: C{str}
+ Convert a L{DateTime} into a L{tuple} of L{int}s that performs better when pickled.
- @return: L{DateTime} result
+ @param dt: the date time to convert
+ @type dt: L{DateTime}
+
+ @return: L{tuple} result
"""
- # Format is "%Y%m%dT%H%M%S"
+ # Expand the date and time components into a tuple
return (
dt.mYear, dt.mMonth, dt.mDay, dt.mHours, dt.mMinutes, dt.mSeconds
)
-def pickledToPyCalendar(ts, withTimezone=None):
+def tupleToDateTime(tp, withTimezone=None):
"""
- Parse an SQL formated timestamp into a DateTime
- @param ts: the SQL timestamp
- @type ts: C{str}
+ Turn an L{tuple} produced by L{tupleFromDateTime} into an L{DateTime} and use the provided
+ time zone.
+ @param tp: the tuple to convert
+ @type tp: L{tuple}
+ @param withTimezone: time zone to use or L{None}
+ @type withTimezone: L{Timezone}
+
@return: L{DateTime} result
"""
- # Format is "%Y%m%dT%H%M%S"
+ # Construct date time from tuple components
return DateTime(
- year=ts[0],
- month=ts[1],
- day=ts[2],
- hours=ts[3],
- minutes=ts[4],
- seconds=ts[5],
+ year=tp[0],
+ month=tp[1],
+ day=tp[2],
+ hours=tp[3],
+ minutes=tp[4],
+ seconds=tp[5],
tzid=withTimezone,
)
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py 2015-04-23 17:29:31 UTC (rev 14698)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py 2015-04-23 17:51:44 UTC (rev 14699)
@@ -27,8 +27,8 @@
from twistedcaldav.caldavxml import TimeRange
from twistedcaldav.config import config
from twistedcaldav.dateops import compareDateTime, normalizeToUTC, \
- parseSQLTimestampToPyCalendar, pickledToPyCalendar, clipPeriod, \
- timeRangesOverlap, normalizePeriodList, pickledFromPyCalendar
+ parseSQLTimestampToPyCalendar, tupleToDateTime, clipPeriod, \
+ timeRangesOverlap, normalizePeriodList, tupleFromDateTime
from twistedcaldav.ical import Component, Property, iCalendarProductID
from twistedcaldav.instance import InstanceList
from twistedcaldav.memcacher import Memcacher
@@ -395,8 +395,8 @@
name, uid, comptype, test_organizer = k
self.accountingItems["fb-resources"][uid] = []
for float, start, end, fbtype in v:
- fbstart = pickledToPyCalendar(start, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
- fbend = pickledToPyCalendar(end, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
+ fbstart = tupleToDateTime(start, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
+ fbend = tupleToDateTime(end, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
self.accountingItems["fb-resources"][uid].append((
float,
str(fbstart),
@@ -426,8 +426,8 @@
continue
# Apply a timezone to any floating times
- fbstart = pickledToPyCalendar(start, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
- fbend = pickledToPyCalendar(end, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
+ fbstart = tupleToDateTime(start, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
+ fbend = tupleToDateTime(end, withTimezone=tzinfo if float == 'Y' else Timezone.UTCTimezone)
# Clip instance to time range
clipped = clipPeriod(Period(fbstart, end=fbend), self.timerange)
@@ -581,8 +581,8 @@
fbtype = 'F'
aggregated_resources.setdefault((name, uid, comptype, test_organizer,), []).append((
float,
- pickledFromPyCalendar(parseSQLTimestampToPyCalendar(start)),
- pickledFromPyCalendar(parseSQLTimestampToPyCalendar(end)),
+ tupleFromDateTime(parseSQLTimestampToPyCalendar(start)),
+ tupleFromDateTime(parseSQLTimestampToPyCalendar(end)),
fbtype,
))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150423/e513bd34/attachment.html>
More information about the calendarserver-changes
mailing list