SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

From: <jo...@us...> - 2007年08月21日 19:42:37
Revision: 3727
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3727&view=rev
Author: jouni
Date: 2007年08月21日 12:42:28 -0700 (2007年8月21日)
Log Message:
-----------
Run a simple sanity check to avoid attempting to parse non-AFM files as AFM.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/afm.py
Modified: trunk/matplotlib/lib/matplotlib/afm.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/afm.py	2007年08月21日 19:10:02 UTC (rev 3726)
+++ trunk/matplotlib/lib/matplotlib/afm.py	2007年08月21日 19:42:28 UTC (rev 3727)
@@ -53,7 +53,27 @@
 else: return True
 
 
+def _sanity_check(fh):
+ """
+ Check if the file at least looks like AFM. 
+ If not, raise RuntimeError.
+ """
 
+ # Remember the file position in case the caller wants to
+ # do something else with the file.
+ pos = fh.tell()
+ try:
+ line = fh.readline()
+ finally:
+ fh.seek(pos, 0)
+
+ # AFM spec, Section 4: The StartFontMetrics keyword [followed by a
+ # version number] must be the first line in the file, and the
+ # EndFontMetrics keyword must be the last non-empty line in the
+ # file. We just check the first line.
+ if not line.startswith('StartFontMetrics'):
+ raise RuntimeError('Not an AFM file')
+
 def _parse_header(fh):
 """
 Reads the font metrics header (up to the char metrics) and returns
@@ -255,6 +275,7 @@
 dkernpairs : a parse_kern_pairs dict, possibly {}
 dcomposite : a parse_composites dict , possibly {}
 """
+ _sanity_check(fh)
 dhead = _parse_header(fh)
 dcmetrics = _parse_char_metrics(fh)
 doptional = _parse_optional(fh)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月27日 13:32:03
Revision: 5686
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5686&view=rev
Author: mdboom
Date: 2008年06月27日 06:31:53 -0700 (2008年6月27日)
Log Message:
-----------
Minor docstring typo (thanks, Chris Walker)
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/afm.py
Modified: trunk/matplotlib/lib/matplotlib/afm.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/afm.py	2008年06月27日 12:51:50 UTC (rev 5685)
+++ trunk/matplotlib/lib/matplotlib/afm.py	2008年06月27日 13:31:53 UTC (rev 5686)
@@ -4,7 +4,7 @@
 than mine) I decided not to go with them because either they were
 either
 
- 1) copyighted or used a non-BSD compatible license
+ 1) copyrighted or used a non-BSD compatible license
 
 2) had too many dependencies and I wanted a free standing lib
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /