|
From: Michael J G. <mic...@us...> - 2011-07-13 14:29:11
|
b1b3a96 (use new filelocator code, 2011-05-14) broke kpsearch
functionality for epsfile.epsfile() because use of the filelocator was
moved after the determination of an initial bbox, which has to open the
file unless a bbox was specified.
Make _readbox() pass kpsearch and appropriate formats to
linefilereader(), and make linefilereader() use the new filelocator
accordingly.
Signed-off-by: Michael J Gruber <mic...@us...>
---
pyx/epsfile.py | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/pyx/epsfile.py b/pyx/epsfile.py
index 4c5fda5..dd1b247 100644
--- a/pyx/epsfile.py
+++ b/pyx/epsfile.py
@@ -65,7 +65,7 @@ class linefilereader:
# in the DSC spec #5001, while '\n\r' *is* a *single* linebreak
# according to the EPSF spec #5002
- def __init__(self, filename, typicallinelen=257):
+ def __init__(self, filename, typicallinelen=257, kpsearch=0, formats=[]):
"""Opens the file filename for reading.
typicallinelen defines the default buffer increase
@@ -74,8 +74,10 @@ class linefilereader:
# note: The maximal line size in an EPS is 255 plus the
# linebreak characters. However, we also handle
# lines longer than that.
-
- self.file = open(filename, "rb")
+ if kpsearch:
+ self.file = filelocator.open(filename, formats, "rb")
+ else:
+ self.file = open(filename, "rb")
self.buffer = ""
self.typicallinelen = typicallinelen
@@ -138,10 +140,10 @@ class linefilereader:
self.file.close()
-def _readbbox(filename):
+def _readbbox(filename, kpsearch=0):
"""returns bounding box of EPS file filename"""
- file = linefilereader(filename)
+ file = linefilereader(filename, kpsearch=kpsearch, formats=[filelocator.format.pict])
# check the %! header comment
if not file.readline().startswith("%!"):
@@ -248,7 +250,7 @@ class epsfile(canvasitem.canvasitem):
self.y_pt = unit.topt(y)
self.filename = filename
self.kpsearch = kpsearch
- self.mybbox = bbox or _readbbox(self.filename)
+ self.mybbox = bbox or _readbbox(self.filename, kpsearch)
# determine scaling in x and y direction
self.scalex = self.scaley = scale
--
1.7.6.336.gdf067
|