This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__="san" | |
__date__ ="$18-May-2010 11:48:34 PM$" | |
from datetime import datetime | |
from reportlab.platypus import * | |
from reportlab.platypus.tables import * | |
from datetime import timedelta | |
from datetime import * | |
from reportlab.lib.styles import * | |
from reportlab.lib.units import * | |
def main(places): | |
doc = SimpleDocTemplate('gfe.pdf') | |
data = [ | |
['P1','_____'], | |
['P2','_____'], | |
['P3','_____'], | |
] | |
elements = [] | |
styles = getSampleStyleSheet() | |
end_date = datetime(year = 2010,month = 8, day = 15) | |
start_date = datetime(year = 2010,month = 5, day = 16) | |
d = start_date | |
dt = timedelta(days = 7) | |
week_number = 1 | |
while d < end_date: | |
d += dt | |
insert_in_data(data, places) | |
cycle(places) | |
t = Table(data, rowHeights = 13.5) | |
t.setStyle(TableStyle([ | |
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), | |
('BOX', (0,0), (-1,-1), 0.25, colors.black), | |
])) | |
elements.append(t) | |
p = Paragraph(d.strftime("%B %d ----") + '- end of week %d' % week_number, styles['Normal'] ) | |
elements.append(p) | |
week_number += 1 | |
doc.build(elements) | |
def insert_in_data(data, the_places): | |
for i, place in enumerate( the_places ): | |
if len(data[i]) > 2: | |
data[i].pop(1) | |
data[i].insert(1, place) | |
def cycle(the_list): | |
tail = the_list.pop() | |
the_list.insert(0,tail) | |
if __name__ == "__main__": | |
places = ['Salle de bain', 'Cuisine', 'Place de sejour'] | |
main(places) | |
print "Hello World" |
So like this we will change the place and of course after the end of the week all the blanks should be checked)).And the screenshot of the result:
