-
-
Save lidgnulinux/5573b688806f9a214f8e1bad41df318d to your computer and use it in GitHub Desktop.
(WIP) simple qi frontend written using python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import glob, os | |
import argparse | |
parser=argparse.ArgumentParser(description="simple qi frontend.") | |
parser.add_argument("option") | |
parser.add_argument("desc") | |
args=parser.parse_args() | |
# list packages | |
def packages(keyword): | |
os.chdir("/var/lib/qi") | |
for file in glob.glob("*." + keyword): | |
print(file.rstrip('\n').split('_')[0]) | |
def description(keyword): | |
os.chdir("/var/lib/qi") | |
package = glob.glob(keyword+"_"+"*.txt") | |
pkg = '/'.join(package) | |
with open(pkg, 'r') as f: | |
for line in f.readlines(): | |
if 'blurb' in line: | |
print(keyword + ": ", line.split('"')[1]) | |
def search(keyword): | |
os.chdir("/var/qi") | |
with open("installed_packages.list", 'r') as f: | |
for line in f.readlines(): | |
if keyword in line: | |
print(line.split('_')[0]) | |
def info(keyword): | |
os.chdir("/var/lib/qi") | |
package = glob.glob(keyword+"_"+"*.txt") | |
pkg = '/'.join(package) | |
with open(pkg, 'r') as f: | |
for line in f.readlines(): | |
print(line, end="") | |
if args.option=="list": | |
packages(args.desc) | |
elif args.option=="desc": | |
description(args.desc) | |
elif args.option=="search": | |
search(args.desc) | |
elif args.option=="info": | |
info(args.desc) | |
else: | |
print ("Use \"list recipe\", \"desc <package name>\" or \"search <pattern>\" as option !") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment