diff --git a/contrib/scripts/process_messages.py b/contrib/scripts/process_messages.py index 313aae1e83..11783c8ce5 100755 --- a/contrib/scripts/process_messages.py +++ b/contrib/scripts/process_messages.py @@ -1,4 +1,7 @@ #!/usr/bin/env python + +from __future__ import print_function + import os import optparse @@ -38,29 +41,29 @@ BASE_DIR = os.path.abspath( def process(command, app_list, language_list): if command == makemessages: - print 'Making messages' + print('Making messages') elif command == compilemessages: - print 'Compiling messages' + print('Compiling messages') elif command == pull_translations: - print 'Pulling translation files' + print('Pulling translation files') elif command == push_translations: - print 'Pushing translation files' + print('Pushing translation files') if command in [compilemessages, makemessages]: for app in app_list: - print 'Processing app: %s...' % app + print('Processing app: %s...' % app) app_path = os.path.join(BASE_DIR, 'apps', app) os.chdir(app_path) for lang in language_list: - print 'Doing language: %s' % lang + print('Doing language: %s' % lang) command(locale=lang) elif command == pull_translations: for lang in language_list: - print 'Doing language: %s' % lang + print('Doing language: %s' % lang) command('-f', '-l', lang) elif command == push_translations: for lang in language_list: - print 'Doing language: %s' % lang + print('Doing language: %s' % lang) command('-s', '-l', lang) diff --git a/contrib/scripts/statistics.py b/contrib/scripts/statistics.py index 0bd9008dda..6c9ade9b85 100755 --- a/contrib/scripts/statistics.py +++ b/contrib/scripts/statistics.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function + import os BASE_PATH = 'mayan/apps' @@ -7,7 +9,7 @@ BASE_PATH = 'mayan/apps' def print_views_summary(module_filename): with open(module_filename) as file_object: - print ' module:', module_filename + print(' module:', module_filename) count_class_based_views = 0 count_function_based_views = 0 for line in file_object: @@ -17,20 +19,20 @@ def print_views_summary(module_filename): if line.startswith('def') and 'request' in line: count_function_based_views += 1 - print ' class based views: {}'.format(count_class_based_views) - print ' function based views: {}'.format(count_function_based_views) + print(' class based views: {}'.format(count_class_based_views)) + print(' function based views: {}'.format(count_function_based_views)) return count_class_based_views, count_function_based_views def print_tests_summary(module_filename): with open(module_filename) as file_object: - print ' module:', module_filename + print(' module:', module_filename) count_tests = 0 for line in file_object: if line.startswith(' def test'): count_tests += 1 - print ' tests: {}'.format(count_tests) + print(' tests: {}'.format(count_tests)) return count_tests @@ -47,10 +49,10 @@ if __name__ == '__main__': for app_name in sorted(os.listdir(BASE_PATH)): if app_name != '__init__.py': count_totals['Apps'] += 1 - print '\n\nApp name: {}'.format(app_name) + print('\n\nApp name: {}'.format(app_name)) app_path = os.path.join(BASE_PATH, app_name) - print '\n Views' + print('\n Views') try: module_filename = os.path.join(app_path, 'views.py') count_class_based_views, count_function_based_views = print_views_summary(module_filename=module_filename) @@ -69,9 +71,9 @@ if __name__ == '__main__': count_totals['Function based views'] += count_function_based_views except OSError: # No views directory, skip app - print ' No views' + print(' No views') - print '\n API Views' + print('\n API Views') try: module_filename = os.path.join(app_path, 'api_views.py') count_class_based_views, count_function_based_views = print_views_summary(module_filename=module_filename) @@ -80,9 +82,9 @@ if __name__ == '__main__': except IOError: # No API views directory, skip app - print ' No API views' + print(' No API views') - print '\n Tests' + print('\n Tests') module_path = os.path.join(app_path, 'tests') try: for module_name in os.listdir(module_path): @@ -94,10 +96,10 @@ if __name__ == '__main__': except OSError: # No tests directory, skip app - print ' No tests' + print(' No tests') - print '-' * 10 + print('-' * 10) - print 'Totals:' + print('Totals:') for key, value in count_totals.items(): - print ' {}: {}'.format(key, value) + print(' {}: {}'.format(key, value)) diff --git a/mayan/apps/common/javascript.py b/mayan/apps/common/javascript.py index c772f3fb38..eb9305835b 100644 --- a/mayan/apps/common/javascript.py +++ b/mayan/apps/common/javascript.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import print_function, unicode_literals import base64 import hashlib @@ -79,7 +79,7 @@ class NPMPackage(object): self._best_version = max_satisfying( self.versions, force_bytes(self.version), loose=True ) - print 'Best version: {}'.format(self._best_version) + print('Best version: {}'.format(self._best_version)) return self._best_version @@ -97,7 +97,7 @@ class NPMPackage(object): return f.tostr() def install(self, include_dependencies=False): - print 'Installing package: {}{}'.format(self.name, self.version) + print('Installing package: {}{}'.format(self.name, self.version)) self._download() self._extract() @@ -186,7 +186,7 @@ class JSDependencyManager(object): for app in app_config_list: for root, dirs, files in os.walk(os.path.join(app.path, 'static')): if 'package.json' in files and not (set(Path(root).parts) & set(['node_modules', 'packages', 'vendors'])): - print 'Installing JavaScript packages for app: {} - {}'.format(app.label, root) + print('Installing JavaScript packages for app: {} - {}'.format(app.label, root)) npm_client = NPMRegistry( module_directory=os.path.join(root, 'node_modules'), package_filename=os.path.join(root, 'package.json') diff --git a/mayan/apps/mirroring/management/commands/mountindex.py b/mayan/apps/mirroring/management/commands/mountindex.py index fa5dd98a23..3d03f7ff41 100644 --- a/mayan/apps/mirroring/management/commands/mountindex.py +++ b/mayan/apps/mirroring/management/commands/mountindex.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +from __future__ import print_function, unicode_literals import datetime from errno import ENOENT @@ -119,7 +119,7 @@ class IndexFS(Operations): try: self.index = Index.objects.get(slug=index_slug) except Index.DoesNotExist: - print 'Unknown index slug: {}.'.format(index_slug) + print('Unknown index slug: {}.'.format(index_slug)) exit(1) def access(self, path, fh=None):