Windows: Fix usage of pkgrepo state

`pkgrepo.py` contains this line:

```
from salt.modules.aptpkg import _strip_uri
```

However, `salt.modules.aptpkg` is just not importable on Windows.
Instead of trying to make this module importable on Windows (which
clearly isn't the intent of the module), placed a copy of `_strip_uri`
into `pkgrepo.py` as this is a small function.

Signed-off-by: Sergey Kizunov <sergey.kizunov@ni.com>
This commit is contained in:
Sergey Kizunov 2017-10-12 17:39:17 -05:00
parent e38f313ac0
commit f54c7a6f01
No known key found for this signature in database
GPG key ID: 9CEE55A1DE138AAB

View file

@ -92,7 +92,7 @@ import sys
# Import salt libs
from salt.exceptions import CommandExecutionError, SaltInvocationError
from salt.modules.aptpkg import _strip_uri
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin
from salt.state import STATE_INTERNAL_KEYWORDS as _STATE_INTERNAL_KEYWORDS
import salt.utils
import salt.utils.pkg.deb
@ -106,6 +106,18 @@ def __virtual__():
return 'pkg.mod_repo' in __salt__
def _strip_uri(repo):
'''
Remove the trailing slash from the URI in a repo definition
'''
splits = repo.split()
for idx in range(len(splits)):
if any(splits[idx].startswith(x)
for x in ('http://', 'https://', 'ftp://')):
splits[idx] = splits[idx].rstrip('/')
return ' '.join(splits)
def managed(name, ppa=None, **kwargs):
'''
This state manages software package repositories. Currently, :mod:`yum