Skip to content

Commit

Permalink
Resolve base pep8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Scopenco committed Oct 23, 2016
1 parent 3c87da7 commit 6993e27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
12 changes: 6 additions & 6 deletions artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -753,7 +755,6 @@ def get_properties(self, pathobj):

return json.loads(text)['properties']


def set_properties(self, pathobj, props, recursive):
"""
Set artifact properties
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion int_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
art_password = config.get("artifactory", "password")
art_auth = (art_username, art_password)


class ArtifactoryPathTest(unittest.TestCase):
cls = artifactory.ArtifactoryPath

Expand Down Expand Up @@ -159,7 +160,6 @@ def test_deploy(self):
p.unlink()
p2.unlink()


def test_deploy_file(self):
P = self.cls

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 6 additions & 9 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,27 @@ 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

check(['.txt'],
('', '', ['.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):
Expand All @@ -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")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 6993e27

Please sign in to comment.