Skip to content

Commit 17cc0c5

Browse files
committed
Library form
1 parent 4cbe5f0 commit 17cc0c5

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#__init__.py
2+
3+
#version
4+
__version__ = "0.0.1"

pipinstall.py

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,50 @@
11
import os
22
import sys
33
import argparse
4-
import utils
4+
import subprocess
55

66
#Functions
7+
8+
# Clear the terminal
9+
def clear_screen():
10+
if os.name == 'nt':
11+
os.system('cls')
12+
else:
13+
os.system('clear')
14+
# end of clear_screen
15+
16+
#install_dom function
17+
def install_dom(dpath):
18+
os.chdir(dpath)
19+
os.getcwd()
20+
#subprocess call to install libraries
21+
subprocess.call([sys.executable, "-m", "pip", "install", "-U", "-r", "requirements.txt"])
22+
#End of install_dom
23+
724
#Path to domains folder
825
def domainPath():
9-
1026
abs_path = os.path.abspath(__file__)
1127
fileDir = os.path.dirname(abs_path)
1228
path = os.path.join(fileDir, 'Domains')
1329
print(path)
1430
return path
1531
#end of domainPath
1632

17-
# check for command line arguments
18-
def check_args(args=None):
19-
if args == None:
20-
print("Please enter the required arguments!")
21-
22-
parser = argparse.ArgumentParser(
23-
description="pipinstall: a library to download multiple libraries in different domains at once.")
24-
parser.add_argument("domain_name",
25-
help="Domain name",
26-
type=str)
27-
28-
return parser.parse_args(args)
29-
# end of check_args
30-
31-
# Main function
32-
def Main():
33-
34-
utils.clear_screen()
35-
print("Welcome to pipinstall! A humble try to make our lives easier :')")
36-
37-
if check_args(sys.argv[1:]).domain_name:
38-
required_domain = check_args(sys.argv[1:]).domain_name
33+
#install function
34+
def install(domain_name=None):
35+
#clear_screen()
36+
print("Welcome to pipinstall! A humble try to make our lives easier :D")
3937

38+
if domain_name is not None:
4039
dpath = domainPath()
41-
dpath = os.path.join(dpath, required_domain)
40+
dpath = os.path.join(dpath, domain_name)
41+
4242
if os.path.isdir(dpath):
43-
utils.install_dom(dpath)
43+
install_dom(dpath)
4444
else:
4545
while not os.path.isdir(dpath):
46-
domain_name = str(input('Domain Name does not exist.\nPlease re-enter the domain name:'))
47-
dpath = os.path.join(dpath, domain_name)
46+
domain_name = str(input("Domain name does not exist. Please enter a valid domain name:\n"))
47+
dpath = os.path.join(dpath,domain_name)
4848
if os.path.isdir(dpath):
49-
utils.install_dom(dpath)
50-
51-
52-
# call Main
53-
if __name__ == '__main__':
54-
Main()
49+
install_dom(dpath)
5550

users/username1/projectname.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#projectname

users/username1/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#favLibs

0 commit comments

Comments
 (0)