-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrab_dependencies.py
More file actions
38 lines (27 loc) · 1017 Bytes
/
grab_dependencies.py
File metadata and controls
38 lines (27 loc) · 1017 Bytes
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
"""
Extract the dependencies from the repository
Issue:
work out dependencies #3
https://github.com/lbillingham/commit_opener/issues/3
"""
def catfile(filename):
"""Get text contents of a file."""
with open(filename, 'r') as fhandle:
return "\n".join(fhandle.read())
def get_dependencies(name, url):
# Let's instantiate the repo object, so we can parse through it.
myrepo = repo.Repo(name, url)
# Extract a local copy
myrepo.extract_local_copy()
# Note: the file has to be opened and read before passing to depsy
# functions.
if myrepo.has("requirements.txt"):
filetext = catfile(myrepo.has("requirements.txt"))
reqs = depsy.models.python(filetext)
elif myrepo.has("setup.py"):
filetext = catfile(myrepo.has("setup.py"))
reqs = depsy.models.parse_setup_py(filetext)
else:
# No standard descriptions of the dependencies so let's try to work
# them out for ourselves.
pass