mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Misc cleanups
Some as suggested by lgtm.com
This commit is contained in:
parent
1018cb2a81
commit
516a70d9cb
5 changed files with 26 additions and 26 deletions
|
@ -141,7 +141,7 @@ class SpawnedProc(object):
|
|||
env: a string->string dictionary, describing the environment variables.
|
||||
"""
|
||||
if name not in env:
|
||||
raise ValueError("'name' variable not found in environment" % name)
|
||||
raise ValueError("'%s' variable not found in environment" % name)
|
||||
exe_path = env.get(name)
|
||||
self.colorize = sys.stdout.isatty()
|
||||
self.messages = []
|
||||
|
@ -291,7 +291,6 @@ class SpawnedProc(object):
|
|||
else:
|
||||
timestampstr = "{timestamp:10.2f} ms".format(timestamp=timestamp)
|
||||
delta = m.when * 1000.0
|
||||
dir = m.dir
|
||||
print(
|
||||
"{dir} {timestampstr} (Line {lineno}): {BOLD}{etext}{RESET}".format(
|
||||
dir=m.dir,
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
complete -f -c math -r
|
||||
complete -f -c math -s s -l scale -r -x
|
||||
complete -f -c math -s s -l scale -r
|
||||
complete -f -c math -s b -l base -r
|
||||
|
|
|
@ -274,7 +274,7 @@ class ManParser(object):
|
|||
|
||||
class Type1ManParser(ManParser):
|
||||
def is_my_type(self, manpage):
|
||||
return compile_and_search('\.SH "OPTIONS"(.*?)', manpage) != None
|
||||
return compile_and_search('\.SH "OPTIONS"(.*?)', manpage) is not None
|
||||
|
||||
def parse_man_page(self, manpage):
|
||||
options_section_regex = re.compile('\.SH "OPTIONS"(.*?)(\.SH|\Z)', re.DOTALL)
|
||||
|
@ -284,7 +284,7 @@ class Type1ManParser(ManParser):
|
|||
options_matched = re.search(options_parts_regex, options_section)
|
||||
add_diagnostic("Command is %r" % CMDNAME)
|
||||
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
add_diagnostic("Unable to find options")
|
||||
if self.fallback(options_section):
|
||||
return True
|
||||
|
@ -292,7 +292,7 @@ class Type1ManParser(ManParser):
|
|||
return True
|
||||
return False
|
||||
|
||||
while options_matched != None:
|
||||
while options_matched is not None:
|
||||
data = options_matched.group(1)
|
||||
last_dotpp_index = data.rfind(".PP")
|
||||
if last_dotpp_index != -1:
|
||||
|
@ -322,10 +322,10 @@ class Type1ManParser(ManParser):
|
|||
add_diagnostic("Trying fallback")
|
||||
options_parts_regex = re.compile("\.TP( \d+)?(.*?)\.TP", re.DOTALL)
|
||||
options_matched = re.search(options_parts_regex, options_section)
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
add_diagnostic("Still not found")
|
||||
return False
|
||||
while options_matched != None:
|
||||
while options_matched is not None:
|
||||
data = options_matched.group(2)
|
||||
data = remove_groff_formatting(data)
|
||||
data = data.strip()
|
||||
|
@ -355,10 +355,10 @@ class Type1ManParser(ManParser):
|
|||
|
||||
options_section = re.sub(ix_remover_regex, "", options_section)
|
||||
options_matched = re.search(options_parts_regex, options_section)
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
add_diagnostic("Still (still!) not found")
|
||||
return False
|
||||
while options_matched != None:
|
||||
while options_matched is not None:
|
||||
data = options_matched.group(1)
|
||||
|
||||
data = remove_groff_formatting(data)
|
||||
|
@ -386,7 +386,7 @@ class Type1ManParser(ManParser):
|
|||
|
||||
class Type2ManParser(ManParser):
|
||||
def is_my_type(self, manpage):
|
||||
return compile_and_search("\.SH OPTIONS(.*?)", manpage) != None
|
||||
return compile_and_search("\.SH OPTIONS(.*?)", manpage) is not None
|
||||
|
||||
def parse_man_page(self, manpage):
|
||||
options_section_regex = re.compile("\.SH OPTIONS(.*?)(\.SH|\Z)", re.DOTALL)
|
||||
|
@ -398,11 +398,11 @@ class Type2ManParser(ManParser):
|
|||
options_matched = re.search(options_parts_regex, options_section)
|
||||
add_diagnostic("Command is %r" % CMDNAME)
|
||||
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
add_diagnostic("%r: Unable to find options" % self)
|
||||
return False
|
||||
|
||||
while options_matched != None:
|
||||
while options_matched is not None:
|
||||
data = options_matched.group(3)
|
||||
data = remove_groff_formatting(data)
|
||||
data = data.strip()
|
||||
|
@ -436,7 +436,7 @@ class Type3ManParser(ManParser):
|
|||
options_matched = re.search(options_parts_regex, options_section)
|
||||
add_diagnostic("Command is %r" % CMDNAME)
|
||||
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
add_diagnostic("Unable to find options section")
|
||||
return False
|
||||
|
||||
|
@ -479,7 +479,7 @@ class Type4ManParser(ManParser):
|
|||
options_matched = re.search(options_parts_regex, options_section)
|
||||
add_diagnostic("Command is %r" % CMDNAME)
|
||||
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
print("Unable to find options section", file=sys.stderr)
|
||||
return False
|
||||
|
||||
|
@ -520,7 +520,7 @@ class TypeScdocManParser(ManParser):
|
|||
def parse_man_page(self, manpage):
|
||||
options_section_regex = re.compile("\.SH OPTIONS(.*?)\.SH", re.DOTALL)
|
||||
options_section_matched = re.search(options_section_regex, manpage)
|
||||
if options_section_matched == None:
|
||||
if options_section_matched is None:
|
||||
return False
|
||||
options_section = options_section_matched.group(1)
|
||||
|
||||
|
@ -528,11 +528,11 @@ class TypeScdocManParser(ManParser):
|
|||
options_matched = re.match(options_parts_regex, options_section)
|
||||
add_diagnostic("Command is %r" % CMDNAME)
|
||||
|
||||
if options_matched == None:
|
||||
if options_matched is None:
|
||||
add_diagnostic("%r: Unable to find options" % self)
|
||||
return False
|
||||
|
||||
while options_matched != None:
|
||||
while options_matched is not None:
|
||||
# Get first option and move options_section
|
||||
option = options_matched.group(1)
|
||||
options_section = options_section[options_matched.end() : :]
|
||||
|
@ -568,7 +568,7 @@ class TypeScdocManParser(ManParser):
|
|||
|
||||
class TypeDarwinManParser(ManParser):
|
||||
def is_my_type(self, manpage):
|
||||
return compile_and_search("\.S[hH] DESCRIPTION", manpage) != None
|
||||
return compile_and_search("\.S[hH] DESCRIPTION", manpage) is not None
|
||||
|
||||
def trim_groff(self, line):
|
||||
# Remove initial period
|
||||
|
|
|
@ -902,7 +902,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||
"quote",
|
||||
"redirection",
|
||||
"valid_path",
|
||||
"autosuggestion" "user",
|
||||
"autosuggestion",
|
||||
"user",
|
||||
"host",
|
||||
"cancel",
|
||||
]
|
||||
|
|
|
@ -230,7 +230,7 @@ bool is_windows_subsystem_for_linux() {
|
|||
debug_shared(msg_level, L"Backtrace:\n" + join_strings(bt, L'\n') + L'\n');
|
||||
}
|
||||
|
||||
#else // HAVE_BACKTRACE_SYMBOLS
|
||||
#else // HAVE_BACKTRACE_SYMBOLS
|
||||
|
||||
[[gnu::noinline]] void show_stackframe(const wchar_t msg_level, int, int) {
|
||||
debug_shared(msg_level, L"Sorry, but your system does not support backtraces");
|
||||
|
@ -600,12 +600,11 @@ bool should_suppress_stderr_for_tests() {
|
|||
static void debug_shared(const wchar_t level, const wcstring &msg) {
|
||||
pid_t current_pid;
|
||||
if (!is_forked_child()) {
|
||||
std::fwprintf(stderr, L"<%lc> %ls: %ls\n", static_cast<unsigned long>(level), program_name,
|
||||
msg.c_str());
|
||||
std::fwprintf(stderr, L"<%lc> %ls: %ls\n", level, program_name, msg.c_str());
|
||||
} else {
|
||||
current_pid = getpid();
|
||||
std::fwprintf(stderr, L"<%lc> %ls: %d: %ls\n", static_cast<unsigned long>(level),
|
||||
program_name, current_pid, msg.c_str());
|
||||
std::fwprintf(stderr, L"<%lc> %ls: %d: %ls\n", level, program_name, current_pid,
|
||||
msg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1674,7 +1673,7 @@ wcstring format_size(long long sz) {
|
|||
if (sz < (1024 * 1024) || !sz_name[i + 1]) {
|
||||
long isz = (static_cast<long>(sz)) / 1024;
|
||||
if (isz > 9)
|
||||
result.append(format_string(L"%d%ls", isz, sz_name[i]));
|
||||
result.append(format_string(L"%ld%ls", isz, sz_name[i]));
|
||||
else
|
||||
result.append(
|
||||
format_string(L"%.1f%ls", static_cast<double>(sz) / 1024, sz_name[i]));
|
||||
|
|
Loading…
Reference in a new issue