From 6993e276dde05172d5b5f6002eb77c4739b8a74c Mon Sep 17 00:00:00 2001 From: Andrei Scopenco Date: Sun, 23 Oct 2016 12:28:10 +0300 Subject: [PATCH] Resolve base pep8 warnings --- artifactory.py | 12 ++++++------ int_test.py | 2 +- setup.py | 1 + test.py | 15 ++++++--------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/artifactory.py b/artifactory.py index 93e9ddd..ba44a89 100755 --- a/artifactory.py +++ b/artifactory.py @@ -83,7 +83,6 @@ def read_config(config_path=default_config_path): verify = p.getboolean(section, 'verify') if p.has_option(section, 'verify') else True cert = p.get(section, 'cert') if p.has_option(section, 'cert') else None - result[section] = {'username': username, 'password': password, 'verify': verify, @@ -121,6 +120,7 @@ def without_http_prefix(url): return url[8:] return url + def get_base_url(config, url): """ Look through config and try to find best matching base for 'url' @@ -141,6 +141,7 @@ def get_base_url(config, url): if without_http_prefix(url).startswith(without_http_prefix(item)): return item + def get_config_entry(config, url): """ Look through config and try to find best matching entry for 'url' @@ -170,6 +171,7 @@ def get_global_config_entry(url): read_global_config() return get_config_entry(global_config, url) + def get_global_base_url(url): """ Look through global config and try to find best matching base for 'url' @@ -753,7 +755,6 @@ def get_properties(self, pathobj): return json.loads(text)['properties'] - def set_properties(self, pathobj, props, recursive): """ Set artifact properties @@ -762,7 +763,7 @@ def set_properties(self, pathobj, props, recursive): 'api/storage', str(pathobj.relative_to(pathobj.drive)).strip('/')]) - params = { 'properties': encode_properties(props) } + params = {'properties': encode_properties(props)} if not recursive: params['recursive'] = '0' @@ -778,7 +779,6 @@ def set_properties(self, pathobj, props, recursive): if code != 204: raise RuntimeError(text) - def del_properties(self, pathobj, props, recursive): """ Delete artifact properties @@ -790,7 +790,7 @@ def del_properties(self, pathobj, props, recursive): 'api/storage', str(pathobj.relative_to(pathobj.drive)).strip('/')]) - params = { 'properties': ','.join(sorted(props)) } + params = {'properties': ','.join(sorted(props))} if not recursive: params['recursive'] = '0' @@ -884,7 +884,7 @@ def __new__(cls, *args, **kwargs): return obj def _init(self, *args, **kwargs): - if not 'template' in kwargs: + if 'template' not in kwargs: kwargs['template'] = _FakePathTemplate(_artifactory_accessor) super(ArtifactoryPath, self)._init(*args, **kwargs) diff --git a/int_test.py b/int_test.py index 540b49d..16e36be 100755 --- a/int_test.py +++ b/int_test.py @@ -25,6 +25,7 @@ art_password = config.get("artifactory", "password") art_auth = (art_username, art_password) + class ArtifactoryPathTest(unittest.TestCase): cls = artifactory.ArtifactoryPath @@ -159,7 +160,6 @@ def test_deploy(self): p.unlink() p2.unlink() - def test_deploy_file(self): P = self.cls diff --git a/setup.py b/setup.py index 30c5458..f63921e 100755 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ except ImportError: from distutils.core import setup + # PyPi RST variant doesn't understand the 'code' tag. so replacing it # with a regular quote def rst_strip_code_tag(string): diff --git a/test.py b/test.py index 53b5850..3b12f0f 100755 --- a/test.py +++ b/test.py @@ -112,7 +112,6 @@ def test_splitroot_custom_root(self): check("https://custom/root/foo/baz", ('https://custom/root', '/foo/', 'baz')) - def test_parse_parts(self): check = self._check_parse_parts @@ -120,20 +119,20 @@ def test_parse_parts(self): ('', '', ['.txt'])) check(['http://b/artifactory/c/d.xml'], - ('http://b/artifactory', '/c/', - ['http://b/artifactory/c/', 'd.xml'])) + ('http://b/artifactory', '/c/', + ['http://b/artifactory/c/', 'd.xml'])) check(['http://example.com/artifactory/foo'], ('http://example.com/artifactory', '/foo/', - ['http://example.com/artifactory/foo/'])) + ['http://example.com/artifactory/foo/'])) check(['http://example.com/artifactory/foo/bar'], ('http://example.com/artifactory', '/foo/', - ['http://example.com/artifactory/foo/', 'bar'])) + ['http://example.com/artifactory/foo/', 'bar'])) check(['http://example.com/artifactory/foo/bar/artifactory'], ('http://example.com/artifactory', '/foo/', - ['http://example.com/artifactory/foo/', 'bar', 'artifactory'])) + ['http://example.com/artifactory/foo/', 'bar', 'artifactory'])) class PureArtifactoryPathTest(unittest.TestCase): @@ -148,7 +147,6 @@ def test_root(self): self.assertEqual(P('http://a/artifactory/').root, '') - def test_anchor(self): P = self.cls b = P("http://b/artifactory/c/d.xml") @@ -262,7 +260,6 @@ def test_listdir(self): a.rest_get = MM(return_value=(self.file_stat, 200)) - self.assertRaises(OSError, a.listdir, p) def test_mkdir(self): @@ -348,7 +345,7 @@ def test_artifactory_config(self): self.assertEqual(c['password'], 'ilikerandompasswords') self.assertEqual(c['verify'], False) self.assertEqual(c['cert'], - os.path.expanduser('~/path-to-cert')) + os.path.expanduser('~/path-to-cert')) c = artifactory.get_config_entry(cfg, 'http://bar.net/artifactory') self.assertEqual(c['username'], 'foo')