-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpeb.py
110 lines (79 loc) · 3.13 KB
/
peb.py
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
'''!
Project Entries Binder (ProjEB) Command Line Interface (CLI)
Date created: 28th April 2019
License: GNU General Public License version 3 for academic or
not-for-profit use only
ProjEB is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import argparse
import os
import random
import subprocess
import sys
import libprojeb
def listDependencies(codefile):
"""!
Function to list the dependencies (with version number, if any)
of the given code file.
Usage:
python peb.py listdep --codefile=<path to Python code file>
Results are shown in the following format:
<count> : <dependency name> : <version> : <dependency file path>
@param codefile String: Path to Python code file.
"""
codefile = os.path.abspath(codefile)
results = libprojeb.listDependencies(codefile)
print("Count : Dependency Name : Version : Dependency File Path")
count = 1
for x in results:
print("%s : %s : %s : %s" % (str(count), x[0], x[1], x[2]))
count = count + 1
def listPythonInstalledModules():
"""!
Function to list the non-standard libraries (with version number,
if any) installed in Python.
Usage:
python peb.py listpim
Results are shown in the following format:
<count> : <module name> : <version>
"""
results = libprojeb.listPythonInstalledModules()
print("Count : Module Name : Version")
count = 1
for x in results:
print("%s : %s : %s" % (str(count), x[0], x[1]))
count = count + 1
def listPythonSystem():
"""!
Function to list information about the installed Python system.
Usage:
python peb.py listpysys
Results are shown in the following format:
<count> : <attribute name> : <attribute value>
"""
results = libprojeb.listPythonSystem()
print("Count : Attribute : Value")
count = 1
for x in results:
print("%s : %s : %s" % (str(count), x, results[x]))
count = count + 1
if __name__ == '__main__':
parser = argparse.ArgumentParser()
subparser = parser.add_subparsers(dest="command")
listdep = subparser.add_parser("listdep")
listdep.add_argument('--codefile', type=str, required=True, help="path of file to check for dependencies")
listpim = subparser.add_parser("listpim")
listpysys = subparser.add_parser("listpysys")
args = parser.parse_args()
if args.command.lower() == "listdep": listDependencies(os.path.abspath(args.codefile))
elif args.command.lower() == "listpim": listPythonInstalledModules()
elif args.command.lower() == "listpysys": listPythonSystem()