Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unnecessary == True checks #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def list_packages():
'''
list_packages(): shows the list of packages
'''
if isfile("C:\\Program Files\\xpykg\\db.json") == True:
if isfile("C:\\Program Files\\xpykg\\db.json") :
with open("C:\\Program Files\\xpykg\\db.json", 'r') as db:
contents = loads(db.read())
for i in list(contents.keys()):
if is_installed(i) == True:
if is_installed(i) :
print("{} {} [installed by xpykg]".format(i , contents[i]['version']))
else:
print("{} {}".format(i, contents[i]['version']))
Expand All @@ -76,7 +76,7 @@ def search_packages(query: str):
search_packages(query: str): search packages matching to query
'''

if isfile("C:\\Program Files\\xpykg\\db.json") == True:
if isfile("C:\\Program Files\\xpykg\\db.json"):
with open("C:\\Program Files\\xpykg\\db.json", 'r') as db:
contents = loads(db.read())
count = 0
Expand All @@ -90,7 +90,7 @@ def search_packages(query: str):

if len(matching) == len(query):
count = count + 1
if is_installed(i) == True:
if is_installed(i) :
print("{} {} [installed by xpykg]".format(i, contents[i]['version']))
else:
print("{} {}".format(i, contents[i]['version']))
Expand All @@ -106,7 +106,7 @@ def install_package(package: str):
install_package(package): install package to
'''

if isfile("C:\\Program Files\\xpykg\\db.json") == True:
if isfile("C:\\Program Files\\xpykg\\db.json"):
with open("C:\\Program Files\\xpykg\\db.json", 'r') as db:
contents = loads(db.read())

Expand Down Expand Up @@ -176,7 +176,7 @@ def is_installed(pkgname: str):
'''
is_installed(pkgname) -> True/False.. this function determines that a package is installed or not
'''
if isfile("C:\\Program Files\\xpykg\\installed-packages") == True:
if isfile("C:\\Program Files\\xpykg\\installed-packages") :
with open("C:\\Program Files\\xpykg\\installed-packages", 'r') as database:
contents = database.read()
for i in contents.splitlines():
Expand All @@ -194,7 +194,7 @@ def get_installed_package_version(pkgname: str):
get_installed_package_version(pkgname).. if pkgname is installed by xpykg then return which version is installed by xpykg
'''

if is_installed(pkgname) == True:
if is_installed(pkgname) :
with open("C:\\Program Files\\xpykg\\installed-packages", 'r') as database:
contents = database.read().splitlines()
for i in contents:
Expand All @@ -218,7 +218,7 @@ def uninstall_package(pkgname: str):
'''
uninstall_package(pkgname): remove pkgname if installed by xpykg
'''
if is_installed(pkgname) == True:
if is_installed(pkgname) :
with open("C:\\Program Files\\xpykg\\installed-packages", 'r+') as ipkg:
contents = ipkg.read().splitlines()
index = 0
Expand Down Expand Up @@ -291,7 +291,7 @@ def upgrade_packages():
contents = loads(db.read())

for i in list(contents.keys()):
if is_installed(i) == True and vtoi(contents[i]['version']) > vtoi(get_installed_package_version(i)):
if is_installed(i) and vtoi(contents[i]['version']) > vtoi(get_installed_package_version(i)):
version_list.append(i)
version.append(contents[i]['version'])

Expand Down