diff options
author | neodarz <neodarz@neodarz.net> | 2017-11-05 15:09:26 +0100 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2017-11-05 15:09:26 +0100 |
commit | b5f86deb375795c26b1041982237f2518aa3aa88 (patch) | |
tree | 295bcf1dcda740f364618bb45afe6d1438ce97b7 /scripts | |
parent | e24718601a4075da4740a34579f21d5abc78f686 (diff) | |
download | dotfiles_ascii-b5f86deb375795c26b1041982237f2518aa3aa88.tar.xz dotfiles_ascii-b5f86deb375795c26b1041982237f2518aa3aa88.zip |
Add abilty to search for error code
Diffstat (limited to '')
-rwxr-xr-x | scripts/.scripts/linux_system_error_list.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/scripts/.scripts/linux_system_error_list.py b/scripts/.scripts/linux_system_error_list.py index 43f1cb5..ee1a7a6 100755 --- a/scripts/.scripts/linux_system_error_list.py +++ b/scripts/.scripts/linux_system_error_list.py @@ -1,6 +1,6 @@ #!/bin/python -import re +import re, sys from terminaltables import DoubleTable data = [] @@ -25,6 +25,22 @@ def get_content(file): get_content("/usr/include/asm-generic/errno-base.h") get_content("/usr/include/asm-generic/errno.h") -table = DoubleTable(data, "Error code") -table.justify_columns = {0: 'right', 1: 'center', 2: 'left'} -print(table.table) +if len(sys.argv) == 2 and sys.argv[1] == "list": + table = DoubleTable(data, "Error code") + table.justify_columns = {0: 'right', 1: 'center', 2: 'left'} + print(table.table) +elif (len(sys.argv) == 2 or len(sys.argv) == 3) and sys.argv[1] == "search": + if len(sys.argv) == 3: + data_searched = [] + data_searched.append(['Error', 'Code', 'Comment']) + for line in data: + if re.search(sys.argv[2],str(line)): + data_searched.append(line) + table = DoubleTable(data_searched, "Error code") + table.justify_columns = {0: 'right', 1: 'center', 2: 'left'} + print(table.table) + else: + print("search <search_string> # You can send regex following re.search python function") +else: + print("search <search_string> # You can send regex following re.search python function") + print("list # Return list of all error from errno.h and errno-base.h") |