mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-10-31 05:54:03 +00:00 
			
		
		
		
	Convert tabs to spaces in Python scripts (PEP-8) part 1.
This commit is contained in:
		
							parent
							
								
									0a35d3d13d
								
							
						
					
					
						commit
						493597a500
					
				
							
								
								
									
										182
									
								
								404main
									
									
									
									
									
								
							
							
						
						
									
										182
									
								
								404main
									
									
									
									
									
								
							| @ -31,131 +31,131 @@ import apt_pkg | |||||||
| import apt | import apt | ||||||
| 
 | 
 | ||||||
| def process_deps(cache, deps): | def process_deps(cache, deps): | ||||||
| 	"""Takes a list of (build) dependencies and processes it.""" |     """Takes a list of (build) dependencies and processes it.""" | ||||||
| 
 | 
 | ||||||
| 	for basedep in [d.or_dependencies[0] for d in deps]: |     for basedep in [d.or_dependencies[0] for d in deps]: | ||||||
| 		if not packages.has_key(basedep.name) and basedep.name != '': |         if not packages.has_key(basedep.name) and basedep.name != '': | ||||||
| 			# Check the (build) dependencies recursively |             # Check the (build) dependencies recursively | ||||||
| 			find_main(cache, basedep.name) |             find_main(cache, basedep.name) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_package_version(cache, distro, pack): | def get_package_version(cache, distro, pack): | ||||||
| 	if pack not in cache: |     if pack not in cache: | ||||||
| 		return None |         return None | ||||||
| 	for version in (cache[pack].candidate, cache[pack].installed): |     for version in (cache[pack].candidate, cache[pack].installed): | ||||||
| 		if not version: |         if not version: | ||||||
| 			continue |             continue | ||||||
| 		for origin in version.origins: |         for origin in version.origins: | ||||||
| 			if origin.archive == distro: |             if origin.archive == distro: | ||||||
| 				return version |                 return version | ||||||
| 	return None |     return None | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Cache::CompTypeDeb isn't exposed via python-apt | # Cache::CompTypeDeb isn't exposed via python-apt | ||||||
| def comp_type_deb(op): | def comp_type_deb(op): | ||||||
| 	ops = ("", "<=", ">=", "<<", ">>", "=", "!=") |     ops = ("", "<=", ">=", "<<", ">>", "=", "!=") | ||||||
| 	if (op & 15) < 7: |     if (op & 15) < 7: | ||||||
| 		return ops[op & 15] |         return ops[op & 15] | ||||||
| 	return "" |     return "" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def find_main(cache, pack): | def find_main(cache, pack): | ||||||
| 	"""Searches the dependencies and build dependencies of a package recursively |     """Searches the dependencies and build dependencies of a package recursively | ||||||
| 	to determine if they are all in the 'main' component or not.""" |     to determine if they are all in the 'main' component or not.""" | ||||||
| 
 | 
 | ||||||
| 	global packages |     global packages | ||||||
| 
 | 
 | ||||||
| 	if pack in packages: |     if pack in packages: | ||||||
| 		return |         return | ||||||
| 
 | 
 | ||||||
| 	# Retrieve information about the package |     # Retrieve information about the package | ||||||
| 	version = get_package_version(cache, distro, pack) |     version = get_package_version(cache, distro, pack) | ||||||
| 
 | 
 | ||||||
| 	if not version: |     if not version: | ||||||
| 		packages[pack] = False |         packages[pack] = False | ||||||
| 		return |         return | ||||||
| 	elif [origin for origin in version.origins if origin.component == 'main']: |     elif [origin for origin in version.origins if origin.component == 'main']: | ||||||
| 		packages[pack] = True |         packages[pack] = True | ||||||
| 		return |         return | ||||||
| 	else: |     else: | ||||||
| 		if not packages.has_key(pack): |         if not packages.has_key(pack): | ||||||
| 			packages[pack] = False |             packages[pack] = False | ||||||
| 
 | 
 | ||||||
| 		# Retrieve package dependencies |         # Retrieve package dependencies | ||||||
| 		process_deps(cache, version.dependencies) |         process_deps(cache, version.dependencies) | ||||||
| 
 | 
 | ||||||
| 		# Retrieve package build dependencies. There's no handy |         # Retrieve package build dependencies. There's no handy | ||||||
| 		# attribute on version for this, so unfortunately we have to |         # attribute on version for this, so unfortunately we have to | ||||||
| 		# do a lot of messing about with apt. |         # do a lot of messing about with apt. | ||||||
| 		deps = [] |         deps = [] | ||||||
| 		src_records = apt_pkg.SourceRecords() |         src_records = apt_pkg.SourceRecords() | ||||||
| 		got_src = False |         got_src = False | ||||||
| 		while src_records.lookup(version.source_name): |         while src_records.lookup(version.source_name): | ||||||
| 			if pack in src_records.binaries: |             if pack in src_records.binaries: | ||||||
| 				got_src = True |                 got_src = True | ||||||
| 				break |                 break | ||||||
| 		if got_src: |         if got_src: | ||||||
| 			for deptype, all_deps in src_records.build_depends.iteritems(): |             for deptype, all_deps in src_records.build_depends.iteritems(): | ||||||
| 				for or_deps in all_deps: |                 for or_deps in all_deps: | ||||||
| 					base_deps = [] |                     base_deps = [] | ||||||
| 					for (name, ver, op) in or_deps: |                     for (name, ver, op) in or_deps: | ||||||
| 						base_deps.append(apt.package.BaseDependency(name, op, ver, False)) |                         base_deps.append(apt.package.BaseDependency(name, op, ver, False)) | ||||||
| 					deps.append(apt.package.Dependency(base_deps)) |                     deps.append(apt.package.Dependency(base_deps)) | ||||||
| 
 | 
 | ||||||
| 		process_deps(cache, deps) |         process_deps(cache, deps) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
| 
 | 
 | ||||||
| 	global packages, distro |     global packages, distro | ||||||
| 
 | 
 | ||||||
| 	# Check if the amount of arguments is correct |     # Check if the amount of arguments is correct | ||||||
| 	if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] in ('help', '-h', '--help'): |     if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] in ('help', '-h', '--help'): | ||||||
| 		print 'Usage: %s <package name> [<distribution>]' % sys.argv[0] |         print 'Usage: %s <package name> [<distribution>]' % sys.argv[0] | ||||||
| 		sys.exit(1) |         sys.exit(1) | ||||||
| 
 | 
 | ||||||
|         cache = apt.cache.Cache() |         cache = apt.cache.Cache() | ||||||
| 
 | 
 | ||||||
| 	if len(sys.argv) == 3 and sys.argv[2]: |     if len(sys.argv) == 3 and sys.argv[2]: | ||||||
| 		distro = sys.argv[2] |         distro = sys.argv[2] | ||||||
| 		if not get_package_version(cache, distro, 'bash'): |         if not get_package_version(cache, distro, 'bash'): | ||||||
| 			print '«%s» is not a valid distribution.' % distro |             print '«%s» is not a valid distribution.' % distro | ||||||
| 			print 'Remember that for 404main to work with a certain distribution it must be in your /etc/apt/sources.list file.' |             print 'Remember that for 404main to work with a certain distribution it must be in your /etc/apt/sources.list file.' | ||||||
| 			sys.exit(1) |             sys.exit(1) | ||||||
| 	else: |     else: | ||||||
| 		distro = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).stdout.read().strip('\n') |         distro = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).stdout.read().strip('\n') | ||||||
| 
 | 
 | ||||||
| 	if not get_package_version(cache, distro, sys.argv[1]): |     if not get_package_version(cache, distro, sys.argv[1]): | ||||||
| 		print 'Can\'t find package «%s» in distribution «%s».' % (sys.argv[1], distro) |         print 'Can\'t find package «%s» in distribution «%s».' % (sys.argv[1], distro) | ||||||
| 		sys.exit(1) |         sys.exit(1) | ||||||
| 
 | 
 | ||||||
