Projet

Général

Profil

0002-python3-deprecate-file-builtin.patch

Paul Marillonnet, 06 mai 2019 15:30

Télécharger (5,2 ko)

Voir les différences:

Subject: [PATCH 2/2] python3: deprecate file builtin

 debian-wheezy/debian_config.py                           | 3 ++-
 debian/debian_config.py                                  | 3 ++-
 samples/authentic2-plugin-template/setup.py              | 5 ++---
 src/authentic2/management/commands/load-ldif.py          | 4 ++--
 src/authentic2/saml/management/commands/sync-metadata.py | 2 +-
 tests/test_commands.py                                   | 5 +++--
 6 files changed, 12 insertions(+), 10 deletions(-)
debian-wheezy/debian_config.py
17 17
ADMINS = (('root', 'root@localhost'),)
18 18

  
19 19
if os.path.exists('/var/lib/authentic2/secret_key'):
20
    SECRET_KEY = file('/var/lib/authentic2/secret_key').read()
20
    with open('/var/lib/authentic2/secret_key') as f:
21
        SECRET_KEY = f.read()
21 22

  
22 23
LOGGING = {
23 24
    'version': 1,
debian/debian_config.py
17 17
ADMINS = (('root', 'root@localhost'),)
18 18

  
19 19
if os.path.exists('/var/lib/authentic2/secret_key'):
20
    SECRET_KEY = file('/var/lib/authentic2/secret_key').read()
20
    with open('/var/lib/authentic2/secret_key') as f:
21
        SECRET_KEY = f.read()
21 22

  
22 23
LOGGING = {
23 24
    'version': 1,
samples/authentic2-plugin-template/setup.py
22 22
                            ['git', 'rev-list', 'HEAD']).splitlines())
23 23
    return '0.0.0'
24 24

  
25
README = file(os.path.join(
26
    os.path.dirname(__file__),
27
    'README')).read()
25
with open(os.path.join(os.path.dirname(__file__), 'README')) as f:
26
    README = f.read()
28 27

  
29 28
setup(name='authentic2-plugin-template',
30 29
        version=get_version(),
src/authentic2/management/commands/load-ldif.py
77 77
    def parse(self, *args, **kwargs):
78 78
        ldif.LDIFParser.parse(self, *args, **kwargs)
79 79
        if self.options['result']:
80
            with file(self.options['result'], 'w') as f:
80
            with open(self.options['result'], 'w') as f:
81 81
                json.dump(self.json, f)
82 82

  
83 83

  
......
138 138
        options['verbosity'] = int(options['verbosity'])
139 139
        ldif_files = options.pop('ldif_file')
140 140
        for arg in ldif_files:
141
            f = file(arg)
141
            f = open(arg)
142 142
            parser = DjangoUserLDIFParser(f, options=options, command=self)
143 143
            parser.parse()
144 144
            if not options['fake']:
src/authentic2/saml/management/commands/sync-metadata.py
308 308
            metadata_file = six.BytesIO(response.content)
309 309
        else:
310 310
            try:
311
                metadata_file = file(metadata_file_path)
311
                metadata_file = open(metadata_file_path)
312 312
            except:
313 313
                raise CommandError('Unable to open file %s' % metadata_file_path)
314 314

  
tests/test_commands.py
6 6
from django.utils.timezone import now
7 7
import py
8 8

  
9
from authentic2.compat import FileType
9 10
from authentic2.models import Attribute, DeletedUser
10 11
from authentic2_auth_oidc.models import OIDCProvider
11 12
from django_rbac.utils import get_ou_model
......
43 44
        def __init__(self, *args, **kwargs):
44 45
            self.users = []
45 46
            assert len(args) == 1
46
            assert isinstance(args[0], file)
47
            assert isinstance(args[0], FileType)
47 48
            assert kwargs['options']['extra_attribute'] == {'ldap_attr': 'first_name'}
48 49
            assert kwargs['options']['result'] == 'result'
49 50

  
......
61 62
        def __init__(self, *args, **kwargs):
62 63
            self.users = []
63 64
            assert len(args) == 1
64
            assert isinstance(args[0], file)
65
            assert isinstance(args[0], FileType)
65 66
            assert kwargs['options']['extra_attribute'] == {
66 67
                'ldap_attr': 'first_name'}
67 68
            assert kwargs['options']['result'] == 'result'
68
-