Skip to content
Browse files

pyflakes cleanups

removed trailing whitespaces
  • Loading branch information...
1 parent d6b4190 commit c51d9ca6a0f36a437fc5231bdc6b390bdf6b362d tom_gross committed Mar 12, 2010
View
23 dateable/chronos/browser/base_view.py
@@ -1,5 +1,3 @@
-from time import strftime
-
import BTrees
import datetime
import calendar
@@ -24,11 +22,11 @@
# This evilness must go:
DAYS = [
- 'Monday',
- 'Tuesday',
- 'Wednesday',
- 'Thursday',
- 'Friday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
'Saturday',
'Sunday',
]
@@ -54,17 +52,17 @@
def derive_ampmtime(timeobj):
"""Derives the 12 hour clock am/pm identifier and proper hour.
-
+
Some random tests.
-
+
>>> from datetime import time
-
+
>>> derive_ampmtime(time(1, 30))
(1, 'a')
-
+
>>> derive_ampmtime(time(13, 30))
(1, 'p')
-
+
>>> derive_ampmtime(time(12, 01))
(12, 'p')
@@ -215,7 +213,6 @@ def monthweeks(year=None, month=None, daydate=None, firstweekday=None):
firstcalday.day) != firstweekday:
firstcalday -= ONEDAY
- done = False
weeks = []
day = firstcalday
nextday = day + ONEDAY
View
23 dateable/chronos/browser/day.py
@@ -29,7 +29,6 @@
from displaytable import DayGrid
from interfaces import IPositionedView, IEventDisplay
-from dateable import kalends
from base_view import BaseCalendarView
from zope.i18nmessageid import MessageFactory
@@ -40,7 +39,7 @@
class DayView(BaseCalendarView):
"""Holds the rendering information for day views"""
-
+
implements(IPositionedView)
def __getitem__(self, key):
@@ -59,7 +58,7 @@ def calcInfo(self):
p_cal = getToolByName(self.context, 'portal_calendar')
self.from_hour = p_cal.hour_start
self.to_hour = p_cal.hour_end
-
+
self.hour_count = self.to_hour - self.from_hour
# We might want to make this more flexible for different layouts
@@ -72,31 +71,29 @@ def calcInfo(self):
self.before_line = False
self.after_line = False
if self.from_hour > 0:
- self.height = self.height + self.hour_height
+ self.height = self.height + self.hour_height
self.before_line = True
if self.to_hour < 23:
- self.height = self.height + self.hour_height
+ self.height = self.height + self.hour_height
self.after_line = True
def getDate(self):
return self.first_day
-
+
def getDays(self):
return [self.getDate()]
-
+
def getEventDisplays(self):
""" gathers event-like objects from an event provider """
- provider = kalends.IEventProvider(self.context)
-
occurrences = self.getOccurrencesInDay(self.today)
displays = [getMultiAdapter([occurrence, self], IEventDisplay)
for occurrence in occurrences]
-
+
# Handle overlapping displays:
daygrid = DayGrid(0, 0, self.height, self.day_width)
daygrid.extend(displays)
daygrid.flatten()
-
+
return daygrid
def getTodayInfo(self):
@@ -105,8 +102,8 @@ def getTodayInfo(self):
istoday = True
else:
istoday = False
- return {'year': today.year,
- 'month': today.month,
+ return {'year': today.year,
+ 'month': today.month,
'day': today.day,
'istoday': istoday}
View
17 dateable/chronos/browser/events.py
@@ -15,13 +15,12 @@
class EventListingView(BaseCalendarView):
"""View that lists events.
"""
-
+
eventlist = PageTemplateFile('events.pt')
-
+
def _getEventList(self, start=None, stop=None):
provider = kalends.IEventProvider(self.context)
- now = datetime.datetime.now()
- events = list(provider.getOccurrences(start=start, stop=stop,
+ events = list(provider.getOccurrences(start=start, stop=stop,
**self.request.form))
events.sort()
months = []
@@ -51,9 +50,9 @@ def _getEventList(self, start=None, stop=None):
if month_info:
months.append(month_info)
-
+
return months
-
+
def upcomingEvents(self):
"""Show all upcoming events"""
now = datetime.datetime.now()
@@ -82,8 +81,6 @@ def monthEvents(self):
def weekEvents(self):
"""Show all events for a particular week"""
- month = self.default_day.month
- year = self.default_day.year
start = isoweek.weeknr2datetime(self.default_day.year, self.week(), 1)
stop = start + datetime.timedelta(7)
months = self._getEventList(start=start,stop=stop)
@@ -100,14 +97,14 @@ def popup_in_tabs(self):
# The popup needs to be in the tabs for the list views,
# but it makes no sense for the list and past view:
return self.__name__ not in (u'list.html', u'past.html')
-
+
def url(self, start=None, stop=None):
provider = kalends.IWebEventCreator(self.context)
return provider.url(start, stop)
def render_filter(self):
provider = queryMultiAdapter(
- (self.context, self.request, self),
+ (self.context, self.request, self),
IContentProvider, 'eventfilter')
if provider is None:
return ''
View
30 dateable/chronos/browser/interfaces.py
@@ -20,7 +20,7 @@
interfaces.py
"""
from zope.interface import Interface
-from zope.schema import Int, Date, Datetime, TextLine, Text, Bool, Choice, Set
+from zope.schema import Int, Date
from zope.viewlet.interfaces import IViewletManager
from zope.i18nmessageid import MessageFactory
@@ -36,20 +36,20 @@ class IUnPositionedView(ICalendarView):
class IPositionedView(ICalendarView):
"""A view that uses absolute positioning to render events"""
-
- width = Int(title=u"Width",
+
+ width = Int(title=u"Width",
description=u"The total width of the view")
-
- height = Int(title=u"Height",
+
+ height = Int(title=u"Height",
description=u"The total height of the view")
-
+
first_day = Date(title=u"First Day",
description=u"The first day of the view")
-
- days = Int(title=u"Days",
+
+ days = Int(title=u"Days",
description=u"The number of days shown")
- from_hour = Int(title=u"From hour",
+ from_hour = Int(title=u"From hour",
description=u"The time at the top of the view")
to_hour = Int(title=u"To hour",
@@ -59,9 +59,9 @@ class IPositionedView(ICalendarView):
class IEventPosition(Interface):
"""An events position
- Contains the information needed to properly display an event on a
+ Contains the information needed to properly display an event on a
IPositionedView."""
-
+
def getCssPositionString():
"""Returns a properly formatted css-style position string.
@@ -72,9 +72,9 @@ def getCssPositionString():
class IEventDisplay(Interface):
"""An events display information
- Contains the information needed to properly display an event on a
+ Contains the information needed to properly display an event on a
IPositionedView."""
-
+
def getCssPositionString():
"""Returns a properly formatted css-style position string.
@@ -85,14 +85,14 @@ def getCssPositionString():
def getCssStatusClass(self):
"""Returns a CSS class name according to the status of this event
for the current user attendee (if there is one). Possible classes are:
-
+
need-action
accepted
declined
tentative
delegated
<empty>
-
+
It is up to the actual stylesheet to do something with this class.
"""
View
22 dateable/chronos/browser/thumbnail.py
@@ -1,49 +1,46 @@
from time import localtime
from zope.interface import implements
-from zope.component import getAdapters, getMultiAdapter
+from zope.component import getMultiAdapter
from zope.i18nmessageid import MessageFactory
from zope.viewlet.interfaces import IViewlet, IViewletManager
from kss.core import KSSView, kssaction
from Acquisition import aq_inner
-from DateTime import DateTime
from Products.PythonScripts.standard import url_quote_plus
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
-from interfaces import INavigation
-
PLMF = MessageFactory('plonelocales')
class NavigationView(KSSView):
-
+
@kssaction
def navigationChange(self, month, year, viewname):
core = self.getCommandSet('core')
manager = getMultiAdapter((core.context, core.request, core.view,),
IViewletManager, name='chronos.navigation')
renderer = getMultiAdapter(
- (core.context, core.request, core.view, manager),
- IViewlet,
+ (core.context, core.request, core.view, manager),
+ IViewlet,
name='chronos.ajaxnavigation'
)
renderer = renderer.__of__(self.context)
renderer.update(int(month), int(year), viewname)
result = renderer.render()
core.replaceInnerHTML('#chronosPopupCalendar', result)
-
+
# This is a mildly modified copy of the standard plone calendar portlet:
class ThumbnailMonth(BrowserView):
implements(IViewlet)
-
+
render = ViewPageTemplateFile('thumbnail.pt')
updated = False
@@ -55,12 +52,12 @@ def __init__(self, context, request, view, manager):
self.request = request
self.view = view
self.manager = manager
-
+
def update(self, month=None, year=None, viewname=None):
if self.updated:
return
self.updated = True
-
+
if viewname is None:
viewname = self.view.__name__
self.viewname = viewname
@@ -91,7 +88,6 @@ def update(self, month=None, year=None, viewname=None):
def getEventsForCalendar(self):
- context = aq_inner(self.context)
year = self.year
month = self.month
weeks = self.calendar.getEventsForCalendar(month, year)
@@ -102,7 +98,6 @@ def getEventsForCalendar(self):
continue
day['is_today'] = self.isToday(daynumber)
day['date_string'] = '%s-%s-%s' % (year, month, daynumber)
-
return weeks
def getEventString(self, event):
@@ -199,4 +194,3 @@ def getQueryString(self):
query_string = '%s&amp;' % query_string
return query_string
-
View
8 dateable/chronos/tests/test_time_format_inference.py
@@ -6,13 +6,13 @@ def test_inference(self):
"""Make sure our crazy localTimeOnlyFormat function works."""
# Test every combination: datelike-to-nondatelike, nondatelike-to-datelike, datelike-to-datelike, and nondatelike-to-nondatelike:
self.assertEqual(localTimeFormatFromLocalDateTimeFormat("ab: %H:%I at %a-%Y"), '%H:%I')
-
+
# Test beginning with a token, ending with an unknown token, and having tokens run right up against each other:
self.assertEqual(localTimeFormatFromLocalDateTimeFormat("%Sab: %H:%I%I at %a-%Y %?"), '%Sab: %H:%I%I%?')
-
+
# Test some other cases I no longer remember:
self.assertEqual(localTimeFormatFromLocalDateTimeFormat("%b %d, %Y %I:%M %p"), '%I:%M %p')
-
+
# Test adjacent % signs:
self.assertEqual(localTimeFormatFromLocalDateTimeFormat("b %%% smoo"), '% ')
@@ -21,5 +21,3 @@ def test_suite():
suite.addTest(makeSuite(TestSequenceFunctions))
return suite
-if __name__ == '__main__':
- unittest.main()
View
5 dateable/chronos/utils.py
@@ -1,6 +1,5 @@
import calendar
from datetime import date
-from time import strftime
def get_view_day(request):
@@ -45,11 +44,11 @@ def set_view_day(request, day):
def localTimeFormatFromLocalDateTimeFormat(format):
"""Derive a time-only format from a format string possibly including both time and date tokens.
-
+
Needed because there's no apparent definition of a localized time format string (apart from format strings that mix in date as well) in Plone < 3.2. Algorithm: find each strftime substitution token (like %S) and decide whether it conveys any time information (seconds, minutes, etc.). Keep the time-like tokens, and discard the date-like ones. Also keep any characters between successive time-like tokens. Discard leading and trailing characters.
"""
# TODO: If we end up butting two tokens up against each other, insert a space between them.
-
+
chunks = format.split('%')[1:] # Always throw away the first chunk. Whether we keep or discard prefixes and suffixes, we have to do the same for both to support right-to-left and left-to-right languages.
kill = 'aAbBdjmUwWxyY' # date-like tokens
limbo = '' # chars between tokens
View
1 setup.py
@@ -1,5 +1,4 @@
from setuptools import setup, find_packages
-import sys, os
f = open('dateable/chronos/version.txt')
version = f.read().strip()

0 comments on commit c51d9ca

Please sign in to comment.
Something went wrong with that request. Please try again.