morango 0.7.1__py2.py3-none-any.whl → 0.8.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of morango might be problematic. Click here for more details.

Files changed (50) hide show
  1. morango/__init__.py +1 -6
  2. morango/api/viewsets.py +6 -1
  3. morango/apps.py +1 -2
  4. morango/constants/transfer_stages.py +1 -1
  5. morango/constants/transfer_statuses.py +1 -1
  6. morango/migrations/0001_initial.py +0 -2
  7. morango/migrations/0001_squashed_0024_auto_20240129_1757.py +583 -0
  8. morango/migrations/0002_auto_20170511_0400.py +0 -2
  9. morango/migrations/0003_auto_20170519_0543.py +0 -2
  10. morango/migrations/0004_auto_20170520_2112.py +0 -2
  11. morango/migrations/0005_auto_20170629_2139.py +0 -2
  12. morango/migrations/0006_instanceidmodel_system_id.py +0 -2
  13. morango/migrations/0007_auto_20171018_1615.py +0 -2
  14. morango/migrations/0008_auto_20171114_2217.py +0 -2
  15. morango/migrations/0009_auto_20171205_0252.py +0 -2
  16. morango/migrations/0010_auto_20171206_1615.py +0 -2
  17. morango/migrations/0011_sharedkey.py +0 -2
  18. morango/migrations/0012_auto_20180927_1658.py +0 -2
  19. morango/migrations/0013_auto_20190627_1513.py +0 -2
  20. morango/migrations/0014_syncsession_extra_fields.py +0 -2
  21. morango/migrations/0015_auto_20200508_2104.py +2 -3
  22. morango/migrations/0016_store_deserialization_error.py +2 -3
  23. morango/migrations/0017_store_last_transfer_session_id.py +1 -2
  24. morango/migrations/0018_auto_20210714_2216.py +2 -3
  25. morango/migrations/0019_auto_20220113_1807.py +2 -3
  26. morango/migrations/0020_postgres_fix_nullable.py +0 -2
  27. morango/migrations/0021_store_partition_index_create.py +0 -2
  28. morango/migrations/0022_rename_instance_fields.py +0 -2
  29. morango/migrations/0023_add_instance_id_fields.py +0 -2
  30. morango/migrations/0024_auto_20240129_1757.py +28 -0
  31. morango/models/__init__.py +0 -6
  32. morango/models/certificates.py +3 -9
  33. morango/models/core.py +13 -23
  34. morango/models/fields/crypto.py +4 -7
  35. morango/models/fields/uuids.py +2 -1
  36. morango/models/utils.py +5 -6
  37. morango/proquint.py +2 -3
  38. morango/registry.py +1 -32
  39. morango/sync/backends/utils.py +10 -11
  40. morango/sync/syncsession.py +7 -12
  41. morango/urls.py +3 -3
  42. morango/utils.py +2 -3
  43. {morango-0.7.1.dist-info → morango-0.8.1.dist-info}/METADATA +7 -7
  44. morango-0.8.1.dist-info/RECORD +78 -0
  45. {morango-0.7.1.dist-info → morango-0.8.1.dist-info}/WHEEL +1 -1
  46. morango/models/morango_mptt.py +0 -33
  47. morango-0.7.1.dist-info/RECORD +0 -77
  48. {morango-0.7.1.dist-info → morango-0.8.1.dist-info}/AUTHORS.md +0 -0
  49. {morango-0.7.1.dist-info → morango-0.8.1.dist-info}/LICENSE +0 -0
  50. {morango-0.7.1.dist-info → morango-0.8.1.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.9 on 2017-06-30 00:15
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.9.13 on 2017-10-18 21:15
3
- from __future__ import unicode_literals
4
-
5
3
  import datetime
6
4
 
7
5
  import django.db.models.deletion
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.9.7 on 2017-11-14 22:17
3
- from __future__ import unicode_literals
4
-
5
3
  import django.db.models.deletion
6
4
  import django.db.models.manager
7
5
  from django.db import migrations
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.9.7 on 2017-12-05 08:52
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
 
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.9.13 on 2017-12-06 22:15
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.13 on 2018-06-12 18:38
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.15 on 2018-09-27 16:58
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.21 on 2019-06-27 22:13
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
 
7
5
  import morango.models.fields.uuids
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.27 on 2019-12-30 18:28
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2020-05-08 21:04
3
- from __future__ import unicode_literals
4
-
5
- from django.db import migrations, models
3
+ from django.db import migrations
4
+ from django.db import models
6
5
 
7
6
 
8
7
  class Migration(migrations.Migration):
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.28 on 2020-06-10 23:48
3
- from __future__ import unicode_literals
4
-
5
- from django.db import migrations, models
3
+ from django.db import migrations
4
+ from django.db import models
6
5
 
7
6
 
8
7
  class Migration(migrations.Migration):
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.28 on 2021-06-25 23:13
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
4
+
6
5
  import morango.models.fields.uuids
7
6
 
8
7
 
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2021-07-14 22:16
3
- from __future__ import unicode_literals
4
-
5
- from django.db import migrations, models
3
+ from django.db import migrations
4
+ from django.db import models
6
5
 
7
6
 
8
7
  class Migration(migrations.Migration):
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2022-01-13 18:07
3
- from __future__ import unicode_literals
4
-
5
- from django.db import migrations, models
3
+ from django.db import migrations
4
+ from django.db import models
6
5
 
7
6
 
8
7
  class Migration(migrations.Migration):
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2022-01-13 18:07
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
 
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2022-04-27 16:59
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2023-01-31 18:53
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
 
7
5
 
@@ -1,7 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by Django 1.11.29 on 2023-01-31 19:03
3
- from __future__ import unicode_literals
4
-
5
3
  from django.db import migrations
6
4
  from django.db import models
7
5
 
@@ -0,0 +1,28 @@
1
+ # Generated by Django 3.2.23 on 2024-01-29 17:57
2
+ from django.db import migrations
3
+ from django.db import models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ('morango', '0023_add_instance_id_fields'),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name='certificate',
15
+ name='level',
16
+ field=models.PositiveIntegerField(editable=False),
17
+ ),
18
+ migrations.AlterField(
19
+ model_name='certificate',
20
+ name='lft',
21
+ field=models.PositiveIntegerField(editable=False),
22
+ ),
23
+ migrations.AlterField(
24
+ model_name='certificate',
25
+ name='rght',
26
+ field=models.PositiveIntegerField(editable=False),
27
+ ),
28
+ ]
@@ -21,9 +21,6 @@ from morango.models.fields import __all__ as fields_all
21
21
  from morango.models.fields.crypto import SharedKey
