From e0cdf8e0ac7cc0bfd89e9166fea83c1b01e8c246 Mon Sep 17 00:00:00 2001 From: alvinpenner Date: Mon, 26 Jan 2009 00:19:35 +0000 Subject: [PATCH] add support for 'iso-8859-1' --- share/extensions/svgcalendar.py | 156 ++++++++++++++++---------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/share/extensions/svgcalendar.py b/share/extensions/svgcalendar.py index 7410d3079..0dca58fc5 100755 --- a/share/extensions/svgcalendar.py +++ b/share/extensions/svgcalendar.py @@ -1,92 +1,92 @@ #!/usr/bin/env python - -''' + +''' calendar.py A calendar generator plugin for Inkscape, but also can be used as a standalone command line application. - -Copyright (C) 2008 Aurelio A. Heckert - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' + +Copyright (C) 2008 Aurelio A. Heckert + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' __version__ = "0.1" import inkex, simplestyle, re, calendar from datetime import * - -class SVGCalendar (inkex.Effect): - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("--tab", - action="store", type="string", - dest="tab") - self.OptionParser.add_option("--month", - action="store", type="int", - dest="month", default=0, - help="Month to be generated. If 0, then the entry year will be generated.") +class SVGCalendar (inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab") + self.OptionParser.add_option("--month", + action="store", type="int", + dest="month", default=0, + help="Month to be generated. If 0, then the entry year will be generated.") self.OptionParser.add_option("--year", - action="store", type="int", - dest="year", default=0, - help="Year to be generated. If 0, then the current year will be generated.") + action="store", type="int", + dest="year", default=0, + help="Year to be generated. If 0, then the current year will be generated.") self.OptionParser.add_option("--fill-empty-day-boxes", - action="store", type="inkbool", - dest="fill_edb", default=True, - help="Fill empty day boxes with next month days.") + action="store", type="inkbool", + dest="fill_edb", default=True, + help="Fill empty day boxes with next month days.") self.OptionParser.add_option("--start-day", - action="store", type="string", - dest="start_day", default="sun", - help='Week start day. ("sun" or "mon")') + action="store", type="string", + dest="start_day", default="sun", + help='Week start day. ("sun" or "mon")') self.OptionParser.add_option("--weekend", - action="store", type="string", - dest="weekend", default="sat+sun", - help='Define the weekend days. ("sat+sun" or "sat" or "sun")') + action="store", type="string", + dest="weekend", default="sat+sun", + help='Define the weekend days. ("sat+sun" or "sat" or "sun")') self.OptionParser.add_option("--color-year", - action="store", type="string", - dest="color_year", default="#888", - help='Color for the year header.') + action="store", type="string", + dest="color_year", default="#888", + help='Color for the year header.') self.OptionParser.add_option("--color-month", - action="store", type="string", - dest="color_month", default="#666", - help='Color for the month name header.') + action="store", type="string", + dest="color_month", default="#666", + help='Color for the month name header.') self.OptionParser.add_option("--color-day-name", - action="store", type="string", - dest="color_day_name", default="#999", - help='Color for the week day names header.') + action="store", type="string", + dest="color_day_name", default="#999", + help='Color for the week day names header.') self.OptionParser.add_option("--color-day", - action="store", type="string", - dest="color_day", default="#000", - help='Color for the common day box.') + action="store", type="string", + dest="color_day", default="#000", + help='Color for the common day box.') self.OptionParser.add_option("--color-weekend", - action="store", type="string", - dest="color_weekend", default="#777", - help='Color for the weekend days.') + action="store", type="string", + dest="color_weekend", default="#777", + help='Color for the weekend days.') self.OptionParser.add_option("--color-nmd", - action="store", type="string", - dest="color_nmd", default="#BBB", - help='Color for the next month day, in enpty day boxes.') + action="store", type="string", + dest="color_nmd", default="#BBB", + help='Color for the next month day, in enpty day boxes.') self.OptionParser.add_option("--month-names", - action="store", type="string", + action="store", type="string", dest="month_names", default='January February March April May June '+\ - 'July August September October November December', + 'July August September October November December', help='The month names for localization.') self.OptionParser.add_option("--day-names", - action="store", type="string", - dest="day_names", default='Sun Mon Tue Wed Thu Fri Sat', - help='The week day names for localization.') + action="store", type="string", + dest="day_names", default='Sun Mon Tue Wed Thu Fri Sat', + help='The week day names for localization.') def validate_options(self): # Convert string names lists in real lists: @@ -94,7 +94,7 @@ class SVGCalendar (inkex.Effect): self.options.month_names = re.split( '\s+', m.group(1) ) m = re.match( '\s*(.*[^\s])\s*', self.options.day_names ) self.options.day_names = re.split( '\s+', m.group(1) ) - # Validate names lists: + # Validate names lists: if len(self.options.month_names) != 12: inkex.errormsg('The month name list "'+ str(self.options.month_names)+ @@ -102,7 +102,7 @@ class SVGCalendar (inkex.Effect): self.options.month_names = ['January','February','March', 'April', 'May', 'June', 'July', 'August', 'September', - 'October','November','December'] + 'October','November','December'] if len(self.options.day_names) != 7: inkex.errormsg('The day name list "'+ str(self.options.day_names)+ @@ -186,27 +186,27 @@ class SVGCalendar (inkex.Effect): return cal2 def write_month_header(self, g, m): - txt_atts = {'style': simplestyle.formatStyle(self.style_month), + txt_atts = {'style': simplestyle.formatStyle(self.style_month), 'x': str( (self.month_w - self.day_w) / 2 ), 'y': str( self.day_h / 5 ) } - inkex.etree.SubElement(g, 'text', txt_atts).text = self.options.month_names[m-1] + inkex.etree.SubElement(g, 'text', txt_atts).text = unicode(self.options.month_names[m-1], "iso-8859-1") gw = inkex.etree.SubElement(g, 'g') week_x = 0 if self.options.start_day=='sun': for wday in self.options.day_names: - txt_atts = {'style': simplestyle.formatStyle(self.style_day_name), + txt_atts = {'style': simplestyle.formatStyle(self.style_day_name), 'x': str( self.day_w * week_x ), 'y': str( self.day_h ) } - inkex.etree.SubElement(gw, 'text', txt_atts).text = wday + inkex.etree.SubElement(gw, 'text', txt_atts).text = unicode(wday, "iso-8859-1") week_x += 1 else: w2 = self.options.day_names[1:] w2.append(self.options.day_names[0]) for wday in w2: - txt_atts = {'style': simplestyle.formatStyle(self.style_day_name), + txt_atts = {'style': simplestyle.formatStyle(self.style_day_name), 'x': str( self.day_w * week_x ), 'y': str( self.day_h ) } - inkex.etree.SubElement(gw, 'text', txt_atts).text = wday + inkex.etree.SubElement(gw, 'text', txt_atts).text = unicode(wday, "iso-8859-1") week_x += 1 def create_month(self, m): @@ -249,7 +249,7 @@ class SVGCalendar (inkex.Effect): style = self.style_day if self.is_weekend(week_x): style = self.style_weekend if day == 0: style = self.style_nmd - txt_atts = {'style': simplestyle.formatStyle(style), + txt_atts = {'style': simplestyle.formatStyle(style), 'x': str( self.day_w * week_x ), 'y': str( self.day_h * (week_y+2) ) } if day==0 and not self.options.fill_edb: @@ -278,7 +278,7 @@ class SVGCalendar (inkex.Effect): txt_atts = { 'id': 'year_'+str(self.options.year) } self.year_g = inkex.etree.SubElement(parent, 'g', txt_atts) - txt_atts = {'style': simplestyle.formatStyle(self.style_year), + txt_atts = {'style': simplestyle.formatStyle(self.style_year), 'x': str( self.doc_w / 2 ), 'y': str( self.day_w * 1.5 ) } inkex.etree.SubElement(self.year_g, 'text', txt_atts).text = str(self.options.year) @@ -289,6 +289,6 @@ class SVGCalendar (inkex.Effect): self.create_month(self.options.month) -if __name__ == '__main__': - e = SVGCalendar() - e.affect() +if __name__ == '__main__': + e = SVGCalendar() + e.affect() -- 2.30.2