summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Ou <shunhsingou@google.com>2012-10-17 12:08:47 +0800
committerEarl Ou <shunhsingou@google.com>2012-10-17 12:08:47 +0800
commit030bf17cb3792e9f9e0492e0d0e24f6cb819c7e0 (patch)
tree4f30becbb38996c6d0f499c04d688044e6c5db5a
parentf579ab7314ada4d49163ebeb58861c04194dc2d4 (diff)
downloadandroid_packages_apps_Snap-030bf17cb3792e9f9e0492e0d0e24f6cb819c7e0.tar.gz
android_packages_apps_Snap-030bf17cb3792e9f9e0492e0d0e24f6cb819c7e0.tar.bz2
android_packages_apps_Snap-030bf17cb3792e9f9e0492e0d0e24f6cb819c7e0.zip
Parse the layer of exiftool output
Change-Id: I0ee45608126d49913a96790f2c2e99ec66ccbca4
-rwxr-xr-xtests/exiftool_parser/parser.py41
1 files changed, 30 insertions, 11 deletions
diff --git a/tests/exiftool_parser/parser.py b/tests/exiftool_parser/parser.py
index 32984886c..351c1b63c 100755
--- a/tests/exiftool_parser/parser.py
+++ b/tests/exiftool_parser/parser.py
@@ -25,31 +25,50 @@ print "<exif>"
#
# 1. tag:
#
-# x) name = value
-# - Tag 0x1234
+# | | | x) name = value
+# | | | - Tag 0x1234
#
# 2. IFD indicator:
#
-# + [xxx directory with xx entries]
+# | | | + [xxx directory with xx entries]
#
p = re.compile(
- "(^.*?[0-9]\).*? = .*?\n.*?- Tag 0x[0-9a-f]{4})|(\+ \[.*? directory with [0-9]+ entries]$)"
+ "(((?:\| )+)[0-9]*\).*? = .*?\n.*?- Tag 0x[0-9a-f]{4})" + "|"
+ + "(((?:\| )*)\+ \[.*? directory with [0-9]+ entries]$)"
, re.M)
tags = p.findall(text)
+layer = 0
+ifds = []
+
for s in tags:
- if s[1]:
- ifd = s[1][3:].split()[0]
+ # IFD indicator
+ if s[2]:
+ l = len(s[3])
+ ifd = s[2][l + 3:].split()[0]
+ new_layer = l / 2 + 1
+ if new_layer > layer:
+ ifds.append(ifd)
+ else:
+ for i in range(layer - new_layer):
+ ifds.pop()
+ ifds[-1] = ifd
+ layer = new_layer
else:
+ l = len(s[1])
s = s[0]
+ new_layer = l / 2
+ if new_layer < layer:
+ for i in range(layer - new_layer):
+ ifds.pop()
+ layer = new_layer
+
# find the raw value in the parenthesis
- p = re.compile("\(.*\)\n")
- value = p.search(s)
+ value = re.search("\(.*\)\n", s)
if value:
value = value.group(0)[1:-2]
else:
- p = re.compile("=.*\n")
- value = p.search(s)
+ value = re.search("=.*\n", s)
value = value.group(0)[2:-1]
# find the ID
@@ -61,6 +80,6 @@ for s in tags:
p = re.compile("[0-9]*?\).*? = ")
name = p.search(s)
name = name.group(0)[4:-3]
- print (' <tag ifd="' + ifd + '" id="'
+ print (' <tag ifd="' + ifds[-1] + '" id="'
+ _id + '" name="' + name +'">' + value + "</tag>")
print "</exif>"