annotate paint/package.py @ 21:4df3e715817d

now have passing tests again
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 27 Feb 2012 13:44:52 -0800
parents 11bc01a089e7
children 54c1e7e43a54
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 """
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 package model for python PAckage INTrospection
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
5 import os
9
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
6 import shutil
19
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
7 import subprocess
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
8 import sys
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
9 import tarfile
5
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
10 import tempfile
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
11 import urllib2
21
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
12 import urlparse
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
13 import utils
5
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
14
19
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
15 try:
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
16 from subprocess import check_call as call
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
17 except ImportError:
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
18 from subporcess import call
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
19
10
d63ae03cc300 * fix up __init__ imports
Jeff Hammel <jhammel@mozilla.com>
parents: 9
diff changeset
20 __all__ = ['Package']
d63ae03cc300 * fix up __init__ imports
Jeff Hammel <jhammel@mozilla.com>
parents: 9
diff changeset
21
4
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 class Package(object):
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
23 # XXX much of this is generic resource stuff and should be split off
4
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 def __init__(self, src):
e230ac76aaa4 stub package model
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 self.src = src
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
27
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
28 # ephemeral data
5
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
29 self._tmppath = None
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
30 self._egg_info = None
5
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
31
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
32 def path(self):
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
33 """filesystem path to package"""
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
34
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
35 # return cached copy if it exists
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
36 if self._tmppath:
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
37 return self._tmppath
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
38
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
39 # fetch from the web if a URL
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
40 tmpfile = None
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
41 src = self.src
5
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
42 if utils.isURL(self.src):
8
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
43 tmpfile = src = self.fetch()
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
44
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
45 # unpack if an archive
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
46 if self.is_archive(src):
8
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
47 try:
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
48 self.unpack(src)
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
49 finally:
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
50 if tmpfile:
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
51 os.remove(tmpfile)
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
52 return self._tmppath
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
53
5
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
54 return self.src
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
55
5b74792d46e4 stub package model;
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
56 def fetch(self):
8
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
57 """fetch from remote source to a temporary file"""
15
8c8b7482772f fix a few failures but still failing
Jeff Hammel <jhammel@mozilla.com>
parents: 14
diff changeset
58 resource = urllib2.urlopen(self.src)
11
c41a946d34af stub out info method
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
59 fd, filename = tempfile.mkstemp()
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
60 os.write(fd, resource.read())
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
61 os.close(fd)
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
62 return filename
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
63
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
64 def unpack(self, archive):
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
65 """unpack the archive to a temporary destination"""
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
66 # TODO: should handle zipfile additionally at least
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
67 # Ideally, this would be pluggable, etc
8
c1181e9c9ca2 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
68 assert tarfile.is_tarfile(archive), "%s is not an archive" % self.src
9
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
69 tf = tarfile.TarFile.open(archive)
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
70 self._tmppath = tempfile.mkdtemp()
19
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
71 members = tf.getmembers()
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
72
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
73 # cut off the top level directory
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
74 assert not [i for i in members if not os.path.sep in i.name]
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
75 tld = set()
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
76 for member in members:
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
77 directory, member.name = member.name.split(os.path.sep, 1)
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
78 tld.add(directory)
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
79 assert len(tld) == 1
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
80
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
81 # extract
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
82 for member in members:
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
83 tf.extract(member, path=self._tmppath)
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
84 tf.close()
7
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
85
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
86 def is_archive(self, path):
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
87 """returns if the filesystem path is an archive"""
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
88 # TODO: should handle zipfile additionally at least
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
89 # Ideally, this would be pluggable, etc
a7bf894c96c7 yet more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
90 return tarfile.is_tarfile(path)
9
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
91
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
92 def cleanup(self):
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
93 if self._tmppath:
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
94 shutil.rmtree(self._tmppath)
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
95 self._tmppath = None
562230cc2e86 now the package class should at least extracts things. it doesnt actually do anything useful
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
96
18
4c4d1e194bf7 leave in debugging code for now
Jeff Hammel <jhammel@mozilla.com>
parents: 17
diff changeset
97 # __del__ = cleanup
11
c41a946d34af stub out info method
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
98
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
99 ### python-package-specific functionality
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
100
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
101 def egg_info(self):
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
102 """build the egg_info directory"""
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
103
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
104 if self._egg_info:
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
105 # return cached copy
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
106 return self._egg_info
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
107
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
108 directory = self.path()
16
e6cdc58fc4f5 more helpful debugging
Jeff Hammel <jhammel@mozilla.com>
parents: 15
diff changeset
109 setup_py = os.path.join(directory, 'setup.py')
e6cdc58fc4f5 more helpful debugging
Jeff Hammel <jhammel@mozilla.com>
parents: 15
diff changeset
110 if not os.path.exists(setup_py):
17
e74fc40e1f64 interpolate string
Jeff Hammel <jhammel@mozilla.com>
parents: 16
diff changeset
111 raise AssertionError("%s does not exist" % setup_py)
11
c41a946d34af stub out info method
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
112
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
113 # setup the egg info
19
c54db80d6e7f fix test
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
114 call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=subprocess.PIPE)
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
115
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
116 # get the .egg-info directory
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
117 egg_info = [i for i in os.listdir(directory)
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
118 if i.endswith('.egg-info')]
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
119 assert len(egg_info) == 1, 'Expected one .egg-info directory in %s, got: %s' % (directory, egg_info)
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
120 egg_info = os.path.join(directory, egg_info[0])
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
121 assert os.path.isdir(egg_info), "%s is not a directory" % egg_info
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
122
14
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
123 # cache it
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
124 self._egg_info = egg_info
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
125 return self._egg_info
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
126
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
127 def info(self):
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
128 """return info dictionary for package"""
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
129 # could use pkginfo
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
130
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
131 egg_info = self.egg_info()
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
132
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
133 # read the package information
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
134 pkg_info = os.path.join(egg_info, 'PKG-INFO')
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
135 info_dict = {}
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
136 for line in file(pkg_info).readlines():
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
137 if not line or line[0].isspace():
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
138 continue # XXX neglects description
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
139 assert ':' in line
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
140 key, value = [i.strip() for i in line.split(':', 1)]
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
141 info_dict[key] = value
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
142
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
143 # return the information
20
11bc01a089e7 return only the dictionary
Jeff Hammel <jhammel@mozilla.com>
parents: 19
diff changeset
144 return info_dict
13
0dd1f8f83be2 moving towards some sort of organization
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
145
11
c41a946d34af stub out info method
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
146 def dependencies(self):
14
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
147 """return the dependencies"""
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
148
21
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
149 # get the egg_info directory
14
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
150 egg_info = self.egg_info()
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
151
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
152 # read the dependencies
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
153 requires = os.path.join(egg_info, 'requires.txt')
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
154 if os.path.exists(requires):
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
155 dependencies = [i.strip() for i in file(requires).readlines() if i.strip()]
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
156 else:
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
157 dependencies = []
21
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
158 dependencies = dict([(i, None) for i in dependencies])
14
6d27c2136163 a decent structure; need to reuse more
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
159
21
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
160 # read the dependency links
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
161 dependency_links = os.path.join(egg_info, 'dependency_links.txt')
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
162 if os.path.exists(dependency_links):
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
163 links = [i.strip() for i in file(dependency_links).readlines() if i.strip()]
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
164 for link in links:
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
165 # XXX pretty ghetto
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
166 assert '#egg=' in link
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
167 url, dep = link.split('#egg=', 1)
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
168 if dep in dependencies:
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
169 dependencies[dep] = link
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
170
4df3e715817d now have passing tests again
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
171 return dependencies