Fix pylint errors 'unused variable'

partially blueprint reduce-pylint-warnings
Change-Id: Iaf0b4e919474db513fe18110f8bf9404df2fb5dd
This commit is contained in:
Nikolay Starodubtsev 2015-09-03 14:28:11 +03:00 committed by Victor Ryzhenkin
parent b1fc727e73
commit a1b34c611e
13 changed files with 45 additions and 47 deletions

View File

@ -93,7 +93,7 @@ class Controller(object):
return None return None
def list(self, req): def list(self, req):
user, passwd, keystone = self._check_auth(req) user, _, keystone = self._check_auth(req)
# Once we get here we were authorized by keystone # Once we get here we were authorized by keystone
token = keystone.auth_token token = keystone.auth_token
@ -144,7 +144,7 @@ class Controller(object):
# Now as we have all parameters we can try to auth user in actual # Now as we have all parameters we can try to auth user in actual
# tenant # tenant
user, passwd, keystone = self._check_auth(req, tenant) user, _, keystone = self._check_auth(req, tenant)
# Once we get here we were authorized by keystone # Once we get here we were authorized by keystone
token = keystone.auth_token token = keystone.auth_token
m_cli = muranoclient(token) m_cli = muranoclient(token)
@ -198,7 +198,7 @@ class Controller(object):
service_id = service.service_id service_id = service.service_id
environment_id = service.environment_id environment_id = service.environment_id
tenant = service.tenant tenant = service.tenant
user, passwd, keystone = self._check_auth(req, tenant) _, _, keystone = self._check_auth(req, tenant)
# Once we get here we were authorized by keystone # Once we get here we were authorized by keystone
token = keystone.auth_token token = keystone.auth_token
m_cli = muranoclient(token) m_cli = muranoclient(token)
@ -227,7 +227,7 @@ class Controller(object):
service_id = db_service.service_id service_id = db_service.service_id
environment_id = db_service.environment_id environment_id = db_service.environment_id
tenant = db_service.tenant tenant = db_service.tenant
user, passwd, keystone = self._check_auth(req, tenant) _, _, keystone = self._check_auth(req, tenant)
# Once we get here we were authorized by keystone # Once we get here we were authorized by keystone
token = keystone.auth_token token = keystone.auth_token
m_cli = muranoclient(token) m_cli = muranoclient(token)

View File

@ -200,7 +200,7 @@ def build_entity_map(value):
if isinstance(value, types.DictionaryType): if isinstance(value, types.DictionaryType):
if '?' in value and 'id' in value['?']: if '?' in value and 'id' in value['?']:
id_map[value['?']['id']] = value id_map[value['?']['id']] = value
for k, v in value.iteritems(): for v in value.itervalues():
build_entity_map_recursive(v, id_map) build_entity_map_recursive(v, id_map)
if isinstance(value, types.ListType): if isinstance(value, types.ListType):
for item in value: for item in value:

View File

@ -58,7 +58,7 @@ class MuranoPlException(Exception):
result = MuranoPlException( result = MuranoPlException(
names, str(exception), stacktrace) names, str(exception), stacktrace)
exc_type, exc_value, exc_traceback = sys.exc_info() _, _, exc_traceback = sys.exc_info()
result.original_exception = exception result.original_exception = exception
result.original_traceback = exc_traceback result.original_traceback = exc_traceback
return result return result

View File

