mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Update old utils paths references to use new paths
This commit is contained in:
parent
94c2a12be6
commit
3416e398c6
3 changed files with 15 additions and 16 deletions
|
@ -29,16 +29,16 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
DEFAULT_ENDING = salt.utils.to_bytes(os.linesep)
|
||||
DEFAULT_ENDING = salt.utils.stringutils.to_bytes(os.linesep)
|
||||
|
||||
|
||||
def trim_line_end(line):
|
||||
'''
|
||||
Remove CRLF or LF from the end of line.
|
||||
'''
|
||||
if line[-2:] == salt.utils.to_bytes('\r\n'):
|
||||
if line[-2:] == salt.utils.stringutils.to_bytes('\r\n'):
|
||||
return line[:-2]
|
||||
elif line[-1:] == salt.utils.to_bytes('\n'):
|
||||
elif line[-1:] == salt.utils.stringutils.to_bytes('\n'):
|
||||
return line[:-1]
|
||||
raise Exception("Invalid line ending")
|
||||
|
||||
|
@ -49,8 +49,8 @@ def reline(source, dest, force=False, ending=DEFAULT_ENDING):
|
|||
'''
|
||||
fp, tmp = tempfile.mkstemp()
|
||||
os.close(fp)
|
||||
with salt.utils.fopen(tmp, 'wb') as tmp_fd:
|
||||
with salt.utils.fopen(source, 'rb') as fd:
|
||||
with salt.utils.files.fopen(tmp, 'wb') as tmp_fd:
|
||||
with salt.utils.files.fopen(source, 'rb') as fd:
|
||||
lines = fd.readlines()
|
||||
for line in lines:
|
||||
line_noend = trim_line_end(line)
|
||||
|
|
|
@ -64,8 +64,8 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
|||
cls.test_symlink_list_file_roots = None
|
||||
cls.tmp_dir = tempfile.mkdtemp(dir=TMP)
|
||||
full_path_to_file = os.path.join(FILES, 'file', 'base', 'testfile')
|
||||
with salt.utils.fopen(full_path_to_file, 'rb') as s_fp:
|
||||
with salt.utils.fopen(os.path.join(cls.tmp_dir, 'testfile'), 'wb') as d_fp:
|
||||
with salt.utils.files.fopen(full_path_to_file, 'rb') as s_fp:
|
||||
with salt.utils.files.fopen(os.path.join(cls.tmp_dir, 'testfile'), 'wb') as d_fp:
|
||||
for line in s_fp:
|
||||
d_fp.write(
|
||||
line.rstrip(b'\n').rstrip(b'\r') + os.linesep.encode('utf-8')
|
||||
|
@ -81,7 +81,7 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
|||
salt.utils.files.rm_rf(cls.test_symlink_list_file_roots['base'][0])
|
||||
except OSError:
|
||||
pass
|
||||
salt.utils.rm_rf(cls.tmp_dir)
|
||||
salt.utils.files.rm_rf(cls.tmp_dir)
|
||||
|
||||
def tearDown(self):
|
||||
del self.opts
|
||||
|
|
|
@ -20,8 +20,6 @@ from tests.support.paths import TMP_CONF_DIR
|
|||
# Import Salt libs
|
||||
import salt.config
|
||||
import salt.loader
|
||||
import salt.utils.files
|
||||
import salt.utils.yaml
|
||||
from salt.exceptions import SaltRenderError
|
||||
|
||||
from salt.ext import six
|
||||
|
@ -41,6 +39,7 @@ from salt.utils.templates import JINJA, render_jinja_tmpl
|
|||
import salt.utils.dateutils # pylint: disable=unused-import
|
||||
import salt.utils.files
|
||||
import salt.utils.stringutils
|
||||
import salt.utils.yaml
|
||||
|
||||
# Import 3rd party libs
|
||||
try:
|
||||
|
@ -50,7 +49,7 @@ except ImportError:
|
|||
HAS_TIMELIB = False
|
||||
|
||||
TEMPLATES_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
BLINESEP = salt.utils.to_bytes(os.linesep)
|
||||
BLINESEP = salt.utils.stringutils.to_bytes(os.linesep)
|
||||
|
||||
|
||||
class MockFileClient(object):
|
||||
|
@ -75,10 +74,10 @@ def _setup_test_dir(src_dir, test_dir):
|
|||
os.makedirs(test_dir)
|
||||
salt.utils.files.recursive_copy(src_dir, test_dir)
|
||||
filename = os.path.join(test_dir, 'non_ascii')
|
||||
with salt.utils.fopen(filename, 'wb') as fp:
|
||||
with salt.utils.files.fopen(filename, 'wb') as fp:
|
||||
fp.write(b'Assun\xc3\xa7\xc3\xa3o' + BLINESEP)
|
||||
filename = os.path.join(test_dir, 'hello_simple')
|
||||
with salt.utils.fopen(filename, 'wb') as fp:
|
||||
with salt.utils.files.fopen(filename, 'wb') as fp:
|
||||
fp.write(b'world' + BLINESEP)
|
||||
filename = os.path.join(test_dir, 'hello_import')
|
||||
lines = [
|
||||
|
@ -86,7 +85,7 @@ def _setup_test_dir(src_dir, test_dir):
|
|||
r"{% from 'macro' import mymacro -%}",
|
||||
r"{{ mymacro('Hey') ~ mymacro(a|default('a'), b|default('b')) }}",
|
||||
]
|
||||
with salt.utils.fopen(filename, 'wb') as fp:
|
||||
with salt.utils.files.fopen(filename, 'wb') as fp:
|
||||
for line in lines:
|
||||
fp.write(line.encode('utf-8') + BLINESEP)
|
||||
|
||||
|
@ -112,7 +111,7 @@ class TestSaltCacheLoader(TestCase):
|
|||
super(TestSaltCacheLoader, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
salt.utils.rm_rf(self.TEMPDIR)
|
||||
salt.utils.files.rm_rf(self.TEMPDIR)
|
||||
|
||||
def test_searchpath(self):
|
||||
'''
|
||||
|
@ -222,7 +221,7 @@ class TestGetTemplate(TestCase):
|
|||
super(TestGetTemplate, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
salt.utils.rm_rf(self.TEMPDIR)
|
||||
salt.utils.files.rm_rf(self.TEMPDIR)
|
||||
|
||||
def test_fallback(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue