_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q28500
RobotFileParser.parse
train
def parse(self, lines): """Parse the input lines from a robots.txt file. We allow that a user-agent: line is not preceded by one or more blank lines. """ # states: # 0: start state # 1: saw user-agent line # 2: saw an allow or disallow line ...
python
{ "resource": "" }
q28501
RobotFileParser.can_fetch
train
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" if self.disallow_all: return False if self.allow_all: return True # search for given user agent matches # the first match counts parsed_url = u...
python
{ "resource": "" }
q28502
recursive_repr
train
def recursive_repr(fillvalue='...'): 'Decorator to make a repr function return fillvalue for a recursive call' def decorating_function(user_function): repr_running = set() def wrapper(self): key = id(self), get_ident() if key in repr_running: return fill...
python
{ "resource": "" }
q28503
_count_elements
train
def _count_elements(mapping, iterable): 'Tally elements from the iterable.' mapping_get = mapping.get
python
{ "resource": "" }
q28504
Counter._keep_positive
train
def _keep_positive(self): '''Internal method to strip elements with a negative or zero count''' nonpositive = [elem for elem, count in self.items() if not count
python
{ "resource": "" }
q28505
Generator.flatten
train
def flatten(self, msg, unixfrom=False, linesep=None): r"""Print the message object tree rooted at msg to the output file specified when the Generator instance was created. unixfrom is a flag that forces the printing of a Unix From_ delimiter before the first object in the message tree. ...
python
{ "resource": "" }
q28506
Generator.clone
train
def clone(self, fp): """Clone this generator with the exact same options.""" return self.__class__(fp,
python
{ "resource": "" }
q28507
urlretrieve
train
def urlretrieve(url, filename=None, reporthook=None, data=None): """ Retrieve a URL into a temporary location on disk. Requires a URL argument. If a filename is passed, it is used as the temporary file location. The reporthook argument should be a callable that accepts a block number, a read size, ...
python
{ "resource": "" }
q28508
build_opener
train
def build_opener(*handlers): """Create an opener object from a list of handlers. The opener will use several default handlers, including support for HTTP, FTP and when applicable HTTPS. If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not...
python
{ "resource": "" }
q28509
parse_keqv_list
train
def parse_keqv_list(l): """Parse list of key=value strings where keys are not duplicated.""" parsed = {}
python
{ "resource": "" }
q28510
thishost
train
def thishost(): """Return the IP addresses of the current host.""" global _thishost if _thishost is None: try: _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
python
{ "resource": "" }
q28511
getproxies_environment
train
def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named <scheme>_proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. "...
python
{ "resource": "" }
q28512
proxy_bypass_environment
train
def proxy_bypass_environment(host): """Test if proxies should not be used for a particular host. Checks the environment for a variable named no_proxy, which should be a list of DNS suffixes separated by commas, or '*' for all hosts. """ no_proxy = os.environ.get('no_proxy', '') or os.environ.get('N...
python
{ "resource": "" }
q28513
_proxy_bypass_macosx_sysconf
train
def _proxy_bypass_macosx_sysconf(host, proxy_settings): """ Return True iff this host shouldn't be accessed using a proxy This function uses the MacOSX framework SystemConfiguration to fetch the proxy information. proxy_settings come from _scproxy._get_proxy_settings or get mocked ie: { 'exclu...
python
{ "resource": "" }
q28514
OpenerDirector.open
train
def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): """ Accept a URL or a Request object Python-Future: if the URL is passed as a byte-string, decode it first. """ if isinstance(fullurl, bytes): fullurl = fullurl.decode() if isinstance...
python
{ "resource": "" }
q28515
HTTPRedirectHandler.redirect_request
train
def redirect_request(self, req, fp, code, msg, headers, newurl): """Return a Request or None in response to a redirect. This is called by the http_error_30x methods when a redirection response is received. If a redirection should take place, return a new Request to allow http_error_30x...
python
{ "resource": "" }
q28516
HTTPPasswordMgr.reduce_uri
train
def reduce_uri(self, uri, default_port=True): """Accept authority or URI and extract only the authority and path.""" # note HTTP URLs do not have a userinfo component parts = urlsplit(uri) if parts[1]: # URI scheme = parts[0] authority = parts[1] ...
python
{ "resource": "" }
q28517
HTTPPasswordMgr.is_suburi
train
def is_suburi(self, base, test): """Check if test is below base in a URI tree Both args must be URIs in reduced form. """ if base == test: return True if base[0] != test[0]:
python
{ "resource": "" }
q28518
AbstractHTTPHandler.do_open
train
def do_open(self, http_class, req, **http_conn_args): """Return an HTTPResponse object for the request, using http_class. http_class must implement the HTTPConnection API from http.client. """ host = req.host if not host: raise URLError('no host given') # wi...
python
{ "resource": "" }
q28519
URLopener._open_generic_http
train
def _open_generic_http(self, connection_factory, url, data): """Make an HTTP connection using connection_class. This is an internal method that should be called from open_http() or open_https(). Arguments: - connection_factory should take a host name and return an HTT...
python
{ "resource": "" }
q28520
URLopener.open_http
train
def open_http(self, url, data=None): """Use HTTP protocol.""" return
python
{ "resource": "" }
q28521
URLopener.http_error
train
def http_error(self, url, fp, errcode, errmsg, headers, data=None): """Handle http errors. Derived class can override this, or provide specific handlers named http_error_DDD where DDD is the 3-digit error code.""" # First check if there's a specific handler for this error name =...
python
{ "resource": "" }
q28522
URLopener.open_file
train
def open_file(self, url): """Use local file or FTP depending on form of URL.""" if not isinstance(url, str): raise URLError('file error: proxy support for file protocol currently not implemented') if url[:2] == '//'
python
{ "resource": "" }
q28523
URLopener.open_local_file
train
def open_local_file(self, url): """Use local file.""" import future.backports.email.utils as email_utils import mimetypes host, file = splithost(url) localname = url2pathname(file) try: stats = os.stat(localname) except OSError as e: raise ...
python
{ "resource": "" }
q28524
URLopener.open_ftp
train
def open_ftp(self, url): """Use FTP protocol.""" if not isinstance(url, str): raise URLError('ftp error: proxy support for ftp protocol currently not implemented') import mimetypes host, path = splithost(url) if not host: raise URLError('ftp error: no host given') ...
python
{ "resource": "" }
q28525
URLopener.open_data
train
def open_data(self, url, data=None): """Use "data" URL.""" if not isinstance(url, str): raise URLError('data error: proxy support for data protocol currently not implemented') # ignore POSTed data # # syntax of data URLs: # dataurl := "data:" [ mediatype ] [...
python
{ "resource": "" }
q28526
FancyURLopener.prompt_user_passwd
train
def prompt_user_passwd(self, host, realm): """Override this in a GUI environment!""" import getpass try: user = input("Enter username for %s at %s: " % (realm, host)) passwd = getpass.getpass("Enter password for %s in %s at %s: " %
python
{ "resource": "" }
q28527
FixDivisionSafe.match
train
def match(self, node): u""" Since the tree needs to be fixed once and only once if and only if it matches, we can start discarding matches after the first. """ if node.type == self.syms.term: div_idx = find_division(node)
python
{ "resource": "" }
q28528
BufferedSubFile.push
train
def push(self, data): """Push some new data into this object.""" # Handle any previous leftovers data, self._partial = self._partial + data, '' # Crack into lines, but preserve the newlines on the end of each parts = NLCRE_crack.split(data) # The *ahem* interesting behavi...
python
{ "resource": "" }
q28529
FeedParser.close
train
def close(self): """Parse all remaining data and return the root message object.""" self._input.close() self._call_parse() root = self._pop_message() assert not self._msgstack # Look for final set of defects if root.get_content_maintype() == 'multipart' \
python
{ "resource": "" }
q28530
from_float_26
train
def from_float_26(f): """Converts a float to a decimal number, exactly. Note that Decimal.from_float(0.1) is not the same as Decimal('0.1'). Since 0.1 is not exactly representable in binary floating point, the value is stored as the nearest representable value which is 0x1.999999999999ap-4. The ex...
python
{ "resource": "" }
q28531
FixAnnotations.transform
train
def transform(self, node, results): u""" This just strips annotations from the funcdef completely. """ params = results.get(u"params") ret = results.get(u"ret") if ret is not None: assert ret.prev_sibling.type == token.RARROW, u"Invalid return annotation" ...
python
{ "resource": "" }
q28532
newint.to_bytes
train
def to_bytes(self, length, byteorder='big', signed=False): """ Return an array of bytes representing an integer. The integer is represented using length bytes. An OverflowError is raised if the integer is not representable with the given number of bytes. The byteorder ...
python
{ "resource": "" }
q28533
newint.from_bytes
train
def from_bytes(cls, mybytes, byteorder='big', signed=False): """ Return the integer represented by the given array of bytes. The mybytes argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objec...
python
{ "resource": "" }
q28534
parsedate_tz
train
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ res = _parsedate_tz(data) if
python
{ "resource": "" }
q28535
parsedate
train
def parsedate(data): """Convert a time string to a time tuple.""" t = parsedate_tz(data)
python
{ "resource": "" }
q28536
AddrlistClass.gotonext
train
def gotonext(self): """Skip white space and extract comments.""" wslist = [] while self.pos < len(self.field): if self.field[self.pos] in self.LWS + '\n\r': if self.field[self.pos] not in '\n\r': wslist.append(self.field[self.pos])
python
{ "resource": "" }
q28537
AddrlistClass.getaddrlist
train
def getaddrlist(self): """Parse all addresses. Returns a list containing all of the addresses. """ result = [] while self.pos < len(self.field): ad = self.getaddress()
python
{ "resource": "" }
q28538
AddrlistClass.getaddress
train
def getaddress(self): """Parse the next address.""" self.commentlist = [] self.gotonext() oldpos = self.pos oldcl = self.commentlist plist = self.getphraselist() self.gotonext() returnlist = [] if self.pos >= len(self.field): # Bad e...
python
{ "resource": "" }
q28539
AddrlistClass.getaddrspec
train
def getaddrspec(self): """Parse an RFC 2822 addr-spec.""" aslist = [] self.gotonext() while self.pos < len(self.field): preserve_ws = True if self.field[self.pos] == '.': if aslist and not aslist[-1].strip(): aslist.pop() ...
python
{ "resource": "" }
q28540
AddrlistClass.getatom
train
def getatom(self, atomends=None): """Parse an RFC 2822 atom. Optional atomends specifies a different set of end token delimiters (the default is to use self.atomends). This is used e.g. in getphraselist() since phrase endings must not include the `.' (which is legal in phrases)...
python
{ "resource": "" }
q28541
decode_header
train
def decode_header(header): """Decode a message header value without converting charset. Returns a list of (string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character ...
python
{ "resource": "" }
q28542
Header.append
train
def append(self, s, charset=None, errors='strict'): """Append a string to the MIME header. Optional charset, if given, should be a Charset instance or the name of a character set (which will be converted to a Charset instance). A value of None (the default) means that the charset given...
python
{ "resource": "" }
q28543
Header.encode
train
def encode(self, splitchars=';, \t', maxlinelen=None, linesep='\n'): r"""Encode a message header into an RFC-compliant format. There are many issues involved in converting a given string for use in an email header. Only certain character sets are readable in most email clients, and as ...
python
{ "resource": "" }
q28544
_formatparam
train
def _formatparam(param, value=None, quote=True): """Convenience function to format and return a key=value pair. This will quote the value if needed or if quote is true. If value is a three tuple (charset, language, value), it will be encoded according to RFC2231 rules. If it contains non-ascii charac...
python
{ "resource": "" }
q28545
Message.attach
train
def attach(self, payload): """Add the given payload to the current payload. The current payload will always be a list of objects after this method is called. If you want to set the payload to a scalar object, use set_payload() instead.
python
{ "resource": "" }
q28546
Message.get_payload
train
def get_payload(self, i=None, decode=False): """Return a reference to the payload. The payload will either be a list object or a string. If you mutate the list object, you modify the message's payload in place. Optional i returns that index into the payload. Optional decode i...
python
{ "resource": "" }
q28547
Message.set_payload
train
def set_payload(self, payload, charset=None): """Set the payload to the given value. Optional charset sets the message's default
python
{ "resource": "" }
q28548
Message.set_charset
train
def set_charset(self, charset): """Set the charset of the payload to a given character set. charset can be a Charset instance, a string naming a character set, or None. If it is a string it will be converted to a Charset instance. If charset is None, the charset parameter will be remov...
python
{ "resource": "" }
q28549
Message.values
train
def values(self): """Return a list of all the message's header values. These will be sorted in the order they appeared in the original message, or were added to the message, and may contain duplicates. Any
python
{ "resource": "" }
q28550
Message.items
train
def items(self): """Get all the message's header fields and values. These will be sorted in the order they appeared in the original message, or were added to the message, and may contain duplicates. Any fields
python
{ "resource": "" }
q28551
Message.get
train
def get(self, name, failobj=None): """Get a header value. Like __getitem__() but return failobj instead of None when the field is missing. """ name = name.lower()
python
{ "resource": "" }
q28552
Message.get_all
train
def get_all(self, name, failobj=None): """Return a list of all the values for the named field. These will be sorted in the order they appeared in the original message, and may contain duplicates. Any fields deleted and re-inserted are always appended to
python
{ "resource": "" }
q28553
Message.add_header
train
def add_header(self, _name, _value, **_params): """Extended header setting. name is the header field to add. keyword arguments can be used to set additional parameters for the header field, with underscores converted to dashes. Normally the parameter will be added as key="value" unles...
python
{ "resource": "" }
q28554
Message.replace_header
train
def replace_header(self, _name, _value): """Replace a header. Replace the first matching header found in the message, retaining header order and case. If no matching header was found, a KeyError is raised. """ _name = _name.lower()
python
{ "resource": "" }
q28555
Message.get_content_type
train
def get_content_type(self): """Return the message's content type. The returned string is coerced to lower case of the form `maintype/subtype'. If there was no Content-Type header in the message, the default type as given by get_default_type() will be returned. Since according ...
python
{ "resource": "" }
q28556
Message.get_params
train
def get_params(self, failobj=None, header='content-type', unquote=True): """Return the message's Content-Type parameters, as a list. The elements of the returned list are 2-tuples of key/value pairs, as split on the `=' sign. The left hand side of the `=' is the key, while the right ha...
python
{ "resource": "" }
q28557
Message.get_param
train
def get_param(self, param, failobj=None, header='content-type', unquote=True): """Return the parameter value if found in the Content-Type header. Optional failobj is the object to return if there is no Content-Type header, or the Content-Type header has no such parameter. Opt...
python
{ "resource": "" }
q28558
Message.set_param
train
def set_param(self, param, value, header='Content-Type', requote=True, charset=None, language=''): """Set a parameter in the Content-Type header. If the parameter already exists in the header, its value will be replaced with the new value. If header is Content-Type an...
python
{ "resource": "" }
q28559
Message.del_param
train
def del_param(self, param, header='content-type', requote=True): """Remove the given parameter completely from the Content-Type header. The header will be re-written in place without the parameter or its value. All values will be quoted as necessary unless requote is False. Optional he...
python
{ "resource": "" }
q28560
Message.set_type
train
def set_type(self, type, header='Content-Type', requote=True): """Set the main type and subtype for the Content-Type header. type must be a string in the form "maintype/subtype", otherwise a ValueError is raised. This method replaces the Content-Type header, keeping all the par...
python
{ "resource": "" }
q28561
Message.get_filename
train
def get_filename(self, failobj=None): """Return the filename associated with the payload if present. The filename is extracted from the Content-Disposition header's `filename' parameter, and it is unquoted. If that header is missing the `filename' parameter, this method falls back to l...
python
{ "resource": "" }
q28562
Message.get_boundary
train
def get_boundary(self, failobj=None): """Return the boundary associated with the payload if present. The boundary is extracted from the Content-Type header's `boundary' parameter, and it is unquoted. """ missing = object() boundary = self.get_param('boundary', missing)
python
{ "resource": "" }
q28563
Message.set_boundary
train
def set_boundary(self, boundary): """Set the boundary parameter in Content-Type to 'boundary'. This is subtly different than deleting the Content-Type header and adding a new one with a new boundary parameter via add_header(). The main difference is that using the set_boundary() method...
python
{ "resource": "" }
q28564
Message.get_content_charset
train
def get_content_charset(self, failobj=None): """Return the charset parameter of the Content-Type header. The returned string is always coerced to lower case. If there is no Content-Type header, or if that header has no charset parameter, failobj is returned. """ missing...
python
{ "resource": "" }
q28565
getfqdn
train
def getfqdn(name=''): """Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname from
python
{ "resource": "" }
q28566
maybe_2to3
train
def maybe_2to3(filename, modname=None): """Returns a python3 version of filename.""" need_2to3 = False filename = os.path.abspath(filename) if any(filename.startswith(d) for d in DIRS): need_2to3 = True elif modname is not None and any(modname.startswith(p) for p in PACKAGES): need_2...
python
{ "resource": "" }
q28567
walk
train
def walk(self): """Walk over the message tree, yielding each subpart. The walk is performed in depth-first order. This method is a
python
{ "resource": "" }
q28568
body_line_iterator
train
def body_line_iterator(msg, decode=False): """Iterate over the parts, returning string payloads line-by-line. Optional decode (default False) is passed through to .get_payload(). """ for subpart in msg.walk():
python
{ "resource": "" }
q28569
typed_subpart_iterator
train
def typed_subpart_iterator(msg, maintype='text', subtype=None): """Iterate over the subparts with a given MIME type. Use `maintype' as the main MIME type to match against; this defaults to "text". Optional `subtype' is the MIME subtype to match against; if omitted, only the main type is matched. "...
python
{ "resource": "" }
q28570
_structure
train
def _structure(msg, fp=None, level=0, include_default=False): """A handy debugging aid""" if fp is None: fp = sys.stdout tab = ' ' * (level * 4) print(tab + msg.get_content_type(), end='', file=fp)
python
{ "resource": "" }
q28571
add_charset
train
def add_charset(charset, header_enc=None, body_enc=None, output_charset=None): """Add character set properties to the global registry. charset is the input character set, and must be the canonical name of a character set. Optional header_enc and body_enc is either Charset.QP for quoted-printable, ...
python
{ "resource": "" }
q28572
Charset.get_body_encoding
train
def get_body_encoding(self): """Return the content-transfer-encoding used for body encoding. This is either the string `quoted-printable' or `base64' depending on the encoding used, or it is a function in which case you should call the function with a single argument, the Message object...
python
{ "resource": "" }
q28573
Charset.body_encode
train
def body_encode(self, string): """Body-encode a string by converting it first to bytes. The type of encoding (base64 or quoted-printable) will be based on self.body_encoding. If body_encoding is None, we assume the output charset is a 7bit encoding, so re-encoding the decoded s...
python
{ "resource": "" }
q28574
SimpleXMLRPCDispatcher.register_instance
train
def register_instance(self, instance, allow_dotted_names=False): """Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. If the registered instance has a _dispatch method then that method will be called with the name of the XML-RPC method ...
python
{ "resource": "" }
q28575
SimpleXMLRPCDispatcher.register_introspection_functions
train
def register_introspection_functions(self): """Registers the XML-RPC introspection methods in the system namespace. see http://xmlrpc.usefulinc.com/doc/reserved.html """ self.funcs.update({'system.listMethods' : self.system_listMethods,
python
{ "resource": "" }
q28576
SimpleXMLRPCDispatcher._dispatch
train
def _dispatch(self, method, params): """Dispatches the XML-RPC method. XML-RPC calls are forwarded to a registered function that matches the called XML-RPC method name. If no such function exists then the call is forwarded to the registered instance, if available. If th...
python
{ "resource": "" }
q28577
ServerHTMLDoc.markup
train
def markup(self, text, escape=None, funcs={}, classes={}, methods={}): """Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.""" escape = escape or self.escape results = [] here = 0 # XXX Note that t...
python
{ "resource": "" }
q28578
ServerHTMLDoc.docroutine
train
def docroutine(self, object, name, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" anchor = (cl and cl.__name__ or '') + '-' + name note = '' title = '<a name="%s"><strong>%s</strong></a>' % ( ...
python
{ "resource": "" }
q28579
ServerHTMLDoc.docserver
train
def docserver(self, server_name, package_documentation, methods): """Produce HTML documentation for an XML-RPC server.""" fdict = {} for key, value in methods.items(): fdict[key] = '#-' + key fdict[value] = fdict[key] server_name = self.escape(server_name) ...
python
{ "resource": "" }
q28580
needs_fixing
train
def needs_fixing(raw_params, kwargs_default=_kwargs_default_name): u""" Returns string with the name of the kwargs dict if the params after the first star need fixing Otherwise returns empty string """ found_kwargs = False needs_fix = False for t in raw_params[2:]: if t.type == toke...
python
{ "resource": "" }
q28581
common_substring
train
def common_substring(s1, s2): """ Returns the longest common substring to the two strings, starting from the left. """ chunks = [] path1 = splitall(s1) path2 = splitall(s2)
python
{ "resource": "" }
q28582
detect_python2
train
def detect_python2(source, pathname): """ Returns a bool indicating whether we think the code is Py2 """ RTs.setup_detect_python2() try: tree = RTs._rt_py2_detect.refactor_string(source, pathname) except ParseError as e: if e.msg != 'bad input' or e.value != '=': rais...
python
{ "resource": "" }
q28583
all_patterns
train
def all_patterns(name): u""" Accepts a string and returns a pattern of possible patterns involving that name Called by simple_mapping_to_pattern for each name in the mapping it receives. """ # i_ denotes an import-like node # u_ denotes a node that appears to be a usage of the name if u'.' ...
python
{ "resource": "" }
q28584
Features.update_mapping
train
def update_mapping(self): u""" Called every time we care about the mapping of names to features. """
python
{ "resource": "" }
q28585
Features.PATTERN
train
def PATTERN(self): u""" Uses the mapping of names to features to return a PATTERN suitable
python
{ "resource": "" }
q28586
indentation
train
def indentation(node): """ Returns the indentation for this node Iff a node is in a suite, then it has indentation. """ while node.parent is not None and node.parent.type != syms.suite: node = node.parent if node.parent is None: return u"" # The first three children of a suit...
python
{ "resource": "" }
q28587
suitify
train
def suitify(parent): """ Turn the stuff after the first colon in parent's children into a suite, if it wasn't already """ for node in parent.children: if node.type == syms.suite: # already in the prefered format, do nothing return # One-liners have no suite node,...
python
{ "resource": "" }
q28588
is_docstring
train
def is_docstring(node): """ Returns True if the node appears to be a docstring """ return (node.type == syms.simple_stmt and
python
{ "resource": "" }
q28589
future_import
train
def future_import(feature, node): """ This seems to work """ root = find_root(node) if does_tree_import(u"__future__", feature, node): return # Look for a shebang or encoding line shebang_encoding_idx = None for idx, node in enumerate(root.children): # Is it a shebang ...
python
{ "resource": "" }
q28590
parse_args
train
def parse_args(arglist, scheme): u""" Parse a list of arguments into a dict """ arglist = [i for i in arglist if i.type != token.COMMA] ret_mapping = dict([(k, None) for k in scheme]) for i, arg in enumerate(arglist): if arg.type == syms.argument and arg.children[1].type == token.EQUAL...
python
{ "resource": "" }
q28591
check_future_import
train
def check_future_import(node): """If this is a future import, return set of symbols that are imported, else return None.""" # node should be the import statement here savenode = node if not (node.type == syms.simple_stmt and node.children): return set() node = node.children[0] # now ...
python
{ "resource": "" }
q28592
date.replace
train
def replace(self, year=None, month=None, day=None): """Return a new date with new values for the specified fields.""" if year is None: year = self._year if month is None:
python
{ "resource": "" }
q28593
time.replace
train
def replace(self, hour=None, minute=None, second=None, microsecond=None, tzinfo=True): """Return a new time with new values for the specified fields.""" if hour is None: hour = self.hour if minute is None: minute = self.minute if second is None: ...
python
{ "resource": "" }
q28594
datetime.timestamp
train
def timestamp(self): "Return POSIX timestamp as float" if self._tzinfo is None: return _time.mktime((self.year, self.month, self.day, self.hour, self.minute,
python
{ "resource": "" }
q28595
datetime.replace
train
def replace(self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, tzinfo=True): """Return a new datetime with new values for the specified fields.""" if year is None: year = self.year if month is None: month = self.m...
python
{ "resource": "" }
q28596
datetime.isoformat
train
def isoformat(self, sep='T'): """Return the time formatted according to ISO. This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if self.microsecond == 0. If self.tzinfo is not None, the UTC offset is also attached, giving 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-...
python
{ "resource": "" }
q28597
Parser.parsestr
train
def parsestr(self, text, headersonly=False): """Create a message structure from a string. Returns the root of the message structure. Optional headersonly is a flag specifying whether to stop parsing after reading the headers or not. The default is False, meaning
python
{ "resource": "" }
q28598
BytesParser.parse
train
def parse(self, fp, headersonly=False): """Create a message structure from the data in a binary file. Reads all the data from the file and returns the root of the message structure. Optional headersonly is a flag specifying whether to stop parsing after reading the headers or not. The...
python
{ "resource": "" }
q28599
BytesParser.parsebytes
train
def parsebytes(self, text, headersonly=False): """Create a message structure from a byte string. Returns the root of the message structure. Optional headersonly is a flag specifying whether
python
{ "resource": "" }