mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 23:11:44 +01:00
Initial unittests for new design. Signed-off-by: Ruslan Kuprieiev <[email protected]>
26 lines
658 B
Python
26 lines
658 B
Python
import os
|
|
|
|
|
|
class Cache(object):
|
|
CACHE_DIR = 'cache'
|
|
|
|
def __init__(self, dvc_dir):
|
|
self.cache_dir = os.path.abspath(os.path.realpath(os.path.join(dvc_dir, self.CACHE_DIR)))
|
|
|
|
@staticmethod
|
|
def init(dvc_dir):
|
|
cache_dir = os.path.join(dvc_dir, Cache.CACHE_DIR)
|
|
os.mkdir(cache_dir)
|
|
return Cache(dvc_dir)
|
|
|
|
def all(self):
|
|
clist = []
|
|
for cache in os.listdir(self.cache_dir):
|
|
path = os.path.join(self.cache_dir, cache)
|
|
if os.path.isfile(path):
|
|
clist.append(path)
|
|
return clist
|
|
|
|
def get(self, md5):
|
|
return os.path.join(self.cache_dir, md5)
|