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
|
# Copyright 2008 The Tor Project, Inc. See LICENSE for licensing information.
class PackageMetasystem:
def __init__(self, repository):
self._repostitory = repository
self._systems = {}
def addPackageSystem(self, system):
self._systems[system.getName()] = system
def getSysForPackage(self, pkg):
return self._systems.get(pkg['format'], None)
@staticmethod
def create(repository):
r = PackageMetasystem(repository)
try:
import rpm
except ImportError:
pass
else:
import thandy.packagesys.RPMPackages
r.addPackageSystem(thandy.packagesys.RPMPackages.RPMPackageSystem(
repository))
import thandy.packagesys.ExePackages
r.addPackageSystem(thandy.packagesys.ExePackages.ExePackageSystem(
repository))
return r
class PackageSystem:
def getName(self):
raise NotImplemented()
def packageHandlesFromJSON(self, json):
raise NotImplemented()
def canBeAutomatic(self):
return True
def canHaveUI(self):
return False
def getTransaction(self):
return PackageTransaction()
class PackageTransaction:
def __init__(self):
self._transactions = []
def _start(self):
pass
def _commit(self):
pass
def run(self):
self._start()
for cb in self._transactions:
cb(self)
self._commit()
def addInstall(self, packageHandle):
self._transactions.append(packageHandle.install)
def addRemove(self, packageHandle):
self._transactions.append(packageHandle.remove)
class PackageHandle:
def __init__(self):
pass
def getRelativePath(self):
raise NotImplemented()
def isInstalled(self, transaction=None):
raise NotImplemented()
def anyVersionInstalled(self, transaction=None):
raise NotImplemented()
def getInstalledVersion(self, transaction=None):
raise NotImplemented()
def install(self, transaction):
raise NotImplemented()
def remove(self, transaction):
raise NotImplemented()
def checkInstall(self, transaction=None):
raise NotImplemented()
|