55import pathlib
66import typing
77from dataclasses import dataclass
8- from typing import IO , Union
8+ from typing import IO
99
1010from ._utils import TrackType
1111from .api import track
@@ -72,23 +72,21 @@ def remote(uid: str, server: str = "https://higlass.io/api/v1", **kwargs):
7272 return RemoteTileset (uid , server , ** kwargs )
7373
7474
75- def hash_absolute_filepath_as_default_uid (
76- fn : typing .Callable [[str , str ], LocalTileset ]
77- ):
78- def wrapper (filepath : Union [str , IO [bytes ]], uid : None | str = None ):
75+ def hash_file_as_default_uid (fn : typing .Callable [[str | IO [bytes ], str ], LocalTileset ]):
76+ def wrapper (file : str | IO [bytes ], uid : None | str = None ):
7977 if uid is None :
80- if isinstance (filepath , str ):
81- abspath = pathlib .Path (filepath ).absolute ()
78+ if isinstance (file , str ):
79+ abspath = pathlib .Path (file ).absolute ()
8280 uid = hashlib .md5 (str (abspath ).encode ()).hexdigest ()
8381 else :
8482 # File-like object likely provided
85- uid = hashlib .md5 (str (hash (filepath )).encode ()).hexdigest ()
86- return fn (filepath , uid )
83+ uid = hashlib .md5 (str (hash (file )).encode ()).hexdigest ()
84+ return fn (file , uid )
8785
8886 return wrapper
8987
9088
91- @hash_absolute_filepath_as_default_uid
89+ @hash_file_as_default_uid
9290def bigwig (filepath : str , uid : str ):
9391 try :
9492 from clodius .tiles .bigwig import tiles , tileset_info
@@ -105,7 +103,7 @@ def bigwig(filepath: str, uid: str):
105103 )
106104
107105
108- @hash_absolute_filepath_as_default_uid
106+ @hash_file_as_default_uid
109107def beddb (filepath : str , uid : str ):
110108 try :
111109 from clodius .tiles .beddb import tiles , tileset_info
@@ -122,7 +120,7 @@ def beddb(filepath: str, uid: str):
122120 )
123121
124122
125- @hash_absolute_filepath_as_default_uid
123+ @hash_file_as_default_uid
126124def multivec (filepath : str , uid : str ):
127125 try :
128126 from clodius .tiles .multivec import tiles , tileset_info
@@ -139,7 +137,7 @@ def multivec(filepath: str, uid: str):
139137 )
140138
141139
142- @hash_absolute_filepath_as_default_uid
140+ @hash_file_as_default_uid
143141def cooler (filepath : str , uid : str ):
144142 try :
145143 from clodius .tiles .cooler import tiles , tileset_info
@@ -156,7 +154,7 @@ def cooler(filepath: str, uid: str):
156154 )
157155
158156
159- @hash_absolute_filepath_as_default_uid
157+ @hash_file_as_default_uid
160158def hitile (filepath : str , uid : str ):
161159 try :
162160 from clodius .tiles .hitile import tiles , tileset_info
@@ -173,7 +171,7 @@ def hitile(filepath: str, uid: str):
173171 )
174172
175173
176- @hash_absolute_filepath_as_default_uid
174+ @hash_file_as_default_uid
177175def bed2ddb (filepath : str , uid : str ):
178176 try :
179177 from clodius .tiles .bed2ddb import tiles , tileset_info
0 commit comments