Skip to content

Commit 58d427c

Browse files
Use adaptor in _create_meta
1 parent 2a0c1fa commit 58d427c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pins/boards.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from importlib_resources import files
1313

14-
from ._adaptors import _create_adaptor
14+
from ._adaptors import _Adaptor, _create_adaptor
1515
from .cache import PinsCache
1616
from .config import get_allow_rsc_short_name
1717
from .drivers import default_title, load_data, load_file, save_data
@@ -22,6 +22,8 @@
2222

2323
_log = logging.getLogger(__name__)
2424

25+
_ = default_title # Keep this import for backward compatibility
26+
2527

2628
class IFileSystem(Protocol):
2729
protocol: "str | list"
@@ -621,6 +623,8 @@ def prepare_pin_version(
621623
created: Optional[datetime] = None,
622624
object_name: Optional[str] = None,
623625
):
626+
x = _create_adaptor(x)
627+
624628
meta = self._create_meta(
625629
pin_dir_path,
626630
x,
@@ -642,7 +646,7 @@ def prepare_pin_version(
642646
def _create_meta(
643647
self,
644648
pin_dir_path,
645-
x,
649+
x: _Adaptor,
646650
name: Optional[str] = None,
647651
type: Optional[str] = None,
648652
title: Optional[str] = None,
@@ -659,7 +663,7 @@ def _create_meta(
659663
raise NotImplementedError("Type argument is required.")
660664

661665
if title is None:
662-
title = default_title(x, name)
666+
title = x.default_title(name)
663667

664668
# create metadata from object on disk ---------------------------------
665669
# save all pin data to a temporary folder (including data.txt), so we
@@ -671,7 +675,7 @@ def _create_meta(
671675
p_obj = Path(pin_dir_path) / object_name
672676

673677
# file is saved locally in order to hash, calc size
674-
file_names = save_data(x, str(p_obj), type)
678+
file_names = save_data(x._d, str(p_obj), type)
675679

676680
meta = self.meta_factory.create(
677681
pin_dir_path,
@@ -1122,7 +1126,6 @@ def path_to_deploy_version(self, name: str, version: str):
11221126
def user_name(self):
11231127
return self.fs.api.get_user()["username"]
11241128

1125-
# TODO(NAMC) what about the functions that call this one?
11261129
def prepare_pin_version(self, pin_dir_path, x, name: "str | None", *args, **kwargs):
11271130
adaptor = _create_adaptor(x)
11281131

@@ -1133,9 +1136,7 @@ def prepare_pin_version(self, pin_dir_path, x, name: "str | None", *args, **kwar
11331136

11341137
# TODO(compat): py pins always uses the short name, R pins uses w/e the
11351138
# user passed, but guessing people want the long name?
1136-
meta = super()._create_meta(
1137-
pin_dir_path, adaptor, short_name, *args, **kwargs
1138-
) # TODO(NAMC) ensure .create_meta can accept adaptor
1139+
meta = super()._create_meta(pin_dir_path, adaptor, short_name, *args, **kwargs)
11391140
meta.name = name
11401141

11411142
# copy in files needed by index.html ----------------------------------

0 commit comments

Comments
 (0)