Skip to content

Commit

Permalink
Blacken changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed May 4, 2020
1 parent 5133f0d commit c0078a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
15 changes: 11 additions & 4 deletions salt/modules/aptpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,19 +1646,26 @@ def list_repo_pkgs(*args, **kwargs): # pylint: disable=unused-import


def _skip_source(source):
'''
"""
Decide to skip source or not.
:param source:
:return:
'''
"""
if source.invalid:
if source.uri and source.type and source.type in ("deb", "deb-src", "rpm", "rpm-src"):
if (
source.uri
and source.type
and source.type in ("deb", "deb-src", "rpm", "rpm-src")
):
pieces = source.mysplit(source.line)
if pieces[1].strip()[0] == "[":
options = pieces.pop(1).strip("[]").split()
if len(options) > 0:
log.debug("Source %s will be included although is marked invalid", source.uri)
log.debug(
"Source %s will be included although is marked invalid",
source.uri,
)
return False
return True
else:
Expand Down
22 changes: 11 additions & 11 deletions tests/unit/modules/test_aptpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,34 +610,34 @@ def test_list_downloaded(self):
self.assertDictEqual(list_downloaded, DOWNLOADED_RET)

def test__skip_source(self):
'''
"""
Test __skip_source.
:return:
'''
"""
# Valid source
source_type = 'deb'
source_uri = 'http://cdn-aws.deb.debian.org/debian'
source_line = 'deb http://cdn-aws.deb.debian.org/debian stretch main\n'
source_type = "deb"
source_uri = "http://cdn-aws.deb.debian.org/debian"
source_line = "deb http://cdn-aws.deb.debian.org/debian stretch main\n"

mock_source = MockSourceEntry(source_uri, source_type, source_line, False)

ret = aptpkg._skip_source(mock_source)
self.assertFalse(ret)

# Invalid source type
source_type = 'ded'
source_uri = 'http://cdn-aws.deb.debian.org/debian'
source_line = 'deb http://cdn-aws.deb.debian.org/debian stretch main\n'
source_type = "ded"
source_uri = "http://cdn-aws.deb.debian.org/debian"
source_line = "deb http://cdn-aws.deb.debian.org/debian stretch main\n"

mock_source = MockSourceEntry(source_uri, source_type, source_line, True)

ret = aptpkg._skip_source(mock_source)
self.assertTrue(ret)

# Invalid source type , not skipped
source_type = 'deb'
source_uri = 'http://cdn-aws.deb.debian.org/debian'
source_line = 'deb [http://cdn-aws.deb.debian.org/debian] stretch main\n'
source_type = "deb"
source_uri = "http://cdn-aws.deb.debian.org/debian"
source_line = "deb [http://cdn-aws.deb.debian.org/debian] stretch main\n"

mock_source = MockSourceEntry(source_uri, source_type, source_line, True)

Expand Down

0 comments on commit c0078a5

Please sign in to comment.