Skip to content

Commit d7f5c84

Browse files
committed
Initial 2to3 patch with added copyright statement updates.
- Legacy-Id: 16309
1 parent 1615f46 commit d7f5c84

357 files changed

Lines changed: 1519 additions & 1338 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ietf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright The IETF Trust 2007-2019, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

4-
import checks # pyflakes:ignore
4+
from . import checks # pyflakes:ignore
55

66
# Don't add patch number here:
77
__version__ = "6.98.2.dev0"

ietf/api/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
# Copyright The IETF Trust 2014-2019, All Rights Reserved
12
import re
23
import six
34
import datetime
4-
from urllib import urlencode
5+
from urllib.parse import urlencode
56

67
from django.conf import settings
78
from django.core.exceptions import ObjectDoesNotExist
@@ -129,9 +130,9 @@ def dehydrate(self, bundle, for_list=True):
129130
if not foreign_obj:
130131
if not self.null:
131132
if callable(self.attribute):
132-
raise ApiFieldError(u"The related resource for resource %s could not be found." % (previous_obj))
133+
raise ApiFieldError("The related resource for resource %s could not be found." % (previous_obj))
133134
else:
134-
raise ApiFieldError(u"The model '%r' has an empty attribute '%s' and doesn't allow a null value." % (previous_obj, attr))
135+
raise ApiFieldError("The model '%r' has an empty attribute '%s' and doesn't allow a null value." % (previous_obj, attr))
135136
return None
136137

137138
fk_resource = self.get_related_resource(foreign_obj)

ietf/api/management/commands/makeresources.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright The IETF Trust 2014-2019, All Rights Reserved
22
# -*- coding: utf-8 -*-
3-
from __future__ import print_function
3+
44

55
import os
66
import datetime
@@ -66,7 +66,7 @@ def handle_app_config(self, app, **options):
6666
app_resources = {}
6767
if os.path.exists(resource_file_path):
6868
resources = import_module("%s.resources" % app.name)
69-
for n,v in resources.__dict__.items():
69+
for n,v in list(resources.__dict__.items()):
7070
if issubclass(type(v), type(ModelResource)):
7171
app_resources[n] = v
7272

@@ -164,7 +164,7 @@ def handle_app_config(self, app, **options):
164164
fields=model._meta.fields,
165165
m2m_fields=model._meta.many_to_many,
166166
name=model_name,
167-
imports=[ v for k,v in imports.items() ],
167+
imports=[ v for k,v in list(imports.items()) ],
168168
foreign_keys=foreign_keys,
169169
m2m_keys=m2m_keys,
170170
resource_name=resource_name,
@@ -184,7 +184,7 @@ def handle_app_config(self, app, **options):
184184
while len(new_models) > 0:
185185
list_len = len(new_models)
186186
#debug.show('len(new_models)')
187-
keys = new_models.keys()
187+
keys = list(new_models.keys())
188188
for model_name in keys:
189189
internal_fk_count = 0
190190
for fk in new_models[model_name]["foreign_keys"]+new_models[model_name]["m2m_keys"]:
@@ -207,7 +207,7 @@ def handle_app_config(self, app, **options):
207207
internal_fk_count_limit += 1
208208
else:
209209
print("Failed also with partial ordering, writing resource classes without ordering")
210-
new_model_list = [ v for k,v in new_models.items() ]
210+
new_model_list = [ v for k,v in list(new_models.items()) ]
211211
break
212212

213213
if rfile.tell() == 0:

ietf/api/serializer.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright The IETF Trust 2018-2019, All Rights Reserved
12
import hashlib
23
import json
34

@@ -16,7 +17,7 @@
1617
def filter_from_queryargs(request):
1718
#@debug.trace
1819
def fix_ranges(d):
19-
for k,v in d.items():
20+
for k,v in list(d.items()):
2021
if v.startswith("[") and v.endswith("]"):
2122
d[k] = [ s for s in v[1:-1].split(",") if s ]
2223
elif "," in v:
@@ -27,9 +28,9 @@ def fix_ranges(d):
2728
def is_ascii(s):
2829
return all(ord(c) < 128 for c in s)
2930
# limit parameter keys to ascii.
30-
params = dict( (k,v) for (k,v) in request.GET.items() if is_ascii(k) )
31-
filter = fix_ranges(dict([(k,params[k]) for k in params.keys() if not k.startswith("not__")]))
32-
exclude = fix_ranges(dict([(k[5:],params[k]) for k in params.keys() if k.startswith("not__")]))
31+
params = dict( (k,v) for (k,v) in list(request.GET.items()) if is_ascii(k) )
32+
filter = fix_ranges(dict([(k,params[k]) for k in list(params.keys()) if not k.startswith("not__")]))
33+
exclude = fix_ranges(dict([(k[5:],params[k]) for k in list(params.keys()) if k.startswith("not__")]))
3334
return filter, exclude
3435

3536
def unique_obj_name(obj):
@@ -147,7 +148,7 @@ def end_object(self, obj):
147148
if hasattr(field_value, "_meta"):
148149
self._current[name] = self.expand_related(field_value, name)
149150
else:
150-
self._current[name] = unicode(field_value)
151+
self._current[name] = str(field_value)
151152
except ObjectDoesNotExist:
152153
pass
153154
except AttributeError:
@@ -224,7 +225,7 @@ class JsonExportMixin(object):
224225

225226
def json_view(self, request, filter={}, expand=[]):
226227
qfilter, exclude = filter_from_queryargs(request)
227-
for k in qfilter.keys():
228+
for k in list(qfilter.keys()):
228229
if k.startswith("_"):
229230
del qfilter[k]
230231
qfilter.update(filter)
@@ -244,15 +245,15 @@ def json_view(self, request, filter={}, expand=[]):
244245
try:
245246
qs = self.get_queryset().filter(**filter).exclude(**exclude)
246247
except (FieldError, ValueError) as e:
247-
return HttpResponse(json.dumps({u"error": str(e)}, sort_keys=True, indent=3), content_type=content_type)
248+
return HttpResponse(json.dumps({"error": str(e)}, sort_keys=True, indent=3), content_type=content_type)
248249
try:
249250
if expand:
250251
qs = qs.select_related()
251252
serializer = AdminJsonSerializer()
252253
items = [(getattr(o, key), serializer.serialize([o], expand=expand, query_info=query_info) ) for o in qs ]
253254
qd = dict( ( k, json.loads(v)[0] ) for k,v in items )
254255
except (FieldError, ValueError) as e:
255-
return HttpResponse(json.dumps({u"error": str(e)}, sort_keys=True, indent=3), content_type=content_type)
256+
return HttpResponse(json.dumps({"error": str(e)}, sort_keys=True, indent=3), content_type=content_type)
256257
text = json.dumps({smart_text(self.model._meta): qd}, sort_keys=True, indent=3)
257258
return HttpResponse(text, content_type=content_type)
258259

ietf/api/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright The IETF Trust 2015-2018, All Rights Reserved
1+
# Copyright The IETF Trust 2015-2019, All Rights Reserved
22

33
import json
44
import os
@@ -218,8 +218,8 @@ def test_all_model_resources_exist(self):
218218
#
219219
model_list = apps.get_app_config(name).get_models()
220220
for model in model_list:
221-
if not model._meta.model_name in app_resources.keys():
221+
if not model._meta.model_name in list(app_resources.keys()):
222222
#print("There doesn't seem to be any resource for model %s.models.%s"%(app.__name__,model.__name__,))
223-
self.assertIn(model._meta.model_name, app_resources.keys(),
223+
self.assertIn(model._meta.model_name, list(app_resources.keys()),
224224
"There doesn't seem to be any API resource for model %s.models.%s"%(app.__name__,model.__name__,))
225225

ietf/api/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Copyright The IETF Trust 2017, All Rights Reserved
1+
# Copyright The IETF Trust 2017-2019, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

4-
from __future__ import unicode_literals
4+
55

66
from jwcrypto.jwk import JWK
77

ietf/community/admin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Copyright The IETF Trust 2017-2019, All Rights Reserved
22
# -*- coding: utf-8 -*-
3-
from __future__ import unicode_literals
3+
44

55
from django.contrib import admin
66

77
from ietf.community.models import CommunityList, SearchRule, EmailSubscription
88

99
class CommunityListAdmin(admin.ModelAdmin):
10-
list_display = [u'id', 'user', 'group']
10+
list_display = ['id', 'user', 'group']
1111
raw_id_fields = ['user', 'group', 'added_docs']
1212
admin.site.register(CommunityList, CommunityListAdmin)
1313

1414
class SearchRuleAdmin(admin.ModelAdmin):
15-
list_display = [u'id', 'community_list', 'rule_type', 'state', 'group', 'person', 'text']
15+
list_display = ['id', 'community_list', 'rule_type', 'state', 'group', 'person', 'text']
1616
raw_id_fields = ['community_list', 'state', 'group', 'person', 'name_contains_index']
1717
search_fields = ['person__name', 'group__acronym', 'text', ]
1818
admin.site.register(SearchRule, SearchRuleAdmin)
1919

2020
class EmailSubscriptionAdmin(admin.ModelAdmin):
21-
list_display = [u'id', 'community_list', 'email', 'notify_on']
21+
list_display = ['id', 'community_list', 'email', 'notify_on']
2222
raw_id_fields = ['community_list', 'email']
2323
admin.site.register(EmailSubscription, EmailSubscriptionAdmin)
2424

ietf/community/forms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright The IETF Trust 2012-2019, All Rights Reserved
12
from django import forms
23
from django.db.models import Q
34

@@ -82,9 +83,9 @@ def restrict_state(state_type, slug=None):
8283

8384
if 'group' in self.fields:
8485
self.fields['group'].queryset = self.fields['group'].queryset.filter(state="active").order_by("acronym")
85-
self.fields['group'].choices = [(g.pk, u"%s - %s" % (g.acronym, g.name)) for g in self.fields['group'].queryset]
86+
self.fields['group'].choices = [(g.pk, "%s - %s" % (g.acronym, g.name)) for g in self.fields['group'].queryset]
8687

87-
for name, f in self.fields.iteritems():
88+
for name, f in self.fields.items():
8889
f.required = True
8990

9091
def clean_text(self):

ietf/community/migrations/0001_initial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
# Copyright The IETF Trust 2018-2019, All Rights Reserved
12
# -*- coding: utf-8 -*-
23
# Generated by Django 1.11.10 on 2018-02-20 10:52
3-
from __future__ import unicode_literals
4+
45

56
from django.db import migrations, models
67
import django.db.models.deletion

ietf/community/migrations/0002_auto_20180220_1052.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
# Copyright The IETF Trust 2018-2019, All Rights Reserved
12
# -*- coding: utf-8 -*-
23
# Generated by Django 1.11.10 on 2018-02-20 10:52
3-
from __future__ import unicode_literals
4+
45

56
from django.conf import settings
67
from django.db import migrations, models

0 commit comments

Comments
 (0)