text
stringlengths 0
828
|
|---|
""""""
|
try:
|
for kmsg in kmsgs:
|
self.client.send(
|
topic, self._onmessage(kmsg).dumps().encode(""UTF-8"")
|
)
|
self.client.flush(timeout=timeout)
|
return Result(stdout=""{} message(s) sent"".format(len(kmsgs)))
|
except Exception as exc:
|
return Result.from_exception(exc)"
|
4491,"def send(self, topic, kmsg, timeout=60):
|
"""""" Send the message into the given topic
|
:param str topic: a kafka topic
|
:param ksr.transport.Message kmsg: Message to serialize
|
:param int timeout: Timeout in seconds (not used in proto producer)
|
:return: Execution result
|
:rtype: kser.result.Result
|
""""""
|
result = Result(uuid=kmsg.uuid)
|
try:
|
self.client.produce(
|
topic, self._onmessage(kmsg).dumps().encode(""UTF-8"")
|
)
|
result.stdout = ""Message {}[{}] sent"".format(
|
kmsg.entrypoint, kmsg.uuid
|
)
|
self.client.flush()
|
except Exception as exc:
|
result = Result.from_exception(exc, kmsg.uuid)
|
finally:
|
if result.retcode < 300:
|
return self._onsuccess(kmsg=kmsg, result=result)
|
else:
|
return self._onerror(kmsg=kmsg, result=result)"
|
4492,"def file_strip_ext(
|
afile,
|
skip_version=False,
|
only_known_extensions=False,
|
allow_subformat=True):
|
""""""
|
Strip in the best way the extension from a filename.
|
>>> file_strip_ext(""foo.tar.gz"")
|
'foo'
|
>>> file_strip_ext(""foo.buz.gz"")
|
'foo.buz'
|
>>> file_strip_ext(""foo.buz"")
|
'foo'
|
>>> file_strip_ext(""foo.buz"", only_known_extensions=True)
|
'foo.buz'
|
>>> file_strip_ext(""foo.buz;1"", skip_version=False,
|
... only_known_extensions=True)
|
'foo.buz;1'
|
>>> file_strip_ext(""foo.gif;icon"")
|
'foo'
|
>>> file_strip_ext(""foo.gif;icon"", only_know_extensions=True,
|
... allow_subformat=False)
|
'foo.gif;icon'
|
@param afile: the path/name of a file.
|
@type afile: string
|
@param skip_version: whether to skip a trailing "";version"".
|
@type skip_version: bool
|
@param only_known_extensions: whether to strip out only known extensions or
|
to consider as extension anything that follows a dot.
|
@type only_known_extensions: bool
|
@param allow_subformat: whether to consider also subformats as part of
|
the extension.
|
@type allow_subformat: bool
|
@return: the name/path without the extension (and version).
|
@rtype: string
|
""""""
|
import os
|
afile = afile.split(';')
|
if len(afile) > 1 and allow_subformat and not afile[-1].isdigit():
|
afile = afile[0:-1]
|
if len(afile) > 1 and skip_version and afile[-1].isdigit():
|
afile = afile[0:-1]
|
afile = ';'.join(afile)
|
nextfile = _extensions.sub('', afile)
|
if nextfile == afile and not only_known_extensions:
|
nextfile = os.path.splitext(afile)[0]
|
while nextfile != afile:
|
afile = nextfile
|
nextfile = _extensions.sub('', afile)
|
return nextfile"
|
4493,"def guess_extension(amimetype, normalize=False):
|
""""""
|
Tries to guess extension for a mimetype.
|
@param amimetype: name of a mimetype
|
@time amimetype: string
|
@return: the extension
|
@rtype: string
|
""""""
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.