desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Return the multiline comment at lineno split into a list of
comment line numbers and the accompanying comment line'
| @staticmethod
def _split_comment(lineno, comment):
| return [((lineno + index), line) for (index, line) in enumerate(comment.splitlines())]
|
'Loads a template from a file or a string'
| def load_template(self, templatename, template_string=None):
| if (template_string is not None):
return Template(template_string, **self.tmpl_options)
if ('/' not in templatename):
templatename = ((('/' + templatename.replace('.', '/')) + '.') + self.extension)
return self.lookup.get_template(templatename)
|
'Replace characters with their character entity references.
Only characters corresponding to a named entity are replaced.'
| def escape_entities(self, text):
| return compat.text_type(text).translate(self.codepoint2entity)
|
'Replace characters with their character references.
Replace characters by their named entity references.
Non-ASCII characters, if they do not have a named entity reference,
are replaced by numerical character references.
The return value is guaranteed to be ASCII.'
| def escape(self, text):
| return self.__escapable.sub(self.__escape, compat.text_type(text)).encode('ascii')
|
'Unescape character references.
All character references (both entity references and numerical
character references) are unescaped.'
| def unescape(self, text):
| return self.__characterrefs.sub(self.__unescape, text)
|
'Return ``True`` if this :class:`.TemplateLookup` is
capable of returning a :class:`.Template` object for the
given ``uri``.
:param uri: String URI of the template to be resolved.'
| def has_template(self, uri):
| try:
self.get_template(uri)
return True
except exceptions.TemplateLookupException:
return False
|
'Return a :class:`.Template` object corresponding to the given
``uri``.
The default implementation raises
:class:`.NotImplementedError`. Implementations should
raise :class:`.TemplateLookupException` if the given ``uri``
cannot be resolved.
:param uri: String URI of the template to be resolved.
:param relativeto: if pr... | def get_template(self, uri, relativeto=None):
| raise NotImplementedError()
|
'Convert the given ``filename`` to a URI relative to
this :class:`.TemplateCollection`.'
| def filename_to_uri(self, uri, filename):
| return uri
|
'Adjust the given ``uri`` based on the calling ``filename``.
When this method is called from the runtime, the
``filename`` parameter is taken directly to the ``filename``
attribute of the calling template. Therefore a custom
:class:`.TemplateCollection` subclass can place any string
identifier desired in the ``filename... | def adjust_uri(self, uri, filename):
| return uri
|
'Return a :class:`.Template` object corresponding to the given
``uri``.
.. note:: The ``relativeto`` argument is not supported here at
the moment.'
| def get_template(self, uri):
| try:
if self.filesystem_checks:
return self._check(uri, self._collection[uri])
else:
return self._collection[uri]
except KeyError:
u = re.sub('^\\/+', '', uri)
for dir in self.directories:
dir = dir.replace(os.path.sep, posixpath.sep)
... |
'Adjust the given ``uri`` based on the given relative URI.'
| def adjust_uri(self, uri, relativeto):
| key = (uri, relativeto)
if (key in self._uri_cache):
return self._uri_cache[key]
if (uri[0] != '/'):
if (relativeto is not None):
v = self._uri_cache[key] = posixpath.join(posixpath.dirname(relativeto), uri)
else:
v = self._uri_cache[key] = ('/' + uri)
els... |
'Convert the given ``filename`` to a URI relative to
this :class:`.TemplateCollection`.'
| def filename_to_uri(self, filename):
| try:
return self._uri_cache[filename]
except KeyError:
value = self._relativeize(filename)
self._uri_cache[filename] = value
return value
|
'Return the portion of a filename that is \'relative\'
to the directories in this lookup.'
| def _relativeize(self, filename):
| filename = posixpath.normpath(filename)
for dir in self.directories:
if (filename[0:len(dir)] == dir):
return filename[len(dir):]
else:
return None
|
'Place a new :class:`.Template` object into this
:class:`.TemplateLookup`, based on the given string of
``text``.'
| def put_string(self, uri, text):
| self._collection[uri] = Template(text, lookup=self, uri=uri, **self.template_args)
|
'Place a new :class:`.Template` object into this
:class:`.TemplateLookup`, based on the given
:class:`.Template` object.'
| def put_template(self, uri, template):
| self._collection[uri] = template
|
'print a line or lines of python which already contain indentation.
The indentation of the total block of lines will be adjusted to that of
the current indent level.'
| def write_indented_block(self, block):
| self.in_indent_lines = False
for l in re.split('\\r?\\n', block):
self.line_buffer.append(l)
self._update_lineno(1)
|
'print a series of lines of python.'
| def writelines(self, *lines):
| for line in lines:
self.writeline(line)
|
'print a line of python, indenting it according to the current
indent level.
this also adjusts the indentation counter according to the
content of the line.'
| def writeline(self, line):
| if (not self.in_indent_lines):
self._flush_adjusted_lines()
self.in_indent_lines = True
if ((line is None) or re.match('^\\s*#', line) or re.match('^\\s*$', line)):
hastext = False
else:
hastext = True
is_comment = (line and len(line) and (line[0] == '#'))
if ((not is... |
'close this printer, flushing any remaining lines.'
| def close(self):
| self._flush_adjusted_lines()
|
'return true if the given line is an \'unindentor\',
relative to the last \'indent\' event received.'
| def _is_unindentor(self, line):
| if (len(self.indent_detail) == 0):
return False
indentor = self.indent_detail[(-1)]
if (indentor is None):
return False
match = re.match('^\\s*(else|elif|except|finally).*\\:', line)
if (not match):
return False
return True
|
'indent the given line according to the current indent level.
stripspace is a string of space that will be truncated from the
start of the line before indenting.'
| def _indent_line(self, line, stripspace=''):
| return re.sub(('^%s' % stripspace), (self.indentstring * self.indent), line)
|
'reset the flags which would indicate we are in a backslashed
or triple-quoted section.'
| def _reset_multi_line_flags(self):
| (self.backslashed, self.triplequoted) = (False, False)
|
'return true if the given line is part of a multi-line block,
via backslash or triple-quote.'
| def _in_multi_line(self, line):
| current_state = (self.backslashed or self.triplequoted)
if re.search('\\\\$', line):
self.backslashed = True
else:
self.backslashed = False
triples = len(re.findall('\\"\\"\\"|\\\'\\\'\\\'', line))
if ((triples == 1) or ((triples % 2) != 0)):
self.triplequoted = (not self.tri... |
'Return the visitor function for this node or `None` if no visitor
exists for this node. In that case the generic visit function is
used instead.'
| def get_visitor(self, node):
| method = ('visit_' + node.__class__.__name__)
return getattr(self, method, None)
|
'Visit a node.'
| def visit(self, node):
| f = self.get_visitor(node)
if (f is not None):
return f(node)
return self.generic_visit(node)
|
'Called if no explicit visitor function exists for a node.'
| def generic_visit(self, node):
| for (field, value) in iter_fields(node):
if isinstance(value, list):
for item in value:
if isinstance(item, AST):
self.visit(item)
elif isinstance(value, AST):
self.visit(value)
|
'Retrieve a value from the cache, using the given creation function
to generate a new value.'
| def get_or_create(self, key, creation_function, **kw):
| return self._ctx_get_or_create(key, creation_function, None, **kw)
|
'Retrieve a value from the cache, using the given creation function
to generate a new value.'
| def _ctx_get_or_create(self, key, creation_function, context, **kw):
| if (not self.template.cache_enabled):
return creation_function()
return self.impl.get_or_create(key, creation_function, **self._get_cache_kw(kw, context))
|
'Place a value in the cache.
:param key: the value\'s key.
:param value: the value.
:param \**kw: cache configuration arguments.'
| def set(self, key, value, **kw):
| self.impl.set(key, value, **self._get_cache_kw(kw, None))
|
'Retrieve a value from the cache.
:param key: the value\'s key.
:param \**kw: cache configuration arguments. The
backend is configured using these arguments upon first request.
Subsequent requests that use the same series of configuration
values will use that same backend.'
| def get(self, key, **kw):
| return self.impl.get(key, **self._get_cache_kw(kw, None))
|
'Invalidate a value in the cache.
:param key: the value\'s key.
:param \**kw: cache configuration arguments. The
backend is configured using these arguments upon first request.
Subsequent requests that use the same series of configuration
values will use that same backend.'
| def invalidate(self, key, **kw):
| self.impl.invalidate(key, **self._get_cache_kw(kw, None))
|
'Invalidate the cached content of the "body" method for this
template.'
| def invalidate_body(self):
| self.invalidate('render_body', __M_defname='render_body')
|
'Invalidate the cached content of a particular ``<%def>`` within this
template.'
| def invalidate_def(self, name):
| self.invalidate(('render_%s' % name), __M_defname=('render_%s' % name))
|
'Invalidate a nested ``<%def>`` within this template.
Caching of nested defs is a blunt tool as there is no
management of scope -- nested defs that use cache tags
need to have names unique of all other nested defs in the
template, else their content will be overwritten by
each other.'
| def invalidate_closure(self, name):
| self.invalidate(name, __M_defname=name)
|
'Retrieve a value from the cache, using the given creation function
to generate a new value.
This function *must* return a value, either from
the cache, or via the given creation function.
If the creation function is called, the newly
created value should be populated into the cache
under the given key before being ret... | def get_or_create(self, key, creation_function, **kw):
| raise NotImplementedError()
|
'Place a value in the cache.
:param key: the value\'s key.
:param value: the value.
:param \**kw: cache configuration arguments.'
| def set(self, key, value, **kw):
| raise NotImplementedError()
|
'Retrieve a value from the cache.
:param key: the value\'s key.
:param \**kw: cache configuration arguments.'
| def get(self, key, **kw):
| raise NotImplementedError()
|
'Invalidate a value in the cache.
:param key: the value\'s key.
:param \**kw: cache configuration arguments.'
| def invalidate(self, key, **kw):
| raise NotImplementedError()
|
'shift(hours, minutes, seconds, milliseconds, ratio)
Add given values to start and end attributes.
All arguments are optional and have a default value of 0.'
| def shift(self, *args, **kwargs):
| self.start.shift(*args, **kwargs)
self.end.shift(*args, **kwargs)
|
'slice([starts_before][, starts_after][, ends_before][, ends_after]) -> SubRipFile clone
All arguments are optional, and should be coercible to SubRipTime
object.
It reduce the set of subtitles to those that match match given time
constraints.
The returned set is a clone, but still contains references to original
subti... | def slice(self, starts_before=None, starts_after=None, ends_before=None, ends_after=None):
| clone = copy(self)
if starts_before:
clone.data = (i for i in clone.data if (i.start < starts_before))
if starts_after:
clone.data = (i for i in clone.data if (i.start > starts_after))
if ends_before:
clone.data = (i for i in clone.data if (i.end < ends_before))
if ends_after... |
'at(timestamp) -> SubRipFile clone
timestamp argument should be coercible to SubRipFile object.
A specialization of slice. Return all subtiles visible at the
timestamp mark.
Example:
>>> subs.at((0, 0, 20, 0)).shift(seconds=2)
>>> subs.at(seconds=20).shift(seconds=2)'
| def at(self, timestamp=None, **kwargs):
| time = (timestamp or kwargs)
return self.slice(starts_before=time, ends_after=time)
|
'shift(hours, minutes, seconds, milliseconds, ratio)
Shift `start` and `end` attributes of each items of file either by
applying a ratio or by adding an offset.
`ratio` should be either an int or a float.
Example to convert subtitles from 23.9 fps to 25 fps:
>>> subs.shift(ratio=25/23.9)
All "time" arguments are option... | def shift(self, *args, **kwargs):
| for item in self:
item.shift(*args, **kwargs)
|
'clean_indexes()
Sort subs and reset their index attribute. Should be called after
destructive operations like split or such.'
| def clean_indexes(self):
| self.sort()
for (index, item) in enumerate(self):
item.index = (index + 1)
|
'open([path, [encoding]])
If you do not provide any encoding, it can be detected if the file
contain a bit order mark, unless it is set to utf-8 as default.'
| @classmethod
def open(cls, path='', encoding=None, error_handling=ERROR_PASS):
| (source_file, encoding) = cls._open_unicode_file(path, claimed_encoding=encoding)
new_file = cls(path=path, encoding=encoding)
new_file.read(source_file, error_handling=error_handling)
source_file.close()
return new_file
|
'from_string(source, **kwargs) -> SubRipFile
`source` -> a unicode instance or at least a str instance encoded with
`sys.getdefaultencoding()`'
| @classmethod
def from_string(cls, source, **kwargs):
| error_handling = kwargs.pop('error_handling', None)
new_file = cls(**kwargs)
new_file.read(source.splitlines(True), error_handling=error_handling)
return new_file
|
'read(source_file, [error_handling])
This method parse subtitles contained in `source_file` and append them
to the current instance.
`source_file` -> Any iterable that yield unicode strings, like a file
opened with `codecs.open()` or an array of unicode.'
| def read(self, source_file, error_handling=ERROR_PASS):
| self.eol = self._guess_eol(source_file)
self.extend(self.stream(source_file, error_handling=error_handling))
return self
|
'stream(source_file, [error_handling])
This method yield SubRipItem instances a soon as they have been parsed
without storing them. It is a kind of SAX parser for .srt files.
`source_file` -> Any iterable that yield unicode strings, like a file
opened with `codecs.open()` or an array of unicode.
Example:
>>> import pys... | @classmethod
def stream(cls, source_file, error_handling=ERROR_PASS):
| string_buffer = []
for (index, line) in enumerate(chain(source_file, '\n')):
if line.strip():
string_buffer.append(line)
else:
source = string_buffer
string_buffer = []
if (source and all(source)):
try:
(yield Su... |
'save([path][, encoding][, eol])
Use initial path if no other provided.
Use initial encoding if no other provided.
Use initial eol if no other provided.'
| def save(self, path=None, encoding=None, eol=None):
| path = (path or self.path)
encoding = (encoding or self.encoding)
save_file = codecs.open(path, 'w+', encoding=encoding)
self.write_into(save_file, eol=eol)
save_file.close()
|
'write_into(output_file [, eol])
Serialize current state into `output_file`.
`output_file` -> Any instance that respond to `write()`, typically a
file object'
| def write_into(self, output_file, eol=None):
| output_eol = (eol or self.eol)
for item in self:
string_repr = str(item)
if (output_eol != '\n'):
string_repr = string_repr.replace('\n', output_eol)
output_file.write(string_repr)
if (not string_repr.endswith((2 * output_eol))):
output_file.write(output_e... |
'SubRipTime(hours, minutes, seconds, milliseconds)
All arguments are optional and have a default value of 0.'
| def __init__(self, hours=0, minutes=0, seconds=0, milliseconds=0):
| super(SubRipTime, self).__init__()
self.ordinal = ((((hours * self.HOURS_RATIO) + (minutes * self.MINUTES_RATIO)) + (seconds * self.SECONDS_RATIO)) + milliseconds)
|
'Coerce many types to SubRipTime instance.
Supported types:
- str/unicode
- int/long
- datetime.time
- any iterable
- dict'
| @classmethod
def coerce(cls, other):
| if isinstance(other, SubRipTime):
return other
if isinstance(other, basestring):
return cls.from_string(other)
if isinstance(other, int):
return cls.from_ordinal(other)
if isinstance(other, time):
return cls.from_time(other)
try:
return cls(**other)
except... |
'shift(hours, minutes, seconds, milliseconds)
All arguments are optional and have a default value of 0.'
| def shift(self, *args, **kwargs):
| if ('ratio' in kwargs):
self *= kwargs.pop('ratio')
self += self.__class__(*args, **kwargs)
|
'int -> SubRipTime corresponding to a total count of milliseconds'
| @classmethod
def from_ordinal(cls, ordinal):
| return cls(milliseconds=int(ordinal))
|
'str/unicode(HH:MM:SS,mmm) -> SubRipTime corresponding to serial
raise InvalidTimeString'
| @classmethod
def from_string(cls, source):
| items = cls.RE_TIME_SEP.split(source)
if (len(items) != 4):
raise InvalidTimeString
return cls(*(cls.parse_int(i) for i in items))
|
'datetime.time -> SubRipTime corresponding to time object'
| @classmethod
def from_time(cls, source):
| return cls(hours=source.hour, minutes=source.minute, seconds=source.second, milliseconds=(source.microsecond // 1000))
|
'Convert SubRipTime instance into a pure datetime.time object'
| def to_time(self):
| return time(self.hours, self.minutes, self.seconds, (self.milliseconds * 1000))
|
'Create SSL socket and connect to peer'
| def connect(self):
| if getattr(self, 'ssl_context', None):
if (not isinstance(self.ssl_context, SSL.Context)):
raise TypeError(('Expecting OpenSSL.SSL.Context type for "ssl_context" attribute; got %r instead' % self.ssl_context))
ssl_context = self.ssl_context
else:
ssl_c... |
'Close socket and shut down SSL connection'
| def close(self):
| self.sock.close()
|
'@param ssl_context:SSL context
@type ssl_context: OpenSSL.SSL.Context
@param debuglevel: debug level for HTTPSHandler
@type debuglevel: int'
| def __init__(self, ssl_context, debuglevel=0):
| AbstractHTTPHandler.__init__(self, debuglevel)
if (ssl_context is not None):
if (not isinstance(ssl_context, SSL.Context)):
raise TypeError(('Expecting OpenSSL.SSL.Context type for "ssl_context" keyword; got %r instead' % ssl_context))
self.ssl_context = ssl_c... |
'Opens HTTPS request
@param req: HTTP request
@return: HTTP Response object'
| def https_open(self, req):
| customHTTPSContextConnection = type('CustomHTTPSContextConnection', (HTTPSConnection, object), {'ssl_context': self.ssl_context})
return self.do_open(customHTTPSContextConnection, req)
|
'Processes cookies for a HTTP request.
@param request: request to process
@type request: urllib2.Request
@return: request
@rtype: urllib2.Request'
| def http_request(self, request):
| COOKIE_HEADER_NAME = 'Cookie'
tmp_request = urllib2.Request(request.get_full_url(), request.data, {}, request.origin_req_host, request.unverifiable)
self.cookiejar.add_cookie_header(tmp_request)
new_cookies = tmp_request.get_header(COOKIE_HEADER_NAME)
if new_cookies:
if request.has_header(CO... |
'@param ssl_context: SSL context to use with this configuration
@type ssl_context: OpenSSL.SSL.Context
@param debug: if True, output debugging information
@type debug: bool
@param proxies: proxies to use for
@type proxies: dict with basestring keys and values
@param no_proxy: hosts for which a proxy should not be used
... | def __init__(self, ssl_context, debug=False, proxies=None, no_proxy=None, cookie=None, http_basicauth=None, headers=None):
| self.ssl_context = ssl_context
self.debug = debug
self.proxies = proxies
self.no_proxy = no_proxy
self.cookie = cookie
self.http_basicauth = http_basicauth
self.headers = headers
|
'Override parent class __init__ to enable setting of certDN
setting
@type certDN: string
@param certDN: Set the expected Distinguished Name of the
server to avoid errors matching hostnames. This is useful
where the hostname is not fully qualified
@type hostname: string
@param hostname: hostname to match against peer c... | def __init__(self, certDN=None, hostname=None, subj_alt_name_match=True):
| self.__certDN = None
self.__hostname = None
if (certDN is not None):
self.certDN = certDN
if (hostname is not None):
self.hostname = hostname
if subj_alt_name_match:
if (not SUBJ_ALT_NAME_SUPPORT):
log.warning('Overriding "subj_alt_name_match" keyword set... |
'Verify server certificate
@type connection: OpenSSL.SSL.Connection
@param connection: SSL connection object
@type peerCert: basestring
@param peerCert: server host certificate as OpenSSL.crypto.X509
instance
@type errorStatus: int
@param errorStatus: error status passed from caller. This is the value
returned by the ... | def __call__(self, connection, peerCert, errorStatus, errorDepth, preverifyOK):
| if peerCert.has_expired():
log.error('Certificate %r in peer certificate chain has expired', peerCert.get_subject())
return False
elif (errorDepth == 0):
peerCertSubj = peerCert.get_subject()
peerCertDN = peerCertSubj.get_components()
peerCertDN.sort(... |
'Extract subjectAltName DNS name settings from certificate extensions
@param peer_cert: peer certificate in SSL connection. subjectAltName
settings if any will be extracted from this
@type peer_cert: OpenSSL.crypto.X509'
| @classmethod
def _get_subj_alt_name(cls, peer_cert):
| dns_name = []
general_names = SubjectAltName()
for i in range(peer_cert.get_extension_count()):
ext = peer_cert.get_extension(i)
ext_name = ext.get_short_name()
if (ext_name == cls.SUBJ_ALT_NAME_EXT_NAME):
ext_dat = ext.get_data()
decoded_dat = der_decoder.dec... |
'Create SSL socket object
@param ctx: SSL context
@type ctx: OpenSSL.SSL.Context
@param sock: underlying socket object
@type sock: socket.socket'
| def __init__(self, ctx, sock=None):
| if (sock is not None):
self.socket = sock
else:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.__ssl_conn = SSL.Connection(ctx, self.socket)
self.buf_size = self.__class__.default_buf_size
... |
'Close underlying socket when this object goes out of scope'
| def __del__(self):
| self.close()
|
'Buffer size for makefile method recv() operations'
| @property
def buf_size(self):
| return self.__buf_size
|
'Buffer size for makefile method recv() operations'
| @buf_size.setter
def buf_size(self, value):
| if (not isinstance(value, (int, long))):
raise TypeError(('Expecting int or long type for "buf_size"; got %r instead' % type(value)))
self.__buf_size = value
|
'Shutdown the SSL connection and call the close method of the
underlying socket'
| def close(self):
| if (self._makefile_refs < 1):
self.__ssl_conn.shutdown()
else:
self._makefile_refs -= 1
|
'Set the shutdown state of the Connection.
@param mode: bit vector of either or both of SENT_SHUTDOWN and
RECEIVED_SHUTDOWN'
| def set_shutdown(self, mode):
| self.__ssl_conn.set_shutdown(mode)
|
'Get the shutdown state of the Connection.
@return: bit vector of either or both of SENT_SHUTDOWN and
RECEIVED_SHUTDOWN'
| def get_shutdown(self):
| return self.__ssl_conn.get_shutdown()
|
'bind to the given address - calls method of the underlying socket
@param addr: address/port number tuple
@type addr: tuple'
| def bind(self, addr):
| self.__ssl_conn.bind(addr)
|
'Listen for connections made to the socket.
@param backlog: specifies the maximum number of queued connections and
should be at least 1; the maximum value is system-dependent (usually 5).
@param backlog: int'
| def listen(self, backlog):
| self.__ssl_conn.listen(backlog)
|
'Set the connection to work in server mode. The handshake will be
handled automatically by read/write'
| def set_accept_state(self):
| self.__ssl_conn.set_accept_state()
|
'Accept an SSL connection.
@return: pair (ssl, addr) where ssl is a new SSL connection object and
addr is the address bound to the other end of the SSL connection.
@rtype: tuple'
| def accept(self):
| return self.__ssl_conn.accept()
|
'Set the connection to work in client mode. The handshake will be
handled automatically by read/write'
| def set_connect_state(self):
| self.__ssl_conn.set_connect_state()
|
'Call the connect method of the underlying socket and set up SSL on
the socket, using the Context object supplied to this Connection object
at creation.
@param addr: address/port number pair
@type addr: tuple'
| def connect(self, addr):
| self.__ssl_conn.connect(addr)
|
'Send the shutdown message to the Connection.
@param how: for socket.socket this flag determines whether read, write
or both type operations are supported. OpenSSL.SSL.Connection doesn\'t
support this so this parameter is IGNORED
@return: true if the shutdown message exchange is completed and false
otherwise (in which... | def shutdown(self, how):
| return self.__ssl_conn.shutdown()
|
'Renegotiate this connection\'s SSL parameters.'
| def renegotiate(self):
| return self.__ssl_conn.renegotiate()
|
'@return: numbers of bytes that can be safely read from the SSL
buffer.
@rtype: int'
| def pending(self):
| return self.__ssl_conn.pending()
|
'Send data to the socket. Nb. The optional flags argument is ignored.
- retained for compatibility with socket.socket interface
@param data: data to send down the socket
@type data: string'
| def send(self, data, *flags_arg):
| return self.__ssl_conn.send(data)
|
'Receive data from the Connection.
@param size: The maximum amount of data to be received at once
@type size: int
@return: data received.
@rtype: string'
| def recv(self, size=default_buf_size):
| return self.__ssl_conn.recv(size)
|
'Set this connection\'s underlying socket blocking _mode_.
@param mode: blocking mode
@type mode: int'
| def setblocking(self, mode):
| self.__ssl_conn.setblocking(mode)
|
'@return: file descriptor number for the underlying socket
@rtype: int'
| def fileno(self):
| return self.__ssl_conn.fileno()
|
'See socket.socket.getsockopt'
| def getsockopt(self, *args):
| return self.__ssl_conn.getsockopt(*args)
|
'See socket.socket.setsockopt
@return: value of the given socket option
@rtype: int/string'
| def setsockopt(self, *args):
| return self.__ssl_conn.setsockopt(*args)
|
'Return the SSL state of this connection.'
| def state_string(self):
| return self.__ssl_conn.state_string()
|
'Specific to Python socket API and required by httplib: convert
response into a file-like object. This implementation reads using recv
and copies the output into a StringIO buffer to simulate a file object
for consumption by httplib
Nb. Ignoring optional file open mode (StringIO is generic and will
open for read and w... | def makefile(self, *args):
| self._makefile_refs += 1
_buf_size = self.buf_size
i = 0
stream = StringIO()
startTime = datetime.utcnow()
try:
dat = self.__ssl_conn.recv(_buf_size)
while dat:
i += 1
stream.write(dat)
dat = self.__ssl_conn.recv(_buf_size)
except (SSL.Zero... |
'@return: the socket\'s own address
@rtype:'
| def getsockname(self):
| return self.__ssl_conn.getsockname()
|
'@return: remote address to which the socket is connected'
| def getpeername(self):
| return self.__ssl_conn.getpeername()
|
'Retrieve the Context object associated with this Connection.'
| def get_context(self):
| return self.__ssl_conn.get_context()
|
'Retrieve the other side\'s certificate (if any)'
| def get_peer_certificate(self):
| return self.__ssl_conn.get_peer_certificate()
|
'Returns the number of recurrences in this set. It will have go
trough the whole recurrence, if this hasn\'t been done before.'
| def count(self):
| if (self._len is None):
for x in self:
pass
return self._len
|
'Returns the last recurrence before the given datetime instance. The
inc keyword defines what happens if dt is an occurrence. With
inc=True, if dt itself is an occurrence, it will be returned.'
| def before(self, dt, inc=False):
| if self._cache_complete:
gen = self._cache
else:
gen = self
last = None
if inc:
for i in gen:
if (i > dt):
break
last = i
else:
for i in gen:
if (i >= dt):
break
last = i
return last
|
'Returns the first recurrence after the given datetime instance. The
inc keyword defines what happens if dt is an occurrence. With
inc=True, if dt itself is an occurrence, it will be returned.'
| def after(self, dt, inc=False):
| if self._cache_complete:
gen = self._cache
else:
gen = self
if inc:
for i in gen:
if (i >= dt):
return i
else:
for i in gen:
if (i > dt):
return i
return None
|
'Generator which yields up to `count` recurrences after the given
datetime instance, equivalent to `after`.
:param dt:
The datetime at which to start generating recurrences.
:param count:
The maximum number of recurrences to generate. If `None` (default),
dates are generated until the recurrence rule is exhausted.
:par... | def xafter(self, dt, count=None, inc=False):
| if self._cache_complete:
gen = self._cache
else:
gen = self
if inc:
comp = (lambda dc, dtc: (dc >= dtc))
else:
comp = (lambda dc, dtc: (dc > dtc))
n = 0
for d in gen:
if comp(d, dt):
(yield d)
if (count is not None):
... |
'Returns all the occurrences of the rrule between after and before.
The inc keyword defines what happens if after and/or before are
themselves occurrences. With inc=True, they will be included in the
list, if they are found in the recurrence set.'
| def between(self, after, before, inc=False, count=1):
| if self._cache_complete:
gen = self._cache
else:
gen = self
started = False
l = []
if inc:
for i in gen:
if (i > before):
break
elif (not started):
if (i >= after):
started = True
... |
'Output a string that would generate this RRULE if passed to rrulestr.
This is mostly compatible with RFC2445, except for the
dateutil-specific extension BYEASTER.'
| def __str__(self):
| output = []
(h, m, s) = ([None] * 3)
if self._dtstart:
output.append(self._dtstart.strftime('DTSTART:%Y%m%dT%H%M%S'))
(h, m, s) = self._dtstart.timetuple()[3:6]
parts = [('FREQ=' + FREQNAMES[self._freq])]
if (self._interval != 1):
parts.append(('INTERVAL=' + str(self._interva... |
'If a `BYXXX` sequence is passed to the constructor at the same level as
`FREQ` (e.g. `FREQ=HOURLY,BYHOUR={2,4,7},INTERVAL=3`), there are some
specifications which cannot be reached given some starting conditions.
This occurs whenever the interval is not coprime with the base of a
given unit and the difference between ... | def __construct_byset(self, start, byxxx, base):
| cset = set()
if isinstance(byxxx, integer_types):
byxxx = (byxxx,)
for num in byxxx:
i_gcd = gcd(self._interval, base)
if ((i_gcd == 1) or (divmod((num - start), i_gcd)[1] == 0)):
cset.add(num)
if (len(cset) == 0):
raise ValueError('Invalid rrule byxxx ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.