Use Python 3 style print function.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
@@ -38,29 +41,29 @@ BASE_DIR = os.path.abspath(
|
|||||||
|
|
||||||
def process(command, app_list, language_list):
|
def process(command, app_list, language_list):
|
||||||
if command == makemessages:
|
if command == makemessages:
|
||||||
print 'Making messages'
|
print('Making messages')
|
||||||
elif command == compilemessages:
|
elif command == compilemessages:
|
||||||
print 'Compiling messages'
|
print('Compiling messages')
|
||||||
elif command == pull_translations:
|
elif command == pull_translations:
|
||||||
print 'Pulling translation files'
|
print('Pulling translation files')
|
||||||
elif command == push_translations:
|
elif command == push_translations:
|
||||||
print 'Pushing translation files'
|
print('Pushing translation files')
|
||||||
|
|
||||||
if command in [compilemessages, makemessages]:
|
if command in [compilemessages, makemessages]:
|
||||||
for app in app_list:
|
for app in app_list:
|
||||||
print 'Processing app: %s...' % app
|
print('Processing app: %s...' % app)
|
||||||
app_path = os.path.join(BASE_DIR, 'apps', app)
|
app_path = os.path.join(BASE_DIR, 'apps', app)
|
||||||
os.chdir(app_path)
|
os.chdir(app_path)
|
||||||
for lang in language_list:
|
for lang in language_list:
|
||||||
print 'Doing language: %s' % lang
|
print('Doing language: %s' % lang)
|
||||||
command(locale=lang)
|
command(locale=lang)
|
||||||
elif command == pull_translations:
|
elif command == pull_translations:
|
||||||
for lang in language_list:
|
for lang in language_list:
|
||||||
print 'Doing language: %s' % lang
|
print('Doing language: %s' % lang)
|
||||||
command('-f', '-l', lang)
|
command('-f', '-l', lang)
|
||||||
elif command == push_translations:
|
elif command == push_translations:
|
||||||
for lang in language_list:
|
for lang in language_list:
|
||||||
print 'Doing language: %s' % lang
|
print('Doing language: %s' % lang)
|
||||||
command('-s', '-l', lang)
|
command('-s', '-l', lang)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
BASE_PATH = 'mayan/apps'
|
BASE_PATH = 'mayan/apps'
|
||||||
@@ -7,7 +9,7 @@ BASE_PATH = 'mayan/apps'
|
|||||||
|
|
||||||
def print_views_summary(module_filename):
|
def print_views_summary(module_filename):
|
||||||
with open(module_filename) as file_object:
|
with open(module_filename) as file_object:
|
||||||
print ' module:', module_filename
|
print(' module:', module_filename)
|
||||||
count_class_based_views = 0
|
count_class_based_views = 0
|
||||||
count_function_based_views = 0
|
count_function_based_views = 0
|
||||||
for line in file_object:
|
for line in file_object:
|
||||||
@@ -17,20 +19,20 @@ def print_views_summary(module_filename):
|
|||||||
if line.startswith('def') and 'request' in line:
|
if line.startswith('def') and 'request' in line:
|
||||||
count_function_based_views += 1
|
count_function_based_views += 1
|
||||||
|
|
||||||
print ' class based views: {}'.format(count_class_based_views)
|
print(' class based views: {}'.format(count_class_based_views))
|
||||||
print ' function based views: {}'.format(count_function_based_views)
|
print(' function based views: {}'.format(count_function_based_views))
|
||||||
return count_class_based_views, count_function_based_views
|
return count_class_based_views, count_function_based_views
|
||||||
|
|
||||||
|
|
||||||
def print_tests_summary(module_filename):
|
def print_tests_summary(module_filename):
|
||||||
with open(module_filename) as file_object:
|
with open(module_filename) as file_object:
|
||||||
print ' module:', module_filename
|
print(' module:', module_filename)
|
||||||
count_tests = 0
|
count_tests = 0
|
||||||
for line in file_object:
|
for line in file_object:
|
||||||
if line.startswith(' def test'):
|
if line.startswith(' def test'):
|
||||||
count_tests += 1
|
count_tests += 1
|
||||||
|
|
||||||
print ' tests: {}'.format(count_tests)
|
print(' tests: {}'.format(count_tests))
|
||||||
return count_tests
|
return count_tests
|
||||||
|
|
||||||
|
|
||||||
@@ -47,10 +49,10 @@ if __name__ == '__main__':
|
|||||||
for app_name in sorted(os.listdir(BASE_PATH)):
|
for app_name in sorted(os.listdir(BASE_PATH)):
|
||||||
if app_name != '__init__.py':
|
if app_name != '__init__.py':
|
||||||
count_totals['Apps'] += 1
|
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)
|
app_path = os.path.join(BASE_PATH, app_name)
|
||||||
|
|
||||||
print '\n Views'
|
print('\n Views')
|
||||||
try:
|
try:
|
||||||
module_filename = os.path.join(app_path, 'views.py')
|
module_filename = os.path.join(app_path, 'views.py')
|
||||||
count_class_based_views, count_function_based_views = print_views_summary(module_filename=module_filename)
|
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
|
count_totals['Function based views'] += count_function_based_views
|
||||||
except OSError:
|
except OSError:
|
||||||
# No views directory, skip app
|
# No views directory, skip app
|
||||||
print ' No views'
|
print(' No views')
|
||||||
|
|
||||||
print '\n API Views'
|
print('\n API Views')
|
||||||
try:
|
try:
|
||||||
module_filename = os.path.join(app_path, 'api_views.py')
|
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)
|
count_class_based_views, count_function_based_views = print_views_summary(module_filename=module_filename)
|
||||||
@@ -80,9 +82,9 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
# No API views directory, skip app
|
# 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')
|
module_path = os.path.join(app_path, 'tests')
|
||||||
try:
|
try:
|
||||||
for module_name in os.listdir(module_path):
|
for module_name in os.listdir(module_path):
|
||||||
@@ -94,10 +96,10 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
except OSError:
|
except OSError:
|
||||||
# No tests directory, skip app
|
# 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():
|
for key, value in count_totals.items():
|
||||||
print ' {}: {}'.format(key, value)
|
print(' {}: {}'.format(key, value))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -79,7 +79,7 @@ class NPMPackage(object):
|
|||||||
self._best_version = max_satisfying(
|
self._best_version = max_satisfying(
|
||||||
self.versions, force_bytes(self.version), loose=True
|
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
|
return self._best_version
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ class NPMPackage(object):
|
|||||||
return f.tostr()
|
return f.tostr()
|
||||||
|
|
||||||
def install(self, include_dependencies=False):
|
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._download()
|
||||||
self._extract()
|
self._extract()
|
||||||
@@ -186,7 +186,7 @@ class JSDependencyManager(object):
|
|||||||
for app in app_config_list:
|
for app in app_config_list:
|
||||||
for root, dirs, files in os.walk(os.path.join(app.path, 'static')):
|
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'])):
|
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(
|
npm_client = NPMRegistry(
|
||||||
module_directory=os.path.join(root, 'node_modules'),
|
module_directory=os.path.join(root, 'node_modules'),
|
||||||
package_filename=os.path.join(root, 'package.json')
|
package_filename=os.path.join(root, 'package.json')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from errno import ENOENT
|
from errno import ENOENT
|
||||||
@@ -119,7 +119,7 @@ class IndexFS(Operations):
|
|||||||
try:
|
try:
|
||||||
self.index = Index.objects.get(slug=index_slug)
|
self.index = Index.objects.get(slug=index_slug)
|
||||||
except Index.DoesNotExist:
|
except Index.DoesNotExist:
|
||||||
print 'Unknown index slug: {}.'.format(index_slug)
|
print('Unknown index slug: {}.'.format(index_slug))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def access(self, path, fh=None):
|
def access(self, path, fh=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user