| 	print 'Checking package «%s» in distribution «%s»...' % (sys.argv[1], distro) |     print 'Checking package «%s» in distribution «%s»...' % (sys.argv[1], distro) | ||||||
| 
 | 
 | ||||||
| 	find_main(cache, sys.argv[1]) |     find_main(cache, sys.argv[1]) | ||||||
| 
 | 
 | ||||||
| 	# True if everything checked until the point is in main |     # True if everything checked until the point is in main | ||||||
| 	all_in_main = True |     all_in_main = True | ||||||
| 
 | 
 | ||||||
| 	for package in packages: |     for package in packages: | ||||||
| 		if not packages[package]: |         if not packages[package]: | ||||||
| 			if all_in_main: |             if all_in_main: | ||||||
| 				print 'The following packages aren\'t in main:' |                 print 'The following packages aren\'t in main:' | ||||||
| 				all_in_main = False |                 all_in_main = False | ||||||
| 			print '  ', package |             print '  ', package | ||||||
| 
 | 
 | ||||||
| 	if all_in_main: |     if all_in_main: | ||||||
| 		print 'Package «%s» and all its dependencies and build dependencies are in main.' % sys.argv[1] |         print 'Package «%s» and all its dependencies and build dependencies are in main.' % sys.argv[1] | ||||||
| 
 | 
 | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
| 
 | 
 | ||||||
| 	# Global variable to hold the status of all packages |     # Global variable to hold the status of all packages | ||||||
| 	packages = {} |     packages = {} | ||||||
| 
 | 
 | ||||||
| 	# Global variable to hold the target distribution |     # Global variable to hold the target distribution | ||||||
| 	distro = '' |     distro = '' | ||||||
| 
 | 
 | ||||||
| 	try: |     try: | ||||||
| 		main() |         main() | ||||||
| 	except KeyboardInterrupt: |     except KeyboardInterrupt: | ||||||
| 		print 'Aborted.' |         print 'Aborted.' | ||||||
| 		sys.exit(1) |         sys.exit(1) | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								dgetlp
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								dgetlp
									
									
									
									
									
								
							| @ -45,7 +45,7 @@ If you specify the -d option then it won't do anything, except download the | |||||||
| .dsc file, but just print the commands it would run otherwise. | .dsc file, but just print the commands it would run otherwise. | ||||||
| 
 | 
 | ||||||
| Example: | Example: | ||||||
| 	%prog http://launchpadlibrarian.net/10348157/coreutils_5.97-5.4ubuntu1.dsc |     %prog http://launchpadlibrarian.net/10348157/coreutils_5.97-5.4ubuntu1.dsc | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| unpack_cmd = "dpkg-source -x " | unpack_cmd = "dpkg-source -x " | ||||||
|  | |||||||
| @ -26,22 +26,22 @@ import re, os, sys | |||||||
| from tempfile import mkstemp | from tempfile import mkstemp | ||||||
| 
 | 
 | ||||||
| try: | try: | ||||||
| 	from debian.changelog import Changelog |     from debian.changelog import Changelog | ||||||
| except ImportError: | except ImportError: | ||||||
| 	print 'This utility requires modules from the «python-debian» package, which isn\'t currently installed.' |     print 'This utility requires modules from the «python-debian» package, which isn\'t currently installed.' | ||||||
| 	sys.exit(1) |     sys.exit(1) | ||||||
| 
 | 
 | ||||||
| if not os.path.exists('/usr/bin/reportbug'): | if not os.path.exists('/usr/bin/reportbug'): | ||||||
| 	print 'This utility requires the «reportbug» package, which isn\'t currently installed.' |     print 'This utility requires the «reportbug» package, which isn\'t currently installed.' | ||||||
| 	sys.exit(1) |     sys.exit(1) | ||||||
| 
 | 
 | ||||||
