#98 file schema URIs on windows

PyXB 1.1.3
closed
None
fixed
Content model
major
PyXB 1.1.2
defect
2011-05-22
2010-12-27
Anonymous
No

Originally created by: Barry.Gallagher@…

For the generation of wrapper files I saw the threads saying use "file:"
for pyxbgen which worked for me until I had sub schemas that were also
files. The second file's name was getting "<file:/>" prepended and
wasn't being found when I tried something like "pyxbgen -u
file:local.xsd -m local_out". I decided to check for the uri resulting
in a local file and didn't let the archive directory get modified in
that case.

For the first issue I changed utils/utility.py at line 550 from:

try:

if 0 <= uri.find(':'):

xmls = urllib2.urlopen(uri).read()

else:

xmls = file(uri).read()
archive_directory = None

to:

try:

try:

f = urllib2.urlopen(uri)

except:

try:

import urllib
f = urllib.urlopen(uri) #urllib and urllib2 handle

slightly differently so let both try.

except:

f = file(uri)

xmls = f.read()
if isinstance(f, file) or isinstance(f.fp, file): #catch any

regular files or urllib files

archive_directory = None

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2010-12-27
    • component changed from Generation Model to Content model
     
  • Peter A. Bigot

    Peter A. Bigot - 2011-05-22
    • status changed from new to closed
    • resolution set to fixed

    Like #97, this seems plausible but I'm not going to try to validate the check on a windows system. I implemented a slightly different control flow so on failure the "best" exception could still be raised.

    commit ae34ce5cadf80356fd054c5c7a85f85b9bddabcf
    Author: Peter A. Bigot <pabigot@…>
    Date: Sun May 22 08:53:46 2011 -0500

    trac/98: file schema URIs on windows

    Per submitter suggestion, fall back to urllib if urllib2 fails; use file as
    last resort.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks