Projet

Général

Profil

0002-python3-deprecate-file-builtin.patch

Paul Marillonnet, 06 mai 2019 16:37

Télécharger (4,91 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                                   | 4 ++--
 6 files changed, 11 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
50 50
        def __init__(self, *args, **kwargs):
51 51
            self.users = []
52 52
            assert len(args) == 1
53
            assert isinstance(args[0], file)
53
            assert isinstance(args[0], FileType)
54 54
            assert kwargs['options']['extra_attribute'] == {'ldap_attr': 'first_name'}
55 55
            assert kwargs['options']['result'] == 'result'
56 56

  
......
68 68
        def __init__(self, *args, **kwargs):
69 69
            self.users = []
70 70
            assert len(args) == 1
71
            assert isinstance(args[0], file)
71
            assert isinstance(args[0], FileType)
72 72
            assert kwargs['options']['extra_attribute'] == {
73 73
                'ldap_attr': 'first_name'}
74 74
            assert kwargs['options']['result'] == 'result'
75
-