[Scribus] Calendar script - a summary

Elmar Jobs infonews
Fri Oct 29 13:29:50 CEST 2004


OK, I just tried some things with the nice calendar script from Henry 
(http://www.dotrose.com/misc/computer/cal-tabloid.py), based on the last 
Emails.

The main problem was:
>> I just found what caused the bug in the calendar script here: it
>> seems that python doesn't accept characters larger than 128, i. e.
>> German Umlauts, French accents etc. EVEN WITHIN LINES OF COMMENTS.

Wolfgang Pagel wrote:
> Try 'M\xe4rz' for 'M?rz' ... It works in so called long strings, with
> the hexadezimal (ascii-)code written \x?? (here e4) or with the octal
> code \??? (here 344). Hope the MONTHs in the script are long strings
Craig Ringer wrote:
 > I must admit that I'm getting some odd behaviour still - in
 > particular, I can say:
 >
 > print u'M?rz'

That's one solution, but it breaks the code in another place because the 
list of months is used to name the text and graphics objects (e.g. 
"TextJanuary").

I wrote:
> That's correct. The problem is the internal encoding. You can change
> it by inserting
> import sys sys.setdefaultencoding('utf-8')   # or ISO8859-1
> at the top of the script. I might be that your distribution prohibits
>  setting this value (than the function is unknown). For SuSE I had to
> edit /usr/lib/python/site.py and remove the two lines
> if hasattr(sys, "setdefaultencoding"):
 >    del sys.setdefaultencoding
> at the end of the file.

That one works but it's a bad hack. There are reasons why site.py is 
like it is.

The solution is:

1.
In list MonthList, prepend all names with nun ASCII-Chars with an 'u', 
or write these chars in HEX/OCT
e.g. u'M?rz' oder 'M\xe4rz'

2.
Change all occurrences of MonthList[Month] in CreateText() and 
CreateImage() to str(Month).

That should work. Maybe Henry can include these changes in the latest 
version of the script and post it to scribus.net.

	Elmar

P.S.: I uploaded a slightly changed version to 
http://www.ejobs.de/stuff/calendar_A3.py for those interested.




More information about the scribus mailing list