- exploit how 'iterkeys' is default iterator for dict

- use values()

- pep8
This commit is contained in:
L.C. Rees 2012-06-01 12:03:17 -06:00
parent 140e8781df
commit cdb5e89631
23 changed files with 125 additions and 120 deletions

View File

@ -62,10 +62,10 @@ class Master(object):
'--log-level',
dest='log_level',
default='warning',
choices=list(salt.log.LOG_LEVELS.keys()),
choices=list(salt.log.LOG_LEVELS),
help='Console log level. One of %s. For the logfile settings '
'see the config file. Default: \'%%default\'.' %
', '.join([repr(l) for l in salt.log.LOG_LEVELS.keys()])
', '.join([repr(l) for l in salt.log.LOG_LEVELS])
)
log_format = '%(asctime)s,%(msecs)03.0f [%(name)-15s][%(levelname)-8s] %(message)s'
options, args = parser.parse_args()
@ -153,10 +153,10 @@ class Minion(object):
'--log-level',
dest='log_level',
default='warning',
choices=list(salt.log.LOG_LEVELS.keys()),
choices=list(salt.log.LOG_LEVELS),
help='Console log level. One of %s. For the logfile settings '
'see the config file. Default: \'%%default\'.' %
', '.join([repr(l) for l in list(salt.log.LOG_LEVELS.keys())]))
', '.join([repr(l) for l in list(salt.log.LOG_LEVELS)]))
options, args = parser.parse_args()
log_format = '%(asctime)s,%(msecs)03.0f [%(name)-15s][%(levelname)-8s] %(message)s'
@ -272,10 +272,10 @@ class Syndic(object):
'--log-level',
dest='log_level',
default='warning',
choices=list(salt.log.LOG_LEVELS.keys()),
choices=list(salt.log.LOG_LEVELS),
help=('Console log level. One of %s. For the logfile settings '
'see the config file. Default: \'%%default\'.' %
', '.join([repr(l) for l in salt.log.LOG_LEVELS.keys()]))
', '.join([repr(l) for l in salt.log.LOG_LEVELS]))
)
options, args = parser.parse_args()

View File

@ -518,7 +518,7 @@ class LocalClient(Client):
if 'classes' in ndata:
if isinstance(ndata['classes'], dict):
ret[env] = list(ndata['classes'].keys())
ret[env] = list(ndata['classes'])
elif isinstance(ndata['classes'], list):
ret[env] = ndata['classes']
else:

View File

@ -453,7 +453,7 @@ class Loader(object):
'''
List the functions
'''
return sorted(funcs.keys())
return sorted(funcs)
def list_modules(self, funcs):
'''

View File

@ -482,7 +482,7 @@ class AESFuncs(object):
if 'classes' in ndata:
if isinstance(ndata['classes'], dict):
ret[env] = list(ndata['classes'].keys())
ret[env] = list(ndata['classes'])
elif isinstance(ndata['classes'], list):
ret[env] = ndata['classes']
else:

View File

@ -92,8 +92,9 @@ def list_aliases():
salt '*' aliases.list_aliases
'''
ret = {}
for (alias, target, comment) in __parse_aliases():
if not alias: continue
for alias, target, comment in __parse_aliases():
if not alias:
continue
ret[alias] = target
return ret

View File

@ -25,7 +25,7 @@ def _detect_os():
Apache commands and paths differ depending on packaging
'''
httpd = ('CentOS', 'Scientific', 'RedHat', 'Fedora', 'Arch')
apache2 = ('Ubuntu','Debian',)
apache2 = ('Ubuntu', 'Debian',)
if __grains__['os'] in httpd:
return 'apachectl'
elif __grains__['os'] in apache2:

View File

@ -8,6 +8,7 @@ import re
# Import Salt libs
import salt.utils
def __virtual__():
'''
Confirm this module is on a Debian based system

View File

@ -120,9 +120,9 @@ def _run(cmd,
if err:
err = err.rstrip()
ret['stdout'] = out
ret['stderr'] = err
ret['pid'] = proc.pid
ret['stdout'] = out
ret['stderr'] = err
ret['pid'] = proc.pid
ret['retcode'] = proc.returncode
return ret
@ -149,7 +149,7 @@ def run(cmd, cwd=None, runas=None, shell=DEFAULT_SHELL, env=()):
return out
def run_stdout(cmd, cwd=None, runas=None, shell=DEFAULT_SHELL, env=()):
def run_stdout(cmd, cwd=None, runas=None, shell=DEFAULT_SHELL, env=()):
'''
Execute a command, and only return the standard out

View File

@ -7,7 +7,7 @@ __grains__ = {}
# Change the default outputter to make it more readable
__outputter__ = {
'item' : 'txt',
'item': 'txt',
'items': 'yaml',
}
@ -33,6 +33,7 @@ def item(key=None):
'''
return __grains__.get(key, '')
def ls():
'''
Return a list of all available grains

View File

@ -467,10 +467,8 @@ def get_disks(name):
target = targets[0]
else:
continue
if 'dev' in list(target.attributes.keys()) \
and 'file' in list(source.attributes.keys()):
disks[target.getAttribute('dev')] = \
{'file': source.getAttribute('file')}
if 'dev' in list(target.attributes) and 'file' in list(source.attributes):
disks[target.getAttribute('dev')] = {'file': source.getAttribute('file')}
for dev in disks:
disks[dev].update(yaml.safe_load(subprocess.Popen('qemu-img info ' \
+ disks[dev]['file'],

View File

@ -34,7 +34,7 @@ def __virtual__():
'''
Only load this module if the mysql config is set
'''
if any(k.startswith('mysql.') for k in list(__opts__.keys())):
if any(k.startswith('mysql.') for k in list(__opts__):
if has_mysqldb:
return 'mysql'
return False

View File

@ -315,7 +315,7 @@ def set_auth_key_from_file(
newkey = {}
rval = ''
newkey = _validate_keys(lfile)
for k in newkey.keys():
for k in newkey:
rval += set_auth_key(
user,
k,

View File

@ -223,7 +223,7 @@ def get_nics(vm_):
# driver, source, and match can all have optional attributes
if re.match('(driver|source|address)', v_node.tagName):
temp = {}
for key in v_node.attributes.keys():
for key in v_node.attributes:
temp[key] = v_node.getAttribute(key)
nic[str(v_node.tagName)] = temp
# virtualport needs to be handled separately, to pick up the
@ -231,7 +231,7 @@ def get_nics(vm_):
if v_node.tagName == "virtualport":
temp = {}
temp['type'] = v_node.getAttribute('type')
for key in v_node.attributes.keys():
for key in v_node.attributes:
temp[key] = v_node.getAttribute(key)
nic['virtualport'] = temp
if 'mac' not in nic:
@ -275,7 +275,7 @@ def get_graphics(vm_):
for node in doc.getElementsByTagName("domain"):
g_nodes = node.getElementsByTagName("graphics")
for g_node in g_nodes:
for key in g_node.attributes.keys():
for key in g_node.attributes:
out[key] = g_node.getAttribute(key)
return out
@ -301,8 +301,7 @@ def get_disks(vm_):
target = targets[0]
else:
continue
if 'dev' in list(target.attributes.keys()) \
and 'file' in list(source.attributes.keys()):
if 'dev' in list(target.attributes) and 'file' in list(source.attributes):
disks[target.getAttribute('dev')] = {
'file': source.getAttribute('file')}
for dev in disks:

View File

@ -168,7 +168,7 @@ class TxtOutputter(Outputter):
def __call__(self, data, **kwargs):
if hasattr(data, 'keys'):
for key in data.keys():
for key in data:
value = data[key]
# Don't blow up on non-strings
try:

View File

@ -143,7 +143,7 @@ class Pillar(object):
'''
envs = set(['base'])
if 'file_roots' in self.opts:
envs.update(list(self.opts['file_roots'].keys()))
envs.update(list(self.opts['file_roots']))
return envs
def get_tops(self):

View File

@ -16,7 +16,7 @@ def down():
minions = client.cmd('*', 'test.ping', timeout=1)
keys = key._keys('acc')
ret = sorted(keys - set(minions.keys()))
ret = sorted(keys - set(minions))
for minion in ret:
print(minion)
return ret

View File

@ -31,10 +31,7 @@ import salt.pillar
import salt.fileclient
from salt._compat import string_types, callable
from salt.template import (
compile_template,
compile_template_str,
)
from salt.template import compile_template, compile_template_str
log = logging.getLogger(__name__)
@ -68,7 +65,7 @@ def trim_req(req):
'''
Trim any function off of a requisite
'''
reqfirst = list(req.keys())[0]
reqfirst = next(iter(req))
if '.' in reqfirst:
return {reqfirst.split('.')[0]: req[reqfirst]}
return req
@ -88,7 +85,7 @@ def state_args(id_, state, high):
continue
if len(item) != 1:
continue
args.add(list(item.keys())[0])
args.add(next(iter(item)))
return args
@ -111,7 +108,7 @@ def find_name(name, state, high):
continue
if len(arg) != 1:
continue
if arg[list(arg.keys())[0]] == name:
if arg[next(iter(arg))] == name:
ext_id = nid
return ext_id
@ -131,10 +128,10 @@ def format_log(ret):
elif isinstance(chg, dict):
if 'diff' in chg:
if isinstance(chg['diff'], string_types):
msg = 'File changed:\n{0}'.format(
chg['diff'])
if isinstance(chg[list(chg.keys())[0]], dict):
if 'new' in chg[list(chg.keys())[0]]:
msg = 'File changed:\n{0}'.format(chg['diff'])
chgfirst = next(iter(chg))
if isinstance(chg[chgfirst], dict):
if 'new' in chg[chgfirst]:
# This is the return data from a package install
msg = 'Installed Packages:\n'
for pkg in chg:
@ -335,7 +332,7 @@ class State(object):
deflen = len(aspec[3])
for ind in range(arglen - deflen):
if aspec[0][ind] not in data:
errors.append('Missing parameter ' + aspec[0][ind]\
errors.append('Missing parameter ' + aspec[0][ind]
+ ' for state ' + full)
# If this chunk has a recursive require, then it will cause a
# recursive loop when executing, check for it
@ -352,9 +349,10 @@ class State(object):
reqdec = 'watch'
if reqdec:
for req in data[reqdec]:
if data['state'] == req.keys()[0]:
if fnmatch.fnmatch(data['name'], req[list(req.keys())[0]]) \
or fnmatch.fnmatch(data['__id__'], req[list(req.keys())[0]]):
reqfirst = next(iter(req))
if data['state'] == reqfirst:
if (fnmatch.fnmatch(data['name'], req[reqfirst])
or fnmatch.fnmatch(data['__id__'], req[reqfirst])):
err = ('Recursive require detected in SLS {0} for'
' require {1} in ID {2}').format(
data['__sls__'],
@ -384,7 +382,7 @@ class State(object):
.format(name, body['__sls__']))
errors.append(err)
continue
for state, run in body.items():
for state in body:
if state.startswith('__'):
continue
if not isinstance(body[state], list):
@ -413,12 +411,12 @@ class State(object):
#
# Add the requires to the reqs dict and check them
# all for recursive requisites.
if list(arg.keys())[0] == 'require' \
or list(arg.keys())[0] == 'watch':
if not isinstance(arg[list(arg.keys())[0]], list):
argfirst = next(iter(arg))
if argfirst == 'require' or argfirst == 'watch':
if not isinstance(arg[argfirst], list):
errors.append(('The require or watch'
' statement in state "{0}" in sls "{1}" needs'
' to be formed as a list').format(
' statement in state "{0}" in sls "{1}" '
'needs to be formed as a list').format(
name,
body['__sls__']
))
@ -426,7 +424,7 @@ class State(object):
# list are all single key dicts.
else:
reqs[name] = {}
for req in arg[list(arg.keys())[0]]:
for req in arg[argfirst]:
if not isinstance(req, dict):
err = ('Requisite declaration {0}'
' in SLS {1} is not formed as a'
@ -435,18 +433,20 @@ class State(object):
body['__sls__'])
errors.append(err)
continue
req_key = list(req.keys())[0]
req_key = next(iter(req))
req_val = req[req_key]
if not ishashable(req_val):
errors.append((
'Illegal requisite "{0}", please check your syntax.\n'
'Illegal requisite "{0}", '
'please check your syntax.\n'
).format(str(req_val)))
# Check for global recursive requisites
reqs[name][req_val] = req_key
if req_val in reqs:
if name in reqs[req_val]:
if reqs[req_val][name] == state:
if reqs[req_val][
name] == state:
err = ('A recursive '
'requisite was found, SLS '
'"{0}" ID "{1}" ID "{2}"'
@ -456,10 +456,12 @@ class State(object):
req_val
)
errors.append(err)
# Make sure that there is only one key in the dict
if len(list(arg.keys())) != 1:
errors.append(('Multiple dictionaries defined'
' in argument of state "{0}" in sls {1}').format(
# Make sure that there is only one key in the
# dict
if len(list(arg)) != 1:
errors.append(('Multiple dictionaries '
'defined in argument of state "{0}" in sls'
' {1}').format(
name,
body['__sls__']))
if not fun:
@ -469,7 +471,8 @@ class State(object):
' sls {1}').format(state, body['__sls__']))
elif fun > 1:
errors.append(('Too many functions declared in state'
' "{0}" in sls {1}').format(state, body['__sls__']))
' "{0}" in sls {1}').format(
state, body['__sls__']))
return errors
def verify_chunks(self, chunks):
@ -633,26 +636,27 @@ class State(object):
for arg in run:
update = False
for hind in range(len(high[name][state])):
if isinstance(arg, string_types) and \
isinstance(high[name][state][hind], string_types):
if (isinstance(arg, string_types) and
isinstance(high[name][state][hind], string_types)):
# replacing the function, replace the index
high[name][state].pop(hind)
high[name][state].insert(hind, arg)
update = True
continue
if isinstance(arg, dict) and \
isinstance(high[name][state][hind], dict):
if (isinstance(arg, dict) and
isinstance(high[name][state][hind], dict)):
# It is an option, make sure the options match
if (list(arg.keys())[0] ==
list(high[name][state][hind].keys())[0]):
argfirst = next(iter(arg))
if (argfirst ==
next(iter(high[name][state][hind]))):
# They match, check if the option is a
# watch or require, append, otherwise
# replace
if list(arg.keys())[0] == 'require' or \
list(arg.keys())[0] == 'watch':
if (argfirst == 'require' or
argfirst == 'watch'):
# Extend the list
(high[name][state][hind][arg.keys()[0]]
.extend(arg[arg.keys()[0]]))
(high[name][state][hind][argfirst]
.extend(arg[argfirst]))
update = True
else:
# Replace the value
@ -682,7 +686,7 @@ class State(object):
# How did we get this far?
continue
# Split out the components
key = list(arg.keys())[0]
key = next(iter(arg))
if not key in req_in:
continue
rkey = key.split('_')[0]
@ -698,7 +702,8 @@ class State(object):
if not _state in extend[name]:
extend[name][_state] = []
for ind in range(len(extend[name][_state])):
if list(extend[name][_state][ind].keys())[0] == rkey:
if next(iter(
extend[name][_state][ind])) == rkey:
# Extending again
extend[name][_state][ind][rkey].append(
{state: id_}
@ -719,7 +724,7 @@ class State(object):
continue
if len(ind) < 1:
continue
_state = list(ind.keys())[0]
_state = next(iter(ind))
name = ind[_state]
if key == 'use_in':
# Add the running states args to the
@ -738,7 +743,7 @@ class State(object):
continue
if len(arg) != 1:
continue
if list(arg.keys())[0] in ignore_args:
if next(iter(arg)) in ignore_args:
continue
extend[ext_id][_state].append(arg)
continue
@ -759,7 +764,7 @@ class State(object):
continue
if len(arg) != 1:
continue
if list(arg.keys())[0] in ignore_args:
if next(iter(arg)) in ignore_args:
continue
extend[id_][state].append(arg)
continue
@ -769,7 +774,8 @@ class State(object):
if not _state in extend[name]:
extend[name][_state] = []
for ind in range(len(extend[name][_state])):
if list(extend[name][_state][ind].keys())[0] == rkey:
if next(iter(
extend[name][_state][ind])) == rkey:
# Extending again
extend[name][_state][ind][rkey].append(
{state: id_}
@ -801,7 +807,8 @@ class State(object):
cdata = self.format_call(data)
try:
if 'kwargs' in cdata:
ret = self.states[cdata['full']](*cdata['args'], **cdata['kwargs'])
ret = self.states[cdata['full']](
*cdata['args'], **cdata['kwargs'])
else:
ret = self.states[cdata['full']](*cdata['args'])
except:
@ -841,9 +848,8 @@ class State(object):
Check if the low data chunk should send a failhard signal
'''
tag = _gen_tag(low)
if low.get('failhard', False) \
or self.opts['failhard'] \
and tag in running:
if (low.get('failhard', False) or self.opts['failhard']
and tag in running):
return not running[tag]['result']
return False
@ -861,13 +867,13 @@ class State(object):
return 'met'
reqs = {'require': [], 'watch': []}
status = 'unmet'
for r_state in reqs.keys():
for r_state in reqs:
if r_state in low:
for req in low[r_state]:
req = trim_req(req)
found = False
for chunk in chunks:
req_key = list(req.keys())[0]
req_key = next(iter(req))
req_val = req[req_key]
if (fnmatch.fnmatch(chunk['name'], req_val) or
fnmatch.fnmatch(chunk['__id__'], req_val)):
@ -910,8 +916,7 @@ class State(object):
requisites = ('require', 'watch')
status = self.check_requisite(low, running, chunks)
if status == 'unmet':
lost = {'require': [],
'watch': []}
lost = {'require': [], 'watch': []}
reqs = []
for requisite in requisites:
if not requisite in low:
@ -920,7 +925,7 @@ class State(object):
req = trim_req(req)
found = False
for chunk in chunks:
req_key = list(req.keys())[0]
req_key = next(iter(req))
req_val = req[req_key]
if (fnmatch.fnmatch(chunk['name'], req_val) or
fnmatch.fnmatch(chunk['__id__'], req_val)):
@ -1070,7 +1075,7 @@ class BaseHighState(object):
'''
envs = set(['base'])
if 'file_roots' in self.opts:
envs.update(list(self.opts['file_roots'].keys()))
envs.update(list(self.opts['file_roots']))
return envs
def get_tops(self):
@ -1148,7 +1153,7 @@ class BaseHighState(object):
Cleanly merge the top files
'''
top = collections.defaultdict(dict)
for sourceenv, ctops in tops.items():
for ctops in tops.values():
for ctop in ctops:
for env, targets in ctop.items():
if env == 'include':
@ -1190,11 +1195,11 @@ class BaseHighState(object):
err = ('The top file matches for environment {0} are not '
'laid out as a dict').format(env)
errors.append(err)
for match, slsmods in matches.items():
for slsmods in matches.values():
for slsmod in slsmods:
if isinstance(slsmod, dict):
# This value is a match option
for key, val in slsmod.items():
for val in slsmod.values():
if not val:
err = ('Improperly formatted top file matcher '
'in environment {0}: {1} file'.format(
@ -1258,7 +1263,7 @@ class BaseHighState(object):
'''
if not self.opts['autoload_dynamic_modules']:
return
syncd = self.state.functions['saltutil.sync_all'](list(matches.keys()))
syncd = self.state.functions['saltutil.sync_all'](list(matches))
if syncd[2]:
self.opts['grains'] = salt.loader.grains(self.opts)
faux = {'state': 'file', 'fun': 'recurse'}
@ -1345,8 +1350,9 @@ class BaseHighState(object):
'__env__': env,
comps[0]: [comps[1]]}
continue
errors.append(('Name {0} in sls {1} is not a dictionary'
.format(name, sls)))
errors.append(
('Name {0} in sls {1} is not a dictionary'
.format(name, sls)))
continue
skeys = set()
for key in state[name]:

View File

@ -229,7 +229,7 @@ def _source_list(source, source_hash, env):
# to check, if it is salt then check the master list
if len(single) != 1:
continue
single_src = single.keys()[0]
single_src = next(iter(single))
single_hash = single[single_src]
proto = urlparse(single_src).scheme
if proto == 'salt':

View File

@ -99,7 +99,7 @@ def installed(name,
cwd=cwd):
pkg_list = __salt__['pip.list'](name, bin_env, runas=user, cwd=cwd)
version = list(pkg_list.values())[0]
pkg_name = list(pkg_list.keys())[0]
pkg_name = next(iter(pkg_list))
ret['result'] = True
ret['changes']["{0}=={1}".format(pkg_name, version)] = 'Installed'
ret['comment'] = 'Package was successfully installed'

View File

@ -89,7 +89,6 @@ def present(
name, config, fingerprint))
def absent(name, user, config='.ssh/known_hosts'):
'''
Verifies that the specified host is not known by the given user

View File

@ -170,7 +170,7 @@ class ModuleCase(TestCase):
'''
Return the result data from a single state return
'''
return ret[ret.keys()[0]]['result']
return ret[next(iter(ret))]['result']
def run_state(self, function, **kwargs):
'''

View File

@ -19,7 +19,7 @@ class CMDTest(integration.ModuleCase):
cmd.run
'''
ret = self.run_state('cmd.run', name='ls')
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_run(self):
@ -27,5 +27,5 @@ class CMDTest(integration.ModuleCase):
cmd.run test interface
'''
ret = self.run_state('cmd.run', name='ls', test=True)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)

View File

@ -19,7 +19,7 @@ class FileTest(integration.ModuleCase):
name = os.path.join(integration.TMP, 'symlink')
tgt = os.path.join(integration.TMP, 'target')
ret = self.run_state('file.symlink', name=name, target=tgt)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_symlink(self):
@ -29,7 +29,7 @@ class FileTest(integration.ModuleCase):
name = os.path.join(integration.TMP, 'symlink')
tgt = os.path.join(integration.TMP, 'target')
ret = self.run_state('file.symlink', test=True, name=name, target=tgt)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_absent_file(self):
@ -40,7 +40,7 @@ class FileTest(integration.ModuleCase):
with open(name, 'w+') as fp_:
fp_.write('killme')
ret = self.run_state('file.absent', name=name)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
self.assertFalse(os.path.isfile(name))
@ -51,7 +51,7 @@ class FileTest(integration.ModuleCase):
name = os.path.join(integration.TMP, 'dir_to_kill')
os.makedirs(name)
ret = self.run_state('file.absent', name=name)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
self.assertFalse(os.path.isdir(name))
@ -62,7 +62,7 @@ class FileTest(integration.ModuleCase):
name = os.path.join(integration.TMP, 'link_to_kill')
os.symlink(name, '{0}.tgt'.format(name))
ret = self.run_state('file.absent', name=name)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
self.assertFalse(os.path.islink(name))
@ -74,7 +74,7 @@ class FileTest(integration.ModuleCase):
with open(name, 'w+') as fp_:
fp_.write('killme')
ret = self.run_state('file.absent', test=True, name=name)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
self.assertTrue(os.path.isfile(name))
@ -99,7 +99,7 @@ class FileTest(integration.ModuleCase):
with open(name, 'r') as fp_:
minion_data = fp_.read()
self.assertEqual(master_data, minion_data)
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_managed(self):
@ -113,7 +113,7 @@ class FileTest(integration.ModuleCase):
name=name,
source='salt://grail/scene33')
self.assertFalse(os.path.isfile(name))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_directory(self):
@ -126,7 +126,7 @@ class FileTest(integration.ModuleCase):
name=name,
)
self.assertTrue(os.path.isdir(name))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_directory(self):
@ -140,7 +140,7 @@ class FileTest(integration.ModuleCase):
name=name,
)
self.assertFalse(os.path.isdir(name))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_recurse(self):
@ -154,7 +154,7 @@ class FileTest(integration.ModuleCase):
source='salt://grail',
)
self.assertTrue(os.path.isfile(os.path.join(name, '36', 'scene')))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_recurse(self):
@ -169,7 +169,7 @@ class FileTest(integration.ModuleCase):
source='salt://grail',
)
self.assertFalse(os.path.isfile(os.path.join(name, '36', 'scene')))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_sed(self):
@ -187,7 +187,7 @@ class FileTest(integration.ModuleCase):
)
with open(name, 'r') as fp_:
self.assertIn('salt', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_sed(self):
@ -206,7 +206,7 @@ class FileTest(integration.ModuleCase):
)
with open(name, 'r') as fp_:
self.assertIn('change', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_comment(self):
@ -249,7 +249,7 @@ class FileTest(integration.ModuleCase):
)
with open(name, 'r') as fp_:
self.assertNotIn('#comment', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_uncomment(self):
@ -262,7 +262,7 @@ class FileTest(integration.ModuleCase):
ret = self.run_state('file.uncomment', name=name, regex='^comment')
with open(name, 'r') as fp_:
self.assertNotIn('#comment', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_uncomment(self):
@ -280,7 +280,7 @@ class FileTest(integration.ModuleCase):
)
with open(name, 'r') as fp_:
self.assertIn('#comment', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_append(self):
@ -297,7 +297,7 @@ class FileTest(integration.ModuleCase):
)
with open(name, 'r') as fp_:
self.assertIn('cheese', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_append(self):
@ -315,7 +315,7 @@ class FileTest(integration.ModuleCase):
)
with open(name, 'r') as fp_:
self.assertNotIn('cheese', fp_.read())
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)
def test_touch(self):
@ -328,7 +328,7 @@ class FileTest(integration.ModuleCase):
name=name,
)
self.assertTrue(os.path.isfile(name))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertTrue(result)
def test_test_touch(self):
@ -342,7 +342,7 @@ class FileTest(integration.ModuleCase):
name=name,
)
self.assertFalse(os.path.isfile(name))
result = ret[ret.keys()[0]]['result']
result = ret[next(iter(ret))]['result']
self.assertIsNone(result)