mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-10-31 14:04:03 +00:00 
			
		
		
		
	Convert tabs to spaces in Python scripts (PEP-8) part 1.
This commit is contained in:
		
							parent
							
								
									0a35d3d13d
								
							
						
					
					
						commit
						493597a500
					
				| @ -19,6 +19,8 @@ import optparse | |||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
| 
 | 
 | ||||||
|  | from ubuntutools.logger import Logger | ||||||
|  | 
 | ||||||
| default_whitelisted_mimetypes = [ | default_whitelisted_mimetypes = [ | ||||||
|     "application/vnd.font-fontforge-sfd", # font source: fontforge |     "application/vnd.font-fontforge-sfd", # font source: fontforge | ||||||
|     "application/x-elc", |     "application/x-elc", | ||||||
| @ -81,7 +83,8 @@ default_whitelisted_extensions = [ | |||||||
|     ".xgf",   # font source format: Xgridfit |     ".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 = magic.open(magic.MAGIC_MIME_TYPE) | ||||||
|     ms.load() |     ms.load() | ||||||
| 
 | 
 | ||||||
| @ -89,7 +92,8 @@ def main(whitelisted_mimetypes, whitelisted_extensions, directory, verbose=False | |||||||
|         for f in files: |         for f in files: | ||||||
|             mimetype = ms.file(os.path.join(root, f)) |             mimetype = ms.file(os.path.join(root, f)) | ||||||
|             if mimetype not in whitelisted_mimetypes: |             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: |                     if verbose: | ||||||
|                         print "%s (%s)" % (os.path.join(root, f), mimetype) |                         print "%s (%s)" % (os.path.join(root, f), mimetype) | ||||||
|                     else: |                     else: | ||||||
| @ -121,10 +125,10 @@ if __name__ == "__main__": | |||||||
|     (options, args) = parser.parse_args() |     (options, args) = parser.parse_args() | ||||||
| 
 | 
 | ||||||
|     if len(args) != 0: |     if len(args) != 0: | ||||||
| 		print >> sys.stderr, "%s: This script does not take any additional parameters." % \ |         Logger.error("This script does not take any additional parameters.") | ||||||
| 				(script_name) |  | ||||||
|         sys.exit(1) |         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, |     main(options.whitelisted_mimetypes, whitelisted_extensions, | ||||||
|          options.directory, options.verbose) |          options.directory, options.verbose) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user