From 5be98ed60daac27a7d99fe89b9ed4709bfb218aa Mon Sep 17 00:00:00 2001 From: Earl Ou Date: Thu, 18 Oct 2012 16:38:32 +0800 Subject: use NO_VALUE when the output of exiftool is invalid Change-Id: I85c0054d70ff1639e643a30658ca59f1803f7d13 --- tests/exiftool_parser/parser.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'tests') 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 "" # | | | + [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 (' ' + value + "") -- cgit v1.2.3