Skip to content

Commit

Permalink
Remove raw string formatting in doc/, salt/auth/, and salt/cloud/
Browse files Browse the repository at this point in the history
  • Loading branch information
terminalmage committed Aug 24, 2015
1 parent 579c786 commit 9051706
Show file tree
Hide file tree
Showing 29 changed files with 176 additions and 164 deletions.
2 changes: 1 addition & 1 deletion doc/.scripts/compile-translation-catalogs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def main():

for locale, po_files in sorted(entries.items()):
lc_messages_path = os.path.join(LOCALES_DIR, locale, 'LC_MESSAGES')
print('\nCompiling the {0!r} locale:'.format(locale))
print('\nCompiling the \'{0}\' locale:'.format(locale))
for po_file in sorted(po_files):
relpath = os.path.relpath(po_file, lc_messages_path)
print ' {0}.po -> {0}.mo'.format(relpath.split('.po', 1)[0])
Expand Down
2 changes: 1 addition & 1 deletion doc/.scripts/download-translation-catalog
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():
sys.exit(1)

for locale in sys.argv[1:]:
print('Download {0!r} translations catalog...'.format(locale))
print('Download \'{0}\' translations catalog...'.format(locale))
txclib.utils.exec_command('pull', ['-l', locale], tx_root)

print('Done')
Expand Down
4 changes: 2 additions & 2 deletions doc/.scripts/setup-transifex-config
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def main():
config.set(HOST, 'password', password)

config.write(open(RCFILE, 'w'))
print('username and password stored in {0!r}'.format(RCFILE))
print('username and password stored in \'{0}\''.format(RCFILE))

os.chmod(RCFILE, 0600)
print('Secured the permissions on {0!r} to 0600'.format(RCFILE))
print('Secured the permissions on \'{0}\' to 0600'.format(RCFILE))

sys.exit(0)