22
22
  from morango.models.fields.uuids import UUIDModelMixin
23
23
  from morango.models.manager import SyncableModelManager
24
- from morango.models.morango_mptt import MorangoMPTTModel
25
- from morango.models.morango_mptt import MorangoMPTTTreeManager
26
- from morango.models.morango_mptt import MorangoTreeQuerySet
27
24
  from morango.models.query import SyncableModelQuerySet
28
25
  from morango.registry import syncable_models
29
26
 
@@ -41,9 +38,6 @@ __all__ += [
41
38
  "SyncableModelManager",
42
39
  "SyncableModelQuerySet",
43
40
  "syncable_models",
44
- "MorangoTreeQuerySet",
45
- "MorangoMPTTTreeManager",
46
- "MorangoMPTTModel",
47
41
  "DatabaseIDModel",
48
42
  "InstanceIDModel",
49
43
  "SyncSession",
@@ -3,8 +3,6 @@
3
3
  Each certificate has a ``private_key`` used for signing (child) certificates (thus giving certain permissions)
4
4
  and a ``public_key`` used for verifying that a certificate(s) was properly signed.
5
5
  """
6
- from __future__ import unicode_literals
7
-
8
6
  import json
9
7
  import string
10
8
 
@@ -13,8 +11,6 @@ from django.core.management import call_command
13
11
  from django.db import models
14
12
  from django.db import transaction
15
13
  from django.utils import timezone
16
- from django.utils.six import string_types
17
- from future.utils import python_2_unicode_compatible
18
14
 
19
15
  from .fields.crypto import Key
20
16
  from .fields.crypto import PrivateKeyField
@@ -30,7 +26,6 @@ from morango.errors import NonceExpired
30
26
  from morango.utils import _assert
31
27
 
32
28
 
33
- @python_2_unicode_compatible
34
29
  class Certificate(mptt.models.MPTTModel, UUIDModelMixin):
35
30
 
36
31
  uuid_input_fields = ("public_key", "profile", "salt")
@@ -199,7 +194,7 @@ class Certificate(mptt.models.MPTTModel, UUIDModelMixin):
199
194
  def save_certificate_chain(cls, cert_chain, expected_last_id=None):
200
195
 
201
196
  # parse the chain from json if needed
202
- if isinstance(cert_chain, string_types):
197
+ if isinstance(cert_chain, str):
203
198
  cert_chain = json.loads(cert_chain)
204
199
 
205
200
  # start from the bottom of the chain
@@ -324,16 +319,15 @@ class ScopeDefinition(models.Model):
324
319
  return Scope(definition=self, params=params)
325
320
 
326
321
  def get_description(self, params):
327
- if isinstance(params, string_types):
322
+ if isinstance(params, str):
328
323
  params = json.loads(params)
329
324
  return string.Template(self.description).safe_substitute(params)
330
325
 
331
326
 
332
- @python_2_unicode_compatible
333
327
  class Filter(object):
334
328
  def __init__(self, template, params={}):
335
329
  # ensure params have been deserialized
336
- if isinstance(params, string_types):
330
+ if isinstance(params, str):
337
331
  params = json.loads(params)
338
332
  self._template = template
339
333
  self._params = params
morango/models/core.py CHANGED
@@ -1,5 +1,3 @@
1
- from __future__ import unicode_literals
2
-
3
1
  import functools
4
2
  import json
5
3
  import logging
@@ -24,7 +22,6 @@ from django.db.models.deletion import Collector
24
22
  from django.db.models.expressions import CombinedExpression
25
23
  from django.db.models.fields.related import ForeignKey
26
24
  from django.db.models.functions import Cast
27
- from django.utils import six
28
25
  from django.utils import timezone
29
26
  from django.utils.functional import cached_property
30
27
 
@@ -39,7 +36,6 @@ from morango.models.fields.uuids import UUIDField
39
36
  from morango.models.fields.uuids import UUIDModelMixin
40
37
  from morango.models.fsic_utils import remove_redundant_instance_counters
41
38
  from morango.models.manager import SyncableModelManager
42
- from morango.models.morango_mptt import MorangoMPTTModel
43
39
  from morango.models.utils import get_0_4_system_parameters
44
40
  from morango.models.utils import get_0_5_mac_address
45
41
  from morango.models.utils import get_0_5_system_id
@@ -355,10 +351,10 @@ class TransferSession(models.Model):
355
351
 
356
352
  def get_touched_record_ids_for_model(self, model):
357
353
  if isinstance(model, SyncableModel) or (
358
- isinstance(model, six.class_types) and issubclass(model, SyncableModel)
354
+ isinstance(model, type) and issubclass(model, SyncableModel)
359
355
  ):
360
356
  model = model.morango_model_name
361
- _assert(isinstance(model, six.string_types), "Model must resolve to string")
357
+ _assert(isinstance(model, str), "Model must resolve to string")
362
358
  return Store.objects.filter(
363
359
  model_name=model, last_transfer_session_id=self.id
364
360
  ).values_list("id", flat=True)
@@ -422,7 +418,7 @@ class StoreQueryset(models.QuerySet):
422
418
  self.annotate(id_cast=Cast("id", TextField()))
423
419
  # remove dashes from char uuid
424
420
  .annotate(
425
- fixed_id=Func(F("id_cast"), Value("-"), Value(""), function="replace")
421
+ fixed_id=Func(F("id_cast"), Value("-"), Value(""), function="replace", output_field=TextField())
426
422
  )
427
423
  # return as list
428
424
  .values_list("fixed_id", flat=True)
@@ -612,7 +608,7 @@ class DatabaseMaxCounter(AbstractCounter):
612
608
  )
613
609
  else:
614
610
  updated_fsic = {}
615
- for key, value in six.iteritems(fsics):
611
+ for key, value in fsics.items():
616
612
  if key in internal_fsic:
617
613
  # if same instance id, update fsic with larger value
618
614
  if fsics[key] > internal_fsic[key]:
@@ -622,7 +618,7 @@ class DatabaseMaxCounter(AbstractCounter):
622
618
  updated_fsic[key] = fsics[key]
623
619
 
624
620
  # load database max counters
625
- for (key, value) in six.iteritems(updated_fsic):
621
+ for (key, value) in updated_fsic.items():
626
622
  for f in sync_filter:
627
623
  DatabaseMaxCounter.objects.update_or_create(
628
624
  instance_id=key, partition=f, defaults={"counter": value}
@@ -845,10 +841,8 @@ class SyncableModel(UUIDModelMixin):
845
841
  with transaction.atomic():
846
842
  if hard_delete:
847
843
  # set hard deletion for all related models
848
- for model, instances in six.iteritems(collector.data):
849
- if issubclass(model, SyncableModel) or issubclass(
850
- model, MorangoMPTTModel
851
- ):
844
+ for model, instances in collector.data.items():
845
+ if issubclass(model, SyncableModel):
852
846
  for obj in instances:
853
847
  obj._update_hard_deleted_models()
854
848
  return collector.delete()
@@ -932,15 +926,8 @@ class SyncableModel(UUIDModelMixin):
932
926
  continue
933
927
  if f.attname in self._morango_internal_fields_not_to_serialize:
934
928
  continue
935
- # case if model is morango mptt
936
- if f.attname in getattr(
937
- self,
938
- "_internal_mptt_fields_not_to_serialize",
939
- "_internal_fields_not_to_serialize",
940
- ):
941
- continue
942
- if hasattr(f, "value_from_object_json_compatible"):
943
- data[f.attname] = f.value_from_object_json_compatible(self)
929
+ if getattr(f, "morango_serialize_to_string", False):
930
+ data[f.attname] = f.value_to_string(self)
944
931
  else:
945
932
  data[f.attname] = f.value_from_object(self)
946
933
  return data
@@ -951,7 +938,10 @@ class SyncableModel(UUIDModelMixin):
951
938
  kwargs = {}
952
939
  for f in cls._meta.concrete_fields:
953
940
  if f.attname in dict_model:
954
- kwargs[f.attname] = dict_model[f.attname]
941
+ if getattr(f, "morango_serialize_to_string", False):
942
+ kwargs[f.attname] = f.to_python(dict_model[f.attname])
943
+ else:
944
+ kwargs[f.attname] = dict_model[f.attname]
955
945
  return cls(**kwargs)
956
946
 
957
947
  @classmethod
@@ -6,7 +6,6 @@ desirability/efficiency from left to right). We have a base ``Key`` class which
6
6
  """
7
7
  import hashlib
8
8
  import re
9
- import sys
10
9
 
11
10
  import rsa as PYRSA
12
11
  from django.db import models
@@ -41,10 +40,8 @@ try:
41
40
  except ImportError:
42
41
  CRYPTOGRAPHY_EXISTS = False
43
42
 
44
- if sys.version_info[0] < 3:
45
- from base64 import encodestring as b64encode, decodestring as b64decode
46
- else:
47
- from base64 import encodebytes as b64encode, decodebytes as b64decode
43
+
44
+ from base64 import encodebytes as b64encode, decodebytes as b64decode
48
45
 
49
46
 
50
47
  PKCS8_HEADER = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A"
@@ -347,7 +344,7 @@ class RSAKeyBaseField(models.TextField):
347
344
 
348
345
 
349
346
  class PublicKeyField(RSAKeyBaseField):
350
- def from_db_value(self, value, expression, connection, context):
347
+ def from_db_value(self, value, expression, connection):
351
348
  if not value:
352
349
  return None
353
350
  return Key(public_key_string=value)
@@ -366,7 +363,7 @@ class PublicKeyField(RSAKeyBaseField):
366
363
 
367
364
 
368
365
  class PrivateKeyField(RSAKeyBaseField):
369
- def from_db_value(self, value, expression, connection, context):
366
+ def from_db_value(self, value, expression, connection):
370
367
  if not value:
371
368
  return None
372
369
  return Key(private_key_string=value)
@@ -2,6 +2,7 @@ import hashlib
2
2
  import uuid
3
3
 
4
4
  from django.db import models
5
+
5
6
  from morango.utils import _assert
6
7
 
7
8
 
@@ -41,7 +42,7 @@ class UUIDField(models.CharField):
41
42
  raise TypeError(self.error_messages["invalid"] % {"value": value})
42
43
  return value.hex
43
44
 
44
- def from_db_value(self, value, expression, connection, context):
45
+ def from_db_value(self, value, expression, connection):
45
46
  return self.to_python(value)
46
47
 
47
48
  def to_python(self, value):
morango/models/utils.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import hashlib
2
- import ifcfg
3
2
  import os
4
3
  import platform
5
4
  import socket
@@ -7,10 +6,10 @@ import subprocess
7
6
  import sys
8
7
  import uuid
9
8
 
10
- from .fields.uuids import sha2_uuid
11
-
9
+ import ifcfg
12
10
  from django.conf import settings
13
- from django.utils import six
11
+
12
+ from .fields.uuids import sha2_uuid
14
13
 
15
14
 
16
15
  def _get_database_path():
@@ -109,7 +108,7 @@ def _get_android_uuid():
109
108
  def _do_salted_hash(value):
110
109
  if not value:
111
110
  return ""
112
- if not isinstance(value, six.string_types):
111
+ if not isinstance(value, str):
113
112
  value = str(value)
114
113
  try:
115
114
  value = value.encode()
@@ -185,7 +184,7 @@ def _get_mac_address_flags(mac):
185
184
  """
186
185
  See: https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local
187
186
  """
188
- if isinstance(mac, six.integer_types):
187
+ if isinstance(mac, int):
189
188
  mac = _mac_int_to_ether(mac)
190
189
 
191
190
  first_octet = int(mac[:2], base=16)
morango/proquint.py CHANGED
@@ -4,7 +4,6 @@ The simplest ways to use this module are the :func:`humanize` and :func:`uuid`
4
4
  functions. For tighter control over the output, see :class:`HumanHasher`.
5
5
  """
6
6
  import uuid
7
- from django.utils import six
8
7
 
9
8
  # Copyright (c) 2014 SUNET. All rights reserved.
10
9
  #
@@ -59,7 +58,7 @@ def from_int(data):
59
58
  :type data: int
60
59
  :rtype: string
61
60
  """
62
- if not isinstance(data, six.integer_types):
61
+ if not isinstance(data, int):
63
62
  raise TypeError("Input must be integer")
64
63
 
65
64
  res = []
@@ -84,7 +83,7 @@ def to_int(data):
84
83
  :type data: string
85
84
  :rtype: int
86
85
  """
87
- if not isinstance(data, six.string_types):
86
+ if not isinstance(data, str):
88
87
  raise TypeError("Input must be string")
89
88
 
90
89
  res = 0
morango/registry.py CHANGED
@@ -7,7 +7,6 @@ import sys
7
7
  from collections import OrderedDict
8
8
 
9
9
  from django.db.models.fields.related import ForeignKey
10
- from django.utils import six
11
10
 
12
11
  from morango.constants import transfer_stages
13
12
  from morango.errors import InvalidMorangoModelConfiguration
@@ -111,36 +110,6 @@ class SyncableModelRegistry(object):
111
110
  raise InvalidMorangoModelConfiguration(
112
111
  "Syncing models with more than 1 self referential ForeignKey is not supported."
113
112
  )
114
- try:
115
- from mptt import models
116
- from morango.models.morango_mptt import (
117
- MorangoMPTTModel,
118
- MorangoMPTTTreeManager,
119
- MorangoTreeQuerySet,
120
- )
121
-
122
- # mptt syncable model checks
123
- if issubclass(model, models.MPTTModel):
124
- if not issubclass(model, MorangoMPTTModel):
125
- raise InvalidMorangoModelConfiguration(
126
- "{} that inherits from MPTTModel, should instead inherit from MorangoMPTTModel.".format(
127
- name
128
- )
129
- )
130
- if not isinstance(model.objects, MorangoMPTTTreeManager):
131
- raise InvalidMorangoModelConfiguration(
132
- "Manager for {} must inherit from MorangoMPTTTreeManager.".format(
133
- name
134
- )
135
- )
136
- if not isinstance(model.objects.none(), MorangoTreeQuerySet):
137
- raise InvalidMorangoModelConfiguration(
138
- "Queryset for {} model must inherit from MorangoTreeQuerySet.".format(
139
- name
140
- )
141
- )
142
- except ImportError:
143
- pass
144
113
  # syncable model checks
145
114
  if not isinstance(model.objects, SyncableModelManager):
146
115
  raise InvalidMorangoModelConfiguration(
@@ -178,7 +147,7 @@ class SyncableModelRegistry(object):
178
147
  self._insert_model_in_dependency_order(model, profile)
179
148
 
180
149
  # for each profile, create a dict mapping from morango_model_name to model class
181
- for profile, model_list in six.iteritems(self.profile_models):
150
+ for profile, model_list in self.profile_models.items():
182
151
  mapping = OrderedDict()
183
152
  for model in model_list:
184
153
  mapping[model.morango_model_name] = model
@@ -1,8 +1,7 @@
1
1
  import sqlite3
2
+ from functools import lru_cache
2
3
  from importlib import import_module
3
4
 
4
- from django.utils.lru_cache import lru_cache
5
-
6
5
  from morango.errors import MorangoError
7
6
 
8
7
 
@@ -110,15 +109,15 @@ class TemporaryTable(object):
110
109
  """
111
110
  fields = []
112
111
  params = []
113
- with self.connection.schema_editor() as schema_editor:
114
- for field in self.fields:
115
- # generates the SQL expression for the table column
116
- field_sql, field_params = schema_editor.column_sql(
117
- self, field, include_default=True
118
- )
119
- field_sql_name = self.connection.ops.quote_name(field.column)
120
- fields.append("{name} {sql}".format(name=field_sql_name, sql=field_sql))
121
- params.extend(field_params)
112
+ schema_editor = self.connection.schema_editor()
113
+ for field in self.fields:
114
+ # generates the SQL expression for the table column
115
+ field_sql, field_params = schema_editor.column_sql(
116
+ self, field, include_default=True
117
+ )
118
+ field_sql_name = self.connection.ops.quote_name(field.column)
119
+ fields.append("{name} {sql}".format(name=field_sql_name, sql=field_sql))
120
+ params.extend(field_params)
122
121
  with self.connection.cursor() as c:
123
122
  self.backend._create_temporary_table(c, self.sql_name, fields, params)
124
123
 
@@ -7,12 +7,10 @@ import os
7
7
  import socket
8
8
  import uuid
9
9
  from io import BytesIO
10
+ from urllib.parse import urljoin
11
+ from urllib.parse import urlparse
10
12
 
11
13
  from django.utils import timezone
12
- from django.utils.six import iteritems
13
- from django.utils.six import raise_from
14
- from django.utils.six.moves.urllib.parse import urljoin
15
- from django.utils.six.moves.urllib.parse import urlparse
16
14
  from requests.adapters import HTTPAdapter
17
15
  from requests.exceptions import HTTPError
18
16
  from requests.packages.urllib3.util.retry import Retry
@@ -299,7 +297,7 @@ class NetworkSyncConnection(Connection):
299
297
  try:
300
298
  self._get_sync_session(sync_session)
301
299
  except HTTPError as e:
302
- raise_from(MorangoResumeSyncError("Failure resuming sync session"), e)
300
+ raise MorangoResumeSyncError("Failure resuming sync session") from e
303
301
 
304
302
  # update process id
305
303
  sync_session.process_id = os.getpid()
@@ -440,7 +438,7 @@ class NetworkSyncConnection(Connection):
440
438
  # convert user arguments into query str for passing to auth layer
441
439
  if isinstance(userargs, dict):
442
440
  userargs = "&".join(
443
- ["{}={}".format(key, val) for (key, val) in iteritems(userargs)]
441
+ ["{}={}".format(key, val) for (key, val) in userargs.items()]
444
442
  )
445
443
  return self.session.post(
446
444
  self.urlresolve(api_urls.CERTIFICATE), json=data, auth=(userargs, password)
@@ -627,12 +625,9 @@ class TransferClient(object):
627
625
  """
628
626
  result = self.controller.proceed_to_and_wait_for(stage, callback=callback)
629
627
  if result == transfer_statuses.ERRORED:
630
- raise_from(
631
- MorangoError(
632
- error_msg or "Stage `{}` failed".format(self.context.stage)
633
- ),
634
- self.context.error,
635
- )
628
+ raise MorangoError(
629
+ error_msg or "Stage `{}` failed".format(self.context.stage)
630
+ ) from self.context.error
636
631
 
637
632
  def initialize(self, sync_filter):
638
633
  """
morango/urls.py CHANGED
@@ -1,4 +1,4 @@
1
- from django.conf.urls import include
2
- from django.conf.urls import url
1
+ from django.urls import include
2
+ from django.urls import path
3
3
 
4
- urlpatterns = [url(r"^api/morango/v1/", include("morango.api.urls"))]
4
+ urlpatterns = [path("api/morango/v1/", include("morango.api.urls"))]