GUI development
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import json
|
||||
import modules.vars as horsy_vars
|
||||
|
||||
|
||||
def get_auth():
|
||||
with open('config.cfg') as f:
|
||||
with open(horsy_vars.horsypath + 'config.cfg') as f:
|
||||
config = json.load(f)
|
||||
|
||||
try:
|
||||
@@ -17,17 +18,17 @@ def get_auth():
|
||||
print('password')
|
||||
password = input('> ')
|
||||
config['auth'] = {'email': email, 'password': password}
|
||||
with open('config.cfg', 'w') as f:
|
||||
with open(horsy_vars.horsypath + 'config.cfg', 'w') as f:
|
||||
json.dump(config, f)
|
||||
print('[OK] Auth created')
|
||||
return config['auth']
|
||||
|
||||
|
||||
def del_auth():
|
||||
with open('config.cfg') as f:
|
||||
with open(horsy_vars.horsypath + 'config.cfg') as f:
|
||||
config = json.load(f)
|
||||
if config['auth']:
|
||||
config['auth'] = None
|
||||
with open('config.cfg', 'w') as f:
|
||||
with open(horsy_vars.horsypath + 'config.cfg', 'w') as f:
|
||||
json.dump(config, f)
|
||||
print('[OK] Auth deleted')
|
||||
|
||||
@@ -12,11 +12,17 @@ client = SearchClient.create(
|
||||
index = client.init_index('packages')
|
||||
|
||||
|
||||
def search(query):
|
||||
def search(query, is_gui=False):
|
||||
res = index.search(query)['hits']
|
||||
ret_res = list()
|
||||
for i in res:
|
||||
print(textwrap.shorten(f"{i['name']} by {i['authorName']} - {i['description']}",
|
||||
width=os.get_terminal_size().columns))
|
||||
if not is_gui:
|
||||
print(textwrap.shorten(f"{i['name']} by {i['authorName']} - {i['description']}",
|
||||
width=os.get_terminal_size().columns))
|
||||
else:
|
||||
ret_res.append(i['name'])
|
||||
|
||||
return ret_res
|
||||
|
||||
|
||||
def info(package):
|
||||
|
||||
Reference in New Issue
Block a user