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
|
import os
from abc import ABCMeta, abstractmethod
from six import add_metaclass
class LockfilePackageMeta(object):
"""
Basic struct representing package meta from lockfile.
"""
__slots__ = ("name", "version", "sky_id", "integrity", "integrity_algorithm", "tarball_path")
@staticmethod
def from_str(s):
return LockfilePackageMeta(*s.strip().split(" "))
def __init__(self, name, version, sky_id, integrity, integrity_algorithm):
self.name = name
self.version = version
self.sky_id = sky_id
self.integrity = integrity
self.integrity_algorithm = integrity_algorithm
self.tarball_path = "{}-{}.tgz".format(name, version)
def to_str(self):
return " ".join([self.name, self.version, self.sky_id, self.integrity, self.integrity_algorithm])
class LockfilePackageMetaInvalidError(RuntimeError):
pass
@add_metaclass(ABCMeta)
class BaseLockfile(object):
@classmethod
def load(cls, path):
"""
:param path: lockfile path
:type path: str
:rtype: BaseLockfile
"""
pj = cls(path)
pj.read()
return pj
def __init__(self, path):
if not os.path.isabs(path):
raise TypeError("Absolute path required, given: {}".format(path))
self.path = path
self.data = None
@abstractmethod
def read(self):
pass
@abstractmethod
def write(self, path=None):
pass
@abstractmethod
def get_packages_meta(self):
pass
@abstractmethod
def update_tarball_resolutions(self, fn):
pass
|