svgcalendar.py revision 52bc35e1956391dd3b08ecbedd022da25e746c9c
'''
A calendar generator plugin for Inkscape, but also can be used as a standalone
command line application.
Copyright (C) 2008 Aurelio A. Heckert <aurium(a)gmail.com>
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.2"
from datetime import *
dest="tab")
help="Month to be generated. If 0, then the entry year will be generated.")
help="Year to be generated. If 0, then the current year will be generated.")
help="Fill empty day boxes with next month days.")
help='Week start day. ("sun" or "mon")')
help='Define the weekend days. ("sat+sun" or "sat" or "sun")')
help='Automatically set the size and positions.')
help='Number of months side by side.')
help='The width of the month days box.')
help='The space between the month boxes.')
help='Color for the year header.')
help='Color for the month name header.')
help='Color for the week day names header.')
help='Color for the common day box.')
help='Color for the weekend days.')
help='Color for the next month day, in enpty day boxes.')
'July August September October November December',
help='The month names for localization.')
help='The week day names for localization.')
help='The input encoding of the names.')
def validate_options(self):
#inkex.errormsg( self.options.input_encode )
# Convert string names lists in real lists:
# Validate names lists:
'" is invalid. Using default.')
'April', 'May', 'June',
'July', 'August', 'September',
'October','November','December']
'" is invalid. Using default.')
# Convert year 0 to current year:
# Year 1 starts it's week at monday, obligatorily
# Set the calendar start day:
else:
# Convert string numbers with unit to user space float numbers:
# initial values:
month_x_pos = 0
month_y_pos = 0
#month_margin month_width months_per_line auto_organize
else:
else:
#self.month_w = self.doc_w / self.months_per_line
else:
) / 2 ) #- self.month_margin
else:
'font-family': 'arial',
'text-anchor': 'middle',
'text-align': 'center',
}
# weekend values: "sat+sun" or "sat" or "sun"
else:
return False
cal2 = []
if day != 0:
return cal2
def write_month_header(self, g, m):
try:
inkex.etree.SubElement(g, 'text', txt_atts).text = unicode(self.options.month_names[m-1], self.options.input_encode)
except:
exit(1)
week_x = 0
try:
except:
exit(1)
week_x += 1
else:
try:
except:
exit(1)
week_x += 1
def create_month(self, m):
txt_atts = {
self.month_x_pos) +
self.write_month_header(g, m)
if m == 1:
before_month = \
else:
before_month = \
if m == 12:
next_month = \
else:
next_month = \
# How mutch before month days will be showed:
week_y = 0
week_x = 0
pass # draw nothing
elif day==0:
if before:
bmd -= 1
else:
bmd += 1
else:
week_x += 1
week_y += 1
txt_atts = {
self.create_month(m)
else:
e = SVGCalendar()
e.affect()