summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2012-11-12 22:15:28 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-11-12 22:15:29 -0800
commita230880c0313d7e85922e72ec1640d7b34490d3f (patch)
tree36b5bf719947195e0d0472b3edf103eb6f1f6d94 /tests
parent4825985f68eb05cfdddfd5e67f75e56829226e59 (diff)
parent097b6014918a2ebf6f92241ac0d08f760883d90b (diff)
downloadandroid_packages_apps_Gallery2-a230880c0313d7e85922e72ec1640d7b34490d3f.tar.gz
android_packages_apps_Gallery2-a230880c0313d7e85922e72ec1640d7b34490d3f.tar.bz2
android_packages_apps_Gallery2-a230880c0313d7e85922e72ec1640d7b34490d3f.zip
Merge "Parse the layer of exiftool output" into gb-ub-photos-bryce
Diffstat (limited to 'tests')
-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>"