comparison sat/tools/stream.py @ 2866:8ce5748bfe97

plugin XEP-0363: updated to namespace "urn:xmpp:http:upload:0", handle headers
author Goffi <goffi@goffi.org>
date Fri, 22 Mar 2019 19:26:08 +0100
parents 003b8b4b56a7
children ab2696e34d29
comparison
equal deleted inserted replaced
2865:9213c6dff48d 2866:8ce5748bfe97
35 def startStream(consumer): 35 def startStream(consumer):
36 """start producing the stream 36 """start producing the stream
37 37
38 @return (D): deferred fired when stream is finished 38 @return (D): deferred fired when stream is finished
39 """ 39 """
40 pass
40 41
41 42
42 class SatFile(object): 43 class SatFile(object):
43 """A file-like object to have high level files manipulation""" 44 """A file-like object to have high level files manipulation"""
44 45
45 # TODO: manage "with" statement 46 # TODO: manage "with" statement
46 47
47 def __init__( 48 def __init__(self, host, client, path, mode="rb", uid=None, size=None, data_cb=None,
48 self, 49 auto_end_signals=True):
49 host,
50 client,
51 path,
52 mode="rb",
53 uid=None,
54 size=None,
55 data_cb=None,
56 auto_end_signals=True,
57 ):
58 """ 50 """
59 @param host: %(doc_host)s 51 @param host: %(doc_host)s
60 @param path(str): path of the file to get 52 @param path(str): path of the file to get
61 @param mode(str): same as for built-in "open" function 53 @param mode(str): same as for built-in "open" function
62 @param uid(unicode, None): unique id identifing this progressing element 54 @param uid(unicode, None): unique id identifing this progressing element
63 This uid will be used with self.host.progressGet 55 This uid will be used with self.host.progressGet
64 will be automaticaly generated if None 56 will be automaticaly generated if None
65 @param size(None, int): size of the file (when known in advance) 57 @param size(None, int): size of the file (when known in advance)
66 @param data_cb(None, callable): method to call on each data read/write 58 @param data_cb(None, callable): method to call on each data read/write
67 mainly useful to do things like calculating hash 59 mainly useful to do things like calculating hash
68 @param auto_end_signals(bool): if True, progressFinished and progressError signals are automatically sent 60 @param auto_end_signals(bool): if True, progressFinished and progressError signals
69 if False, you'll have to call self.progressFinished and self.progressError yourself 61 are automatically sent.
62 if False, you'll have to call self.progressFinished and self.progressError
63 yourself.
70 progressStarted signal is always sent automatically 64 progressStarted signal is always sent automatically
71 """ 65 """
72 self.host = host 66 self.host = host
73 self.profile = client.profile 67 self.profile = client.profile
74 self.uid = uid or unicode(uuid.uuid4()) 68 self.uid = uid or unicode(uuid.uuid4())