Expand Down
2 changes: 1 addition & 1 deletion doc/.scripts/update-transifex-source-translations
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def main():
)
for idx, resource_name in enumerate(sorted(handled_resources)):
sys.stdout.write(
'[{0:>{pad}}/{1}] Removing resource {resource_name!r}'.format(
'[{0:>{pad}}/{1}] Removing resource \'{resource_name}\''.format(
idx + 1,
non_handled_resources,
pad=len(str(non_handled_resources)),
Expand Down
4 changes: 2 additions & 2 deletions salt/auth/pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PamMessage(Structure):
]

def __repr__(self):
return '<PamMessage {0} {1!r}>'.format(self.msg_style, self.msg)
return '<PamMessage {0} \'{1}\'>'.format(self.msg_style, self.msg)


class PamResponse(Structure):
Expand All @@ -82,7 +82,7 @@ class PamResponse(Structure):
]

def __repr__(self):
return '<PamResponse {0} {1!r}>'.format(self.resp_retcode, self.resp)
return '<PamResponse {0} \'{1}\'>'.format(self.resp_retcode, self.resp)


CONV_FUNC = CFUNCTYPE(c_int,
Expand Down
85 changes: 43 additions & 42 deletions salt/cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def lookup_providers(self, lookup):
if alias not in self.opts['providers'] or \
driver not in self.opts['providers'][alias]:
raise SaltCloudSystemExit(
'No cloud providers matched {0!r}. Available: {1}'.format(
'No cloud providers matched \'{0}\'. Available: {1}'.format(
lookup, ', '.join(self.get_configured_providers())
)
)
Expand All @@ -531,7 +531,7 @@ def lookup_providers(self, lookup):

if not providers:
raise SaltCloudSystemExit(
'No cloud providers matched {0!r}. '
'No cloud providers matched \'{0}\'. '
'Available selections: {1}'.format(
lookup, ', '.join(self.get_configured_providers())
)
Expand Down Expand Up @@ -744,7 +744,7 @@ def _optimize_providers(self, providers):
fun = '{0}.optimize_providers'.format(driver)
if fun not in self.clouds:
log.debug(
'The {0!r} cloud driver is unable to be optimized.'.format(
'The \'{0}\' cloud driver is unable to be optimized.'.format(
driver
)
)
Expand Down Expand Up @@ -780,7 +780,7 @@ def location_list(self, lookup='all'):
# The capability to gather locations is not supported by this
# cloud module
log.debug(
'The {0!r} cloud driver defined under {1!r} provider '
'The \'{0}\' cloud driver defined under \'{1}\' provider '
'alias is unable to get the locations information'.format(
driver, alias
)
Expand Down Expand Up @@ -823,7 +823,7 @@ def image_list(self, lookup='all'):
# The capability to gather images is not supported by this
# cloud module
log.debug(
'The {0!r} cloud driver defined under {1!r} provider '
'The \'{0}\' cloud driver defined under \'{1}\' provider '
'alias is unable to get the images information'.format(
driver,
alias
Expand Down Expand Up @@ -866,7 +866,7 @@ def size_list(self, lookup='all'):
# The capability to gather sizes is not supported by this
# cloud module
log.debug(
'The {0!r} cloud driver defined under {1!r} provider '
'The \'{0}\' cloud driver defined under \'{1}\' provider '
'alias is unable to get the sizes information'.format(
driver,
alias
Expand Down Expand Up @@ -1066,7 +1066,7 @@ def destroy(self, names, cached=False):
# We need to ask one by one!?
print(
'There are several minion keys who\'s name starts '
'with {0!r}. We need to ask you which one should be '
'with \'{0}\'. We need to ask you which one should be '
'deleted:'.format(
name
)
Expand All @@ -1083,7 +1083,7 @@ def destroy(self, names, cached=False):
selection = int(selection)
except ValueError:
print(
'{0!r} is not a valid selection.'.format(selection)
'\'{0}\' is not a valid selection.'.format(selection)
)

try:
Expand All @@ -1094,16 +1094,16 @@ def destroy(self, names, cached=False):
continue

delete = input(
'Delete {0!r}? [Y/n]? '.format(filename)
'Delete \'{0}\'? [Y/n]? '.format(filename)
)
if delete == '' or delete.lower().startswith('y'):
salt.utils.cloud.remove_key(
self.opts['pki_dir'], filename
)
print('Deleted {0!r}'.format(filename))
print('Deleted \'{0}\''.format(filename))
break

print('Did not delete {0!r}'.format(filename))
print('Did not delete \'{0}\''.format(filename))
break

if names and not processed:
Expand Down Expand Up @@ -1162,8 +1162,8 @@ def create(self, vm_, local_master=True):
fun = '{0}.create'.format(driver)
if fun not in self.clouds:
log.error(
'Creating {0[name]!r} using {0[provider]!r} as the provider '
'cannot complete since {1!r} is not available'.format(
'Creating \'{0[name]}\' using \'{0[provider]}\' as the provider '
'cannot complete since \'{1}\' is not available'.format(
vm_,
driver
)
Expand All @@ -1182,12 +1182,12 @@ def create(self, vm_, local_master=True):
raise SaltCloudConfigError(
(
'There\'s no master defined on the '
'{0!r} VM settings'
'\'{0}\' VM settings'
).format(vm_['name'])
)

if 'pub_key' not in vm_ and 'priv_key' not in vm_:
log.debug('Generating minion keys for {0[name]!r}'.format(vm_))
log.debug('Generating minion keys for \'{0[name]}\''.format(vm_))
priv, pub = salt.utils.cloud.gen_keys(
salt.config.get_cloud_config_value(
'keysize',
Expand All @@ -1211,7 +1211,7 @@ def create(self, vm_, local_master=True):
if make_master is True:
if 'master_pub' not in vm_ and 'master_pem' not in vm_:
log.debug(
'Generating the master keys for {0[name]!r}'.format(
'Generating the master keys for \'{0[name]}\''.format(
vm_
)
)
Expand Down Expand Up @@ -1317,8 +1317,8 @@ def extras(self, extra_):
fun = '{0}.{1}'.format(driver, extra_['action'])
if fun not in self.clouds:
log.error(
'Creating {0[name]!r} using {0[provider]!r} as the provider '
'cannot complete since {1!r} is not available'.format(
'Creating \'{0[name]}\' using \'{0[provider]}\' as the provider '
'cannot complete since \'{1}\' is not available'.format(
extra_,
driver
)
Expand Down Expand Up @@ -1450,9 +1450,10 @@ def do_action(self, names, kwargs):
if 'id' in vm_details and vm_details['id'] in names:
vm_name = vm_details['id']
else:
log.debug('vm:{0} in provider:{1} is not in name list:{2!r}'.format(
vm_name, driver, names
))
log.debug(
'vm:{0} in provider:{1} is not in name '
'list:\'{2}\''.format(vm_name, driver, names)
)
continue
with context.func_globals_inject(
self.clouds[fun],
Expand Down Expand Up @@ -1486,7 +1487,7 @@ def do_function(self, prov, func, kwargs):
matches = self.lookup_providers(prov)
if len(matches) > 1:
raise SaltCloudSystemExit(
'More than one results matched {0!r}. Please specify '
'More than one results matched \'{0}\'. Please specify '
'one of: {1}'.format(
prov,
', '.join([
Expand All @@ -1500,12 +1501,12 @@ def do_function(self, prov, func, kwargs):
fun = '{0}.{1}'.format(driver, func)
if fun not in self.clouds:
raise SaltCloudSystemExit(
'The {0!r} cloud provider alias, for the {1!r} driver, does '
'not define the function {2!r}'.format(alias, driver, func)
'The \'{0}\' cloud provider alias, for the \'{1}\' driver, does '
'not define the function \'{2}\''.format(alias, driver, func)
)

log.debug(
'Trying to execute {0!r} with the following kwargs: {1}'.format(
'Trying to execute \'{0}\' with the following kwargs: {1}'.format(
fun, kwargs
)
)
Expand Down Expand Up @@ -1538,13 +1539,13 @@ def __filter_non_working_providers(self):
if fun not in self.clouds:
# Mis-configured provider that got removed?
log.warn(
'The cloud driver, {0!r}, configured under the '
'{1!r} cloud provider alias, could not be loaded. '
'The cloud driver, \'{0}\', configured under the '
'\'{1}\' cloud provider alias, could not be loaded. '
'Please check your provider configuration files and '
'ensure all required dependencies are installed '
'for the {0!r} driver.\n'
'for the \'{0}\' driver.\n'
'In rare cases, this could indicate the \'{2}()\' '
'function could not be found.\nRemoving {0!r} from '
'function could not be found.\nRemoving \'{0}\' from '
'the available providers list'.format(
driver, alias, fun
)
Expand All @@ -1564,8 +1565,8 @@ def __filter_non_working_providers(self):
):
if self.clouds[fun]() is False:
log.warn(
'The cloud driver, {0!r}, configured under the '
'{1!r} cloud provider alias is not properly '
'The cloud driver, \'{0}\', configured under the '
'\'{1}\' cloud provider alias is not properly '
'configured. Removing it from the available '
'providers list.'.format(driver, alias)
)
Expand Down Expand Up @@ -1596,7 +1597,7 @@ def interpolated_map(self, query='list_nodes', cached=False):
if 'Errors' not in interpolated_map:
interpolated_map['Errors'] = {}
msg = (
'No provider for the mapped {0!r} profile was found. '
'No provider for the mapped \'{0}\' profile was found. '
'Skipped VMS: {1}'.format(
profile, ', '.join(names)
)
Expand Down Expand Up @@ -1806,11 +1807,11 @@ def map_data(self, cached=False):
for profile_name, nodes in six.iteritems(self.rendered_map):
if profile_name not in self.opts['profiles']:
msg = (
'The required profile, {0!r}, defined in the map '
'The required profile, \'{0}\', defined in the map '
'does not exist. The defined nodes, {1}, will not '
'be created.'.format(
profile_name,
', '.join('{0!r}'.format(node) for node in nodes)
', '.join('\'{0}\''.format(node) for node in nodes)
)
)
log.error(msg)
Expand All @@ -1829,9 +1830,9 @@ def map_data(self, cached=False):
deprecated = 'map_{0}'.format(setting)
if deprecated in overrides:
log.warn(
'The use of {0!r} on the {1!r} mapping has '
'The use of \'{0}\' on the \'{1}\' mapping has '
'been deprecated. The preferred way now is to '
'just define {2!r}. For now, salt-cloud will do '
'just define \'{2}\'. For now, salt-cloud will do '
'the proper thing and convert the deprecated '
'mapping into the preferred one.'.format(
deprecated, nodename, setting
Expand Down Expand Up @@ -1886,7 +1887,7 @@ def get_matching_by_name(name):
# Machine already removed
break

log.warn('{0!r} already exists, removing from '
log.warn('\'{0}\' already exists, removing from '
'the create map.'.format(name))

if 'existing' not in ret:
Expand Down Expand Up @@ -1949,7 +1950,7 @@ def run_map(self, dmap):
if profile.get('make_master', False) is True
))
master_minion_name = master_name
log.debug('Creating new master {0!r}'.format(master_name))
log.debug('Creating new master \'{0}\''.format(master_name))
if salt.config.get_cloud_config_value(
'deploy',
master_profile,
Expand All @@ -1962,7 +1963,7 @@ def run_map(self, dmap):

# Generate the master keys
log.debug(
'Generating master keys for {0[name]!r}'.format(master_profile)
'Generating master keys for \'{0[name]}\''.format(master_profile)
)
priv, pub = salt.utils.cloud.gen_keys(
salt.config.get_cloud_config_value(
Expand Down Expand Up @@ -2001,7 +2002,7 @@ def run_map(self, dmap):
continue

log.debug(
'Generating minion keys for {0[name]!r}'.format(profile)
'Generating minion keys for \'{0[name]}\''.format(profile)
)
priv, pub = salt.utils.cloud.gen_keys(
salt.config.get_cloud_config_value(
Expand Down Expand Up @@ -2116,7 +2117,7 @@ def run_map(self, dmap):
output[name].pop('deploy_kwargs', None)
except SaltCloudException as exc:
log.error(
'Failed to deploy {0!r}. Error: {1}'.format(
'Failed to deploy \'{0}\'. Error: {1}'.format(
name, exc
),
# Show the traceback if the debug logging level is enabled
Expand Down Expand Up @@ -2193,7 +2194,7 @@ def create_multiprocessing(parallel_data, queue=None):
)
except SaltCloudException as exc:
log.error(
'Failed to deploy {0[name]!r}. Error: {1}'.format(
'Failed to deploy \'{0[name]}\'. Error: {1}'.format(
parallel_data, exc
),
# Show the traceback if the debug logging level is enabled
Expand Down
Loading

0 comments on commit 9051706

Please sign in to comment.