#!/usr/bin/python # author: Martin Michel # created: May 2008 """ This script is the bridge between the calling Colendar.app application and pdfcal.py. The script takes all the passed arguments from the AppleScript and then utilizes the imported pdfcal script to create a PDF calendar or to return all available calendar languages. """ import sys from pdfcal import * def main(): action = sys.argv[1] # the AppleScript wants to create a new PDF calendar if action == 'createcal': # getting and coercing the passed arguments year = int(sys.argv[2]) format = sys.argv[3] lang = sys.argv[4] red = float(sys.argv[5]) green = float(sys.argv[6]) blue = float(sys.argv[7]) alpha = 1 actsaturday = int(sys.argv[8]) suntint = float(sys.argv[9]) sattint = float(sys.argv[10]) sunday = int(sys.argv[11]) actweeknos = int(sys.argv[12]) weeknoday = int(sys.argv[13]) filepath = sys.argv[14] # creating the PDF calendar pdfcal = PDFCalendar() pdfcal.setyear(year) pdfcal.setlang(lang) pdfcal.setformat(format) pdfcal.setcolor(red, green, blue, alpha) if actsaturday: pdfcal.actsaturday() else: pdfcal.deactsaturday() if actweeknos: pdfcal.actweeknos() else: pdfcal.deactweeknos() pdfcal.setweeknoday(weeknoday) pdfcal.setsunday(sunday) pdfcal.setsattint(sattint) pdfcal.setsuntint(suntint) pdfcal.setfilepath(filepath) pdfcal.create() # the AppleScript wants to get the available calendar languages elif action == 'getlangs': pdfcal = PDFCalendar() langs = pdfcal.getlangs() langs.sort() for lang in langs: print lang # the AppleScript wants to get the available calendar formats elif action == 'getformats': pdfcal = PDFCalendar() formats = pdfcal.getformats() formats.sort() for format in formats: print format if __name__ == '__main__': main()