(self, link)
return parts
Get parts of part that must be os.path.joined with cache_dir
Get parts of part that must be os.path.joined with cache_dir
Get parts of part that must be os . path . joined with cache_dir
def _get_cache_path_parts(self, link):
        # type: (Link) -> List[str]
        """Get parts of part that must be os.path.joined with cache_dir
        """

        # We want to generate an url to use as our cache key, we don't want to
        # just re-use the URL because it might have other items in the fragment
        # and we don't care about those.
        key_parts = [link.url_without_fragment]
        if link.hash_name is not None and link.hash is not None:
            key_parts.append("=".join([link.hash_name, link.hash]))
        key_url = "#".join(key_parts)

        # Encode our key url with sha224, we'll use this because it has similar
        # security properties to sha256, but with a shorter total output (and
        # thus less secure). However the differences don't make a lot of
        # difference for our use case here.
        hashed = hashlib.sha224(key_url.encode()).hexdigest()

        # We want to nest the directories some to prevent having a ton of top
        # level directories where we might run out of sub directories on some
        # FS.
        parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]]

        return parts
def _get_cache_path_parts ( self , link ) : # type: (Link) -> List[str] # We want to generate an url to use as our cache key, we don't want to # just re-use the URL because it might have other items in the fragment # and we don't care about those. key_parts = [ link . url_without_fragment ] if link . hash_name is not None and link . hash is not None : key_parts . append ( "=" . join ( [ link . hash_name , link . hash ] ) ) key_url = "#" . join ( key_parts ) # Encode our key url with sha224, we'll use this because it has similar # security properties to sha256, but with a shorter total output (and # thus less secure). However the differences don't make a lot of # difference for our use case here. hashed = hashlib . sha224 ( key_url . encode ( ) ) . hexdigest ( ) # We want to nest the directories some to prevent having a ton of top # level directories where we might run out of sub directories on some # FS. parts = [ hashed [ : 2 ] , hashed [ 2 : 4 ] , hashed [ 4 : 6 ] , hashed [ 6 : ] ] return parts