| def get_most_recent_debian_version(changelog): | def get_most_recent_debian_version(changelog): | ||||||
| 	for v in changelog.get_versions(): |     for v in changelog.get_versions(): | ||||||
| 		if not re.search('(ubuntu|build)', v.full_version): |         if not re.search('(ubuntu|build)', v.full_version): | ||||||
| 			return v.full_version |             return v.full_version | ||||||
| 
 | 
 | ||||||
| def get_bug_body(changelog): | def get_bug_body(changelog): | ||||||
| 	return '''In Ubuntu, the attached patch was applied to achieve the following: |     return '''In Ubuntu, the attached patch was applied to achieve the following: | ||||||
| 
 | 
 | ||||||
| ## ---------------- REPLACE THIS WITH ACTUAL INFORMATION --------------------- | ## ---------------- REPLACE THIS WITH ACTUAL INFORMATION --------------------- | ||||||
| ## Please add all necessary information about why the change needed to go in | ## Please add all necessary information about why the change needed to go in | ||||||
| @ -56,56 +56,56 @@ Thanks for considering the patch. | |||||||
| ''' % ("\n".join([a for a in changelog._blocks[0].changes()])) | ''' % ("\n".join([a for a in changelog._blocks[0].changes()])) | ||||||
| 
 | 
 | ||||||
| def gen_debdiff(changelog): | def gen_debdiff(changelog): | ||||||
| 	pkg = changelog.package |     pkg = changelog.package | ||||||
| 
 | 
 | ||||||
| 	oldver = changelog._blocks[1].version |     oldver = changelog._blocks[1].version | ||||||
| 	newver = changelog._blocks[0].version |     newver = changelog._blocks[0].version | ||||||
| 
 | 
 | ||||||
| 	(fd, debdiff) = mkstemp() |     (fd, debdiff) = mkstemp() | ||||||
| 	os.close(fd) |     os.close(fd) | ||||||
| 
 | 
 | ||||||
| 	if os.system('bzr diff -r tag:%s > /dev/null 2>&1' % oldver) == 256: |     if os.system('bzr diff -r tag:%s > /dev/null 2>&1' % oldver) == 256: | ||||||
| 		print "Extracting bzr diff between %s and %s" % (oldver, newver) |         print "Extracting bzr diff between %s and %s" % (oldver, newver) | ||||||
| 		cmd = 'bzr diff -r tag:%s | filterdiff -x "*changelog*" > %s' % (oldver, debdiff) |         cmd = 'bzr diff -r tag:%s | filterdiff -x "*changelog*" > %s' % (oldver, debdiff) | ||||||
| 		run_cmd(cmd) |         run_cmd(cmd) | ||||||
| 	else: |     else: | ||||||
| 		if oldver.epoch is not None: |         if oldver.epoch is not None: | ||||||
| 			oldver = str(oldver)[str(oldver).index(":")+1:] |             oldver = str(oldver)[str(oldver).index(":")+1:] | ||||||
| 		if newver.epoch is not None: |         if newver.epoch is not None: | ||||||
| 			newver = str(newver)[str(newver).index(":")+1:] |             newver = str(newver)[str(newver).index(":")+1:] | ||||||
| 
 | 
 | ||||||
| 		olddsc = '../%s_%s.dsc' % (pkg, oldver) |         olddsc = '../%s_%s.dsc' % (pkg, oldver) | ||||||
| 		newdsc = '../%s_%s.dsc' % (pkg, newver) |         newdsc = '../%s_%s.dsc' % (pkg, newver) | ||||||
| 
 | 
 | ||||||
| 		check_file(olddsc) |         check_file(olddsc) | ||||||
| 		check_file(newdsc) |         check_file(newdsc) | ||||||
| 
 | 
 | ||||||
