Fixes some pep8 warning/errors.

- Using flake8 so a bit more than that.

Change-Id: I63fa21f7d3d02f96c0c56804fdd56da37c952d7d
This commit is contained in:
Chmouel Boudjnah 2012-05-24 16:14:35 +02:00
parent 33d107aa1d
commit bb2fbb7030
19 changed files with 20 additions and 28 deletions

View File

@ -15,9 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import sqlalchemy.exc
import webob.exc
from keystone import catalog
from keystone import config
from keystone import exception

View File

@ -178,4 +178,4 @@ class EndpointController(wsgi.Application):
def delete_endpoint(self, context, endpoint_id):
self.assert_admin(context)
endpoint_ref = self.catalog_api.delete_endpoint(context, endpoint_id)
self.catalog_api.delete_endpoint(context, endpoint_id)

View File

@ -16,7 +16,6 @@
import functools
from keystone import config
from keystone.common import utils

View File

@ -19,7 +19,6 @@
import json
import eventlet.db_pool
import sqlalchemy as sql
from sqlalchemy import types as sql_types
from sqlalchemy.exc import DisconnectionError

View File

@ -20,7 +20,6 @@
import os
import sys
import sqlalchemy
from migrate.versioning import api as versioning_api
from keystone import config

View File

@ -198,7 +198,6 @@ def ldap_check_password(password, hashed):
if password is None:
return False
password_utf8 = trunc_password(password).encode('utf-8')
h = passlib.hash.ldap_salted_sha1.encrypt(password_utf8)
return passlib.hash.ldap_salted_sha1.verify(password_utf8, hashed)

View File

@ -37,7 +37,8 @@ class Ec2(kvs.Base):
return credential
def delete_credential(self, credential_id):
old_credential = self.db.get('credential-%s' % credential_id)
# This will ensure credential-%s is here before deleting
self.db.get('credential-%s' % credential_id)
self.db.delete('credential-%s' % credential_id)
credential_list = set(self.db.get('credential_list', []))
credential_list.remove(credential_id)

View File

@ -15,7 +15,6 @@
# under the License.
from keystone.common import sql
from keystone.common.sql import migration
class Ec2Credential(sql.ModelBase, sql.DictBase):

View File

@ -100,7 +100,7 @@ class Identity(identity.Driver):
else:
metadata_ref = {}
return (_filter_user(user_ref), tenant_ref, metadata_ref)
return (_filter_user(user_ref), tenant_ref, metadata_ref)
def get_tenant(self, tenant_id):
return self.tenant.get(tenant_id)

View File

@ -581,7 +581,8 @@ class RoleController(wsgi.Application):
"""
self.assert_admin(context)
user_ref = self.identity_api.get_user(context, user_id)
# Ensure user exists by getting it first.
self.identity_api.get_user(context, user_id)
tenant_ids = self.identity_api.get_tenants_for_user(context, user_id)
o = []
for tenant_id in tenant_ids:

View File

@ -444,7 +444,7 @@ class AuthProtocol(object):
:return wsgi env variable name (ex. 'HTTP_X_AUTH_TOKEN')
"""
return 'HTTP_%s' % key.replace('-', '_').upper()
return 'HTTP_%s' % key.replace('-', '_').upper()
def _add_headers(self, env, headers):
"""Add http headers to environment."""

View File

@ -48,7 +48,6 @@ def canonicalize_emails(changelog, mapping):
# Get requirements from the first file that exists
def get_reqs_from_files(requirements_files):
reqs_in = []
for requirements_file in requirements_files:
if os.path.exists(requirements_file):
return open(requirements_file, 'r').read().split('\n')

View File

@ -80,7 +80,7 @@ def checkout_vendor(repo, rev):
# write out a modified time
with open(modcheck, 'w') as fd:
fd.write('1')
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
LOG.warning('Failed to checkout %s', repo)
cd(working_dir)
return revdir

2
run_tests.py Normal file → Executable file
View File

@ -56,9 +56,7 @@ To run a single test module:
"""
import gettext
import heapq
import logging
import os
import unittest
import sys

View File

@ -15,7 +15,6 @@
# under the License.
import subprocess
import nose.exc
from keystone import config
from keystone import test
@ -43,7 +42,7 @@ def delete_object(name):
def clear_live_database():
roles = ['keystone_admin']
groups = ['baz', 'bar', 'tenent4add', 'fake1', 'fake2']
users = ['foo', 'two', 'fake1', 'fake2','no_meta']
users = ['foo', 'two', 'fake1', 'fake2', 'no_meta']
roles = ['keystone_admin', 'useless']
for group in groups:

View File

@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import nose.exc
from keystone import config
from keystone import test
from keystone.common.ldap import fakeldap

View File

@ -114,7 +114,8 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.tenant_bar['id'],
{'extra': 'extra'})
self.identity_api.delete_user(user['id'])
metadata = self.identity_api.get_metadata(user['id'], self.tenant_bar['id'])
metadata = self.identity_api.get_metadata(user['id'],
self.tenant_bar['id'])
self.assertEquals(metadata, {})
def test_delete_tenant_with_metadata(self):
@ -126,9 +127,11 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.tenant_bar['id'],
{'extra': 'extra'})
self.identity_api.delete_tenant(self.tenant_bar['id'])
metadata = self.identity_api.get_metadata(user['id'], self.tenant_bar['id'])
metadata = self.identity_api.get_metadata(user['id'],
self.tenant_bar['id'])
self.assertEquals(metadata, {})
class SqlToken(test.TestCase, test_backend.TokenTests):
def setUp(self):
super(SqlToken, self).setUp()

View File

@ -30,25 +30,25 @@ class SetupTest(unittest.TestCase):
def test_str_dict_replace(self):
string = 'Johnnie T. Hozer'
mapping = {'T.': 'The'}
self.assertEqual('Johnnie The Hozer',
self.assertEqual('Johnnie The Hozer',
canonicalize_emails(string, mapping))
def test_mailmap_with_fullname(self):
with open(self.mailmap, 'w') as mm_fh:
mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n")
self.assertEqual({'<email@bar.com>' : '<email@foo.com>'},
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
parse_mailmap(self.mailmap))
def test_mailmap_with_firstname(self):
with open(self.mailmap, 'w') as mm_fh:
mm_fh.write("Foo <email@foo.com> Foo <email@bar.com>\n")
self.assertEqual({'<email@bar.com>' : '<email@foo.com>'},
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
parse_mailmap(self.mailmap))
def test_mailmap_with_noname(self):
with open(self.mailmap, 'w') as mm_fh:
mm_fh.write("<email@foo.com> <email@bar.com>\n")
self.assertEqual({'<email@bar.com>' : '<email@foo.com>'},
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
parse_mailmap(self.mailmap))
def tearDown(self):

View File

@ -26,6 +26,7 @@ from keystone.middleware import swift_auth
def setUpModule(self):
self.stubs = stubout.StubOutForTesting()
# Stub out swift_utils.get_logger. get_logger tries to configure
# syslogging to '/dev/log', which will fail on OS X.
def fake_get_logger(config, log_route=None):
@ -156,7 +157,7 @@ class TestAuthorize(unittest.TestCase):
exception=webob.exc.HTTPForbidden)
def test_authorize_succeeds_for_reseller_admin(self):
roles =[self.test_auth.reseller_admin_role]
roles = [self.test_auth.reseller_admin_role]
identity = self._get_identity(roles=roles)
req = self._check_authenticate(identity=identity)
self.assertTrue(req.environ.get('swift_owner'))