Commit a1e0d26e authored by Julien Muchembled's avatar Julien Muchembled

downloadunpacked: drop code that's not required anymore by slapos.recipe.cmmi

parent 25369e03
......@@ -29,10 +29,8 @@ import os
import subprocess
import tarfile
import tempfile
from hashlib import md5
from setuptools import archive_util
from . import is_true, EnvironMixin, Shared
from . import make_read_only_recursively # for slapos.recipe.cmmi
class Recipe(EnvironMixin):
......@@ -154,34 +152,3 @@ extraction_drivers = archive_util.extraction_drivers
patched_extraction_drivers = extraction_drivers[:2] + (
unpack_tarfile_patched,
)
class Signature: # for slapos.recipe.cmmi
def __init__(self, filename):
self.filename = filename
self.item_list = []
def update(self, key, value):
self.item_list.append(('%r: %r' % (key, value)).encode())
def hexdigest(self): # -> str
m = md5()
for item in self.item_list:
m.update(item)
return m.hexdigest()
def dumps(self):
return b'\n'.join(self.item_list)
def test(self, folder_path):
assert type(folder_path) is str, folder_path
digest = self.hexdigest()
if os.path.basename(folder_path) == digest:
target_path = os.path.join(folder_path, self.filename)
if os.path.exists(target_path) and open(target_path, 'rb').read() == self.dumps():
return True
return False
def save(self, folder_path):
with open(os.path.join(folder_path, self.filename), 'wb') as f:
f.write(self.dumps())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment