cc-4105: code formatting improvements

This commit is contained in:
Rudi Grinberg 2012-08-14 17:17:18 -04:00
parent d51687ed6a
commit 96b57d688a
1 changed files with 3 additions and 6 deletions

View File

@ -182,8 +182,7 @@ def remove_whitespace(dictionary):
if hasattr(v,'strip'): if hasattr(v,'strip'):
stripped = v.strip() stripped = v.strip()
# ghetto and maybe unnecessary # ghetto and maybe unnecessary
if stripped == '' or stripped == u'': if stripped == '' or stripped == u'': bad_keys.append(k)
bad_keys.append(k)
for bad_key in bad_keys: del nd[bad_key] for bad_key in bad_keys: del nd[bad_key]
return nd return nd
@ -200,8 +199,7 @@ def parse_int(s):
""" """
if s.isdigit(): return s if s.isdigit(): return s
else: else:
try: try : return reduce(op.add, takewhile(lambda x: x.isdigit(), s))
return reduce(op.add, takewhile(lambda x: x.isdigit(), s))
except: return 0 except: return 0
def normalized_metadata(md, original_path): def normalized_metadata(md, original_path):
@ -212,8 +210,7 @@ def normalized_metadata(md, original_path):
""" """
new_md = copy.deepcopy(md) new_md = copy.deepcopy(md)
# replace all slashes with dashes # replace all slashes with dashes
for k,v in new_md.iteritems(): for k,v in new_md.iteritems(): new_md[k] = unicode(v).replace('/','-')
new_md[k] = unicode(v).replace('/','-')
# Specific rules that are applied in a per attribute basis # Specific rules that are applied in a per attribute basis
format_rules = { format_rules = {
# It's very likely that the following isn't strictly necessary. But the # It's very likely that the following isn't strictly necessary. But the