@ -180,7 +180,7 @@ class RepeatMacro(expressions.DslExpression):
def execute(self, context): def execute(self, context):
count = helpers.evaluate(self._count, context) count = helpers.evaluate(self._count, context)
for t in range(0, count): for _ in range(0, count):
try: try:
self._code.execute(context) self._code.execute(context)
except exceptions.BreakException: except exceptions.BreakException:
@ -214,7 +214,7 @@ class SwitchMacro(expressions.DslExpression):
raise exceptions.DslSyntaxError( raise exceptions.DslSyntaxError(
'Switch value must be of dictionary type') 'Switch value must be of dictionary type')
self._switch = Switch self._switch = Switch
for key, value in self._switch.iteritems(): for key in self._switch.iterkeys():
if not isinstance(key, (yaql_expression.YaqlExpression, if not isinstance(key, (yaql_expression.YaqlExpression,
types.BooleanType)): types.BooleanType)):
raise exceptions.DslSyntaxError( raise exceptions.DslSyntaxError(

View File

@ -275,7 +275,7 @@ class MuranoClass(dsl_types.MuranoClass):
while i < len(versions_list): while i < len(versions_list):
package1, requirement1 = versions_list[i] package1, requirement1 = versions_list[i]
dst_package = None dst_package = None
for j, (package2, requirement2) in enumerate(versions_list): for j, (package2, _) in enumerate(versions_list):
if i == j: if i == j:
continue continue
if package2.version in requirement1 and ( if package2.version in requirement1 and (

View File

@ -172,7 +172,7 @@ class HotPackage(package_base.PackageBase):
@staticmethod @staticmethod
def _translate_outputs(hot): def _translate_outputs(hot):
result = {} result = {}
for key, value in (hot.get('outputs') or {}).items(): for key in (hot.get('outputs') or {}).keys():
result[key] = { result[key] = {
"Contract": YAQL("$.string()"), "Contract": YAQL("$.string()"),
"Usage": "Out" "Usage": "Out"
@ -259,7 +259,7 @@ class HotPackage(package_base.PackageBase):
hot_env = YAQL("$.hotEnvironment") hot_env = YAQL("$.hotEnvironment")
copy_outputs = [] copy_outputs = []
for key, value in (hot.get('outputs') or {}).items(): for key in (hot.get('outputs') or {}).keys():
copy_outputs.append({YAQL('$.' + key): YAQL('$outputs.' + key)}) copy_outputs.append({YAQL('$.' + key): YAQL('$outputs.' + key)})
deploy = [ deploy = [

View File

@ -111,7 +111,7 @@ class Package(object):
def _zip_dir(path, zip_file): def _zip_dir(path, zip_file):
for root, dirs, files in os.walk(path): for root, _, files in os.walk(path):
for f in files: for f in files:
abs_path = os.path.join(root, f) abs_path = os.path.join(root, f)
relative_path = os.path.relpath(abs_path, path) relative_path = os.path.relpath(abs_path, path)

View File

@ -106,8 +106,7 @@ class MuranoClient(rest_client.RestClient):
def deploy_session(self, environment_id, session_id): def deploy_session(self, environment_id, session_id):
post_body = None post_body = None
url = 'v1/environments/{0}/sessions/{1}/deploy' url = 'v1/environments/{0}/sessions/{1}/deploy'
resp, body = self.post(url.format(environment_id, session_id), resp, _ = self.post(url.format(environment_id, session_id), post_body)
post_body)
return resp return resp
@ -283,13 +282,13 @@ class MuranoClient(rest_client.RestClient):
def delete_app_in_env_template(self, env_template_name): def delete_app_in_env_template(self, env_template_name):
"""Delete an application in an environment template.""" """Delete an application in an environment template."""
resp, body = self.delete('v1/templates/{0}/services/{1}'. resp, _ = self.delete('v1/templates/{0}/services/{1}'.
format(env_template_name, 'ID')) format(env_template_name, 'ID'))
return resp return resp
def delete_env_template(self, env_template_id): def delete_env_template(self, env_template_id):
"""Check the deletion of an environment template.""" """Check the deletion of an environment template."""
resp, body = self.delete('v1/templates/{0}'.format(env_template_id)) resp, _ = self.delete('v1/templates/{0}'.format(env_template_id))
return resp return resp
def get_env_template(self, env_template_id): def get_env_template(self, env_template_id):

View File

@ -153,7 +153,7 @@ class TestEnvTemplate(base.TestCase):
@attr(type='negative') @attr(type='negative')
def test_double_delete_env_template(self): def test_double_delete_env_template(self):
"""Check the deletion of an wrong environment template request.""" """Check the deletion of an wrong environment template request."""
resp, env_template = self.client.create_env_template('test_env_temp') _, env_template = self.client.create_env_template('test_env_temp')
self.client.delete_env_template(env_template['id']) self.client.delete_env_template(env_template['id'])
@ -165,7 +165,7 @@ class TestEnvTemplate(base.TestCase):
@attr(type='negative') @attr(type='negative')
def test_get_deleted_env_template(self): def test_get_deleted_env_template(self):
"""Check the deletion of an wrong environment template request.""" """Check the deletion of an wrong environment template request."""
resp, env_template = self.client.create_env_template('test_env_temp') _, env_template = self.client.create_env_template('test_env_temp')
self.client.delete_env_template(env_template['id']) self.client.delete_env_template(env_template['id'])

View File

@ -80,7 +80,7 @@ class TestCaseShell(testtools.TestCase):
return (stdout, stderr) return (stdout, stderr)
def test_help(self): def test_help(self):
stdout, stderr = self.shell('--help') stdout, _ = self.shell('--help')
usage = """usage: murano-test-runner [-h] [-v] [--config-file CONFIG_FILE] usage = """usage: murano-test-runner [-h] [-v] [--config-file CONFIG_FILE]
[--os-auth-url OS_AUTH_URL] [--os-auth-url OS_AUTH_URL]
[--os-username OS_USERNAME] [--os-username OS_USERNAME]
@ -96,13 +96,12 @@ class TestCaseShell(testtools.TestCase):
importutils.import_module('keystonemiddleware.auth_token') importutils.import_module('keystonemiddleware.auth_token')
self.override_config('admin_user', 'new_value', 'keystone_authtoken') self.override_config('admin_user', 'new_value', 'keystone_authtoken')
stdout, stderr = self.shell( self.shell('-p io.murano.test.MyTest1 io.murano.test.MyTest2')
'-p io.murano.test.MyTest1 io.murano.test.MyTest2')
mock_client.assert_has_calls([mock.call(**self.auth_params)]) mock_client.assert_has_calls([mock.call(**self.auth_params)])
def test_package_all_tests(self): def test_package_all_tests(self):
stdout, stderr = self.shell('-p io.murano.test.MyTest1') _, stderr = self.shell('-p io.murano.test.MyTest1')
# NOTE(efedorova): May be, there is a problem with test-runner, since # NOTE(efedorova): May be, there is a problem with test-runner, since
# all logs are passed to stderr # all logs are passed to stderr
self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr) self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -112,7 +111,7 @@ class TestCaseShell(testtools.TestCase):
self.assertNotIn('thisIsNotAtestMethod', stderr) self.assertNotIn('thisIsNotAtestMethod', stderr)
def test_package_by_class(self): def test_package_by_class(self):
stdout, stderr = self.shell( _, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest2') '-p io.murano.test.MyTest1 io.murano.test.MyTest2')
self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr) self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -121,7 +120,7 @@ class TestCaseShell(testtools.TestCase):
self.assertIn('io.murano.test.MyTest2.testSimple2.....OK', stderr) self.assertIn('io.murano.test.MyTest2.testSimple2.....OK', stderr)
def test_package_by_test_name(self): def test_package_by_test_name(self):
stdout, stderr = self.shell( _, stderr = self.shell(
'-p io.murano.test.MyTest1 testSimple1') '-p io.murano.test.MyTest1 testSimple1')
self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr) self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -130,7 +129,7 @@ class TestCaseShell(testtools.TestCase):
self.assertNotIn('io.murano.test.MyTest2.testSimple2.....OK', stderr) self.assertNotIn('io.murano.test.MyTest2.testSimple2.....OK', stderr)
def test_package_by_test_and_class_name(self): def test_package_by_test_and_class_name(self):
stdout, stderr = self.shell( _, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest2.testSimple1') '-p io.murano.test.MyTest1 io.murano.test.MyTest2.testSimple1')
self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr) self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -139,17 +138,17 @@ class TestCaseShell(testtools.TestCase):
self.assertNotIn('io.murano.test.MyTest2.testSimple2.....OK', stderr) self.assertNotIn('io.murano.test.MyTest2.testSimple2.....OK', stderr)
def test_service_methods(self): def test_service_methods(self):
stdout, stderr = self.shell( _, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest1.testSimple1') '-p io.murano.test.MyTest1 io.murano.test.MyTest1.testSimple1')
self.assertIn('Executing: io.murano.test.MyTest1.setUp', stderr) self.assertIn('Executing: io.murano.test.MyTest1.setUp', stderr)
self.assertIn('Executing: io.murano.test.MyTest1.tearDown', stderr) self.assertIn('Executing: io.murano.test.MyTest1.tearDown', stderr)
def test_package_is_not_provided(self): def test_package_is_not_provided(self):
stdout, stderr = self.shell(exitcode=1) _, stderr = self.shell(exitcode=1)
self.assertEqual(stderr, 'ERROR: Package name is required parameter.') self.assertEqual(stderr, 'ERROR: Package name is required parameter.')
def test_wrong_parent(self): def test_wrong_parent(self):
stdout, stderr = self.shell( _, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest3', exitcode=1) '-p io.murano.test.MyTest1 io.murano.test.MyTest3', exitcode=1)
self.assertIn('Class io.murano.test.MyTest3 is not inherited from' self.assertIn('Class io.murano.test.MyTest3 is not inherited from'
' io.murano.test.TestFixture. Skipping it.', stderr) ' io.murano.test.TestFixture. Skipping it.', stderr)

View File

@ -54,7 +54,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'get_package': ''} {'get_package': ''}
) )
for i in range(7): for dummy in range(7):
self.expect_policy_check('get_package') self.expect_policy_check('get_package')
pkg = self._add_pkg('test_tenant', type='Library') pkg = self._add_pkg('test_tenant', type='Library')
@ -106,7 +106,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'get_package': ''} {'get_package': ''}
) )
for i in range(7): for dummy in range(7):
self.expect_policy_check('get_package') self.expect_policy_check('get_package')
pkg = self._add_pkg('test_tenant', type='Library') pkg = self._add_pkg('test_tenant', type='Library')
@ -156,7 +156,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'get_package': ''} {'get_package': ''}
) )
for i in range(9): for dummy in range(9):
self.expect_policy_check('get_package') self.expect_policy_check('get_package')
result = self.controller.search(self._get('/v1/catalog/packages/')) result = self.controller.search(self._get('/v1/catalog/packages/'))
@ -238,7 +238,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'get_package': '@'} {'get_package': '@'}
) )
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -261,7 +261,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'download_package': '@'} {'download_package': '@'}
) )
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -278,7 +278,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
def test_download_package_negative(self): def test_download_package_negative(self):
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -295,7 +295,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'get_package': '@'} {'get_package': '@'}
) )
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -311,7 +311,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.assertEqual(200, result.status_code) self.assertEqual(200, result.status_code)
def test_get_ui_definition_negative(self): def test_get_ui_definition_negative(self):
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -328,7 +328,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules( self._set_policy_rules(
{'get_package': '@'} {'get_package': '@'}
) )
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -345,7 +345,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.assertEqual(package['logo'], result.body) self.assertEqual(package['logo'], result.body)
def test_get_logo_negative(self): def test_get_logo_negative(self):
package_from_dir, package = self._test_package() _, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '') saved_package = db_catalog_api.package_upload(package, '')
@ -375,7 +375,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
file_obj_str = cStringIO.StringIO("This is some dummy data") file_obj_str = cStringIO.StringIO("This is some dummy data")
file_obj = mock.MagicMock(cgi.FieldStorage) file_obj = mock.MagicMock(cgi.FieldStorage)
file_obj.file = file_obj_str file_obj.file = file_obj_str
package_from_dir, package_metadata = self._test_package() package_from_dir, _ = self._test_package()
body = '''\ body = '''\

