scmrepo 1.4.1__py3-none-any.whl → 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of scmrepo might be problematic. Click here for more details.

@@ -0,0 +1,74 @@
1
+ import errno
2
+ import os
3
+ from typing import TYPE_CHECKING, BinaryIO, Callable, Collection, Optional, Union
4
+
5
+ from .pointer import Pointer
6
+ from .progress import LFSCallback
7
+
8
+ if TYPE_CHECKING:
9
+ from scmrepo.git import Git
10
+ from scmrepo.progress import GitProgressEvent
11
+
12
+
13
+ class LFSStorage:
14
+ def __init__(self, path: str):
15
+ self.path = path
16
+
17
+ def fetch(
18
+ self,
19
+ url: str,
20
+ objects: Collection[Pointer],
21
+ progress: Optional[Callable[["GitProgressEvent"], None]] = None,
22
+ ):
23
+ from .client import LFSClient
24
+
25
+ with LFSCallback.as_lfs_callback(progress) as cb:
26
+ cb.set_size(len(objects))
27
+ with LFSClient.from_git_url(url) as client:
28
+ client.download(self, objects, callback=cb)
29
+
30
+ def oid_to_path(self, oid: str):
31
+ return os.path.join(self.path, "objects", oid[0:2], oid[2:4], oid)
32
+
33
+ def exists(self, obj: Union[Pointer, str]):
34
+ oid = obj if isinstance(obj, str) else obj.oid
35
+ path = self.oid_to_path(oid)
36
+ return os.path.exists(path)
37
+
38
+ def open(
39
+ self,
40
+ obj: Union[Pointer, str],
41
+ fetch_url: Optional[str] = None,
42
+ **kwargs,
43
+ ) -> BinaryIO:
44
+ oid = obj if isinstance(obj, str) else obj.oid
45
+ path = self.oid_to_path(oid)
46
+ try:
47
+ return open(path, **kwargs) # pylint: disable=unspecified-encoding
48
+ except FileNotFoundError:
49
+ if not fetch_url or not isinstance(obj, Pointer):
50
+ raise
51
+ try:
52
+ self.fetch(fetch_url, [obj])
53
+ except BaseException as exc:
54
+ raise FileNotFoundError(
55
+ errno.ENOENT, os.strerror(errno.ENOENT), path
56
+ ) from exc
57
+ return open(path, **kwargs) # pylint: disable=unspecified-encoding
58
+
59
+ def close(self):
60
+ pass
61
+
62
+
63
+ def get_storage_path(scm: "Git") -> str:
64
+ """Return the LFS storage directory for the specified repository."""
65
+
66
+ config = scm.get_config()
67
+ git_dir = scm._get_git_dir(scm.root_dir) # pylint: disable=protected-access
68
+ try:
69
+ path = config.get(("lfs",), "storage")
70
+ if os.path.isabs(path):
71
+ return path
72
+ except KeyError:
73
+ path = "lfs"
74
+ return os.path.join(git_dir, path)
scmrepo/git/objects.py CHANGED
@@ -20,7 +20,7 @@ def _to_datetime(time: int, offset: int) -> datetime.datetime:
20
20
 
21
21
  class GitObject(ABC):
22
22
  @abstractmethod
23
- def open(self, mode: str = "r", encoding: str = None):
23
+ def open(self, mode: str = "r", encoding: str = None, **kwargs):
24
24
  pass
25
25
 
26
26
  @property
@@ -82,12 +82,13 @@ class GitTrie:
82
82
  key: tuple,
83
83
  mode: Optional[str] = "r",
84
84
  encoding: Optional[str] = None,
85
+ raw: bool = True,
85
86
  ):
86
87
  obj = self.trie[key]
87
88
  if obj.isdir:
88
89
  raise IsADirectoryError
89
90
 
90
- return obj.open(mode=mode, encoding=encoding)
91
+ return obj.open(mode=mode, encoding=encoding, key=key, raw=raw, rev=self.rev)
91
92
 
92
93
  def exists(self, key: tuple) -> bool:
93
94
  return bool(self.trie.has_node(key))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scmrepo
3
- Version: 1.4.1
3
+ Version: 1.5.0
4
4
  Summary: SCM wrapper and fsspec filesystem for Git for use in DVC
5
5
  Home-page: https://github.com/iterative/scmrepo
6
6
  Maintainer-email: support@dvc.org
@@ -17,13 +17,15 @@ Description-Content-Type: text/x-rst
17
17
  License-File: LICENSE
18
18
  Requires-Dist: gitpython >3
19
19
  Requires-Dist: dulwich >=0.21.6
20
- Requires-Dist: pygit2 >=1.13.0
20
+ Requires-Dist: pygit2 >=1.13.3
21
21
  Requires-Dist: pygtrie >=2.3.2
22
22
  Requires-Dist: fsspec >=2021.7.0
23
23
  Requires-Dist: pathspec >=0.9.0
24
24
  Requires-Dist: asyncssh <3,>=2.13.1
25
25
  Requires-Dist: funcy >=1.14
26
26
  Requires-Dist: shortuuid >=0.5.0
27
+ Requires-Dist: dvc-objects <2,>=1.0.1
28
+ Requires-Dist: dvc-http >=2.29.0
27
29
  Provides-Extra: dev
28
30
  Requires-Dist: pytest ==7.2.0 ; extra == 'dev'
29
31
  Requires-Dist: pytest-sugar ==0.9.5 ; extra == 'dev'
@@ -0,0 +1,37 @@
1
+ scmrepo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ scmrepo/asyn.py,sha256=YdoLzqF7drmnf1yN24-0IwyosPi1Pf5qlLRVUI4L2qo,1529
3
+ scmrepo/base.py,sha256=QvsA_7mzzcKnVIb8N4mT4P1ICDE6fr8biq-3Zi5cGtc,3078
4
+ scmrepo/exceptions.py,sha256=vR8BuCKgKh9lMnCemzNYGHiJctioOmhn_Kv5m8XO69Y,1053
5
+ scmrepo/fs.py,sha256=l89aBdQgL8-QzRS9wt9e2lqdFT9hwZl1av-sjsieJKI,7960
6
+ scmrepo/noscm.py,sha256=4saJAIuz0gqclBstSWebMJA6GxCUTTj2YBIvg-VFp8s,424
7
+ scmrepo/progress.py,sha256=6FdR5JkJE76oR-oEqRKatOdIIKdCudcos0BOZjlAd7I,2143
8
+ scmrepo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ scmrepo/utils.py,sha256=_F3rVvPhES-A2JxLGob0RV8BOnHzxbA9aDPClA7_V8M,1512
10
+ scmrepo/git/__init__.py,sha256=eNnK36gjz5eWtDigUpTBEhOtN56eYr9Xwdw7PessrrQ,17051
11
+ scmrepo/git/config.py,sha256=_pt8Ygdz71xcbo4KvX_5dW14ujHmPJX3z3W8Ikasd-M,940
12
+ scmrepo/git/credentials.py,sha256=i3DzfSY9Q7iHKJTnNBdYdY8eOFJuT4GFtw-jIIplr48,20986
13
+ scmrepo/git/objects.py,sha256=yey3YlNWf3-9FLKDoPBvr2vn_kmC71AN20f8_CUVlNk,4632
14
+ scmrepo/git/stash.py,sha256=wKWnYj_xpdT_3pvHiXtE7_I_By4S-Zbxf4Lv-ZY2sxI,2785
15
+ scmrepo/git/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ scmrepo/git/backend/base.py,sha256=E3WBz1cjZrDyF2eDZ7KBRBmcmW2-o3c4OGbTsQJ78w0,13447
17
+ scmrepo/git/backend/gitpython.py,sha256=Jc-M5UG5EDiS9E6PTEqcNK_vsi2MIYSm5qb9_g-h-nc,25188
18
+ scmrepo/git/backend/dulwich/__init__.py,sha256=iaevbtpny24kqY5391jOnvJ37Rw1MCK0C42NcQuOkV4,34293
19
+ scmrepo/git/backend/dulwich/asyncssh_vendor.py,sha256=-rdMZQPQZVR1b_aZn8CoDd0ml3dK1e8EjDAQQF8CKW8,11439
20
+ scmrepo/git/backend/dulwich/client.py,sha256=sxz6eJ1VNVQA32AxWnpjyearcS8O99NnbyCUyO2cPx4,2345
21
+ scmrepo/git/backend/pygit2/__init__.py,sha256=ZztTMnmon1npW5XEANXksTUi3u9DVA4ib2RXCITe9Hs,36837
22
+ scmrepo/git/backend/pygit2/callbacks.py,sha256=RXhzUU3IhKFinbZPGzdTn3bcmcPa1dF7CNpFW-kTAHk,2668
23
+ scmrepo/git/backend/pygit2/filter.py,sha256=cvmkeQp-Xl-bOk0dcTCJVDkDknF1SYtKtkuOgVbS5b0,2158
24
+ scmrepo/git/lfs/__init__.py,sha256=at5blRIKnKpg_g5dLRDsGWBFi6SbucRlF_DX6aAkGtE,257
25
+ scmrepo/git/lfs/client.py,sha256=GOM2pgdZwVJq6nMLCn6fDv6YRzzAAHVcW9xR0IuYSdA,7184
26
+ scmrepo/git/lfs/exceptions.py,sha256=cLlImmPXWJJUl44S4xcRBa2T9wYRkWTaKQGwJylwOhA,77
27
+ scmrepo/git/lfs/fetch.py,sha256=tH64glllmQcogAr7-OB5dpzNvM5caIEp2sYC5ocYX1Y,4770
28
+ scmrepo/git/lfs/object.py,sha256=2wHbVjloTcAWPtyCnEroEiCr15hq3o-Q0d2qESaEEN4,343
29
+ scmrepo/git/lfs/pointer.py,sha256=l2EmyRsYKAj8nBMvc3rhiUS7eR93-rMfk1TJuQ_CpYQ,3281
30
+ scmrepo/git/lfs/progress.py,sha256=J0j9jlTWeLIK0vLWK9UXEvHsVfKbhJjJp4Bkk55bQ7c,1732
31
+ scmrepo/git/lfs/smudge.py,sha256=sMSatXCTHZ5cAo-gaE_6KXwCHlXGqzkF0dVgIbPwTJU,1563
32
+ scmrepo/git/lfs/storage.py,sha256=I8NXWL1roAc0_66Mt0fsdiy9MP4Oqhk9ATlVjx-rNIU,2246
33
+ scmrepo-1.5.0.dist-info/LICENSE,sha256=-1jhbPjoIVHR0cEgahL4Zhct75Ff4MzYCR_jOaJDPq8,11340
34
+ scmrepo-1.5.0.dist-info/METADATA,sha256=X5lDThMFlonaqgJm3NHjcNFAmvCUfX4s5wUoH500LxE,5606
35
+ scmrepo-1.5.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
36
+ scmrepo-1.5.0.dist-info/top_level.txt,sha256=iunjod6w3GogERsAYfLRupnANXnqzX3jbIfbeIQG5cc,8
37
+ scmrepo-1.5.0.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- scmrepo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- scmrepo/asyn.py,sha256=YdoLzqF7drmnf1yN24-0IwyosPi1Pf5qlLRVUI4L2qo,1529
3
- scmrepo/base.py,sha256=e2O_pSODZxPGBUGDyMXd4P5eSQX1NteXWsqKJ41ITBQ,2930
4
- scmrepo/exceptions.py,sha256=vR8BuCKgKh9lMnCemzNYGHiJctioOmhn_Kv5m8XO69Y,1053
5
- scmrepo/fs.py,sha256=MrzkR8MMa3gVV9DDAzoHsyoWGx1pBRTClaIrPA0e8SM,7904
6
- scmrepo/noscm.py,sha256=4saJAIuz0gqclBstSWebMJA6GxCUTTj2YBIvg-VFp8s,424
7
- scmrepo/progress.py,sha256=6FdR5JkJE76oR-oEqRKatOdIIKdCudcos0BOZjlAd7I,2143
8
- scmrepo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- scmrepo/utils.py,sha256=_F3rVvPhES-A2JxLGob0RV8BOnHzxbA9aDPClA7_V8M,1512
10
- scmrepo/git/__init__.py,sha256=t86_3Rm_9Tp1RvxpM_O_ozriuTkUTTfJaviMChC9KYs,16517
11
- scmrepo/git/credentials.py,sha256=i3DzfSY9Q7iHKJTnNBdYdY8eOFJuT4GFtw-jIIplr48,20986
12
- scmrepo/git/objects.py,sha256=zTC0nx2u7NCl3rlWRhUGc3VCCJK-_qykmkADENYqywE,4564
13
- scmrepo/git/stash.py,sha256=wKWnYj_xpdT_3pvHiXtE7_I_By4S-Zbxf4Lv-ZY2sxI,2785
14
- scmrepo/git/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- scmrepo/git/backend/base.py,sha256=76oYxcSyXfTYuLoRfNr3n_hbtAbw9k6heRgJicWmcBY,12109
16
- scmrepo/git/backend/gitpython.py,sha256=OcC1kWj8uKSBUrTyjhZi_kkIqLw3wUqR0vqqegVWw24,23548
17
- scmrepo/git/backend/dulwich/__init__.py,sha256=NKiyCMTjXlNQuKfNWMEp8TQ-tG30EnNgwT4Qs1vaW_E,32105
18
- scmrepo/git/backend/dulwich/asyncssh_vendor.py,sha256=-rdMZQPQZVR1b_aZn8CoDd0ml3dK1e8EjDAQQF8CKW8,11439
19
- scmrepo/git/backend/dulwich/client.py,sha256=sxz6eJ1VNVQA32AxWnpjyearcS8O99NnbyCUyO2cPx4,2345
20
- scmrepo/git/backend/pygit2/__init__.py,sha256=S1vk-_o0QzVZdvaj9Je_DNZmfWF9wwcYs9nMR6cfbA0,32477
21
- scmrepo/git/backend/pygit2/callbacks.py,sha256=RXhzUU3IhKFinbZPGzdTn3bcmcPa1dF7CNpFW-kTAHk,2668
22
- scmrepo-1.4.1.dist-info/LICENSE,sha256=-1jhbPjoIVHR0cEgahL4Zhct75Ff4MzYCR_jOaJDPq8,11340
23
- scmrepo-1.4.1.dist-info/METADATA,sha256=dJ2QyvrmIIZXjB7oKiMZWzi0EW6PCFLfrIua_OdfzVw,5535
24
- scmrepo-1.4.1.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
25
- scmrepo-1.4.1.dist-info/top_level.txt,sha256=iunjod6w3GogERsAYfLRupnANXnqzX3jbIfbeIQG5cc,8
26
- scmrepo-1.4.1.dist-info/RECORD,,