Avoid locally overriding builtins with variable name input.

feature/documentation-builds-html
Isis Lovecruft 2013-04-15 01:16:39 +00:00
parent 9c20a63a36
commit eea25b80b8
No known key found for this signature in database
GPG Key ID: A3ADB67A2CDB8B35
1 changed files with 5 additions and 5 deletions

View File

@ -43,20 +43,20 @@ class UsageError(Exception):
"""Raised when incorrect usage of the API occurs..""" """Raised when incorrect usage of the API occurs.."""
def _fix_unsafe(input): def _fix_unsafe(shell_input):
""" """
Find characters used to escape from a string into a shell, and wrap them Find characters used to escape from a string into a shell, and wrap them
in quotes if they exist. Regex pilfered from python-3.x shlex module. in quotes if they exist. Regex pilfered from python-3.x shlex module.
:param input: The input intended for the gnupg process. :param str shell_input: The input intended for the GnuPG process.
""" """
## xxx do we want to add ';'? ## xxx do we want to add ';'?
_unsafe = re.compile(r'[^\w@%+=:,./-]', 256) _unsafe = re.compile(r'[^\w@%+=:,./-]', 256)
try: try:
if len(_unsafe.findall(input)) == 0: if len(_unsafe.findall(shell_input)) == 0:
return input return shell_input.strip()
else: else:
clean = "'" + input.replace("'", "'\"'\"'") + "'" clean = "'" + shell_input.replace("'", "'\"'\"'") + "'"
return clean return clean
except TypeError: except TypeError:
return None return None