~live-creator/live-creator/devel

« back to all changes in this revision

Viewing changes to livecreator_qt/pkgset/pkgsettabs/upstreampkgtab.py

  • Committer: Erwan Le Gall
  • Date: 2010-02-17 21:52:24 UTC
  • Revision ID: elegall@cyclope-20100217215224-ykdty3n20850aw68
working on packages managment

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        self.cache = {}
23
23
        for package in apt.Cache():
24
24
            self.cache[package.name]={}
25
 
            self.cache[package.name]["package"] = package
 
25
            self.cache[package.name]["Package"] = package
26
26
            self.cache[package.name]["Checked"] = False
27
27
            self.cache[package.name]["NeededBy"] = set()
28
28
 
29
29
 
 
30
    def packageList(self):
 
31
        """
 
32
            Return the full list of avalaible packages.
 
33
        """
 
34
        return self.cache.keys()
 
35
 
 
36
 
 
37
    def package(self, packageName):
 
38
        """
 
39
            Return an "apt/package" object
 
40
        """
 
41
        return self.cache[packageName]["Package"]
 
42
 
 
43
 
 
44
    def packageChecked(self, packageName):
 
45
        """
 
46
            Return the package "choosed" state
 
47
        """
 
48
        return self.cache[packageName]["Checked"]
 
49
 
 
50
 
 
51
    def packageParents(self, packageName):
 
52
        """
 
53
            Return a list containing all the package which depends of this one.
 
54
        """
 
55
        return self.cache[packageName]["NeededBy"]
 
56
 
 
57
 
30
58
 
31
59
class UpstreamPkg(QtGui.QMainWindow):
32
60
    def __init__(self, livecreatorConfig, xmlFile, summaryPkgTab, parent=None):
164
192
        self.table.cleanCheckList()
165
193
        self.table.initPackDict()
166
194
 
167
 
###########My table model
 
195
 
 
196
 
168
197
class MyTableModel(QtCore.QAbstractTableModel):
 
198
    """
 
199
        Table containing package list.
 
200
    """
169
201
    def __init__(self, xmlFile,  tSize, Description, FilterLine, FilterList, summaryPkgTab, parent=None):
 
202
        """
 
203
            TableModel contains a PackDict which is the list of avalaible packages
 
204
            (list build from host apt sources), and for each package a state :
 
205
             -> Checked : if user choose package or if it's a dependance
 
206
             -> NeededBy : list of other packages that depend of this one. 
 
207
        """
170
208
        QtCore.QAbstractTableModel.__init__(self, parent)
171
209
 
172
210
        self.tSize = tSize
177
215
        self.xmlFile = xmlFile
178
216
        self.summaryPkgTab = summaryPkgTab
179
217
 
180
 
        ########### chargement du cache de packages
 
218
        # This constructor can take a while : he build a dictionnary with all
 
219
        # the packages.
181
220
        self.packdict = PackDict()
 
221
        
 
222
        ### FIXME FROM HERE (A)
182
223
        self.cache = apt.Cache()
183
224
        self.fulllist = self.cache.keys()
184
225
        self.list = self.fulllist[:]
185
 
 
186
226
        
187
227
        #self.checks = {}
188
228
         # ajout (initialisation) du champ "checked" dans chaque instance de Package du cache
195
235
            #    package.checked = True
196
236
        #for package in self.cache:
197
237
            #package.neededBy = set()
 
238
        ### FIXME TO HERE (A)
198
239
 
199
240
        self.columns = ['checked', 'name', 'packageSize', 'candidateVersion', 'summary']
200
241
        self.columnHeaders = { 'checked': '',
205
246
                                }
206
247
 
207
248
        #Load upstream package from xml file
208
 
 
209
 
 
 
249
        package = self.packdict.package("vim")
 
250
        deps=set()
 
251
        dependances = self.dependencies(self.cache,package,deps,"Depends")
 
252
        print ""
 
253
        print ""
 
254
        print ""
 
255
        print dependances
 
256
        print ""
 
257
        print ""
 
258
        print ""
 
259
        print package.candidate.dependencies
 
260
        print ""
 
261
        print ""
 
262
        print ""
210
263
 
211
264
 
212
265
########
 
266
### FIXME FROM HERE (B)
213
267
    def cleanCheckList(self):
214
268
        """
215
269
            Uncheck all packages in list and
220
274
#            package.checked = False
221
275
        for package in self.cache:
222
276
            package.neededBy = set()
223
 
 
 
277
### FIXME TO HERE (B)
224
278
 
225
279
    def initList(self,pkglist):
226
280
        """
227
 
            Initialize the list from xml file
 
281
            Initialize the choosed package list from xml file
228
282
        """
229
283
        for pack in pkglist:
230
284
            try :
482
536
 
483
537
    def dependencies(self,cache, pkg, deps, key="Depends"):
484
538
        """
485
 
            Return the package dependencies
 
539
            Recursive function which return a set of the package
 
540
            dependencies
486
541
        """
487
542
        #print "pkg: %s (%s)" % (pkg.name, deps)
 
543
        # First, check if there is a candidate version for this package
488
544
        candver = cache._depcache.GetCandidateVer(pkg._pkg)
489
545
        if candver == None:
490
546
            return deps