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. </file:>
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
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