diff options
author | Hung-ying Tyan <tyanh@google.com> | 2012-11-12 22:16:14 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-11-12 22:16:14 -0800 |
commit | 201c6d506889bf617010d1f8dfac6fe09a0d982a (patch) | |
tree | e3342e86f0f6c5467932b2ef996684c77cba5d0e /tests | |
parent | f0d2bbed7be5bcce498eee554a3809a7ce785464 (diff) | |
parent | 0ffdd632e3739db5c0389840d410fa95afd59f88 (diff) | |
download | android_packages_apps_Gallery2-201c6d506889bf617010d1f8dfac6fe09a0d982a.tar.gz android_packages_apps_Gallery2-201c6d506889bf617010d1f8dfac6fe09a0d982a.tar.bz2 android_packages_apps_Gallery2-201c6d506889bf617010d1f8dfac6fe09a0d982a.zip |
Merge "use NO_VALUE when the output of exiftool is invalid" into gb-ub-photos-bryce
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/exiftool_parser/parser.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/exiftool_parser/parser.py b/tests/exiftool_parser/parser.py index 5de54a352..7df23f154 100755 --- a/tests/exiftool_parser/parser.py +++ b/tests/exiftool_parser/parser.py @@ -33,7 +33,7 @@ print "<exif>" # | | | + [xxx directory with xx entries] # p = re.compile( - "(((?:\| )+)[0-9]*\).*? = .*?\n.*?- Tag 0x[0-9a-f]{4})" + "|" + "(((?:\| )+)[0-9]*\)(?:(?:.*? = .*?)|(?:.*? \(SubDirectory\) -->))\n.*?- Tag 0x[0-9a-f]{4})" + "|" + "(((?:\| )*)\+ \[.*? directory with [0-9]+ entries]$)" , re.M) tags = p.findall(text) @@ -68,16 +68,22 @@ for s in tags: _id = _id.group(0) # find the name - name = re.search("[0-9]*?\).*? = ", s) - name = name.group(0)[4:-3] + name = re.search("[0-9]*?\).*?(?:(?: = )|(?: \(SubDirectory\) -->))", s) + name = name.group(0).split()[1] # find the raw value in the parenthesis - value = re.search("\(.*\)\n", s) - if (name != 'Model' and value): - value = value.group(0)[1:-2] + value = re.search("\(SubDirectory\) -->", s) + if value: + value = "NO_VALUE" else: - value = re.search("=.*\n", s) - value = value.group(0)[2:-1] + value = re.search("\(.*\)\n", s) + if (name != 'Model' and value): + value = value.group(0)[1:-2] + else: + value = re.search("=.*\n", s) + value = value.group(0)[2:-1] + if "[snip]" in value: + value = "NO_VALUE" print (' <tag ifd="' + ifds[-1] + '" id="' + _id + '" name="' + name +'">' + value + "</tag>") |