-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.py
58 lines (42 loc) · 1.59 KB
/
backend.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
# This is more of an API document now, as we're not inheriting from it any more.
class Backend(object):
def __init__(self, targname, cfg):
self.targname = targname
self.cfg = cfg
self.allrepos = []
self.repo = None
return
def __str__(self):
if isinstance(self.cfg, dict) and 'type' in self.cfg:
return 'generic (type %s)' % (self.cfg['type'],)
else:
return 'generic (no cfg)'
def ListRepos(self): # list the BKs this backend has access to
self.allrepos = []
return self.allrepos
def SetRepo(self, repo): # Set BK for all operations
if not self.allrepos: self.ListRepos()
if not repo in self.allrepos: raise ValueError('repo "%s" not found' % (repo,))
self.repo = repo
def DoneRepo(self):
return
def GetIndexNumber(self):
raise NotImplementedError
def GetChunkNames(self): # returns data chunk names
return []
def GetChunkNamesSizes(self):
return {}
def GetChunkData(self, n):
return ''
def PutChunkData(self, n, data):
return
def DelChunk(self, n):
return
def GetCoreFile(self, fname):
return
def PutCoreFile(self, fname, data):
return
def DelCoreFile(self, fname):
os.remove(OPJ(self.repoDir, fname))
def LocalPathForChunk(self, n): # only for local-drive storage - enables shutil.copyfile optimisation
return ''