-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyfetch.py
More file actions
126 lines (108 loc) · 4.28 KB
/
pyfetch.py
File metadata and controls
126 lines (108 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- coding: utf-8 -*-
import platform
import pip
import os
import sys
import requests
import pkgutil
from bs4 import BeautifulSoup
from colorama import Fore, Back, Style
from time import sleep
def main():
clear()
ver = platform.python_version()
architecture = platform.architecture()
system = platform.platform()
processor = platform.processor()
implementation = platform.python_implementation()
pip_ver = pip.__version__
packages_num = sys.modules.__len__()
python_art = [
Fore.BLUE + " ,.:;!!!;:., " + Fore.BLUE + "Python: " + Fore.YELLOW + ver,
Fore.BLUE + " !!!O:::::!!! " + Fore.BLUE + "Python implementation: " + Fore.YELLOW + implementation,
Fore.BLUE + " !:::::;;;;:: " + Fore.BLUE + "Pip: " + Fore.YELLOW + pip_ver,
Fore.BLUE + " ,,,,,.......!!!!!!" + Fore.YELLOW + " !!;;::., " + Fore.BLUE + "Pip packages: " + Fore.YELLOW + str(packages_num),
Fore.BLUE + " !!!::::::;;;;;;;;;;" + Fore.YELLOW + " !!;;::::., ",
Fore.BLUE + " !!!::::::::;;;;:::::" + Fore.YELLOW + " !!;;::::::: " + Fore.BLUE + "Operating System: " + Fore.YELLOW + system,
Fore.BLUE + "!!!:::::;;;:'''''''' " + Fore.YELLOW + ".;;;;;:;;;;; " + Fore.BLUE + "Architecture: " + Fore.YELLOW + architecture[0],
Fore.BLUE + "!!!::;::::" + Fore.YELLOW + " ,.::::;;;:::::::;;;;;; " + Fore.BLUE + "Processor: " + Fore.YELLOW + processor,
Fore.BLUE + " !!!!:::::" + Fore.YELLOW + " ::::::::::::::::::;;; ",
Fore.BLUE + " !!!:::::" + Fore.YELLOW + " ;;;;;;;````````````` ",
Fore.YELLOW + " !::::::::;!! ",
Fore.YELLOW + " !::::::;O!!! ",
Fore.YELLOW + " `':;!!!;:'` "
]
for i in python_art:
print(i)
print(Fore.WHITE, "\n[1]Show packages list [2]Find module description [3]Exit")
try:
select = int(input("Enter option number: "))
except:
print(Fore.RED, "Error: Valid value. You need to enter a number between 1-3.")
pause()
main()
if select == 1:
print_packages()
elif select == 2:
pypi_scrapping()
elif select == 3:
exit()
else:
pause()
clear()
main()
def clear():
if platform.system() == "Windows":
os.system("cls")
elif platform.system() == "Linux":
os.system("clear")
elif platform.system == "Darwin":
os.system("reset")
else:
print("Your os is not suported!")
sleep(5)
exit()
def pause():
if platform.system() == "Windows":
os.system("pause")
elif platform.system() == "Linux":
input("Press any key to continue . . .")
elif platform.system == "Darwin":
input("Press any key to continue . . .")
else:
print("Your os is not suported!")
sleep(5)
exit()
def print_packages():
for i, value in enumerate(pkgutil.iter_modules()):
print(Fore.YELLOW, "[", i + 1, "]", Fore.WHITE, value.name)
pause()
clear()
main()
def pypi_scrapping():
name = str(input("Enter module name: "))
try:
response = requests.get("https://pypi.org/project/{}".format(name))
if response.status_code == 200:
html = BeautifulSoup(response.text, 'html.parser')
output = html.find(class_="project-description")
print("\n\n", Fore.BLUE, name, Fore.YELLOW, "PyPi Description")
print(Fore.WHITE, output.text)
pause()
clear()
main()
elif response.status_code == 404:
print(
Fore.RED, "Error 404: No module named \"%s\" in PyPi. Please check spelling." % name)
pause()
clear()
main()
else:
print(Fore.RED, "Unknown Error: Something went wrong.")
pause()
clear()
main()
except requests.exceptions.ConnectionError:
print("Error 404: no internet connection.")
if __name__ == "__main__":
main()