Issue 24 in pylibtiff: Enhance parsing of tiff.h

2 views
Skip to first unread message

pyli...@googlecode.com

unread,
Jun 14, 2013, 12:40:21 PM6/14/13
to pylibtif...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 24 by djmuhles...@gmail.com: Enhance parsing of tiff.h
http://code.google.com/p/pylibtiff/issues/detail?id=24

I had patched r87 myself when I got a new libtiff on fedora 18. Hadn't got
around to submitting the patch though. I noticed it got fixed in svn but
thought I'd add a minor detail.

In the svn version exceptions are raised when header refers to values
already defined instead of using numbers. Adding the value dict back to
the eval statement allows those to be parsed and added to the value instead
of raising. Also using re makes a few less lines of code needed to get the
right values into the words.

Not a big deal.. just thought I'd submit anyway.

Index: libtiff/libtiff_ctypes.py
===================================================================
--- libtiff/libtiff_ctypes.py (revision 93)
+++ libtiff/libtiff_ctypes.py (working copy)
@@ -13,6 +13,7 @@
__all__ = ['libtiff', 'TIFF']

import os
+import re
import sys
import numpy as np
from numpy import ctypeslib
@@ -71,10 +72,7 @@
d = {}
for line in f.readlines():
if not line.startswith('#define'): continue
- words = line[7:].lstrip().split()
- if len(words)>2:
- words[1] = ''.join(words[1:])
- del words[2:]
+ words = re.split( "\s*", line[7:].strip(), 1 )
if len (words)!=2: continue
name, value = words
i = value.find('/*')
@@ -82,11 +80,7 @@
if value in d:
value = d[value]
else:
- try:
- value = eval(value)
- except:
- print `value, line`
- raise
+ value = eval(value,d)
d[name] = value
l.append('%s = %s' % (name, value))
f.close()


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

pyli...@googlecode.com

unread,
Sep 13, 2014, 6:29:51 PM9/13/14
to pylibtif...@googlegroups.com
Updates:
Status: WontFix

Comment #1 on issue 24 by pearu.peterson: Enhance parsing of tiff.h
https://code.google.com/p/pylibtiff/issues/detail?id=24

Thanks for the patch. I'll ignore it for now..
Reply all
Reply to author
Forward
0 new messages