_id
stringlengths 2
7
| title
stringlengths 1
88
| partition
stringclasses 3
values | text
stringlengths 31
13.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q2200
|
Skype.PlaceCall
|
train
|
def PlaceCall(self, *Targets):
"""Places a call to a single user or creates a conference call.
:Parameters:
Targets : str
One or more call targets. If multiple targets are specified, a conference call is
created. The call target can be a Skypename, phone number, or speed dial code.
:return: A call object.
:rtype: `call.Call`
"""
calls = self.ActiveCalls
reply = self._DoCommand('CALL %s' % ', '.join(Targets))
# Skype for Windows returns the call status which gives us the call Id;
|
python
|
{
"resource": ""
}
|
q2201
|
Skype.SendCommand
|
train
|
def SendCommand(self, Command):
"""Sends an API command.
:Parameters:
Command : `Command`
Command to send. Use `Command` method to create a command.
"""
try:
|
python
|
{
"resource": ""
}
|
q2202
|
Skype.SendSms
|
train
|
def SendSms(self, *TargetNumbers, **Properties):
"""Creates and sends an SMS message.
:Parameters:
TargetNumbers : str
One or more target SMS numbers.
Properties
Message properties. Properties available are same as `SmsMessage` object properties.
:return: An sms message object. The message is already sent at this point.
:rtype: `SmsMessage`
"""
|
python
|
{
"resource": ""
}
|
q2203
|
Skype.SendVoicemail
|
train
|
def SendVoicemail(self, Username):
"""Sends a voicemail to a specified user.
:Parameters:
Username : str
Skypename of the user.
:note: Should return a `Voicemail` object. This is not implemented yet.
"""
if self._Api.protocol
|
python
|
{
"resource": ""
}
|
q2204
|
Skype.User
|
train
|
def User(self, Username=''):
"""Queries a user object.
:Parameters:
Username : str
Skypename of the user.
:return: A user object.
:rtype: `user.User`
"""
if not Username:
|
python
|
{
"resource": ""
}
|
q2205
|
Skype.Voicemail
|
train
|
def Voicemail(self, Id):
"""Queries the voicemail object.
:Parameters:
Id : int
Voicemail Id.
:return: A voicemail object.
:rtype: `Voicemail`
"""
|
python
|
{
"resource": ""
}
|
q2206
|
Application.Connect
|
train
|
def Connect(self, Username, WaitConnected=False):
"""Connects application to user.
:Parameters:
Username : str
Name of the user to connect to.
WaitConnected : bool
If True, causes the method to wait until the connection is established.
:return: If ``WaitConnected`` is True, returns the stream which can be used to send the
data. Otherwise returns None.
:rtype: `ApplicationStream` or None
"""
if WaitConnected:
self._Connect_Event = threading.Event()
self._Connect_Stream = [None]
self._Connect_Username = Username
self._Connect_ApplicationStreams(self, self.Streams)
|
python
|
{
"resource": ""
}
|
q2207
|
Application.SendDatagram
|
train
|
def SendDatagram(self, Text, Streams=None):
"""Sends datagram to application streams.
:Parameters:
Text : unicode
Text to send.
Streams : sequence of `ApplicationStream`
Streams to send the datagram to or None if all currently connected streams should be
|
python
|
{
"resource": ""
}
|
q2208
|
ApplicationStream.SendDatagram
|
train
|
def SendDatagram(self, Text):
"""Sends datagram to stream.
:Parameters:
Text : unicode
Datagram to send.
"""
|
python
|
{
"resource": ""
}
|
q2209
|
ApplicationStream.Write
|
train
|
def Write(self, Text):
"""Writes data to stream.
:Parameters:
Text : unicode
|
python
|
{
"resource": ""
}
|
q2210
|
Client.CreateEvent
|
train
|
def CreateEvent(self, EventId, Caption, Hint):
"""Creates a custom event displayed in Skype client's events pane.
:Parameters:
EventId : unicode
Unique identifier for the event.
Caption : unicode
Caption text.
Hint : unicode
Hint text. Shown when mouse hoovers over the event.
:return: Event object.
:rtype: `PluginEvent`
"""
|
python
|
{
"resource": ""
}
|
q2211
|
Client.CreateMenuItem
|
train
|
def CreateMenuItem(self, MenuItemId, PluginContext, CaptionText, HintText=u'', IconPath='', Enabled=True,
ContactType=pluginContactTypeAll, MultipleContacts=False):
"""Creates custom menu item in Skype client's "Do More" menus.
:Parameters:
MenuItemId : unicode
Unique identifier for the menu item.
PluginContext : `enums`.pluginContext*
Menu item context. Allows to choose in which client windows will the menu item appear.
CaptionText : unicode
Caption text.
HintText : unicode
Hint text (optional). Shown when mouse hoovers over the menu item.
IconPath : unicode
Path to the icon (optional).
Enabled : bool
Initial state of the menu item. True by default.
ContactType : `enums`.pluginContactType*
In case of `enums.pluginContextContact` tells which contacts the menu item should appear
for. Defaults to `enums.pluginContactTypeAll`.
MultipleContacts : bool
Set to True if multiple contacts should be allowed (defaults to False).
:return: Menu item object.
:rtype: `PluginMenuItem`
"""
|
python
|
{
"resource": ""
}
|
q2212
|
Client.Focus
|
train
|
def Focus(self):
"""Brings the client window into focus.
"""
|
python
|
{
"resource": ""
}
|
q2213
|
Client.OpenDialog
|
train
|
def OpenDialog(self, Name, *Params):
"""Open dialog. Use this method to open dialogs added in newer Skype versions if there is no
dedicated method in Skype4Py.
:Parameters:
Name
|
python
|
{
"resource": ""
}
|
q2214
|
Client.OpenMessageDialog
|
train
|
def OpenMessageDialog(self, Username, Text=u''):
"""Opens "Send an IM Message" dialog.
:Parameters:
Username : str
Message target.
|
python
|
{
"resource": ""
}
|
q2215
|
Client.Start
|
train
|
def Start(self, Minimized=False, Nosplash=False):
"""Starts Skype application.
:Parameters:
Minimized : bool
If True, Skype is started minimized in system tray.
Nosplash : bool
|
python
|
{
"resource": ""
}
|
q2216
|
SkypeAPI.start
|
train
|
def start(self):
"""
Start the thread associated with this API object.
Ensure that the call is made no more than
|
python
|
{
"resource": ""
}
|
q2217
|
SkypeAPI.get_skype
|
train
|
def get_skype(self):
"""Returns Skype window ID or None if Skype not running."""
skype_inst = x11.XInternAtom(self.disp, '_SKYPE_INSTANCE', True)
if not skype_inst:
return
type_ret = Atom()
format_ret = c_int()
nitems_ret = c_ulong()
|
python
|
{
"resource": ""
}
|
q2218
|
Call.Join
|
train
|
def Join(self, Id):
"""Joins with another call to form a conference.
:Parameters:
Id : int
Call Id of the other call to join to the conference.
:return: Conference object.
:rtype: `Conference`
"""
#self._Alter('JOIN_CONFERENCE', Id)
|
python
|
{
"resource": ""
}
|
q2219
|
Settings.Avatar
|
train
|
def Avatar(self, Id=1, Set=None):
"""Sets user avatar picture from file.
:Parameters:
Id : int
Optional avatar Id.
Set : str
New avatar file name.
:deprecated: Use `LoadAvatarFromFile`
|
python
|
{
"resource": ""
}
|
q2220
|
Settings.LoadAvatarFromFile
|
train
|
def LoadAvatarFromFile(self, Filename, AvatarId=1):
"""Loads user avatar picture from file.
:Parameters:
Filename : str
Name of the avatar file.
AvatarId : int
|
python
|
{
"resource": ""
}
|
q2221
|
Settings.SaveAvatarToFile
|
train
|
def SaveAvatarToFile(self, Filename, AvatarId=1):
"""Saves user avatar picture to file.
:Parameters:
Filename : str
Destination path.
AvatarId : int
|
python
|
{
"resource": ""
}
|
q2222
|
User.SaveAvatarToFile
|
train
|
def SaveAvatarToFile(self, Filename, AvatarId=1):
"""Saves user avatar to a file.
:Parameters:
Filename : str
Destination path.
AvatarId : int
Avatar Id.
|
python
|
{
"resource": ""
}
|
q2223
|
User.SetBuddyStatusPendingAuthorization
|
train
|
def SetBuddyStatusPendingAuthorization(self, Text=u''):
"""Sets the BuddyStaus property to `enums.budPendingAuthorization`
additionally specifying the authorization text.
:Parameters:
Text : unicode
|
python
|
{
"resource": ""
}
|
q2224
|
StreamWrite
|
train
|
def StreamWrite(stream, *obj):
"""Writes Python object
|
python
|
{
"resource": ""
}
|
q2225
|
TCPTunnel.close
|
train
|
def close(self):
"""Closes the tunnel."""
try:
self.sock.shutdown(socket.SHUT_RDWR)
|
python
|
{
"resource": ""
}
|
q2226
|
SkypeEvents.ApplicationReceiving
|
train
|
def ApplicationReceiving(self, app, streams):
"""Called when the list of streams with data ready to be read changes."""
# we should only proceed if we are in TCP mode
if stype != socket.SOCK_STREAM:
return
# handle all streams
for stream in streams:
# read object from the stream
obj = StreamRead(stream)
if obj:
if obj[0] == cmdData:
# data were received, reroute it to the tunnel based on the tunnel ID
try:
TCPTunnel.threads[obj[1]].send(obj[2])
except KeyError:
pass
elif obj[0] == cmdConnect:
|
python
|
{
"resource": ""
}
|
q2227
|
SkypeEvents.ApplicationDatagram
|
train
|
def ApplicationDatagram(self, app, stream, text):
"""Called when a datagram is received over a stream."""
# we should only proceed if we are in UDP mode
if stype != socket.SOCK_DGRAM:
return
# decode the data
data =
|
python
|
{
"resource": ""
}
|
q2228
|
chop
|
train
|
def chop(s, n=1, d=None):
"""Chops initial words from a string and returns a list of them and the rest of the string.
The returned list is guaranteed to be n+1 long. If too little words are found in the string,
a ValueError exception is raised.
:Parameters:
s : str or unicode
String to chop from.
n : int
Number of words to chop.
d : str or unicode
Optional delimiter. Any white-char by default.
:return: A list of n first words from the string followed by the rest of the string (``[w1, w2,
|
python
|
{
"resource": ""
}
|
q2229
|
args2dict
|
train
|
def args2dict(s):
"""Converts a string or comma-separated 'ARG="a value"' or 'ARG=value2' strings
into a dictionary.
:Parameters:
s : str or unicode
Input string.
:return: ``{'ARG': 'value'}`` dictionary.
:rtype: dict
"""
d = {}
while s:
t, s = chop(s, 1, '=')
if s.startswith('"'):
# XXX: This function is used to parse strings from Skype. The question is,
# how does Skype escape the double-quotes. The code below implements the
# VisualBasic technique
|
python
|
{
"resource": ""
}
|
q2230
|
EventHandlingBase.RegisterEventHandler
|
train
|
def RegisterEventHandler(self, Event, Target):
"""Registers any callable as an event handler.
:Parameters:
Event : str
Name of the event. For event names, see the respective ``...Events`` class.
Target : callable
Callable to register as the event handler.
:return: True is callable was successfully registered, False if it was already registered.
:rtype: bool
:see: `UnregisterEventHandler`
"""
if not callable(Target):
raise TypeError('%s is not callable' % repr(Target))
|
python
|
{
"resource": ""
}
|
q2231
|
EventHandlingBase.UnregisterEventHandler
|
train
|
def UnregisterEventHandler(self, Event, Target):
"""Unregisters an event handler previously registered with `RegisterEventHandler`.
:Parameters:
Event : str
Name of the event. For event names, see the respective ``...Events`` class.
Target : callable
Callable to unregister.
:return: True if callable was successfully unregistered, False if it wasn't registered
first.
:rtype: bool
:see: `RegisterEventHandler`
"""
if not callable(Target):
|
python
|
{
"resource": ""
}
|
q2232
|
Chat.AddMembers
|
train
|
def AddMembers(self, *Members):
"""Adds new members to the chat.
:Parameters:
Members : `User`
One or more users to add.
"""
|
python
|
{
"resource": ""
}
|
q2233
|
Chat.SendMessage
|
train
|
def SendMessage(self, MessageText):
"""Sends a chat message.
:Parameters:
MessageText : unicode
Message text
:return: Message object
:rtype: `ChatMessage`
"""
|
python
|
{
"resource": ""
}
|
q2234
|
Chat.SetPassword
|
train
|
def SetPassword(self, Password, Hint=''):
"""Sets the chat password.
:Parameters:
Password : unicode
Password
Hint : unicode
Password hint
"""
|
python
|
{
"resource": ""
}
|
q2235
|
ChatMember.CanSetRoleTo
|
train
|
def CanSetRoleTo(self, Role):
"""Checks if the new role can be applied to the member.
:Parameters:
Role : `enums`.chatMemberRole*
New chat member role.
:return: True if the new role can be applied, False otherwise.
:rtype: bool
|
python
|
{
"resource": ""
}
|
q2236
|
CallChannelManager.Connect
|
train
|
def Connect(self, Skype):
"""Connects this call channel manager instance to Skype. This is the first thing you should
do after creating this object.
|
python
|
{
"resource": ""
}
|
q2237
|
CallChannel.SendTextMessage
|
train
|
def SendTextMessage(self, Text):
"""Sends a text message over channel.
:Parameters:
Text : unicode
Text to send.
"""
if self.Type == cctReliable:
self.Stream.Write(Text)
elif self.Type == cctDatagram:
|
python
|
{
"resource": ""
}
|
q2238
|
Conversion.TextToAttachmentStatus
|
train
|
def TextToAttachmentStatus(self, Text):
"""Returns attachment status code.
:Parameters:
Text : unicode
Text, one of 'UNKNOWN', 'SUCCESS', 'PENDING_AUTHORIZATION', 'REFUSED', 'NOT_AVAILABLE',
'AVAILABLE'.
:return: Attachment status.
:rtype: `enums`.apiAttach*
"""
conv = {'UNKNOWN': enums.apiAttachUnknown,
'SUCCESS': enums.apiAttachSuccess,
'PENDING_AUTHORIZATION': enums.apiAttachPendingAuthorization,
'REFUSED': enums.apiAttachRefused,
|
python
|
{
"resource": ""
}
|
q2239
|
Conversion.TextToBuddyStatus
|
train
|
def TextToBuddyStatus(self, Text):
"""Returns buddy status code.
:Parameters:
Text : unicode
Text, one of 'UNKNOWN', 'NEVER_BEEN_FRIEND', 'DELETED_FRIEND', 'PENDING_AUTHORIZATION',
'FRIEND'.
:return: Buddy status.
:rtype: `enums`.bud*
"""
conv = {'UNKNOWN': enums.budUnknown,
'NEVER_BEEN_FRIEND': enums.budNeverBeenFriend,
'DELETED_FRIEND': enums.budDeletedFriend,
|
python
|
{
"resource": ""
}
|
q2240
|
SuperFormMixin.add_composite_field
|
train
|
def add_composite_field(self, name, field):
"""
Add a dynamic composite field to the already existing ones
|
python
|
{
"resource": ""
}
|
q2241
|
SuperFormMixin._init_composite_fields
|
train
|
def _init_composite_fields(self):
"""
Setup the forms and formsets.
"""
# The base_composite_fields class attribute is the *class-wide*
# definition of fields. Because a particular *instance* of the class
# might want to alter self.composite_fields, we create
# self.composite_fields here by copying base_composite_fields.
# Instances should always modify self.composite_fields; they should not
|
python
|
{
"resource": ""
}
|
q2242
|
SuperFormMixin.full_clean
|
train
|
def full_clean(self):
"""
Clean the form, including all formsets and add formset errors to the
errors dict. Errors of nested forms and formsets are only included if
they actually contain errors.
"""
super(SuperFormMixin, self).full_clean()
for field_name, composite in self.forms.items():
composite.full_clean()
if not composite.is_valid() and composite._errors:
|
python
|
{
"resource": ""
}
|
q2243
|
SuperFormMixin.media
|
train
|
def media(self):
"""
Incooperate composite field's media.
"""
media_list = []
media_list.append(super(SuperFormMixin, self).media)
for composite_name in self.composite_fields.keys():
|
python
|
{
"resource": ""
}
|
q2244
|
SuperModelFormMixin.save
|
train
|
def save(self, commit=True):
"""
When saving a super model form, the nested forms and formsets will be
saved as well.
The implementation of ``.save()`` looks like this:
.. code:: python
saved_obj = self.save_form()
self.save_forms()
self.save_formsets()
return saved_obj
That makes it easy to override it in order to change the order in which
things are saved.
The ``.save()`` method will return only a single model instance even if
nested forms are saved as well. That keeps the API similiar to what
Django's model forms are offering.
If ``commit=False`` django's modelform implementation will attach a
|
python
|
{
"resource": ""
}
|
q2245
|
CompositeField.get_prefix
|
train
|
def get_prefix(self, form, name):
"""
Return the prefix that is used for the formset.
"""
return '{form_prefix}{prefix_name}-{field_name}'.format(
|
python
|
{
"resource": ""
}
|
q2246
|
CompositeField.get_initial
|
train
|
def get_initial(self, form, name):
"""
Get the initial data that got passed into the superform for this
composite field. It
|
python
|
{
"resource": ""
}
|
q2247
|
FormField.get_form
|
train
|
def get_form(self, form, name):
"""
Get an instance of the form.
"""
kwargs = self.get_kwargs(form, name)
form_class = self.get_form_class(form, name)
composite_form = form_class(
|
python
|
{
"resource": ""
}
|
q2248
|
ForeignKeyFormField.allow_blank
|
train
|
def allow_blank(self, form, name):
"""
Allow blank determines if the form might be completely empty. If it's
empty it will result in a None as the saved value for the ForeignKey.
"""
if self.blank is not None:
|
python
|
{
"resource": ""
}
|
q2249
|
FormSetField.get_formset
|
train
|
def get_formset(self, form, name):
"""
Get an instance of the formset.
"""
kwargs = self.get_kwargs(form, name)
formset_class = self.get_formset_class(form, name)
formset = formset_class(
|
python
|
{
"resource": ""
}
|
q2250
|
MongoAlchemy.init_app
|
train
|
def init_app(self, app, config_prefix='MONGOALCHEMY'):
"""This callback can be used to initialize an application for the use with this
MongoDB setup. Never use a database in the context of an application not
initialized that way or connections will leak."""
self.config_prefix = config_prefix
def key(suffix):
return '%s_%s' % (config_prefix, suffix)
if key('DATABASE') not in app.config:
raise ImproperlyConfiguredError("You should provide a database name "
"(the %s setting)." % key('DATABASE'))
uri = _get_mongo_uri(app, key)
|
python
|
{
"resource": ""
}
|
q2251
|
BaseQuery.paginate
|
train
|
def paginate(self, page, per_page=20, error_out=True):
"""Returns ``per_page`` items from page ``page`` By default, it will
abort with 404 if no items were found and the page was larger than 1.
This behaviour can be disabled by setting ``error_out`` to ``False``.
Returns a :class:`Pagination` object."""
if page < 1 and error_out:
|
python
|
{
"resource": ""
}
|
q2252
|
Document.save
|
train
|
def save(self, safe=None):
"""Saves the document itself in the database.
The optional ``safe`` argument is a boolean that specifies if the
remove method should wait
|
python
|
{
"resource": ""
}
|
q2253
|
Document.remove
|
train
|
def remove(self, safe=None):
"""Removes the document itself from database.
The optional ``safe`` argument is a boolean that specifies if the
remove method should wait
|
python
|
{
"resource": ""
}
|
q2254
|
list_authors
|
train
|
def list_authors():
"""List all authors.
e.g.: GET /authors"""
authors = Author.query.all()
content = '<p>Authors:</p>'
|
python
|
{
"resource": ""
}
|
q2255
|
BaseEnumeration.name
|
train
|
def name(self):
"""Get the enumeration name of this cursor kind."""
if self._name_map is None:
self._name_map = {}
for key, value in self.__class__.__dict__.items():
if
|
python
|
{
"resource": ""
}
|
q2256
|
Cursor.spelling
|
train
|
def spelling(self):
"""Return the spelling of the entity pointed at by the cursor."""
if not hasattr(self, '_spelling'):
|
python
|
{
"resource": ""
}
|
q2257
|
Cursor.displayname
|
train
|
def displayname(self):
"""
Return the display name for the entity referenced by this cursor.
The display name contains extra information that helps identify the
cursor, such as the parameters of a function or template or the
arguments of a class template specialization.
|
python
|
{
"resource": ""
}
|
q2258
|
Cursor.mangled_name
|
train
|
def mangled_name(self):
"""Return the mangled name for the entity referenced by this cursor."""
if not hasattr(self, '_mangled_name'):
|
python
|
{
"resource": ""
}
|
q2259
|
Cursor.linkage
|
train
|
def linkage(self):
"""Return the linkage of this cursor."""
if not hasattr(self, '_linkage'):
|
python
|
{
"resource": ""
}
|
q2260
|
Cursor.availability
|
train
|
def availability(self):
"""
Retrieves the availability of the entity pointed at by the cursor.
"""
if not hasattr(self, '_availability'):
|
python
|
{
"resource": ""
}
|
q2261
|
Cursor.objc_type_encoding
|
train
|
def objc_type_encoding(self):
"""Return the Objective-C type encoding as a str."""
if not hasattr(self, '_objc_type_encoding'):
self._objc_type_encoding = \
|
python
|
{
"resource": ""
}
|
q2262
|
TranslationUnit.from_source
|
train
|
def from_source(cls, filename, args=None, unsaved_files=None, options=0,
index=None):
"""Create a TranslationUnit by parsing source.
This is capable of processing source code both from files on the
filesystem as well as in-memory contents.
Command-line arguments that would be passed to clang are specified as
a list via args. These can be used to specify include paths, warnings,
etc. e.g. ["-Wall", "-I/path/to/include"].
In-memory file content can be provided via unsaved_files. This is an
iterable of 2-tuples. The first element is the str filename. The
second element defines the content. Content can be provided as str
source code or as file objects (anything with a read() method). If
a file object is being used, content will be read until EOF and the
read cursor will not be reset to its original position.
options is a bitwise or of TranslationUnit.PARSE_XXX flags which will
control parsing behavior.
index is an Index instance to utilize. If not provided, a new Index
will be created for this TranslationUnit.
To parse source from the filesystem, the filename of the file to parse
is specified by the filename argument. Or, filename could be None and
|
python
|
{
"resource": ""
}
|
q2263
|
Token.cursor
|
train
|
def cursor(self):
"""The Cursor this Token corresponds to."""
cursor = Cursor()
cursor._tu = self._tu
|
python
|
{
"resource": ""
}
|
q2264
|
Tree.process
|
train
|
def process(self):
"""
process processes all the files with clang and extracts all relevant
nodes from the generated AST
"""
self.index = cindex.Index.create()
self.headers = {}
for f in self.files:
if f in self.processed:
continue
print('Processing {0}'.format(os.path.basename(f)))
tu = self.index.parse(f, self.flags)
if len(tu.diagnostics) != 0:
fatal = False
for d in tu.diagnostics:
sys.stderr.write(d.format())
sys.stderr.write("\n")
if d.severity == cindex.Diagnostic.Fatal or \
d.severity == cindex.Diagnostic.Error:
fatal = True
if fatal:
sys.stderr.write("\nCould not generate documentation due to parser errors\n")
sys.exit(1)
if not tu:
sys.stderr.write("Could not parse file %s...\n" % (f,))
sys.exit(1)
# Extract comments from files and included files that we are
# supposed to inspect
extractfiles = [f]
for inc in tu.get_includes():
filename = str(inc.include)
self.headers[filename] = True
if filename in self.processed or (not filename in self.files) or filename in extractfiles:
continue
extractfiles.append(filename)
for e in extractfiles:
db = comment.CommentsDatabase(e, tu)
self.add_categories(db.category_names)
self.commentsdbs[e] = db
self.visit(tu.cursor.get_children())
for f in self.processing:
self.processed[f] = True
self.processing = {}
# Construct hierarchy of nodes.
for node in self.all_nodes:
q = node.qid
|
python
|
{
"resource": ""
}
|
q2265
|
Tree.visit
|
train
|
def visit(self, citer, parent=None):
"""
visit iterates over the provided cursor iterator and creates nodes
from the AST cursors.
"""
if not citer:
return
while True:
try:
item = next(citer)
except StopIteration:
return
# Check the source of item
if not item.location.file:
self.visit(item.get_children())
continue
# Ignore files we already processed
if str(item.location.file) in self.processed:
continue
# Ignore files other than the ones we are scanning for
if not str(item.location.file) in self.files:
continue
# Ignore unexposed things
if item.kind == cindex.CursorKind.UNEXPOSED_DECL:
self.visit(item.get_children(), parent)
continue
self.processing[str(item.location.file)] = True
if item.kind in self.kindmap:
cls = self.kindmap[item.kind]
if not cls:
# Skip
continue
# see if we already have a node for this thing
node = self.usr_to_node[item.get_usr()]
if not node or self.is_unique_anon_struct(node, parent):
# Only register new nodes if they are exposed.
if self.cursor_is_exposed(item):
node = cls(item, None)
self.register_node(node, parent)
elif isinstance(parent, nodes.Typedef) and isinstance(node, nodes.Struct):
# Typedefs are handled a bit specially because what happens
# is that clang first exposes an unnamed struct/enum, and
# then exposes the typedef, with as a child again the
|
python
|
{
"resource": ""
}
|
q2266
|
CommentsDatabase.extract
|
train
|
def extract(self, filename, tu):
"""
extract extracts comments from a translation unit for a given file by
iterating over all the tokens in the TU, locating the COMMENT tokens and
finding out to which cursors the comments semantically belong.
"""
it = tu.get_tokens(extent=tu.get_extent(filename, (0,
|
python
|
{
"resource": ""
}
|
q2267
|
defaultsnamedtuple
|
train
|
def defaultsnamedtuple(name, fields, defaults=None):
'''
Generate namedtuple with default values.
:param name: name
:param fields: iterable with field names
:param defaults: iterable or mapping with field defaults
:returns: defaultdict with given fields and given defaults
:rtype: collections.defaultdict
'''
nt = collections.namedtuple(name, fields)
nt.__new__.__defaults__ = (None,) * len(nt._fields)
|
python
|
{
"resource": ""
}
|
q2268
|
PluginManagerBase.init_app
|
train
|
def init_app(self, app):
'''
Initialize this Flask extension for given app.
'''
self.app = app
if not hasattr(app, 'extensions'):
|
python
|
{
"resource": ""
}
|
q2269
|
PluginManagerBase.reload
|
train
|
def reload(self):
'''
Clear plugin manager state and reload plugins.
This method will make use of :meth:`clear` and :meth:`load_plugin`,
so all internal state will be cleared, and all plugins defined in
|
python
|
{
"resource": ""
}
|
q2270
|
BlueprintPluginManager.register_blueprint
|
train
|
def register_blueprint(self, blueprint):
'''
Register given blueprint on curren app.
This method is provided for using inside plugin's module-level
:func:`register_plugin` functions.
:param blueprint: blueprint object with plugin endpoints
:type blueprint: flask.Blueprint
|
python
|
{
"resource": ""
}
|
q2271
|
WidgetPluginManager._resolve_widget
|
train
|
def _resolve_widget(cls, file, widget):
'''
Resolve widget callable properties into static ones.
:param file: file will be used to resolve callable properties.
:type file: browsepy.file.Node
:param widget: widget instance optionally with callable properties
:type widget: object
:returns: a new widget instance of the same
|
python
|
{
"resource": ""
}
|
q2272
|
WidgetPluginManager.iter_widgets
|
train
|
def iter_widgets(self, file=None, place=None):
'''
Iterate registered widgets, optionally matching given criteria.
:param file: optional file object will be passed to widgets' filter
functions.
:type file: browsepy.file.Node or None
:param place: optional template place hint.
:type place: str
:yields: widget instances
:ytype: object
'''
for filter, dynamic, cwidget in self._widgets:
try:
if file and filter and not filter(file):
continue
except BaseException as e:
# Exception is handled as this method execution is deffered,
# making hard to debug for plugin developers.
warnings.warn(
|
python
|
{
"resource": ""
}
|
q2273
|
WidgetPluginManager.create_widget
|
train
|
def create_widget(self, place, type, file=None, **kwargs):
'''
Create a widget object based on given arguments.
If file object is provided, callable arguments will be resolved:
its return value will be used after calling them with file as first
parameter.
All extra `kwargs` parameters will be passed to widget constructor.
:param place: place hint where widget should be shown.
:type place: str
:param type: widget type name as taken from :attr:`widget_types` dict
keys.
:type type: str
:param file: optional file object for widget attribute resolving
|
python
|
{
"resource": ""
}
|
q2274
|
MimetypePluginManager.clear
|
train
|
def clear(self):
'''
Clear plugin manager state.
Registered mimetype functions will be disposed after calling
|
python
|
{
"resource": ""
}
|
q2275
|
iter_cookie_browse_sorting
|
train
|
def iter_cookie_browse_sorting(cookies):
'''
Get sorting-cookie from cookies dictionary.
:yields: tuple of path and sorting property
:ytype: 2-tuple of strings
'''
|
python
|
{
"resource": ""
}
|
q2276
|
get_cookie_browse_sorting
|
train
|
def get_cookie_browse_sorting(path, default):
'''
Get sorting-cookie data for path of current request.
:returns: sorting property
:rtype: string
'''
if request:
|
python
|
{
"resource": ""
}
|
q2277
|
stream_template
|
train
|
def stream_template(template_name, **context):
'''
Some templates can be huge, this function returns an streaming response,
sending the content in chunks and preventing from timeout.
:param template_name: template
:param **context: parameters for templates.
:yields: HTML
|
python
|
{
"resource": ""
}
|
q2278
|
Config.gendict
|
train
|
def gendict(cls, *args, **kwargs):
'''
Pre-translated key dictionary constructor.
See :type:`dict` for more info.
:returns: dictionary with uppercase keys
:rtype: dict
'''
|
python
|
{
"resource": ""
}
|
q2279
|
StateMachine.nearest
|
train
|
def nearest(self):
'''
Get the next state jump.
The next jump is calculated looking at :attr:`current` state
and its possible :attr:`jumps` to find the nearest and bigger
option in :attr:`pending` data.
If none is found, the returned next state label will be None.
:returns: tuple with index, substring and next state label
:rtype: tuple
'''
try:
options = self.jumps[self.current]
except KeyError:
raise KeyError(
'Current state %r not defined in %s.jumps.'
% (self.current, self.__class__)
)
offset = len(self.start)
index = len(self.pending)
if self.streaming:
index -= max(map(len, options))
key = (index, 1)
result = (index, '', None)
|
python
|
{
"resource": ""
}
|
q2280
|
StateMachine.transform
|
train
|
def transform(self, data, mark, next):
'''
Apply the appropriate transformation function on current state data,
which is supposed to end at this point.
It is expected transformation logic makes use of :attr:`start`,
:attr:`current` and :attr:`streaming` instance attributes to
bettee know the state is being left.
:param data: string to transform (includes start)
:type data: str
:param mark: string producing the new state jump
:type mark: str
:param next: state is
|
python
|
{
"resource": ""
}
|
q2281
|
StateMachine.feed
|
train
|
def feed(self, data=''):
'''
Optionally add pending data, switch into streaming mode, and yield
result chunks.
:yields: result chunks
:ytype: str
'''
|
python
|
{
"resource": ""
}
|
q2282
|
StateMachine.finish
|
train
|
def finish(self, data=''):
'''
Optionally add pending data, turn off streaming mode, and yield
result chunks, which implies all pending data will be consumed.
:yields: result chunks
:ytype: str
|
python
|
{
"resource": ""
}
|
q2283
|
TarFileStream.write
|
train
|
def write(self, data):
'''
Write method used by internal tarfile instance to output data.
This method blocks tarfile execution once internal buffer is full.
As this method is blocking, it is used inside the same thread of
|
python
|
{
"resource": ""
}
|
q2284
|
isexec
|
train
|
def isexec(path):
'''
Check if given path points to an executable file.
:param path: file path
:type path: str
:return: True if executable, False otherwise
|
python
|
{
"resource": ""
}
|
q2285
|
fsdecode
|
train
|
def fsdecode(path, os_name=os.name, fs_encoding=FS_ENCODING, errors=None):
'''
Decode given path.
:param path: path will be decoded if using bytes
:type path: bytes or str
:param os_name: operative system name, defaults to os.name
:type os_name: str
:param fs_encoding: current filesystem encoding, defaults to autodetected
:type fs_encoding: str
:return: decoded path
:rtype: str
|
python
|
{
"resource": ""
}
|
q2286
|
fsencode
|
train
|
def fsencode(path, os_name=os.name, fs_encoding=FS_ENCODING, errors=None):
'''
Encode given path.
:param path: path will be encoded if not using bytes
:type path: bytes or str
:param os_name: operative system name, defaults to os.name
:type os_name: str
:param fs_encoding: current filesystem encoding, defaults to autodetected
:type fs_encoding: str
:return: encoded path
:rtype: bytes
|
python
|
{
"resource": ""
}
|
q2287
|
getcwd
|
train
|
def getcwd(fs_encoding=FS_ENCODING, cwd_fnc=os.getcwd):
'''
Get current work directory's absolute path.
Like os.getcwd but garanteed to return an unicode-str object.
:param fs_encoding: filesystem encoding,
|
python
|
{
"resource": ""
}
|
q2288
|
getdebug
|
train
|
def getdebug(environ=os.environ, true_values=TRUE_VALUES):
'''
Get if app is expected to be ran in debug mode looking at environment
variables.
:param environ: environment dict-like object
:type environ: collections.abc.Mapping
:returns: True if
|
python
|
{
"resource": ""
}
|
q2289
|
deprecated
|
train
|
def deprecated(func_or_text, environ=os.environ):
'''
Decorator used to mark functions as deprecated. It will result in a
warning being emmitted hen the function is called.
Usage:
>>> @deprecated
... def fnc():
... pass
Usage (custom message):
>>> @deprecated('This is deprecated')
... def fnc():
... pass
:param func_or_text: message or callable to decorate
:type func_or_text: callable
:param environ: optional environment mapping
:type environ: collections.abc.Mapping
:returns: nested decorator or new decorated function (depending on params)
:rtype: callable
'''
def inner(func):
message = (
'Deprecated function {}.'.format(func.__name__)
if callable(func_or_text) else
|
python
|
{
"resource": ""
}
|
q2290
|
pathsplit
|
train
|
def pathsplit(value, sep=os.pathsep):
'''
Get enviroment PATH elements as list.
This function only cares about spliting across OSes.
:param value: path string, as given by os.environ['PATH']
:type value: str
:param sep: PATH separator, defaults to os.pathsep
:type sep: str
:yields: every path
|
python
|
{
"resource": ""
}
|
q2291
|
pathparse
|
train
|
def pathparse(value, sep=os.pathsep, os_sep=os.sep):
'''
Get enviroment PATH directories as list.
This function cares about spliting, escapes and normalization of paths
across OSes.
:param value: path string, as given by os.environ['PATH']
:type value: str
:param sep: PATH separator, defaults to os.pathsep
:type sep: str
:param os_sep: OS filesystem path separator, defaults to os.sep
:type os_sep: str
:yields: every path
:ytype: str
'''
escapes = []
normpath = ntpath.normpath if os_sep == '\\' else posixpath.normpath
if '\\' not in (os_sep, sep):
escapes.extend((
('\\\\', '<ESCAPE-ESCAPE>', '\\'),
('\\"', '<ESCAPE-DQUOTE>',
|
python
|
{
"resource": ""
}
|
q2292
|
pathconf
|
train
|
def pathconf(path,
os_name=os.name,
isdir_fnc=os.path.isdir,
pathconf_fnc=getattr(os, 'pathconf', None),
pathconf_names=getattr(os, 'pathconf_names', ())):
'''
Get all pathconf variables for given path.
:param path: absolute fs path
:type path: str
:returns: dictionary containing pathconf keys and their values (both str)
:rtype: dict
'''
if pathconf_fnc and pathconf_names:
|
python
|
{
"resource": ""
}
|
q2293
|
which
|
train
|
def which(name,
env_path=ENV_PATH,
env_path_ext=ENV_PATHEXT,
is_executable_fnc=isexec,
path_join_fnc=os.path.join,
os_name=os.name):
'''
Get command absolute path.
:param name: name of executable command
:type name: str
:param env_path: OS environment executable paths, defaults to autodetected
:type env_path: list of str
:param is_executable_fnc: callable will be used to detect if path is
executable, defaults to `isexec`
:type is_executable_fnc: Callable
:param path_join_fnc: callable will be used to join path components
:type path_join_fnc: Callable
|
python
|
{
"resource": ""
}
|
q2294
|
re_escape
|
train
|
def re_escape(pattern, chars=frozenset("()[]{}?*+|^$\\.-#")):
'''
Escape all special regex characters in pattern.
Logic taken from regex module.
:param pattern: regex pattern to escape
:type patterm: str
:returns: escaped pattern
:rtype: str
'''
escape = '\\{}'.format
|
python
|
{
"resource": ""
}
|
q2295
|
register_plugin
|
train
|
def register_plugin(manager):
'''
Register blueprints and actions using given plugin manager.
:param manager: plugin manager
:type manager: browsepy.manager.PluginManager
'''
manager.register_blueprint(player)
manager.register_mimetype_function(detect_playable_mimetype)
# add style tag
manager.register_widget(
place='styles',
type='stylesheet',
endpoint='player.static',
filename='css/browse.css'
)
# register link actions
manager.register_widget(
place='entry-link',
type='link',
endpoint='player.audio',
filter=PlayableFile.detect
)
manager.register_widget(
place='entry-link',
icon='playlist',
type='link',
endpoint='player.playlist',
filter=PlayListFile.detect
)
# register action buttons
manager.register_widget(
place='entry-actions',
css='play',
type='button',
endpoint='player.audio',
filter=PlayableFile.detect
)
manager.register_widget(
place='entry-actions',
|
python
|
{
"resource": ""
}
|
q2296
|
fmt_size
|
train
|
def fmt_size(size, binary=True):
'''
Get size and unit.
:param size: size in bytes
:type size: int
:param binary: whether use binary or standard units, defaults to True
:type binary: bool
:return: size and unit
:rtype: tuple of int and unit as str
'''
if binary:
fmt_sizes = binary_units
|
python
|
{
"resource": ""
}
|
q2297
|
relativize_path
|
train
|
def relativize_path(path, base, os_sep=os.sep):
'''
Make absolute path relative to an absolute base.
:param path: absolute path
:type path: str
:param base: absolute base path
:type base: str
:param os_sep: path component separator, defaults to current OS separator
:type os_sep: str
:return: relative path
:rtype: str or unicode
:raises OutsideDirectoryBase: if path is not
|
python
|
{
"resource": ""
}
|
q2298
|
abspath_to_urlpath
|
train
|
def abspath_to_urlpath(path, base, os_sep=os.sep):
'''
Make filesystem absolute path uri relative using given absolute base path.
:param path: absolute path
:param base: absolute base path
|
python
|
{
"resource": ""
}
|
q2299
|
urlpath_to_abspath
|
train
|
def urlpath_to_abspath(path, base, os_sep=os.sep):
'''
Make uri relative path fs absolute using a given absolute base path.
:param path: relative path
:param base: absolute base path
:param os_sep: path component separator, defaults to current OS separator
:return: absolute path
:rtype: str or unicode
:raises OutsideDirectoryBase: if resulting path is not below base
'''
prefix = base if
|
python
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.