@@ -637,7 +637,7 @@ class BoardManual(BaseBoard):
637637 >>> import fsspec
638638 >>> import os
639639 >>> fs = fsspec.filesystem("github", org = "machow", repo = "pins-python")
640- >>> pin_paths = {"df_csv": "df_csv/20220214T163720Z-9bfad"}
640+ >>> pin_paths = {"df_csv": "df_csv/20220214T163720Z-9bfad/ "}
641641 >>> board = BoardManual("pins/tests/pins-compat", fs, pin_paths=pin_paths)
642642
643643 >>> board.pin_list()
@@ -690,7 +690,9 @@ def pin_meta(self, name, version=None):
690690 # create metadata, rather than read from a file
691691 return self .meta_factory .create_raw (path_to_pin , type = "file" , name = pin_name )
692692
693- path_meta = self .construct_path ([pin_name , meta_name ])
693+ # note that pins on this board should point to versions, so we use an
694+ # empty string to mark version (it ultimately is ignored)
695+ path_meta = self .construct_path ([pin_name , "" , meta_name ])
694696 f = self ._open_pin_meta (path_meta )
695697 meta = self .meta_factory .read_pin_yaml (f , pin_name , VersionRaw ("" ))
696698
@@ -717,21 +719,34 @@ def construct_path(self, elements):
717719 pin_name , * others = elements
718720 pin_path = self .pin_paths [pin_name ]
719721
720- if self .board .strip () == "" :
721- return pin_path
722+ pre_components = [] if not self .board else [self .board ]
722723
723- if len (others ):
724- # this is confusing, but R pins url board has a final "/" indicate that
725- # something is a pin version, rather than a single file. but since other
726- # boards forbid a final /, we need to strip it off to join elements
727- pin_path = pin_path .rstrip ().rstrip ("/" )
724+ # note that for paths where version is specified, it gets omitted,
725+ # since pin_path should point to a pin version
726+ if not pin_path .endswith ("/" ):
727+ if len (others ):
728+ raise ValueError (
729+ f"pin path { pin_path } does not end in '/' so is assumed to be a"
730+ f" single file. Cannot construct a path to elements { elements } ."
731+ )
732+ return "/" .join (pre_components + [pin_path ])
733+
734+ # handle paths to pins (i.e. end with /) ----
735+ stripped = pin_path [:- 1 ]
736+
737+ if len (others ) == 0 :
738+ return "/" .join (pre_components + [pin_path ])
739+ elif len (others ) == 1 :
740+ version = others [0 ]
741+ return "/" .join (pre_components + [pin_path ])
742+ elif len (others ) == 2 :
743+ version , meta = others
728744
729- # this is a bit hacky, but this board only aims at specific pins versions,
730- # so the metadata has the version as "", so we need to remove it.
731- if others [0 ] == "" :
732- return super ().construct_path ([pin_path , * others [1 :]])
745+ return "/" .join (pre_components + [stripped , meta ])
733746
734- return super ().construct_path ([pin_path , * others ])
747+ raise NotImplementedError (
748+ f"Unable to construct path from these elements: { elements } "
749+ )
735750
736751
737752class BoardRsConnect (BaseBoard ):
0 commit comments