2
2
3
3
import os
4
4
import io
5
- from typing import List
6
- from .functions import upload as d , types as t , deal_status , get_uploads as getUploads , download as _download
5
+ from .functions import upload as d ,deal_status , get_uploads as getUploads , download as _download
7
6
8
7
9
8
class Lighthouse :
@@ -14,7 +13,7 @@ def __init__(self, token: str = ""):
14
13
"No token provided: Please provide a token or set the LIGHTHOUSE_TOKEN environment variable"
15
14
)
16
15
17
- def upload (self , source : str , tag : str = '' ) -> t . Upload :
16
+ def upload (self , source : str , tag : str = '' ):
18
17
"""
19
18
Upload a file or directory to the Lighthouse.
20
19
@@ -26,7 +25,7 @@ def upload(self, source: str, tag: str = '') -> t.Upload:
26
25
except Exception as e :
27
26
raise e
28
27
29
- def uploadBlob (self , source : io .BufferedReader , filename : str , tag : str = '' ) -> t . Upload :
28
+ def uploadBlob (self , source : io .BufferedReader , filename : str , tag : str = '' ):
30
29
"""
31
30
Upload Blob a file or directory to the Lighthouse.
32
31
@@ -41,14 +40,13 @@ def uploadBlob(self, source: io.BufferedReader, filename: str, tag: str = '') ->
41
40
raise e
42
41
43
42
@staticmethod
44
- def downloadBlob (dist : io .BufferedWriter , cid : str , chunk_size = 1024 * 1024 * 10 ) -> t . Upload :
43
+ def downloadBlob (dist : io .BufferedWriter , cid : str , chunk_size = 1024 * 1024 * 10 ):
45
44
"""
46
45
Download a Blob (file or directory) from the Lighthouse.
47
46
48
47
:param dist: BufferedWriter, destination to write the downloaded data
49
48
:param cid: str, Content Identifier for the data to be downloaded
50
49
:param chunk_size: int, size of chunks in which the file will be downloaded (default: 10MB)
51
- :param useCidAsTag: bool, flag to use CID as a tag (default: False)
52
50
:return: t.Upload, the download result
53
51
"""
54
52
if not (hasattr (dist , 'read' ) and hasattr (dist , 'close' )):
@@ -57,24 +55,9 @@ def downloadBlob(dist: io.BufferedWriter, cid: str, chunk_size=1024*1024*10) ->
57
55
return _download .download_file_into_writable (cid , dist , chunk_size )
58
56
except Exception as e :
59
57
raise e
60
-
61
- @staticmethod
62
- def downloadBlob (dist : io .BufferedWriter , cid : str , chunk_size = 1024 * 1024 * 10 ) -> t .Upload :
63
- """
64
- Download Blob a file or directory to the Lighthouse.
65
-
66
- :param source: str, path to file or directory
67
- :return: t.Upload, the upload result
68
- """
69
- if not (hasattr (dist , 'read' ) and hasattr (dist , 'close' )):
70
- raise TypeError ("source must have 'read' and 'close' methods" )
71
- try :
72
- return _download .download_file_into_writable (cid , dist , chunk_size )
73
- except Exception as e :
74
- raise e
75
-
58
+
76
59
@staticmethod
77
- def getDealStatus (cid : str ) -> List [ t . DealData ] :
60
+ def getDealStatus (cid : str ):
78
61
"""
79
62
Get deal status from the Lighthouse.
80
63
@@ -87,7 +70,7 @@ def getDealStatus(cid: str) -> List[t.DealData]:
87
70
raise e
88
71
89
72
@staticmethod
90
- def getUploads (publicKey : str , pageNo : int = 1 ) -> List [ t . DealData ] :
73
+ def getUploads (publicKey : str , pageNo : int = 1 ):
91
74
"""
92
75
Get uploads from the Lighthouse.
93
76
@@ -101,7 +84,7 @@ def getUploads(publicKey: str, pageNo: int = 1) -> List[t.DealData]:
101
84
raise e
102
85
103
86
@staticmethod
104
- def download (cid : str ) -> bytes :
87
+ def download (cid : str ):
105
88
"""
106
89
Download content from the Lighthouse using its Content Identifier (CID).
107
90
@@ -114,7 +97,7 @@ def download(cid: str) -> bytes:
114
97
except Exception as e :
115
98
raise e
116
99
117
- def getTagged (self , tag : str ) -> t . Upload :
100
+ def getTagged (self , tag : str ):
118
101
"""
119
102
Retrieve an upload from the Lighthouse using its tag.
120
103
0 commit comments