use print everywhere
This commit is contained in:
parent
c54dcd07d9
commit
7c3f9d7cb7
5 changed files with 13 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
|||
import sys
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from ...packageio import write_packages
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import sys
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import transaction
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import CommandError
|
||||
|
@ -58,11 +59,3 @@ def _read_folder(package, cls, path, check_sister_file=False):
|
|||
|
||||
objects.append(cls.fromfile(json.load(open(full_filename)), package, name))
|
||||
return objects
|
||||
|
||||
|
||||
def _fromfile_validate(cls, data, name):
|
||||
obj = cls.fromfile(json.loads(data), name=name)
|
||||
formatted_data = json_encode(obj.tofile())
|
||||
if data != formatted_data:
|
||||
raise CommandError('%s.json is not correctly formatted, its contents are:\n---\n' +
|
||||
data+'\n---\nbut they should be\n---\n'+formatted_data+'\n---')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
import sys
|
||||
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ from .utils import json_encode
|
|||
|
||||
def write_packages(prettify=False, check_only=False):
|
||||
if not check_only:
|
||||
sys.out.write('Writing Map Packages…')
|
||||
print('Writing Map Packages…')
|
||||
|
||||
count = 0
|
||||
for package in Package.objects.all():
|
||||
if not check_only:
|
||||
sys.out.write('\n'+package.name)
|
||||
print('\n'+package.name)
|
||||
count += write_package(package, prettify, check_only)
|
||||
return count
|
||||
|
||||
|
@ -52,7 +52,7 @@ def _write_folder(objects, path, prettify=False, check_only=False, check_sister_
|
|||
|
||||
count += 1
|
||||
if check_only:
|
||||
sys.stdout.writelines(difflib.unified_diff(
|
||||
printlines(difflib.unified_diff(
|
||||
list(open(full_filename)),
|
||||
[],
|
||||
fromfiledate=timezone.make_aware(
|
||||
|
@ -82,20 +82,20 @@ def _write_object(obj, path, filename, prettify=False, check_only=False):
|
|||
old_data = json.loads(old_data_encoded, parse_int=float)
|
||||
if old_data != json.loads(new_data_encoded, parse_int=float):
|
||||
if not check_only:
|
||||
sys.stdout.write('- Updated: '+os.path.join(path, filename))
|
||||
print('- Updated: '+os.path.join(path, filename))
|
||||
elif old_data_encoded != new_data_encoded:
|
||||
if not prettify:
|
||||
return 0
|
||||
if not check_only:
|
||||
sys.stdout.write('- Beautified: '+os.path.join(path, filename))
|
||||
print('- Beautified: '+os.path.join(path, filename))
|
||||
else:
|
||||
return 0
|
||||
else:
|
||||
if not check_only:
|
||||
sys.stdout.write('- Created: '+os.path.join(path, filename))
|
||||
print('- Created: '+os.path.join(path, filename))
|
||||
|
||||
if check_only:
|
||||
sys.stdout.writelines(difflib.unified_diff(
|
||||
printlines(difflib.unified_diff(
|
||||
[] if old_data is None else [(line+'\n') for line in old_data_encoded.split('\n')],
|
||||
[(line+'\n') for line in new_data_encoded.split('\n')],
|
||||
fromfiledate=timezone.make_aware(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue