improve code style (#32866)
- remove obviously dead code (reported by flake8) - fix PEP8 violations - rename variable using stdlib builtin names - use get_version() from combo's setup.py
This commit is contained in:
parent
e04459825c
commit
0077218685
103
setup.py
103
setup.py
|
@ -76,72 +76,81 @@ class eo_sdist(sdist):
|
|||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
|
||||
|
||||
class install_lib(_install_lib):
|
||||
def run(self):
|
||||
self.run_command('compile_translations')
|
||||
_install_lib.run(self)
|
||||
|
||||
|
||||
def get_version():
|
||||
'''Use the VERSION, if absent generates a version with git describe, if not
|
||||
tag exists, take 0.0.0- and add the length of the commit log.
|
||||
tag exists, take 0.0- and add the length of the commit log.
|
||||
'''
|
||||
if os.path.exists('VERSION'):
|
||||
with open('VERSION', 'r') as v:
|
||||
return v.read()
|
||||
if os.path.exists('.git'):
|
||||
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = subprocess.Popen(['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
result = p.communicate()[0]
|
||||
if p.returncode == 0:
|
||||
return result.split()[0][1:].replace('-', '.')
|
||||
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
||||
if '-' in result: # not a tagged version
|
||||
real_number, commit_count, commit_hash = result.split('-', 2)
|
||||
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
|
||||
else:
|
||||
version = result
|
||||
return version
|
||||
else:
|
||||
return '0.0.0-%s' % len(
|
||||
subprocess.check_output(
|
||||
['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return '0.0.0'
|
||||
return '0.0.post%s' % len(
|
||||
subprocess.check_output(
|
||||
['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return '0.0'
|
||||
|
||||
README = file(os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'README')).read()
|
||||
|
||||
setup(name='authentic2-auth-fc',
|
||||
version=get_version(),
|
||||
license='AGPLv3',
|
||||
description='Authentic2 FranceConnect plugin',
|
||||
long_description=README,
|
||||
author="Entr'ouvert",
|
||||
url='https://repos.entrouvert.org/authentic2-auth-fc.git',
|
||||
author_email="info@entrouvert.com",
|
||||
packages=find_packages('src'),
|
||||
package_dir={
|
||||
'': 'src',
|
||||
},
|
||||
package_data={
|
||||
'authentic2_auth_fc': [
|
||||
'templates/authentic2_auth_fc/*.html',
|
||||
'static/authentic2_auth_fc/css/*.css',
|
||||
'static/authentic2_auth_fc/js/*.js',
|
||||
'static/authentic2_auth_fc/img/*.png',
|
||||
'static/authentic2_auth_fc/img/*.svg',
|
||||
'locale/fr/LC_MESSAGES/django.po',
|
||||
'locale/fr/LC_MESSAGES/django.mo',
|
||||
'*.json',
|
||||
],
|
||||
},
|
||||
install_requires=[
|
||||
'authentic2',
|
||||
'requests>2.11',
|
||||
'requests-oauthlib',
|
||||
setup(
|
||||
name='authentic2-auth-fc',
|
||||
version=get_version(),
|
||||
license='AGPLv3',
|
||||
description='Authentic2 FranceConnect plugin',
|
||||
long_description=README,
|
||||
author="Entr'ouvert",
|
||||
url='https://repos.entrouvert.org/authentic2-auth-fc.git',
|
||||
author_email="info@entrouvert.com",
|
||||
packages=find_packages('src'),
|
||||
package_dir={
|
||||
'': 'src',
|
||||
},
|
||||
package_data={
|
||||
'authentic2_auth_fc': [
|
||||
'templates/authentic2_auth_fc/*.html',
|
||||
'static/authentic2_auth_fc/css/*.css',
|
||||
'static/authentic2_auth_fc/js/*.js',
|
||||
'static/authentic2_auth_fc/img/*.png',
|
||||
'static/authentic2_auth_fc/img/*.svg',
|
||||
'locale/fr/LC_MESSAGES/django.po',
|
||||
'locale/fr/LC_MESSAGES/django.mo',
|
||||
'*.json',
|
||||
],
|
||||
entry_points={
|
||||
'authentic2.plugin': [
|
||||
'authentic2-auth-fc = authentic2_auth_fc:Plugin',
|
||||
],
|
||||
},
|
||||
cmdclass={
|
||||
'build': build,
|
||||
'install_lib': install_lib,
|
||||
'compile_translations': compile_translations,
|
||||
'sdist': eo_sdist},
|
||||
zip_safe=False,
|
||||
},
|
||||
install_requires=[
|
||||
'authentic2',
|
||||
'requests>2.11',
|
||||
'requests-oauthlib',
|
||||
],
|
||||
entry_points={
|
||||
'authentic2.plugin': [
|
||||
'authentic2-auth-fc = authentic2_auth_fc:Plugin',
|
||||
],
|
||||
},
|
||||
cmdclass={
|
||||
'build': build,
|
||||
'install_lib': install_lib,
|
||||
'compile_translations': compile_translations,
|
||||
'sdist': eo_sdist},
|
||||
zip_safe=False,
|
||||
)
|
||||
|
|
|
@ -30,11 +30,11 @@ from authentic2_auth_oidc.utils import parse_timestamp
|
|||
from . import app_settings
|
||||
|
||||
|
||||
def base64url_decode(input):
|
||||
rem = len(input) % 4
|
||||
def base64url_decode(encoded):
|
||||
rem = len(encoded) % 4
|
||||
if rem > 0:
|
||||
input += b'=' * (4 - rem)
|
||||
return base64.urlsafe_b64decode(input)
|
||||
encoded += b'=' * (4 - rem)
|
||||
return base64.urlsafe_b64decode(encoded)
|
||||
|
||||
|
||||
def parse_id_token(id_token, client_id=None, client_secret=None):
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
# authentic2-auth-fc - authentic2 authentication for FranceConnect
|
||||
# Copyright (C) 2019 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
LANGUAGE_CODE = 'en'
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# authentic2-auth-fc - authentic2 authentication for FranceConnect
|
||||
# Copyright (C) 2019 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from authentic2_auth_fc.models import FcAccount
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# authentic2-auth-fc - authentic2 authentication for FranceConnect
|
||||
# Copyright (C) 2019 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import re
|
||||
import urlparse
|
||||
|
|
Reference in New Issue