Convert tabs to spaces in Python scripts (PEP-8) part 1.

This commit is contained in:
Benjamin Drung 2010-12-22 01:28:00 +01:00
parent 0a35d3d13d
commit 493597a500
5 changed files with 237 additions and 233 deletions

View File

@ -19,6 +19,8 @@ import optparse
import os
import sys
from ubuntutools.logger import Logger
default_whitelisted_mimetypes = [
"application/vnd.font-fontforge-sfd", # font source: fontforge
"application/x-elc",
@ -81,7 +83,8 @@ default_whitelisted_extensions = [
".xgf", # font source format: Xgridfit
]
def main(whitelisted_mimetypes, whitelisted_extensions, directory, verbose=False):
def main(whitelisted_mimetypes, whitelisted_extensions, directory,
verbose=False):
ms = magic.open(magic.MAGIC_MIME_TYPE)
ms.load()
@ -89,7 +92,8 @@ def main(whitelisted_mimetypes, whitelisted_extensions, directory, verbose=False
for f in files:
mimetype = ms.file(os.path.join(root, f))
if mimetype not in whitelisted_mimetypes:
if not filter(lambda x: f.lower().endswith(x), whitelisted_extensions):
if not filter(lambda x: f.lower().endswith(x),
whitelisted_extensions):
if verbose:
print "%s (%s)" % (os.path.join(root, f), mimetype)
else:
@ -121,10 +125,10 @@ if __name__ == "__main__":
(options, args) = parser.parse_args()
if len(args) != 0:
print >> sys.stderr, "%s: This script does not take any additional parameters." % \
(script_name)
Logger.error("This script does not take any additional parameters.")
sys.exit(1)
whitelisted_extensions = map(lambda x: x.lower(), options.whitelisted_extensions)
whitelisted_extensions = map(lambda x: x.lower(),
options.whitelisted_extensions)
main(options.whitelisted_mimetypes, whitelisted_extensions,
options.directory, options.verbose)