diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-02-27 20:44:52 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:27 +0200 |
commit | 0f3229a119e53054d98c5e878a9581403628cd08 (patch) | |
tree | e07ad2e91e2544f7b2d61e8f3f653fdda26bfd52 /ishtar_common/management/commands | |
parent | cfabd636d0a6d84e8377be3e4d041b4e75ddda9a (diff) | |
download | Ishtar-0f3229a119e53054d98c5e878a9581403628cd08.tar.bz2 Ishtar-0f3229a119e53054d98c5e878a9581403628cd08.zip |
Migrate to python 3 - Clean old migrations and some old scripts
Diffstat (limited to 'ishtar_common/management/commands')
6 files changed, 8 insertions, 12 deletions
diff --git a/ishtar_common/management/commands/generate_merge_candidates.py b/ishtar_common/management/commands/generate_merge_candidates.py index a4aa87f38..106ce8e13 100644 --- a/ishtar_common/management/commands/generate_merge_candidates.py +++ b/ishtar_common/management/commands/generate_merge_candidates.py @@ -24,13 +24,14 @@ from django.core.exceptions import ObjectDoesNotExist import ishtar_common.models as models + class Command(BaseCommand): args = '' help = 'Regenerate merge candidates' def handle(self, *args, **options): for model in [models.Person, models.Organization]: - sys.stdout.write('\n* %s treatment\n' % unicode(model)) + sys.stdout.write('\n* %s treatment\n' % str(model)) q = model.objects total = q.count() for idx, item in enumerate(q.all()): diff --git a/ishtar_common/management/commands/import_geofla_csv.py b/ishtar_common/management/commands/import_geofla_csv.py index 3b756381d..9b53c8a70 100644 --- a/ishtar_common/management/commands/import_geofla_csv.py +++ b/ishtar_common/management/commands/import_geofla_csv.py @@ -68,7 +68,7 @@ class Command(BaseCommand): default_year)) sys.stdout.write('* Opening file {}\n'.format(csv_file)) nb_created, nb_changed = 0, 0 - with open(csv_file, 'rb') as csvfile: + with open(csv_file, 'rt') as csvfile: reader = csv.DictReader(csvfile) for idx, row in enumerate(reader): if not quiet: diff --git a/ishtar_common/management/commands/import_insee_comm_csv.py b/ishtar_common/management/commands/import_insee_comm_csv.py index d3bbc4a61..d1a8f2084 100644 --- a/ishtar_common/management/commands/import_insee_comm_csv.py +++ b/ishtar_common/management/commands/import_insee_comm_csv.py @@ -52,7 +52,7 @@ class Command(BaseCommand): missing = [] strange = [] linked = set() - with open(csv_file, 'rb') as csvfile: + with open(csv_file, 'rt') as csvfile: reader = csv.DictReader(csvfile) for idx, row in enumerate(reader): if not quiet: @@ -81,7 +81,7 @@ class Command(BaseCommand): year=default_year) if not q.count(): nb_created += 1 - name = row['NomCN'].decode('utf-8').strip() + name = row['NomCN'].strip() name = r.sub(r"\2 \1", name).strip() new_town = Town.objects.create(name=name, year=default_year, numero_insee=new_insee) diff --git a/ishtar_common/management/commands/ishtar_import.py b/ishtar_common/management/commands/ishtar_import.py index 3b04528f0..a8c9d3736 100644 --- a/ishtar_common/management/commands/ishtar_import.py +++ b/ishtar_common/management/commands/ishtar_import.py @@ -32,7 +32,7 @@ class Command(BaseCommand): self.stdout.write("*" * 80 + "\n") for imp in models.Import.objects.exclude(state="AC").all(): self.stdout.write(u"|{: ^6}| {: ^32} | {: ^12} | {}\n".format( - imp.pk, unicode(imp.importer_type)[:32], + imp.pk, str(imp.importer_type)[:32], state[imp.state][:12], imp.name[:128])) self.stdout.write("*" * 80 + "\n") diff --git a/ishtar_common/management/commands/ishtar_migrate_odts.py b/ishtar_common/management/commands/ishtar_migrate_odts.py index 49ed9f2d8..fe7836f0d 100644 --- a/ishtar_common/management/commands/ishtar_migrate_odts.py +++ b/ishtar_common/management/commands/ishtar_migrate_odts.py @@ -24,11 +24,6 @@ import sys from ishtar_common.models import DocumentTemplate from ishtar_common.utils import BColors -try: - input = raw_input -except NameError: - pass - class Command(BaseCommand): help = "Update ODT templates from v1 to v2" diff --git a/ishtar_common/management/commands/reassociate_similar_images.py b/ishtar_common/management/commands/reassociate_similar_images.py index a0483ed3a..0dbb3a765 100644 --- a/ishtar_common/management/commands/reassociate_similar_images.py +++ b/ishtar_common/management/commands/reassociate_similar_images.py @@ -160,8 +160,8 @@ class Command(BaseCommand): nb_conflicted_items += 1 for attr, ref_value, other_value in conflicted_values: conflicts.append(base_csv + [ - attr, unicode(ref_value).encode('utf-8'), - unicode(other_value).encode('utf-8') + attr, str(ref_value).encode('utf-8'), + str(other_value).encode('utf-8') ]) continue |