more 80 chars and suggested simplification

This commit is contained in:
Samuel Keeley
2015-01-22 14:17:57 -08:00
parent a7ceae35d4
commit 94cf5870bc
+9 -7
View File
@@ -107,7 +107,8 @@ def makecatalogs(repopath, options):
iconspath = unicode(iconspath)
if not os.path.exists(iconspath):
print_err_utf8("icons path %s doesn't exist, skipping hashing!" % iconspath)
print_err_utf8("icons path %s doesn't exist, skipping hashing!"
% iconspath)
iconhashing=False
# exit(-1) don't exit so we don't break when no icons dir
else:
@@ -128,19 +129,21 @@ def makecatalogs(repopath, options):
filepath = os.path.join(dirpath, filename)
iconpath = filepath.rsplit(iconspath+'/',1)[1]
iconpath = filepath.rsplit(iconspath+'/', 1)[1]
# Try to read the icon file
try:
print_utf8("Hashing %s..." % (iconpath))
iconhash = hashlib.sha256(open(filepath, 'rb').read()).hexdigest()
icons.update({iconpath:iconhash})
iconhash = (hashlib.sha256(open(filepath, 'rb').
read()).hexdigest())
icons[iconpath] = iconhash
except IOError, inst:
errors.append("IO error for %s: %s" % (filepath, inst))
exitCode = -1
continue
except Exception, inst:
errors.append("Unexpected error for %s: %s" % (filepath, inst))
errors.append("Unexpected error for %s: %s"
% (filepath, inst))
exitCode = -1
continue
@@ -199,7 +202,6 @@ def makecatalogs(repopath, options):
if key.startswith('_'):
del(pkginfo[key])
if iconhashing:
name = pkginfo.get('name')
@@ -218,7 +220,7 @@ def makecatalogs(repopath, options):
iconhash = icons.get(name+'.png')
if iconhash is not None:
pkginfo.update({'icon_hash':iconhash})
pkginfo['icon_hash'] = iconhash
iconhash = None
#simple sanity checking