View File

@ -64,7 +64,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
def test_order_by(self): def test_order_by(self):
pkgs = [] pkgs = []
for i in range(10): for dummy in range(10):
package = api.package_upload(self._stub_package( package = api.package_upload(self._stub_package(
name=str(uuid.uuid4()), name=str(uuid.uuid4()),
fully_qualified_name=str(uuid.uuid4())), self.tenant_id) fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -86,12 +86,12 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
def test_order_by_compound(self): def test_order_by_compound(self):
pkgs_a, pkgs_z = [], [] pkgs_a, pkgs_z = [], []
for i in range(5): for _ in range(5):
package = api.package_upload(self._stub_package( package = api.package_upload(self._stub_package(
name='z', name='z',
fully_qualified_name=str(uuid.uuid4())), self.tenant_id) fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
pkgs_z.append(package) pkgs_z.append(package)
for i in range(5): for _ in range(5):
package = api.package_upload(self._stub_package( package = api.package_upload(self._stub_package(
name='a', name='a',
fully_qualified_name=str(uuid.uuid4())), self.tenant_id) fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -113,7 +113,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
checking that package order is correct. checking that package order is correct.
""" """
pkgs = [] pkgs = []
for i in range(10): for dummy in range(10):
package = api.package_upload(self._stub_package( package = api.package_upload(self._stub_package(
name=str(uuid.uuid4()), name=str(uuid.uuid4()),
fully_qualified_name=str(uuid.uuid4())), self.tenant_id) fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -154,7 +154,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
""" """
pkgs = [] pkgs = []
for i in range(10): for dummy in range(10):
package = api.package_upload(self._stub_package( package = api.package_upload(self._stub_package(
name=str(uuid.uuid4()), name=str(uuid.uuid4()),
fully_qualified_name=str(uuid.uuid4())), self.tenant_id) fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -188,7 +188,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
""" """
# TODO(kzaitsev): fix https://bugs.launchpad.net/murano/+bug/1448782 # TODO(kzaitsev): fix https://bugs.launchpad.net/murano/+bug/1448782
for i in range(10): for dummy in range(10):
api.package_upload(self._stub_package( api.package_upload(self._stub_package(
fully_qualified_name=str(uuid.uuid4())), self.tenant_id) fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
res = api.package_search({}, self.context, limit=4) res = api.package_search({}, self.context, limit=4)

View File

@ -75,7 +75,7 @@ class TestPackageLoader(package_loader.MuranoPackageLoader):
def _build_index(self, directory): def _build_index(self, directory):
yamls = [os.path.join(dirpath, f) yamls = [os.path.join(dirpath, f)
for dirpath, dirnames, files in os.walk(directory) for dirpath, _, files in os.walk(directory)
for f in fnmatch.filter(files, '*.yaml')] for f in fnmatch.filter(files, '*.yaml')]
for class_def_file in yamls: for class_def_file in yamls:
self._load_class(class_def_file) self._load_class(class_def_file)