Skip to content

Instantly share code, notes, and snippets.

@gyst
gyst / pytzfixer.py
Created September 30, 2016 06:38
Transmogrifier recipe for fixing dexterity event start/end dates
# coding=utf-8
from zope.interface import classProvides, implements
from collective.transmogrifier.interfaces import ISectionBlueprint
from collective.transmogrifier.interfaces import ISection
from collective.transmogrifier.utils import Matcher, Condition
import logging
logger = logging.getLogger(__name__)
@gyst
gyst / groupby
Last active December 21, 2015 01:39
Group a list of items into a nested list of subgroups, where the subgroups are of a certain length. Useful e.g. if you want to display a flat list into a 2-column or 3-column layout.
#!/usr/bin/python
def groupby(iterable, groupsize=2):
"""
Split an iterable [a, b, c, ...]
into a nested list of tuples [(a, b), (c, ...)]
where the length of the tuples is governed by groupsize.
The default groupsize results in pairwise grouping: