@@ -834,30 +834,6 @@ def hash_files(self, crypto=None, **kwargs) -> ty.Dict[str, bytes]:
834
834
file_hashes [str (path )] = crypto_obj .hexdigest ()
835
835
return file_hashes
836
836
837
- def __bytes_repr__ (
838
- self , cache : dict # pylint: disable=unused-argument
839
- ) -> ty .Iterable [bytes ]:
840
- """Provided for compatibility with Pydra's hashing function, return the contents
841
- of all the files in the file-set in chunks
842
-
843
- Parameters
844
- ----------
845
- cache : dict
846
- an object passed around by Pydra's hashing function to store cached versions
847
- of previously hashed objects, to allow recursive structures
848
-
849
- Yields
850
- ------
851
- bytes
852
- a chunk of bytes of length FILE_CHUNK_LEN_DEFAULT from the contents of all
853
- files in the file-set.
854
- """
855
- cls = type (self )
856
- yield f"{ cls .__module__ } .{ cls .__name__ } :" .encode ()
857
- for key , chunk_iter in self .byte_chunks ():
858
- yield (",'" + key + "'=" ).encode ()
859
- yield from chunk_iter
860
-
861
837
@classmethod
862
838
def referenced_types (cls ) -> ty .Set [Classifier ]:
863
839
"""Returns a flattened list of nested types referenced within the fileset type
@@ -1633,8 +1609,23 @@ def type_name(cls):
1633
1609
assert cls .__name__ .endswith ("Mock" )
1634
1610
return cls .__name__ [: - len ("Mock" )]
1635
1611
1636
- def __bytes_repr__ (self , cache ):
1637
- yield from (str (fspath ).encode () for fspath in self .fspaths )
1612
+ def byte_chunks (
1613
+ self ,
1614
+ mtime : bool = False ,
1615
+ chunk_len = FILE_CHUNK_LEN_DEFAULT ,
1616
+ relative_to : ty .Optional [os .PathLike ] = None ,
1617
+ ignore_hidden_files : bool = False ,
1618
+ ignore_hidden_dirs : bool = False ,
1619
+ ):
1620
+ if relative_to is None :
1621
+ relative_to = os .path .commonpath (self .fspaths )
1622
+ else :
1623
+ relative_to = str (relative_to )
1624
+ for key , fspath in sorted (
1625
+ ((str (p )[len (relative_to ) :], p ) for p in self .fspaths ),
1626
+ key = itemgetter (0 ),
1627
+ ):
1628
+ yield (key , iter ([key .encode ()])) # empty iterator as files don't exist
1638
1629
1639
1630
@classproperty
1640
1631
def namespace (cls ):
0 commit comments