| 		print "Generating debdiff between %s and %s" % (oldver, newver) |         print "Generating debdiff between %s and %s" % (oldver, newver) | ||||||
| 		cmd = 'debdiff %s %s | filterdiff -x "*changelog*" > %s' % (olddsc, newdsc, debdiff) |         cmd = 'debdiff %s %s | filterdiff -x "*changelog*" > %s' % (olddsc, newdsc, debdiff) | ||||||
| 		run_cmd(cmd) |         run_cmd(cmd) | ||||||
| 
 | 
 | ||||||
| 	return debdiff |     return debdiff | ||||||
| 
 | 
 | ||||||
| def check_file(fname, critical = True): | def check_file(fname, critical = True): | ||||||
| 	if os.path.exists(fname): |     if os.path.exists(fname): | ||||||
| 		return fname |         return fname | ||||||
| 	else: |     else: | ||||||
| 		if not critical: return False |         if not critical: return False | ||||||
| 		print "Couldn't find «%s».\n" % fname |         print "Couldn't find «%s».\n" % fname | ||||||
| 		sys.exit(1) |         sys.exit(1) | ||||||
| 
 | 
 | ||||||
| def edit_debdiff(debdiff): | def edit_debdiff(debdiff): | ||||||
| 	cmd = 'sensible-editor %s' % (debdiff) |     cmd = 'sensible-editor %s' % (debdiff) | ||||||
| 	run_cmd(cmd) |     run_cmd(cmd) | ||||||
| 
 | 
 | ||||||
| def submit_bugreport(body, debdiff, changelog): | def submit_bugreport(body, debdiff, changelog): | ||||||
| 	cmd = 'reportbug -P "User: ubuntu-devel@lists.ubuntu.com" -P "Usertags: origin-ubuntu natty ubuntu-patch" -T patch -A %s -B debian -i %s -V %s %s' % (debdiff, body, deb_version, changelog.package) |     cmd = 'reportbug -P "User: ubuntu-devel@lists.ubuntu.com" -P "Usertags: origin-ubuntu natty ubuntu-patch" -T patch -A %s -B debian -i %s -V %s %s' % (debdiff, body, deb_version, changelog.package) | ||||||
| 	run_cmd(cmd) |     run_cmd(cmd) | ||||||
| 
 | 
 | ||||||
| def run_cmd(cmd): | def run_cmd(cmd): | ||||||
| 	if os.getenv('DEBUG'): |     if os.getenv('DEBUG'): | ||||||
| 		print "%s\n" % cmd |         print "%s\n" % cmd | ||||||
| 	os.system(cmd) |     os.system(cmd) | ||||||
| 
 | 
 | ||||||
| changelog_file = check_file('debian/changelog', critical = False) or check_file('../debian/changelog') | changelog_file = check_file('debian/changelog', critical = False) or check_file('../debian/changelog') | ||||||
| changelog = Changelog(file(changelog_file).read()) | changelog = Changelog(file(changelog_file).read()) | ||||||
|  | |||||||
| @ -19,112 +19,116 @@ 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", | ||||||
| 	"application/x-empty", |     "application/x-empty", | ||||||
| 	"application/x-font-otf",             # font object and source |     "application/x-font-otf",             # font object and source | ||||||
| 	"application/x-font-ttf",             # font object and source |     "application/x-font-ttf",             # font object and source | ||||||
| 	"application/x-font-woff",            # font object and source |     "application/x-font-woff",            # font object and source | ||||||
| 	"application/x-symlink", |     "application/x-symlink", | ||||||
| 	"application/xml", |     "application/xml", | ||||||
| 	"audio/x-wav", |     "audio/x-wav", | ||||||
| 	"font/otf",                           # font object and source |     "font/otf",                           # font object and source | ||||||
| 	"font/ttf",                           # font object and source |     "font/ttf",                           # font object and source | ||||||
| 	"image/gif", |     "image/gif", | ||||||
| 	"image/jpeg", |     "image/jpeg", | ||||||
| 	"image/png", |     "image/png", | ||||||
| 	"image/svg+xml", |     "image/svg+xml", | ||||||
| 	"image/x-icns", |     "image/x-icns", | ||||||
| 	"image/x-ico", |     "image/x-ico", | ||||||
| 	"image/x-ms-bmp", |     "image/x-ms-bmp", | ||||||
| 	"image/x-portable-pixmap", |     "image/x-portable-pixmap", | ||||||
| 	"message/rfc822", |     "message/rfc822", | ||||||
| 	"text/html", |     "text/html", | ||||||
| 	"text/plain", |     "text/plain", | ||||||
| 	"text/rtf", |     "text/rtf", | ||||||
| 	"text/troff", |     "text/troff", | ||||||
| 	"text/x-asm", |     "text/x-asm", | ||||||
| 	"text/x-c", |     "text/x-c", | ||||||
| 	"text/x-c++", |     "text/x-c++", | ||||||
| 	"text/x-diff", |     "text/x-diff", | ||||||
| 	"text/x-fortran", |     "text/x-fortran", | ||||||
| 	"text/x-java", |     "text/x-java", | ||||||
| 	"text/x-lisp", |     "text/x-lisp", | ||||||
| 	"text/x-m4", |     "text/x-m4", | ||||||
| 	"text/x-makefile", |     "text/x-makefile", | ||||||
| 	"text/x-msdos-batch", |     "text/x-msdos-batch", | ||||||
| 	"text/x-pascal", |     "text/x-pascal", | ||||||
| 	"text/x-perl", |     "text/x-perl", | ||||||
| 	"text/x-php", |     "text/x-php", | ||||||
| 	"text/x-po", |     "text/x-po", | ||||||
| 	"text/x-shellscript", |     "text/x-shellscript", | ||||||
| 	"text/x-tex", |     "text/x-tex", | ||||||
| 	"text/x-texinfo", |     "text/x-texinfo", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| default_whitelisted_extensions = [ | default_whitelisted_extensions = [ | ||||||
| 	".fea",   # font source format: afdko (Adobe font development kit for OpenType) |     ".fea",   # font source format: afdko (Adobe font development kit for OpenType) | ||||||
| 	".fog",   # font source format: Fontographer |     ".fog",   # font source format: Fontographer | ||||||
| 	".g2n",   # font source format: fontforge |     ".g2n",   # font source format: fontforge | ||||||
| 	".gdh",   # font source format: Graphite (headers) |     ".gdh",   # font source format: Graphite (headers) | ||||||
| 	".gdl",   # font source format: Graphite |     ".gdl",   # font source format: Graphite | ||||||
| 	".glyph", # font source format: cross-toolkit UFO |     ".glyph", # font source format: cross-toolkit UFO | ||||||
| 	".plate", # font source format: Spiro |     ".plate", # font source format: Spiro | ||||||
| 	".rsa", |     ".rsa", | ||||||
| 	".sfd",   # font source format: fontforge |     ".sfd",   # font source format: fontforge | ||||||
| 	".sfdir", # font source format: fontforge |     ".sfdir", # font source format: fontforge | ||||||
| 	".ttx",   # font source format: fonttools |     ".ttx",   # font source format: fonttools | ||||||
| 	".ufo",   # font source format: cross-toolkit UFO |     ".ufo",   # font source format: cross-toolkit UFO | ||||||
| 	".vfb"    # font source format: FontLab |     ".vfb"    # font source format: FontLab | ||||||
| 	".vtp",   # font source format: OpenType (VOLT) |     ".vtp",   # font source format: OpenType (VOLT) | ||||||
| 	".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, | ||||||
| 	ms = magic.open(magic.MAGIC_MIME_TYPE) |          verbose=False): | ||||||
| 	ms.load() |     ms = magic.open(magic.MAGIC_MIME_TYPE) | ||||||
|  |     ms.load() | ||||||
| 
 | 
 | ||||||
| 	for root, dirs, files in os.walk(directory): |     for root, dirs, files in os.walk(directory): | ||||||
| 		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), | ||||||
| 					if verbose: |                               whitelisted_extensions): | ||||||
| 						print "%s (%s)" % (os.path.join(root, f), mimetype) |                     if verbose: | ||||||
| 					else: |                         print "%s (%s)" % (os.path.join(root, f), mimetype) | ||||||
| 						print os.path.join(root, f) |                     else: | ||||||
| 		for d in (".bzr", "CVS", ".git", ".svn"): |                         print os.path.join(root, f) | ||||||
| 			if d in dirs: |         for d in (".bzr", "CVS", ".git", ".svn"): | ||||||
| 				dirs.remove(d) |             if d in dirs: | ||||||
|  |                 dirs.remove(d) | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
| 	script_name = os.path.basename(sys.argv[0]) |     script_name = os.path.basename(sys.argv[0]) | ||||||
| 	usage = "%s [options]" % (script_name) |     usage = "%s [options]" % (script_name) | ||||||
| 	epilog = "See %s(1) for more info." % (script_name) |     epilog = "See %s(1) for more info." % (script_name) | ||||||
| 	parser = optparse.OptionParser(usage=usage, epilog=epilog) |     parser = optparse.OptionParser(usage=usage, epilog=epilog) | ||||||
| 
 | 
 | ||||||
