desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'This constructor adds a Content-Type: and a MIME-Version: header.
The Content-Type: header is taken from the _maintype and _subtype
arguments. Additional parameters for this header are taken from the
keyword arguments.'
| def __init__(self, _maintype, _subtype, **_params):
| message.Message.__init__(self)
ctype = ('%s/%s' % (_maintype, _subtype))
self.add_header('Content-Type', ctype, **_params)
self['MIME-Version'] = '1.0'
|
'Create a text/* type MIME document.
_text is the string for this message object.
_subtype is the MIME sub content type, defaulting to "plain".
_charset is the character set parameter added to the Content-Type
header. This defaults to "us-ascii". Note that as a side-effect, the
Content-Transfer-Encoding header will a... | def __init__(self, _text, _subtype='plain', _charset=None):
| if (_charset is None):
try:
_text.encode('us-ascii')
_charset = 'us-ascii'
except UnicodeEncodeError:
_charset = 'utf-8'
MIMENonMultipart.__init__(self, 'text', _subtype, **{'charset': _charset})
self.set_payload(_text, _charset)
|
'Create an application/* type MIME document.
_data is a string containing the raw application data.
_subtype is the MIME content type subtype, defaulting to
\'octet-stream\'.
_encoder is a function which will perform the actual encoding for
transport of the application data, defaulting to base64 encoding.
Any additiona... | def __init__(self, _data, _subtype='octet-stream', _encoder=encoders.encode_base64, **_params):
| if (_subtype is None):
raise TypeError('Invalid application MIME subtype')
MIMENonMultipart.__init__(self, 'application', _subtype, **_params)
self.set_payload(_data)
_encoder(self)
|
'Create a message/* type MIME document.
_msg is a message object and must be an instance of Message, or a
derived class of Message, otherwise a TypeError is raised.
Optional _subtype defines the subtype of the contained message. The
default is "rfc822" (this is defined by the MIME standard, even though
the term "rfc82... | def __init__(self, _msg, _subtype='rfc822'):
| MIMENonMultipart.__init__(self, 'message', _subtype)
if (not isinstance(_msg, message.Message)):
raise TypeError('Argument is not an instance of Message')
message.Message.attach(self, _msg)
self.set_default_type('message/rfc822')
|
'Create an image/* type MIME document.
_imagedata is a string containing the raw image data. If this data
can be decoded by the standard Python `imghdr\' module, then the
subtype will be automatically included in the Content-Type header.
Otherwise, you can specify the specific image subtype via the _subtype
parameter.... | def __init__(self, _imagedata, _subtype=None, _encoder=encoders.encode_base64, **_params):
| if (_subtype is None):
_subtype = imghdr.what(None, _imagedata)
if (_subtype is None):
raise TypeError('Could not guess image MIME subtype')
MIMENonMultipart.__init__(self, 'image', _subtype, **_params)
self.set_payload(_imagedata)
_encoder(self)
|
'Creates a multipart/* type message.
By default, creates a multipart/mixed message, with proper
Content-Type and MIME-Version headers.
_subtype is the subtype of the multipart content type, defaulting to
`mixed\'.
boundary is the multipart boundary string. By default it is
calculated as needed.
_subparts is a sequence... | def __init__(self, _subtype='mixed', boundary=None, _subparts=None, **_params):
| MIMEBase.__init__(self, 'multipart', _subtype, **_params)
self._payload = []
if _subparts:
for p in _subparts:
self.attach(p)
if boundary:
self.set_boundary(boundary)
|
'Create an audio/* type MIME document.
_audiodata is a string containing the raw audio data. If this data
can be decoded by the standard Python `sndhdr\' module, then the
subtype will be automatically included in the Content-Type header.
Otherwise, you can specify the specific audio subtype via the
_subtype parameter... | def __init__(self, _audiodata, _subtype=None, _encoder=encoders.encode_base64, **_params):
| if (_subtype is None):
_subtype = _whatsnd(_audiodata)
if (_subtype is None):
raise TypeError('Could not find audio MIME subtype')
MIMENonMultipart.__init__(self, 'audio', _subtype, **_params)
self.set_payload(_audiodata)
_encoder(self)
|
'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 and
its parameters as a tuple
e.g. instance._dispatch(\'add\',(2,3))
If the registered instance does ... | def register_instance(self, instance, allow_dotted_names=False):
| self.instance = instance
self.allow_dotted_names = allow_dotted_names
|
'Registers a function to respond to XML-RPC requests.
The optional name argument can be used to set a Unicode name
for the function.'
| def register_function(self, function, name=None):
| if (name is None):
name = function.__name__
self.funcs[name] = function
|
'Registers the XML-RPC introspection methods in the system
namespace.
see http://xmlrpc.usefulinc.com/doc/reserved.html'
| def register_introspection_functions(self):
| self.funcs.update({'system.listMethods': self.system_listMethods, 'system.methodSignature': self.system_methodSignature, 'system.methodHelp': self.system_methodHelp})
|
'Registers the XML-RPC multicall method in the system
namespace.
see http://www.xmlrpc.com/discuss/msgReader$1208'
| def register_multicall_functions(self):
| self.funcs.update({'system.multicall': self.system_multicall})
|
'Dispatches an XML-RPC method from marshalled (XML) data.
XML-RPC methods are dispatched from the marshalled (XML) data
using the _dispatch method and the result is returned as
marshalled data. For backwards compatibility, a dispatch
function can be provided as an argument (see comment in
SimpleXMLRPCRequestHandler.do_... | def _marshaled_dispatch(self, data, dispatch_method=None, path=None):
| try:
(params, method) = loads(data, use_builtin_types=self.use_builtin_types)
if (dispatch_method is not None):
response = dispatch_method(method, params)
else:
response = self._dispatch(method, params)
response = (response,)
response = dumps(response,... |
'system.listMethods() => [\'add\', \'subtract\', \'multiple\']
Returns a list of the methods supported by the server.'
| def system_listMethods(self):
| methods = set(self.funcs.keys())
if (self.instance is not None):
if hasattr(self.instance, '_listMethods'):
methods |= set(self.instance._listMethods())
elif (not hasattr(self.instance, '_dispatch')):
methods |= set(list_public_methods(self.instance))
return sorted(me... |
'system.methodSignature(\'add\') => [double, int, int]
Returns a list describing the signature of the method. In the
above example, the add method takes two integers as arguments
and returns a double result.
This server does NOT support system.methodSignature.'
| def system_methodSignature(self, method_name):
| return 'signatures not supported'
|
'system.methodHelp(\'add\') => "Adds two integers together"
Returns a string containing documentation for the specified method.'
| def system_methodHelp(self, method_name):
| method = None
if (method_name in self.funcs):
method = self.funcs[method_name]
elif (self.instance is not None):
if hasattr(self.instance, '_methodHelp'):
return self.instance._methodHelp(method_name)
elif (not hasattr(self.instance, '_dispatch')):
try:
... |
'system.multicall([{\'methodName\': \'add\', \'params\': [2, 2]}, ...]) => [[4], ...]
Allows the caller to package multiple XML-RPC calls into a single
request.
See http://www.xmlrpc.com/discuss/msgReader$1208'
| def system_multicall(self, call_list):
| results = []
for call in call_list:
method_name = call['methodName']
params = call['params']
try:
results.append([self._dispatch(method_name, params)])
except Fault as fault:
results.append({'faultCode': fault.faultCode, 'faultString': fault.faultString})
... |
'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 the registered instance has a _dispatch method then that
method will be called with the nam... | def _dispatch(self, method, params):
| func = None
try:
func = self.funcs[method]
except KeyError:
if (self.instance is not None):
if hasattr(self.instance, '_dispatch'):
return self.instance._dispatch(method, params)
else:
try:
func = resolve_dotted_attr... |
'Handles the HTTP POST request.
Attempts to interpret all HTTP POST requests as XML-RPC calls,
which are forwarded to the server\'s _dispatch method for handling.'
| def do_POST(self):
| if (not self.is_rpc_path_valid()):
self.report_404()
return
try:
max_chunk_size = ((10 * 1024) * 1024)
size_remaining = int(self.headers['content-length'])
L = []
while size_remaining:
chunk_size = min(size_remaining, max_chunk_size)
chunk ... |
'Selectively log an accepted request.'
| def log_request(self, code='-', size='-'):
| if self.server.logRequests:
BaseHTTPRequestHandler.log_request(self, code, size)
|
'Handle a single XML-RPC request'
| def handle_xmlrpc(self, request_text):
| response = self._marshaled_dispatch(request_text)
print 'Content-Type: text/xml'
print ('Content-Length: %d' % len(response))
print ()
sys.stdout.flush()
sys.stdout.buffer.write(response)
sys.stdout.buffer.flush()
|
'Handle a single HTTP GET request.
Default implementation indicates an error because
XML-RPC uses the POST method.'
| def handle_get(self):
| code = 400
(message, explain) = BaseHTTPRequestHandler.responses[code]
response = (http.server.DEFAULT_ERROR_MESSAGE % {'code': code, 'message': message, 'explain': explain})
response = response.encode('utf-8')
print ('Status: %d %s' % (code, message))
print ('Content-Type: %s' % http.s... |
'Handle a single XML-RPC request passed through a CGI post method.
If no XML data is given then it is read from stdin. The resulting
XML-RPC response is printed to stdout along with the correct HTTP
headers.'
| def handle_request(self, request_text=None):
| if ((request_text is None) and (os.environ.get('REQUEST_METHOD', None) == 'GET')):
self.handle_get()
else:
try:
length = int(os.environ.get('CONTENT_LENGTH', None))
except (ValueError, TypeError):
length = (-1)
if (request_text is None):
reques... |
'Mark up some plain text, given a context of symbols to look for.
Each context dictionary maps object names to anchor names.'
| def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
| escape = (escape or self.escape)
results = []
here = 0
pattern = re.compile('\\b((http|ftp)://\\S+[\\w/]|RFC[- ]?(\\d+)|PEP[- ]?(\\d+)|(self\\.)?((?:\\w|\\.)+))\\b')
while 1:
match = pattern.search(text, here)
if (not match):
break
(start, end) = match.span(... |
'Produce HTML documentation for a function or method object.'
| def docroutine(self, object, name, mod=None, funcs={}, classes={}, methods={}, cl=None):
| anchor = ((((cl and cl.__name__) or '') + '-') + name)
note = ''
title = ('<a name="%s"><strong>%s</strong></a>' % (self.escape(anchor), self.escape(name)))
if inspect.ismethod(object):
args = inspect.getfullargspec(object)
argspec = inspect.formatargspec(args.args[1:], args.varargs, ... |
'Produce HTML documentation for an XML-RPC server.'
| def docserver(self, server_name, package_documentation, methods):
| fdict = {}
for (key, value) in methods.items():
fdict[key] = ('#-' + key)
fdict[value] = fdict[key]
server_name = self.escape(server_name)
head = ('<big><big><strong>%s</strong></big></big>' % server_name)
result = self.heading(head, '#ffffff', '#7799ee')
doc = self.markup(packag... |
'Set the HTML title of the generated server documentation'
| def set_server_title(self, server_title):
| self.server_title = server_title
|
'Set the name of the generated HTML server documentation'
| def set_server_name(self, server_name):
| self.server_name = server_name
|
'Set the documentation string for the entire server.'
| def set_server_documentation(self, server_documentation):
| self.server_documentation = server_documentation
|
'generate_html_documentation() => html documentation for the server
Generates HTML documentation for the server using introspection for
installed functions and instances that do not implement the
_dispatch method. Alternatively, instances can choose to implement
the _get_method_argstring(method_name) method to provide ... | def generate_html_documentation(self):
| methods = {}
for method_name in self.system_listMethods():
if (method_name in self.funcs):
method = self.funcs[method_name]
elif (self.instance is not None):
method_info = [None, None]
if hasattr(self.instance, '_get_method_argstring'):
method_... |
'Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.'
| def do_GET(self):
| if (not self.is_rpc_path_valid()):
self.report_404()
return
response = self.server.generate_html_documentation().encode('utf-8')
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.send_header('Content-length', str(len(response)))
self.end_headers()
sel... |
'Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.'
| def handle_get(self):
| response = self.generate_html_documentation().encode('utf-8')
print 'Content-Type: text/html'
print ('Content-Length: %d' % len(response))
print ()
sys.stdout.flush()
sys.stdout.buffer.write(response)
sys.stdout.buffer.flush()
|
'A workaround to get special attributes on the ServerProxy
without interfering with the magic __getattr__'
| def __call__(self, attr):
| if (attr == 'close'):
return self.__close
elif (attr == 'transport'):
return self.__transport
raise AttributeError(('Attribute %r not found' % (attr,)))
|
'Return first release in which this feature was recognized.
This is a 5-tuple, of the same form as sys.version_info.'
| def getOptionalRelease(self):
| return self.optional
|
'Return release in which this feature will become mandatory.
This is a 5-tuple, of the same form as sys.version_info, or, if
the feature was dropped, is None.'
| def getMandatoryRelease(self):
| return self.mandatory
|
'Return a distinct copy of the current font'
| def copy(self):
| return Font(self._tk, **self.actual())
|
'Return actual font attributes'
| def actual(self, option=None, displayof=None):
| args = ()
if displayof:
args = ('-displayof', displayof)
if option:
args = (args + (('-' + option),))
return self._call('font', 'actual', self.name, *args)
else:
return self._mkdict(self._split(self._call('font', 'actual', self.name, *args)))
|
'Get font attribute'
| def cget(self, option):
| return self._call('font', 'config', self.name, ('-' + option))
|
'Modify font attributes'
| def config(self, **options):
| if options:
self._call('font', 'config', self.name, *self._set(options))
else:
return self._mkdict(self._split(self._call('font', 'config', self.name)))
|
'Return text width'
| def measure(self, text, displayof=None):
| args = (text,)
if displayof:
args = ('-displayof', displayof, text)
return int(self._call('font', 'measure', self.name, *args))
|
'Return font metrics.
For best performance, create a dummy widget
using this font before calling this method.'
| def metrics(self, *options, **kw):
| args = ()
displayof = kw.pop('displayof', None)
if displayof:
args = ('-displayof', displayof)
if options:
args = (args + self._get(options))
return int(self._call('font', 'metrics', self.name, *args))
else:
res = self._split(self._call('font', 'metrics', self.name, *... |
'Tix maintains a list of directories under which
the tix_getimage and tix_getbitmap commands will
search for image files. The standard bitmap directory
is $TIX_LIBRARY/bitmaps. The addbitmapdir command
adds directory into this list. By using this
command, the image files of an applications can
also be located u... | def tix_addbitmapdir(self, directory):
| return self.tk.call('tix', 'addbitmapdir', directory)
|
'Returns the current value of the configuration
option given by option. Option may be any of the
options described in the CONFIGURATION OPTIONS section.'
| def tix_cget(self, option):
| return self.tk.call('tix', 'cget', option)
|
'Query or modify the configuration options of the Tix application
context. If no option is specified, returns a dictionary all of the
available options. If option is specified with no value, then the
command returns a list describing the one named option (this list
will be identical to the corresponding sublist of the... | def tix_configure(self, cnf=None, **kw):
| if kw:
cnf = _cnfmerge((cnf, kw))
elif cnf:
cnf = _cnfmerge(cnf)
if (cnf is None):
return self._getconfigure('tix', 'configure')
if isinstance(cnf, str):
return self._getconfigure1('tix', 'configure', ('-' + cnf))
return self.tk.call((('tix', 'configure') + self._opti... |
'Returns the file selection dialog that may be shared among
different calls from this application. This command will create a
file selection dialog widget when it is called the first time. This
dialog will be returned by all subsequent calls to tix_filedialog.
An optional dlgclass parameter can be passed to specified ... | def tix_filedialog(self, dlgclass=None):
| if (dlgclass is not None):
return self.tk.call('tix', 'filedialog', dlgclass)
else:
return self.tk.call('tix', 'filedialog')
|
'Locates a bitmap file of the name name.xpm or name in one of the
bitmap directories (see the tix_addbitmapdir command above). By
using tix_getbitmap, you can avoid hard coding the pathnames of the
bitmap files in your application. When successful, it returns the
complete pathname of the bitmap file, prefixed with the... | def tix_getbitmap(self, name):
| return self.tk.call('tix', 'getbitmap', name)
|
'Locates an image file of the name name.xpm, name.xbm or name.ppm
in one of the bitmap directories (see the addbitmapdir command
above). If more than one file with the same name (but different
extensions) exist, then the image type is chosen according to the
depth of the X display: xbm images are chosen on monochrome
d... | def tix_getimage(self, name):
| return self.tk.call('tix', 'getimage', name)
|
'Gets the options maintained by the Tix
scheme mechanism. Available options include:
active_bg active_fg bg
bold_font dark1_bg dark1_fg
dark2_bg dark2_fg disabled_fg
fg fixed_font font
inactive_bg inactive_fg input1_bg
input2_bg italic_font light... | def tix_option_get(self, name):
| return self.tk.call('tix', 'option', 'get', name)
|
'Resets the scheme and fontset of the Tix application to
newScheme and newFontSet, respectively. This affects only those
widgets created after this call. Therefore, it is best to call the
resetoptions command before the creation of any widgets in a Tix
application.
The optional parameter newScmPrio can be given to res... | def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None):
| if (newScmPrio is not None):
return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio)
else:
return self.tk.call('tix', 'resetoptions', newScheme, newFontSet)
|
'Set a variable without calling its action routine'
| def set_silent(self, value):
| self.tk.call('tixSetSilent', self._w, value)
|
'Return the named subwidget (which must have been created by
the sub-class).'
| def subwidget(self, name):
| n = self._subwidget_name(name)
if (not n):
raise TclError(((('Subwidget ' + name) + ' not child of ') + self._name))
n = n[(len(self._w) + 1):]
return self._nametowidget(n)
|
'Return all subwidgets.'
| def subwidgets_all(self):
| names = self._subwidget_names()
if (not names):
return []
retlist = []
for name in names:
name = name[(len(self._w) + 1):]
try:
retlist.append(self._nametowidget(name))
except:
pass
return retlist
|
'Get a subwidget name (returns a String, not a Widget !)'
| def _subwidget_name(self, name):
| try:
return self.tk.call(self._w, 'subwidget', name)
except TclError:
return None
|
'Return the name of all subwidgets.'
| def _subwidget_names(self):
| try:
x = self.tk.call(self._w, 'subwidgets', '-all')
return self.tk.splitlist(x)
except TclError:
return None
|
'Set configuration options for all subwidgets (and self).'
| def config_all(self, option, value):
| if (option == ''):
return
elif (not isinstance(option, str)):
option = repr(option)
if (not isinstance(value, str)):
value = repr(value)
names = self._subwidget_names()
for name in names:
self.tk.call(name, 'configure', ('-' + option), value)
|
'Bind balloon widget to another.
One balloon widget may be bound to several widgets at the same time'
| def bind_widget(self, widget, cnf={}, **kw):
| self.tk.call(self._w, 'bind', widget._w, *self._options(cnf, kw))
|
'Add a button with given name to box.'
| def add(self, name, cnf={}, **kw):
| btn = self.tk.call(self._w, 'add', name, *self._options(cnf, kw))
self.subwidget_list[name] = _dummyButton(self, name)
return btn
|
'This command calls the setmode method for all the entries in this
Tree widget: if an entry has no child entries, its mode is set to
none. Otherwise, if the entry has any hidden child entries, its mode is
set to open; otherwise its mode is set to close.'
| def autosetmode(self):
| self.tk.call(self._w, 'autosetmode')
|
'Close the entry given by entryPath if its mode is close.'
| def close(self, entrypath):
| self.tk.call(self._w, 'close', entrypath)
|
'Returns the current mode of the entry given by entryPath.'
| def getmode(self, entrypath):
| return self.tk.call(self._w, 'getmode', entrypath)
|
'Open the entry given by entryPath if its mode is open.'
| def open(self, entrypath):
| self.tk.call(self._w, 'open', entrypath)
|
'This command is used to indicate whether the entry given by
entryPath has children entries and whether the children are visible. mode
must be one of open, close or none. If mode is set to open, a (+)
indicator is drawn next the entry. If mode is set to close, a (-)
indicator is drawn next the entry. If mode is set to ... | def setmode(self, entrypath, mode='none'):
| self.tk.call(self._w, 'setmode', entrypath, mode)
|
'This command calls the setmode method for all the entries in this
Tree widget: if an entry has no child entries, its mode is set to
none. Otherwise, if the entry has any hidden child entries, its mode is
set to open; otherwise its mode is set to close.'
| def autosetmode(self):
| self.tk.call(self._w, 'autosetmode')
|
'Close the entry given by entryPath if its mode is close.'
| def close(self, entrypath):
| self.tk.call(self._w, 'close', entrypath)
|
'Returns the current mode of the entry given by entryPath.'
| def getmode(self, entrypath):
| return self.tk.call(self._w, 'getmode', entrypath)
|
'Open the entry given by entryPath if its mode is open.'
| def open(self, entrypath):
| self.tk.call(self._w, 'open', entrypath)
|
'Returns a list of items whose status matches status. If status is
not specified, the list of items in the "on" status will be returned.
Mode can be on, off, default'
| def getselection(self, mode='on'):
| c = self.tk.split(self.tk.call(self._w, 'getselection', mode))
return self.tk.splitlist(c)
|
'Returns the current status of entryPath.'
| def getstatus(self, entrypath):
| return self.tk.call(self._w, 'getstatus', entrypath)
|
'Sets the status of entryPath to be status. A bitmap will be
displayed next to the entry its status is on, off or default.'
| def setstatus(self, entrypath, mode='on'):
| self.tk.call(self._w, 'setstatus', entrypath, mode)
|
'Removes the selection anchor.'
| def anchor_clear(self):
| self.tk.call(self, 'anchor', 'clear')
|
'Get the (x,y) coordinate of the current anchor cell'
| def anchor_get(self):
| return self._getints(self.tk.call(self, 'anchor', 'get'))
|
'Set the selection anchor to the cell at (x, y).'
| def anchor_set(self, x, y):
| self.tk.call(self, 'anchor', 'set', x, y)
|
'Delete rows between from_ and to inclusive.
If to is not provided, delete only row at from_'
| def delete_row(self, from_, to=None):
| if (to is None):
self.tk.call(self, 'delete', 'row', from_)
else:
self.tk.call(self, 'delete', 'row', from_, to)
|
'Delete columns between from_ and to inclusive.
If to is not provided, delete only column at from_'
| def delete_column(self, from_, to=None):
| if (to is None):
self.tk.call(self, 'delete', 'column', from_)
else:
self.tk.call(self, 'delete', 'column', from_, to)
|
'If any cell is being edited, de-highlight the cell and applies
the changes.'
| def edit_apply(self):
| self.tk.call(self, 'edit', 'apply')
|
'Highlights the cell at (x, y) for editing, if the -editnotify
command returns True for this cell.'
| def edit_set(self, x, y):
| self.tk.call(self, 'edit', 'set', x, y)
|
'Get the option value for cell at (x,y)'
| def entrycget(self, x, y, option):
| if (option and (option[0] != '-')):
option = ('-' + option)
return self.tk.call(self, 'entrycget', x, y, option)
|
'Return True if display item exists at (x,y)'
| def info_exists(self, x, y):
| return self._getboolean(self.tk.call(self, 'info', 'exists', x, y))
|
'Moves the range of columns from position FROM through TO by
the distance indicated by OFFSET. For example, move_column(2, 4, 1)
moves the columns 2,3,4 to columns 3,4,5.'
| def move_column(self, from_, to, offset):
| self.tk.call(self, 'move', 'column', from_, to, offset)
|
'Moves the range of rows from position FROM through TO by
the distance indicated by OFFSET.
For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.'
| def move_row(self, from_, to, offset):
| self.tk.call(self, 'move', 'row', from_, to, offset)
|
'Return coordinate of cell nearest pixel coordinate (x,y)'
| def nearest(self, x, y):
| return self._getints(self.tk.call(self, 'nearest', x, y))
|
'Queries or sets the size of the column given by
INDEX. INDEX may be any non-negative
integer that gives the position of a given column.
INDEX can also be the string "default"; in this case, this command
queries or sets the default size of all columns.
When no option-value pair is given, this command returns a tuple
c... | def size_column(self, index, **kw):
| return self.tk.split(self.tk.call(self._w, 'size', 'column', index, *self._options({}, kw)))
|
'Queries or sets the size of the row given by
INDEX. INDEX may be any non-negative
integer that gives the position of a given row .
INDEX can also be the string "default"; in this case, this command
queries or sets the default size of all rows.
When no option-value pair is given, this command returns a list con-
tainin... | def size_row(self, index, **kw):
| return self.tk.split(self.tk.call(self, 'size', 'row', index, *self._options({}, kw)))
|
'Clears the cell at (x, y) by removing its display item.'
| def unset(self, x, y):
| self.tk.call(self._w, 'unset', x, y)
|
'Initialize a dialog.
Arguments:
parent -- a parent window (the application window)
title -- the dialog title'
| def __init__(self, parent, title=None):
| Toplevel.__init__(self, parent)
self.withdraw()
if parent.winfo_viewable():
self.transient(parent)
if title:
self.title(title)
self.parent = parent
self.result = None
body = Frame(self)
self.initial_focus = self.body(body)
body.pack(padx=5, pady=5)
self.buttonbox(... |
'Destroy the window'
| def destroy(self):
| self.initial_focus = None
Toplevel.destroy(self)
|
'create dialog body.
return widget that should have initial focus.
This method should be overridden, and is called
by the __init__ method.'
| def body(self, master):
| pass
|
'add standard button box.
override if you do not want the standard buttons'
| def buttonbox(self):
| box = Frame(self)
w = Button(box, text='OK', width=10, command=self.ok, default=ACTIVE)
w.pack(side=LEFT, padx=5, pady=5)
w = Button(box, text='Cancel', width=10, command=self.cancel)
w.pack(side=LEFT, padx=5, pady=5)
self.bind('<Return>', self.ok)
self.bind('<Escape>', self.cancel)
box.... |
'validate the data
This method is called automatically to validate the data before the
dialog is destroyed. By default, it always validates OK.'
| def validate(self):
| return 1
|
'process the data
This method is called automatically to process the data, *after*
the dialog is destroyed. By default, it does nothing.'
| def apply(self):
| pass
|
'Indicate that a formerly enqueued task is complete.
Used by Queue consumer threads. For each get() used to fetch a task,
a subsequent call to task_done() tells the queue that the processing
on the task is complete.
If a join() is currently blocking, it will resume when all items
have been processed (meaning that a ta... | def task_done(self):
| with self.all_tasks_done:
unfinished = (self.unfinished_tasks - 1)
if (unfinished <= 0):
if (unfinished < 0):
raise ValueError('task_done() called too many times')
self.all_tasks_done.notify_all()
self.unfinished_tasks = unfinished
|
'Blocks until all items in the Queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the
queue. The count goes down whenever a consumer thread calls task_done()
to indicate the item was retrieved and all work on it is complete.
When the count of unfinished tasks drops ... | def join(self):
| with self.all_tasks_done:
while self.unfinished_tasks:
self.all_tasks_done.wait()
|
'Return the approximate size of the queue (not reliable!).'
| def qsize(self):
| with self.mutex:
return self._qsize()
|
'Return True if the queue is empty, False otherwise (not reliable!).
This method is likely to be removed at some point. Use qsize() == 0
as a direct substitute, but be aware that either approach risks a race
condition where a queue can grow before the result of empty() or
qsize() can be used.
To create code that needs... | def empty(self):
| with self.mutex:
return (not self._qsize())
|
'Return True if the queue is full, False otherwise (not reliable!).
This method is likely to be removed at some point. Use qsize() >= n
as a direct substitute, but be aware that either approach risks a race
condition where a queue can shrink before the result of full() or
qsize() can be used.'
| def full(self):
| with self.mutex:
return (0 < self.maxsize <= self._qsize())
|
'Put an item into the queue.
If optional args \'block\' is true and \'timeout\' is None (the default),
block if necessary until a free slot is available. If \'timeout\' is
a non-negative number, it blocks at most \'timeout\' seconds and raises
the Full exception if no free slot was available within that time.
Otherwise... | def put(self, item, block=True, timeout=None):
| with self.not_full:
if (self.maxsize > 0):
if (not block):
if (self._qsize() >= self.maxsize):
raise Full
elif (timeout is None):
while (self._qsize() >= self.maxsize):
self.not_full.wait()
elif (time... |
'Remove and return an item from the queue.
If optional args \'block\' is true and \'timeout\' is None (the default),
block if necessary until an item is available. If \'timeout\' is
a non-negative number, it blocks at most \'timeout\' seconds and raises
the Empty exception if no item was available within that time.
Oth... | def get(self, block=True, timeout=None):
| with self.not_empty:
if (not block):
if (not self._qsize()):
raise Empty
elif (timeout is None):
while (not self._qsize()):
self.not_empty.wait()
elif (timeout < 0):
raise ValueError("'timeout' must be a non-nega... |
'Put an item into the queue without blocking.
Only enqueue the item if a free slot is immediately available.
Otherwise raise the Full exception.'
| def put_nowait(self, item):
| return self.put(item, block=False)
|
'Remove and return an item from the queue without blocking.
Only get an item if one is immediately available. Otherwise
raise the Empty exception.'
| def get_nowait(self):
| return self.get(block=False)
|
'Create a new directory in the Directory table. There is a current component
at each point in time for the directory, which is either explicitly created
through start_component, or implicitly when files are added for the first
time. Files are added into the current component, and into the cab file.
To create a director... | def __init__(self, db, cab, basedir, physical, _logical, default, componentflags=None):
| index = 1
_logical = make_id(_logical)
logical = _logical
while (logical in _directories):
logical = ('%s%d' % (_logical, index))
index += 1
_directories.add(logical)
self.db = db
self.cab = cab
self.basedir = basedir
self.physical = physical
self.logical = logica... |
'Add an entry to the Component table, and make this component the current for this
directory. If no component name is given, the directory name is used. If no feature
is given, the current feature is used. If no flags are given, the directory\'s default
flags are used. If no keyfile is given, the KeyPath is left null i... | def start_component(self, component=None, feature=None, flags=None, keyfile=None, uuid=None):
| if (flags is None):
flags = self.componentflags
if (uuid is None):
uuid = gen_uuid()
else:
uuid = uuid.upper()
if (component is None):
component = self.logical
self.component = component
if Win64:
flags |= 256
if keyfile:
keyid = self.cab.gen_i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.