[PythonCAD] FW: PythonCad in win32

Somerlot, Chris CSomerlot at Brwncald.com
Fri Mar 26 14:15:04 EST 2004

Art, I've looked more into this more and have some questions about how
compression is implemented. 

Firstly, the endline characters are easy to fix; Python 2.3 comes with
universal newline supoort. But this isn't solving the problem of reading and
writing files on windows.

If I redirect the doc.writexml in imageio.py to a standard ascii xml file
instead of the compression object, I get good data, and can read it back in

The problem seems to be at line 174 in fileio.py, with 

	file.write(self, self.__compobj.compress(data))

Good data is going in, but bad bad data is coming out. My question has to do
with the following section of fileio:
            self.__compobj = zlib.compressobj(6,
            file.write(self, '\037\213\010')
            file.write(self, chr(8)) # flags FNAME - no FHCRC for gzip
            file.write(self, struct.pack("<L", long(time.time())))
            file.write(self, '\000\377') # extra flags and unknown OS flag

What do the constants do on init of __compobj do? What about the flags? I
can not seem to find any documentation on this stuff other than the value of
the constants. Do you have a link to some documentation?


> -----Original Message-----
> From: Art Haas [mailto:ahaas at airmail.net] 
> Sent: Friday, March 19, 2004 9:05 AM
> To: Somerlot, Chris
> Subject: Re: PythonCad in win32
> On Thu, Mar 18, 2004 at 02:55:22PM -0800, Somerlot, Chris wrote:
> > Art, on the web page you state "... certain to be issues 
> with regards 
> > to file saving and loading on the windows ports due to 
> > line-terminating differences. These will be worked out eventually."
> >  
> > I'd like to start to look into solving this, do you have 
> any pointers 
> > on where to start? I google "zlib line-terminating windows" 
> and don't 
> > get much
> >  
> Hi.
> Thanks for looking into this.
> I don't the the problem is in zlib, but in the 'fileio.py' 
> file. What needs attention is the there are places in the 
> code which search for the unix endline character '\n', so in 
> windows this neglects the '\r' character that is also used. 
> The file 'imageio.py' also does a bit of manipulation with 
> the '\n' character (look around line 1425 or so for a
> doc.writexml() call.
> It may be that the solution to the problem is to simply add 
> some line-ending variables specific to each platform, but 
> that approach could be too simplistic in the long run. It 
> would be great to be able to write a write a file on a unix 
> box, and have it read correctly on windows, and be able to 
> write on windows and read on unix. I only run Linux at home, 
> so I don't have means of testing this stuff at my immediate disposal.
> Art
> -- 
> Man once surrendering his reason, has no remaining guard 
> against absurdities the most monstrous, and like a ship 
> without rudder, is the sport of every wind.
> -Thomas Jefferson to James Smith, 1822

More information about the PythonCAD mailing list