| 	parser.add_option("-v", "--verbose", help="print more information", |     parser.add_option("-v", "--verbose", help="print more information", | ||||||
| 			dest="verbose", action="store_true", default=False) |                       dest="verbose", action="store_true", default=False) | ||||||
| 	parser.add_option("-d", "--directory", |     parser.add_option("-d", "--directory", | ||||||
| 			help="check the files in the specified directory", |                       help="check the files in the specified directory", | ||||||
| 			dest="directory", default=".") |                       dest="directory", default=".") | ||||||
| 	parser.add_option("-m", "--mimetype", metavar="MIMETYPE", |     parser.add_option("-m", "--mimetype", metavar="MIMETYPE", | ||||||
| 			help="Add MIMETYPE to list of whitelisted mimetypes.", |                       help="Add MIMETYPE to list of whitelisted mimetypes.", | ||||||
| 			dest="whitelisted_mimetypes", action="append", |                       dest="whitelisted_mimetypes", action="append", | ||||||
| 			default=default_whitelisted_mimetypes) |                       default=default_whitelisted_mimetypes) | ||||||
| 	parser.add_option("-e", "--extension", metavar="EXTENSION", |     parser.add_option("-e", "--extension", metavar="EXTENSION", | ||||||
| 			help="Add EXTENSION to list of whitelisted extensions.", |                       help="Add EXTENSION to list of whitelisted extensions.", | ||||||
| 			dest="whitelisted_extensions", action="append", |                       dest="whitelisted_extensions", action="append", | ||||||
| 			default=default_whitelisted_extensions) |                       default=default_whitelisted_extensions) | ||||||
| 
 | 
 | ||||||
| 	(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(), | ||||||
| 	main(options.whitelisted_mimetypes, whitelisted_extensions, |                                  options.whitelisted_extensions) | ||||||
| 			options.directory, options.verbose) |     main(options.whitelisted_mimetypes, whitelisted_extensions, | ||||||
|  |          options.directory, options.verbose) | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ usage = "%s [options]" % (script_name) | |||||||
| epilog = "See %s(1) for more info." % (script_name) | epilog = "See %s(1) for more info." % (script_name) | ||||||
| parser = optparse.OptionParser(usage=usage, epilog=epilog) | parser = optparse.OptionParser(usage=usage, epilog=epilog) | ||||||
| parser.add_option("-q", "--quiet", help="print no informational messages", | parser.add_option("-q", "--quiet", help="print no informational messages", | ||||||
| 		dest="quiet", action="store_true", default=False) |                   dest="quiet", action="store_true", default=False) | ||||||
| (options, args) = parser.parse_args() | (options, args) = parser.parse_args() | ||||||
| 
 | 
 | ||||||
| sys.exit(ubuntutools.update_maintainer.update_maintainer(not options.quiet)) | sys.exit(ubuntutools.update_maintainer.update_maintainer(not options.quiet)) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user