Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions zoomeye/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,11 +736,11 @@ def filter_information(self, filters):
result_data, has_equal, not_equal = process_filter(filters, info_data, fields_ip)
if len(result_data) == 0:
return
for item in not_equal:
if fields_ip.get(item.strip()) is None:
for items in not_equal:
if fields_ip.get(items.strip()) is None:
support_fields = ','.join(list(fields_ip.keys()))
show.printf(
"filter command has unsupport fields [{}], support fields has [{}]".format(item, support_fields),
"filter command has unsupport fields [{}], support fields has [{}]".format(items, support_fields),
color='red')
exit(0)
show.print_info_filter(not_equal, result_data, has_equal)
Expand Down
20 changes: 10 additions & 10 deletions zoomeye/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def get_api_key(path) -> str:
:param path:
:return:
"""
key_file = zoomeye_dir + "/apikey"
key_fl = zoomeye_dir + "/apikey"
# api key config does not exits
# raise FileNotFoundError
if not os.path.exists(key_file):
if not os.path.exists(key_fl):
raise FileNotFoundError("not found api key config")
# determine whether the permission of the configuration file is read-only,
# if not, set it to read-only
if not oct(os.stat(key_file).st_mode).endswith("600"):
os.chmod(key_file, 0o600)
if not oct(os.stat(key_fl).st_mode).endswith("600"):
os.chmod(key_fl, 0o600)
# return read file content
with open(key_file, 'r') as f:
with open(key_fl, 'r') as f:
return f.read().strip()


Expand All @@ -42,18 +42,18 @@ def get_jwt_token(path) -> str:
:param path:
:return:
"""
key_file = zoomeye_dir + "/jwt"
key_fl = zoomeye_dir + "/jwt"
# json web token does not exits
# raise FileNotFoundError
if not os.path.exists(key_file):
if not os.path.exists(key_fl):
raise FileNotFoundError("not found access token config")

# determine whether the permission of the configuration file is read-only,
# if not, set it to read-only
if not oct(os.stat(key_file).st_mode).endswith("600"):
os.chmod(key_file, 0o600)
if not oct(os.stat(key_fl).st_mode).endswith("600"):
os.chmod(key_fl, 0o600)
# return read config content
with open(key_file, 'r') as f:
with open(key_fl, 'r') as f:
return f.read().strip()


Expand Down
12 changes: 6 additions & 6 deletions zoomeye/plotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ def generate_histogram(values, labels=None, force_ascii=False):
else:
chars = [" ", "#", "#", "#", "#", "#", "#", "#", "#"]

fmt = []
ft = []
if labels is not None:
cfmt = "{{:{}s}}".format(max([len(str(label)) for label in labels]))
fmt.append(cfmt)
ft.append(cfmt)
# show values
all_int = all(val == int(val) for val in values)
if all_int:
cfmt = "{{:{}d}}".format(max([len(str(val)) for val in values]))
else:
cfmt = "{}"
fmt.append("[" + cfmt + "]")
ft.append("[" + cfmt + "]")

fmt.append("{}")
fmt = " ".join(fmt)
ft.append("{}")
ft = " ".join(ft)

out = []
for k, (val, row) in enumerate(zip(values, matrix)):
Expand All @@ -159,7 +159,7 @@ def generate_histogram(values, labels=None, force_ascii=False):
# cut off trailing zeros
r = trim_zeros(row)
data.append("".join(chars[item] for item in r))
out.append(fmt.format(*data))
out.append(ft.format(*data))
for item in out:
print(' ' + item)

Expand Down