MCPcopy Create free account
hub / github.com/wal-e/wal-e / FileKey

Class FileKey

wal_e/blobstore/file/calling_format.py:31–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30
31class FileKey(object):
32 def __init__(self, bucket, name):
33 self.bucket = bucket
34 self.name = name
35 self.path = os.path.join("/", name.strip("/"))
36 if os.path.isfile(self.path):
37 stat = os.stat(self.path)
38 self.last_modified = epoch_to_iso8601(stat.st_mtime)
39 self.size = stat.st_size
40
41 def get_contents_as_string(self):
42 with open(self.path, 'rb') as fp:
43 contents = fp.read()
44 return contents
45
46 def set_contents_from_file(self, fp):
47 ensure_dir_exists(self.path)
48 with open(self.path, 'wb') as f:
49 shutil.copyfileobj(fp, f)
50 setattr(self, 'size', os.path.getsize(self.path))
51
52 def get_contents_to_file(self, fp):
53 with open(self.path, 'rb') as f:
54 shutil.copyfileobj(f, fp)
55
56
57class Bucket(object):

Callers 2

get_keyMethod · 0.85
listMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected