repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
pygobject/pgi
pgi/overrides/Gtk.py
TextBuffer.set_text
def set_text(self, text, length=-1): """set_text(text, length=-1) {{ all }} """ Gtk.TextBuffer.set_text(self, text, length)
python
def set_text(self, text, length=-1): """set_text(text, length=-1) {{ all }} """ Gtk.TextBuffer.set_text(self, text, length)
[ "def", "set_text", "(", "self", ",", "text", ",", "length", "=", "-", "1", ")", ":", "Gtk", ".", "TextBuffer", ".", "set_text", "(", "self", ",", "text", ",", "length", ")" ]
set_text(text, length=-1) {{ all }}
[ "set_text", "(", "text", "length", "=", "-", "1", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L906-L912
pygobject/pgi
pgi/overrides/Gtk.py
TextBuffer.insert
def insert(self, iter, text, length=-1): """insert(iter, text, length=-1) {{ all }} """ Gtk.TextBuffer.insert(self, iter, text, length)
python
def insert(self, iter, text, length=-1): """insert(iter, text, length=-1) {{ all }} """ Gtk.TextBuffer.insert(self, iter, text, length)
[ "def", "insert", "(", "self", ",", "iter", ",", "text", ",", "length", "=", "-", "1", ")", ":", "Gtk", ".", "TextBuffer", ".", "insert", "(", "self", ",", "iter", ",", "text", ",", "length", ")" ]
insert(iter, text, length=-1) {{ all }}
[ "insert", "(", "iter", "text", "length", "=", "-", "1", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L914-L920
pygobject/pgi
pgi/overrides/Gtk.py
TreeModel.get_iter
def get_iter(self, path): """ :param path: the :obj:`Gtk.TreePath`-struct :type path: :obj:`Gtk.TreePath` :raises: :class:`ValueError` if `path` doesn't exist :returns: a :obj:`Gtk.TreeIter` :rtype: :obj:`Gtk.TreeIter` Returns an iterator pointing to `path`. If ...
python
def get_iter(self, path): """ :param path: the :obj:`Gtk.TreePath`-struct :type path: :obj:`Gtk.TreePath` :raises: :class:`ValueError` if `path` doesn't exist :returns: a :obj:`Gtk.TreeIter` :rtype: :obj:`Gtk.TreeIter` Returns an iterator pointing to `path`. If ...
[ "def", "get_iter", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_coerce_path", "(", "path", ")", "success", ",", "aiter", "=", "super", "(", "TreeModel", ",", "self", ")", ".", "get_iter", "(", "path", ")", "if", "not", "success", ...
:param path: the :obj:`Gtk.TreePath`-struct :type path: :obj:`Gtk.TreePath` :raises: :class:`ValueError` if `path` doesn't exist :returns: a :obj:`Gtk.TreeIter` :rtype: :obj:`Gtk.TreeIter` Returns an iterator pointing to `path`. If `path` does not exist :class:`ValueErr...
[ ":", "param", "path", ":", "the", ":", "obj", ":", "Gtk", ".", "TreePath", "-", "struct", ":", "type", "path", ":", ":", "obj", ":", "Gtk", ".", "TreePath" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1155-L1172
pygobject/pgi
pgi/overrides/Gtk.py
TreeModel.iter_next
def iter_next(self, iter): """ :param iter: the :obj:`Gtk.TreeIter`-struct :type iter: :obj:`Gtk.TreeIter` :returns: a :obj:`Gtk.TreeIter` or :obj:`None` :rtype: :obj:`Gtk.TreeIter` or :obj:`None` Returns an iterator pointing to the node following `iter` at the ...
python
def iter_next(self, iter): """ :param iter: the :obj:`Gtk.TreeIter`-struct :type iter: :obj:`Gtk.TreeIter` :returns: a :obj:`Gtk.TreeIter` or :obj:`None` :rtype: :obj:`Gtk.TreeIter` or :obj:`None` Returns an iterator pointing to the node following `iter` at the ...
[ "def", "iter_next", "(", "self", ",", "iter", ")", ":", "next_iter", "=", "iter", ".", "copy", "(", ")", "success", "=", "super", "(", "TreeModel", ",", "self", ")", ".", "iter_next", "(", "next_iter", ")", "if", "success", ":", "return", "next_iter" ]
:param iter: the :obj:`Gtk.TreeIter`-struct :type iter: :obj:`Gtk.TreeIter` :returns: a :obj:`Gtk.TreeIter` or :obj:`None` :rtype: :obj:`Gtk.TreeIter` or :obj:`None` Returns an iterator pointing to the node following `iter` at the current level. If there is no next `it...
[ ":", "param", "iter", ":", "the", ":", "obj", ":", "Gtk", ".", "TreeIter", "-", "struct", ":", "type", "iter", ":", ":", "obj", ":", "Gtk", ".", "TreeIter" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1174-L1191
pygobject/pgi
pgi/overrides/Gtk.py
TreeModel.iter_previous
def iter_previous(self, iter): """ :param iter: the :obj:`Gtk.TreeIter`-struct :type iter: :obj:`Gtk.TreeIter` :returns: a :obj:`Gtk.TreeIter` or :obj:`None` :rtype: :obj:`Gtk.TreeIter` or :obj:`None` Returns an iterator pointing to the previous node at the current leve...
python
def iter_previous(self, iter): """ :param iter: the :obj:`Gtk.TreeIter`-struct :type iter: :obj:`Gtk.TreeIter` :returns: a :obj:`Gtk.TreeIter` or :obj:`None` :rtype: :obj:`Gtk.TreeIter` or :obj:`None` Returns an iterator pointing to the previous node at the current leve...
[ "def", "iter_previous", "(", "self", ",", "iter", ")", ":", "prev_iter", "=", "iter", ".", "copy", "(", ")", "success", "=", "super", "(", "TreeModel", ",", "self", ")", ".", "iter_previous", "(", "prev_iter", ")", "if", "success", ":", "return", "prev...
:param iter: the :obj:`Gtk.TreeIter`-struct :type iter: :obj:`Gtk.TreeIter` :returns: a :obj:`Gtk.TreeIter` or :obj:`None` :rtype: :obj:`Gtk.TreeIter` or :obj:`None` Returns an iterator pointing to the previous node at the current level. If there is no previous `iter`, :obj:`N...
[ ":", "param", "iter", ":", "the", ":", "obj", ":", "Gtk", ".", "TreeIter", "-", "struct", ":", "type", "iter", ":", ":", "obj", ":", "Gtk", ".", "TreeIter" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1193-L1209
pygobject/pgi
pgi/overrides/Gtk.py
TreeModel.set_row
def set_row(self, treeiter, row): """ :param treeiter: the :obj:`Gtk.TreeIter` :type treeiter: :obj:`Gtk.TreeIter` :param row: a list of values for each column :type row: [:obj:`object`] Sets all values of a row pointed to by `treeiter` from a list of values pas...
python
def set_row(self, treeiter, row): """ :param treeiter: the :obj:`Gtk.TreeIter` :type treeiter: :obj:`Gtk.TreeIter` :param row: a list of values for each column :type row: [:obj:`object`] Sets all values of a row pointed to by `treeiter` from a list of values pas...
[ "def", "set_row", "(", "self", ",", "treeiter", ",", "row", ")", ":", "converted_row", ",", "columns", "=", "self", ".", "_convert_row", "(", "row", ")", "for", "column", "in", "columns", ":", "value", "=", "row", "[", "column", "]", "if", "value", "...
:param treeiter: the :obj:`Gtk.TreeIter` :type treeiter: :obj:`Gtk.TreeIter` :param row: a list of values for each column :type row: [:obj:`object`] Sets all values of a row pointed to by `treeiter` from a list of values passes as `row`. The length of the row has to match the n...
[ ":", "param", "treeiter", ":", "the", ":", "obj", ":", "Gtk", ".", "TreeIter", ":", "type", "treeiter", ":", ":", "obj", ":", "Gtk", ".", "TreeIter" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1231-L1254
pygobject/pgi
pgi/overrides/Gtk.py
TreeModel._convert_value
def _convert_value(self, column, value): '''Convert value to a GObject.Value of the expected type''' if isinstance(value, GObject.Value): return value return GObject.Value(self.get_column_type(column), value)
python
def _convert_value(self, column, value): '''Convert value to a GObject.Value of the expected type''' if isinstance(value, GObject.Value): return value return GObject.Value(self.get_column_type(column), value)
[ "def", "_convert_value", "(", "self", ",", "column", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "GObject", ".", "Value", ")", ":", "return", "value", "return", "GObject", ".", "Value", "(", "self", ".", "get_column_type", "(", "column...
Convert value to a GObject.Value of the expected type
[ "Convert", "value", "to", "a", "GObject", ".", "Value", "of", "the", "expected", "type" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1256-L1261
pygobject/pgi
pgi/overrides/Gtk.py
TreeModel.get
def get(self, treeiter, *columns): """ :param treeiter: the :obj:`Gtk.TreeIter` :type treeiter: :obj:`Gtk.TreeIter` :param \\*columns: a list of column indices to fetch :type columns: (:obj:`int`) Returns a tuple of all values specified by their indices in `columns` ...
python
def get(self, treeiter, *columns): """ :param treeiter: the :obj:`Gtk.TreeIter` :type treeiter: :obj:`Gtk.TreeIter` :param \\*columns: a list of column indices to fetch :type columns: (:obj:`int`) Returns a tuple of all values specified by their indices in `columns` ...
[ "def", "get", "(", "self", ",", "treeiter", ",", "*", "columns", ")", ":", "n_columns", "=", "self", ".", "get_n_columns", "(", ")", "values", "=", "[", "]", "for", "col", "in", "columns", ":", "if", "not", "isinstance", "(", "col", ",", "int", ")"...
:param treeiter: the :obj:`Gtk.TreeIter` :type treeiter: :obj:`Gtk.TreeIter` :param \\*columns: a list of column indices to fetch :type columns: (:obj:`int`) Returns a tuple of all values specified by their indices in `columns` in the order the indices are contained in `columns...
[ ":", "param", "treeiter", ":", "the", ":", "obj", ":", "Gtk", ".", "TreeIter", ":", "type", "treeiter", ":", ":", "obj", ":", "Gtk", ".", "TreeIter" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1263-L1289
pygobject/pgi
pgi/overrides/Gtk.py
ListStore.append
def append(self, row=None): """append(row=None) :param row: a list of values to apply to the newly append row or :obj:`None` :type row: [:obj:`object`] or :obj:`None` :returns: :obj:`Gtk.TreeIter` of the appended row :rtype: :obj:`Gtk.TreeIter` If `row` is :obj:`None` ...
python
def append(self, row=None): """append(row=None) :param row: a list of values to apply to the newly append row or :obj:`None` :type row: [:obj:`object`] or :obj:`None` :returns: :obj:`Gtk.TreeIter` of the appended row :rtype: :obj:`Gtk.TreeIter` If `row` is :obj:`None` ...
[ "def", "append", "(", "self", ",", "row", "=", "None", ")", ":", "if", "row", ":", "return", "self", ".", "_do_insert", "(", "-", "1", ",", "row", ")", "# gtk_list_store_insert() does not know about the \"position == -1\"", "# case, so use append() here", "else", ...
append(row=None) :param row: a list of values to apply to the newly append row or :obj:`None` :type row: [:obj:`object`] or :obj:`None` :returns: :obj:`Gtk.TreeIter` of the appended row :rtype: :obj:`Gtk.TreeIter` If `row` is :obj:`None` the appended row will be empty and to f...
[ "append", "(", "row", "=", "None", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1368-L1390
pygobject/pgi
pgi/overrides/Gtk.py
ListStore.insert_before
def insert_before(self, sibling, row=None): """insert_before(sibling, row=None) :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list of values to apply to the newly inserted row or :obj:`None` :type row...
python
def insert_before(self, sibling, row=None): """insert_before(sibling, row=None) :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list of values to apply to the newly inserted row or :obj:`None` :type row...
[ "def", "insert_before", "(", "self", ",", "sibling", ",", "row", "=", "None", ")", ":", "treeiter", "=", "Gtk", ".", "ListStore", ".", "insert_before", "(", "self", ",", "sibling", ")", "if", "row", "is", "not", "None", ":", "self", ".", "set_row", "...
insert_before(sibling, row=None) :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list of values to apply to the newly inserted row or :obj:`None` :type row: [:obj:`object`] or :obj:`None` :returns: :ob...
[ "insert_before", "(", "sibling", "row", "=", "None", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1439-L1467
pygobject/pgi
pgi/overrides/Gtk.py
ListStore.insert_after
def insert_after(self, sibling, row=None): """insert_after(sibling, row=None) :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list of values to apply to the newly inserted row or :obj:`None` :type row: ...
python
def insert_after(self, sibling, row=None): """insert_after(sibling, row=None) :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list of values to apply to the newly inserted row or :obj:`None` :type row: ...
[ "def", "insert_after", "(", "self", ",", "sibling", ",", "row", "=", "None", ")", ":", "treeiter", "=", "Gtk", ".", "ListStore", ".", "insert_after", "(", "self", ",", "sibling", ")", "if", "row", "is", "not", "None", ":", "self", ".", "set_row", "("...
insert_after(sibling, row=None) :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list of values to apply to the newly inserted row or :obj:`None` :type row: [:obj:`object`] or :obj:`None` :returns: :obj...
[ "insert_after", "(", "sibling", "row", "=", "None", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1472-L1500
pygobject/pgi
pgi/overrides/Gtk.py
ListStore.set_value
def set_value(self, treeiter, column, value): """ {{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()). """ value = self._convert_value(co...
python
def set_value(self, treeiter, column, value): """ {{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()). """ value = self._convert_value(co...
[ "def", "set_value", "(", "self", ",", "treeiter", ",", "column", ",", "value", ")", ":", "value", "=", "self", ".", "_convert_value", "(", "column", ",", "value", ")", "Gtk", ".", "ListStore", ".", "set_value", "(", "self", ",", "treeiter", ",", "colum...
{{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()).
[ "{{", "all", "}}" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1502-L1512
pygobject/pgi
pgi/overrides/Gtk.py
TreeModelRow.get_next
def get_next(self): """Returns the next :obj:`Gtk.TreeModelRow` or None""" next_iter = self.model.iter_next(self.iter) if next_iter: return TreeModelRow(self.model, next_iter)
python
def get_next(self): """Returns the next :obj:`Gtk.TreeModelRow` or None""" next_iter = self.model.iter_next(self.iter) if next_iter: return TreeModelRow(self.model, next_iter)
[ "def", "get_next", "(", "self", ")", ":", "next_iter", "=", "self", ".", "model", ".", "iter_next", "(", "self", ".", "iter", ")", "if", "next_iter", ":", "return", "TreeModelRow", "(", "self", ".", "model", ",", "next_iter", ")" ]
Returns the next :obj:`Gtk.TreeModelRow` or None
[ "Returns", "the", "next", ":", "obj", ":", "Gtk", ".", "TreeModelRow", "or", "None" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1618-L1623
pygobject/pgi
pgi/overrides/Gtk.py
TreeModelRow.get_previous
def get_previous(self): """Returns the previous :obj:`Gtk.TreeModelRow` or None""" prev_iter = self.model.iter_previous(self.iter) if prev_iter: return TreeModelRow(self.model, prev_iter)
python
def get_previous(self): """Returns the previous :obj:`Gtk.TreeModelRow` or None""" prev_iter = self.model.iter_previous(self.iter) if prev_iter: return TreeModelRow(self.model, prev_iter)
[ "def", "get_previous", "(", "self", ")", ":", "prev_iter", "=", "self", ".", "model", ".", "iter_previous", "(", "self", ".", "iter", ")", "if", "prev_iter", ":", "return", "TreeModelRow", "(", "self", ".", "model", ",", "prev_iter", ")" ]
Returns the previous :obj:`Gtk.TreeModelRow` or None
[ "Returns", "the", "previous", ":", "obj", ":", "Gtk", ".", "TreeModelRow", "or", "None" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1625-L1630
pygobject/pgi
pgi/overrides/Gtk.py
TreeModelRow.get_parent
def get_parent(self): """Returns the parent :obj:`Gtk.TreeModelRow` or htis row or None""" parent_iter = self.model.iter_parent(self.iter) if parent_iter: return TreeModelRow(self.model, parent_iter)
python
def get_parent(self): """Returns the parent :obj:`Gtk.TreeModelRow` or htis row or None""" parent_iter = self.model.iter_parent(self.iter) if parent_iter: return TreeModelRow(self.model, parent_iter)
[ "def", "get_parent", "(", "self", ")", ":", "parent_iter", "=", "self", ".", "model", ".", "iter_parent", "(", "self", ".", "iter", ")", "if", "parent_iter", ":", "return", "TreeModelRow", "(", "self", ".", "model", ",", "parent_iter", ")" ]
Returns the parent :obj:`Gtk.TreeModelRow` or htis row or None
[ "Returns", "the", "parent", ":", "obj", ":", "Gtk", ".", "TreeModelRow", "or", "htis", "row", "or", "None" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1632-L1637
pygobject/pgi
pgi/overrides/Gtk.py
TreeModelRow.iterchildren
def iterchildren(self): """Returns a :obj:`Gtk.TreeModelRowIter` for the row's children""" child_iter = self.model.iter_children(self.iter) return TreeModelRowIter(self.model, child_iter)
python
def iterchildren(self): """Returns a :obj:`Gtk.TreeModelRowIter` for the row's children""" child_iter = self.model.iter_children(self.iter) return TreeModelRowIter(self.model, child_iter)
[ "def", "iterchildren", "(", "self", ")", ":", "child_iter", "=", "self", ".", "model", ".", "iter_children", "(", "self", ".", "iter", ")", "return", "TreeModelRowIter", "(", "self", ".", "model", ",", "child_iter", ")" ]
Returns a :obj:`Gtk.TreeModelRowIter` for the row's children
[ "Returns", "a", ":", "obj", ":", "Gtk", ".", "TreeModelRowIter", "for", "the", "row", "s", "children" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1681-L1685
pygobject/pgi
pgi/overrides/Gtk.py
TreeStore.insert
def insert(self, parent, position, row=None): """insert(parent, position, row=None) :param parent: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type parent: :obj:`Gtk.TreeIter` or :obj:`None` :param position: position to insert the new row, or -1 for last ...
python
def insert(self, parent, position, row=None): """insert(parent, position, row=None) :param parent: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type parent: :obj:`Gtk.TreeIter` or :obj:`None` :param position: position to insert the new row, or -1 for last ...
[ "def", "insert", "(", "self", ",", "parent", ",", "position", ",", "row", "=", "None", ")", ":", "return", "self", ".", "_do_insert", "(", "parent", ",", "position", ",", "row", ")" ]
insert(parent, position, row=None) :param parent: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type parent: :obj:`Gtk.TreeIter` or :obj:`None` :param position: position to insert the new row, or -1 for last :type position: :obj:`int` :param row: a list ...
[ "insert", "(", "parent", "position", "row", "=", "None", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1851-L1883
pygobject/pgi
pgi/overrides/Gtk.py
TreeStore.insert_before
def insert_before(self, parent, sibling, row=None): """insert_before(parent, sibling, row=None) :param parent: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type parent: :obj:`Gtk.TreeIter` or :obj:`None` :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling:...
python
def insert_before(self, parent, sibling, row=None): """insert_before(parent, sibling, row=None) :param parent: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type parent: :obj:`Gtk.TreeIter` or :obj:`None` :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling:...
[ "def", "insert_before", "(", "self", ",", "parent", ",", "sibling", ",", "row", "=", "None", ")", ":", "treeiter", "=", "Gtk", ".", "TreeStore", ".", "insert_before", "(", "self", ",", "parent", ",", "sibling", ")", "if", "row", "is", "not", "None", ...
insert_before(parent, sibling, row=None) :param parent: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type parent: :obj:`Gtk.TreeIter` or :obj:`None` :param sibling: A valid :obj:`Gtk.TreeIter`, or :obj:`None` :type sibling: :obj:`Gtk.TreeIter` or :obj:`None` :param row: a list...
[ "insert_before", "(", "parent", "sibling", "row", "=", "None", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1888-L1924
pygobject/pgi
pgi/overrides/Gtk.py
TreeStore.set_value
def set_value(self, treeiter, column, value): """ {{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()). """ value = self._convert_value(co...
python
def set_value(self, treeiter, column, value): """ {{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()). """ value = self._convert_value(co...
[ "def", "set_value", "(", "self", ",", "treeiter", ",", "column", ",", "value", ")", ":", "value", "=", "self", ".", "_convert_value", "(", "column", ",", "value", ")", "Gtk", ".", "TreeStore", ".", "set_value", "(", "self", ",", "treeiter", ",", "colum...
{{ all }} `value` can also be a Python value and will be converted to a :obj:`GObject.Value` using the corresponding column type (See :obj:`Gtk.ListStore.set_column_types`\\()).
[ "{{", "all", "}}" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L1966-L1976
pygobject/pgi
pgi/overrides/Gtk.py
TreeView.insert_column_with_attributes
def insert_column_with_attributes(self, position, title, cell, **kwargs): """ :param position: The position to insert the new column in :type position: :obj:`int` :param title: The title to set the header to :type title: :obj:`str` :param cell: The :obj:`Gtk.CellRendere...
python
def insert_column_with_attributes(self, position, title, cell, **kwargs): """ :param position: The position to insert the new column in :type position: :obj:`int` :param title: The title to set the header to :type title: :obj:`str` :param cell: The :obj:`Gtk.CellRendere...
[ "def", "insert_column_with_attributes", "(", "self", ",", "position", ",", "title", ",", "cell", ",", "*", "*", "kwargs", ")", ":", "column", "=", "TreeViewColumn", "(", ")", "column", ".", "set_title", "(", "title", ")", "column", ".", "pack_start", "(", ...
:param position: The position to insert the new column in :type position: :obj:`int` :param title: The title to set the header to :type title: :obj:`str` :param cell: The :obj:`Gtk.CellRenderer` :type cell: :obj:`Gtk.CellRenderer` {{ docs }}
[ ":", "param", "position", ":", "The", "position", "to", "insert", "the", "new", "column", "in", ":", "type", "position", ":", ":", "obj", ":", "int" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L2098-L2116
pygobject/pgi
pgi/overrides/Gtk.py
TreeViewColumn.set_attributes
def set_attributes(self, cell_renderer, **attributes): """ :param cell_renderer: the :obj:`Gtk.CellRenderer` we're setting the attributes of :type cell_renderer: :obj:`Gtk.CellRenderer` {{ docs }} """ Gtk.CellLayout.clear_attributes(self, cell_renderer) for (na...
python
def set_attributes(self, cell_renderer, **attributes): """ :param cell_renderer: the :obj:`Gtk.CellRenderer` we're setting the attributes of :type cell_renderer: :obj:`Gtk.CellRenderer` {{ docs }} """ Gtk.CellLayout.clear_attributes(self, cell_renderer) for (na...
[ "def", "set_attributes", "(", "self", ",", "cell_renderer", ",", "*", "*", "attributes", ")", ":", "Gtk", ".", "CellLayout", ".", "clear_attributes", "(", "self", ",", "cell_renderer", ")", "for", "(", "name", ",", "value", ")", "in", "attributes", ".", ...
:param cell_renderer: the :obj:`Gtk.CellRenderer` we're setting the attributes of :type cell_renderer: :obj:`Gtk.CellRenderer` {{ docs }}
[ ":", "param", "cell_renderer", ":", "the", ":", "obj", ":", "Gtk", ".", "CellRenderer", "we", "re", "setting", "the", "attributes", "of", ":", "type", "cell_renderer", ":", ":", "obj", ":", "Gtk", ".", "CellRenderer" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L2153-L2164
pygobject/pgi
pgi/overrides/Gtk.py
TreeSelection.get_selected
def get_selected(self): """ :returns: :model: the :obj:`Gtk.TreeModel` :iter: The :obj:`Gtk.TreeIter` or :obj:`None` :rtype: (**model**: :obj:`Gtk.TreeModel`, **iter**: :obj:`Gtk.TreeIter` or :obj:`None`) {{ docs }} """ success, model, aiter = s...
python
def get_selected(self): """ :returns: :model: the :obj:`Gtk.TreeModel` :iter: The :obj:`Gtk.TreeIter` or :obj:`None` :rtype: (**model**: :obj:`Gtk.TreeModel`, **iter**: :obj:`Gtk.TreeIter` or :obj:`None`) {{ docs }} """ success, model, aiter = s...
[ "def", "get_selected", "(", "self", ")", ":", "success", ",", "model", ",", "aiter", "=", "super", "(", "TreeSelection", ",", "self", ")", ".", "get_selected", "(", ")", "if", "success", ":", "return", "(", "model", ",", "aiter", ")", "else", ":", "r...
:returns: :model: the :obj:`Gtk.TreeModel` :iter: The :obj:`Gtk.TreeIter` or :obj:`None` :rtype: (**model**: :obj:`Gtk.TreeModel`, **iter**: :obj:`Gtk.TreeIter` or :obj:`None`) {{ docs }}
[ ":", "returns", ":", ":", "model", ":", "the", ":", "obj", ":", "Gtk", ".", "TreeModel", ":", "iter", ":", "The", ":", "obj", ":", "Gtk", ".", "TreeIter", "or", ":", "obj", ":", "None" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L2178-L2193
pygobject/pgi
pgi/overrides/Gtk.py
TreeSelection.get_selected_rows
def get_selected_rows(self): """ :returns: A list containing a :obj:`Gtk.TreePath` for each selected row and a :obj:`Gtk.TreeModel` or :obj:`None`. :rtype: (:obj:`Gtk.TreeModel`, [:obj:`Gtk.TreePath`]) {{ docs }} """ rows, model = super(TreeSele...
python
def get_selected_rows(self): """ :returns: A list containing a :obj:`Gtk.TreePath` for each selected row and a :obj:`Gtk.TreeModel` or :obj:`None`. :rtype: (:obj:`Gtk.TreeModel`, [:obj:`Gtk.TreePath`]) {{ docs }} """ rows, model = super(TreeSele...
[ "def", "get_selected_rows", "(", "self", ")", ":", "rows", ",", "model", "=", "super", "(", "TreeSelection", ",", "self", ")", ".", "get_selected_rows", "(", ")", "return", "(", "model", ",", "rows", ")" ]
:returns: A list containing a :obj:`Gtk.TreePath` for each selected row and a :obj:`Gtk.TreeModel` or :obj:`None`. :rtype: (:obj:`Gtk.TreeModel`, [:obj:`Gtk.TreePath`]) {{ docs }}
[ ":", "returns", ":", "A", "list", "containing", "a", ":", "obj", ":", "Gtk", ".", "TreePath", "for", "each", "selected", "row", "and", "a", ":", "obj", ":", "Gtk", ".", "TreeModel", "or", ":", "obj", ":", "None", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L2197-L2209
pygobject/pgi
pgi/overrides/Gtk.py
TreeModelFilter.set_value
def set_value(self, iter, column, value): """Set the value of the child model""" # Delegate to child model iter = self.convert_iter_to_child_iter(iter) self.get_model().set_value(iter, column, value)
python
def set_value(self, iter, column, value): """Set the value of the child model""" # Delegate to child model iter = self.convert_iter_to_child_iter(iter) self.get_model().set_value(iter, column, value)
[ "def", "set_value", "(", "self", ",", "iter", ",", "column", ",", "value", ")", ":", "# Delegate to child model", "iter", "=", "self", ".", "convert_iter_to_child_iter", "(", "iter", ")", "self", ".", "get_model", "(", ")", ".", "set_value", "(", "iter", "...
Set the value of the child model
[ "Set", "the", "value", "of", "the", "child", "model" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gtk.py#L2376-L2381
pygobject/pgi
pgi/foreign/__init__.py
get_foreign_module
def get_foreign_module(namespace): """Returns the module or raises ForeignError""" if namespace not in _MODULES: try: module = importlib.import_module("." + namespace, __package__) except ImportError: module = None _MODULES[namespace] = module module = _MODU...
python
def get_foreign_module(namespace): """Returns the module or raises ForeignError""" if namespace not in _MODULES: try: module = importlib.import_module("." + namespace, __package__) except ImportError: module = None _MODULES[namespace] = module module = _MODU...
[ "def", "get_foreign_module", "(", "namespace", ")", ":", "if", "namespace", "not", "in", "_MODULES", ":", "try", ":", "module", "=", "importlib", ".", "import_module", "(", "\".\"", "+", "namespace", ",", "__package__", ")", "except", "ImportError", ":", "mo...
Returns the module or raises ForeignError
[ "Returns", "the", "module", "or", "raises", "ForeignError" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/foreign/__init__.py#L21-L34
pygobject/pgi
pgi/foreign/__init__.py
get_foreign_struct
def get_foreign_struct(namespace, name): """Returns a ForeignStruct implementation or raises ForeignError""" get_foreign_module(namespace) try: return ForeignStruct.get(namespace, name) except KeyError: raise ForeignError("Foreign %s.%s not supported" % (namespace, name))
python
def get_foreign_struct(namespace, name): """Returns a ForeignStruct implementation or raises ForeignError""" get_foreign_module(namespace) try: return ForeignStruct.get(namespace, name) except KeyError: raise ForeignError("Foreign %s.%s not supported" % (namespace, name))
[ "def", "get_foreign_struct", "(", "namespace", ",", "name", ")", ":", "get_foreign_module", "(", "namespace", ")", "try", ":", "return", "ForeignStruct", ".", "get", "(", "namespace", ",", "name", ")", "except", "KeyError", ":", "raise", "ForeignError", "(", ...
Returns a ForeignStruct implementation or raises ForeignError
[ "Returns", "a", "ForeignStruct", "implementation", "or", "raises", "ForeignError" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/foreign/__init__.py#L37-L45
pygobject/pgi
pgi/foreign/__init__.py
require_foreign
def require_foreign(namespace, symbol=None): """Raises ImportError if the specified foreign module isn't supported or the needed dependencies aren't installed. e.g.: check_foreign('cairo', 'Context') """ try: if symbol is None: get_foreign_module(namespace) else: ...
python
def require_foreign(namespace, symbol=None): """Raises ImportError if the specified foreign module isn't supported or the needed dependencies aren't installed. e.g.: check_foreign('cairo', 'Context') """ try: if symbol is None: get_foreign_module(namespace) else: ...
[ "def", "require_foreign", "(", "namespace", ",", "symbol", "=", "None", ")", ":", "try", ":", "if", "symbol", "is", "None", ":", "get_foreign_module", "(", "namespace", ")", "else", ":", "get_foreign_struct", "(", "namespace", ",", "symbol", ")", "except", ...
Raises ImportError if the specified foreign module isn't supported or the needed dependencies aren't installed. e.g.: check_foreign('cairo', 'Context')
[ "Raises", "ImportError", "if", "the", "specified", "foreign", "module", "isn", "t", "supported", "or", "the", "needed", "dependencies", "aren", "t", "installed", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/foreign/__init__.py#L48-L62
pygobject/pgi
pgi/overrides/GLib.py
io_add_watch
def io_add_watch(*args, **kwargs): """io_add_watch(channel, priority, condition, func, *user_data) -> event_source_id""" channel, priority, condition, func, user_data = _io_add_watch_get_args(*args, **kwargs) return GLib.io_add_watch(channel, priority, condition, func, *user_data)
python
def io_add_watch(*args, **kwargs): """io_add_watch(channel, priority, condition, func, *user_data) -> event_source_id""" channel, priority, condition, func, user_data = _io_add_watch_get_args(*args, **kwargs) return GLib.io_add_watch(channel, priority, condition, func, *user_data)
[ "def", "io_add_watch", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "channel", ",", "priority", ",", "condition", ",", "func", ",", "user_data", "=", "_io_add_watch_get_args", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "GLib", "....
io_add_watch(channel, priority, condition, func, *user_data) -> event_source_id
[ "io_add_watch", "(", "channel", "priority", "condition", "func", "*", "user_data", ")", "-", ">", "event_source_id" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L813-L816
pygobject/pgi
pgi/overrides/GLib.py
child_watch_add
def child_watch_add(*args, **kwargs): """child_watch_add(priority, pid, function, *data)""" priority, pid, function, data = _child_watch_add_get_args(*args, **kwargs) return GLib.child_watch_add(priority, pid, function, *data)
python
def child_watch_add(*args, **kwargs): """child_watch_add(priority, pid, function, *data)""" priority, pid, function, data = _child_watch_add_get_args(*args, **kwargs) return GLib.child_watch_add(priority, pid, function, *data)
[ "def", "child_watch_add", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "priority", ",", "pid", ",", "function", ",", "data", "=", "_child_watch_add_get_args", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "GLib", ".", "child_watch_add...
child_watch_add(priority, pid, function, *data)
[ "child_watch_add", "(", "priority", "pid", "function", "*", "data", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L964-L967
pygobject/pgi
pgi/overrides/GLib.py
_VariantCreator._create
def _create(self, format, args): """Create a GVariant object from given format and argument list. This method recursively calls itself for complex structures (arrays, dictionaries, boxed). Return a tuple (variant, rest_format, rest_args) with the generated GVariant, the remaind...
python
def _create(self, format, args): """Create a GVariant object from given format and argument list. This method recursively calls itself for complex structures (arrays, dictionaries, boxed). Return a tuple (variant, rest_format, rest_args) with the generated GVariant, the remaind...
[ "def", "_create", "(", "self", ",", "format", ",", "args", ")", ":", "# leaves (simple types)", "constructor", "=", "self", ".", "_LEAF_CONSTRUCTORS", ".", "get", "(", "format", "[", "0", "]", ")", "if", "constructor", ":", "if", "args", "is", "not", "No...
Create a GVariant object from given format and argument list. This method recursively calls itself for complex structures (arrays, dictionaries, boxed). Return a tuple (variant, rest_format, rest_args) with the generated GVariant, the remainder of the format string, and the remainder o...
[ "Create", "a", "GVariant", "object", "from", "given", "format", "and", "argument", "list", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L153-L187
pygobject/pgi
pgi/overrides/GLib.py
_VariantCreator._create_tuple
def _create_tuple(self, format, args): """Handle the case where the outermost type of format is a tuple.""" format = format[1:] # eat the '(' if args is None: # empty value: we need to call _create() to parse the subtype rest_format = format while rest_forma...
python
def _create_tuple(self, format, args): """Handle the case where the outermost type of format is a tuple.""" format = format[1:] # eat the '(' if args is None: # empty value: we need to call _create() to parse the subtype rest_format = format while rest_forma...
[ "def", "_create_tuple", "(", "self", ",", "format", ",", "args", ")", ":", "format", "=", "format", "[", "1", ":", "]", "# eat the '('", "if", "args", "is", "None", ":", "# empty value: we need to call _create() to parse the subtype", "rest_format", "=", "format",...
Handle the case where the outermost type of format is a tuple.
[ "Handle", "the", "case", "where", "the", "outermost", "type", "of", "format", "is", "a", "tuple", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L189-L221
pygobject/pgi
pgi/overrides/GLib.py
_VariantCreator._create_dict
def _create_dict(self, format, args): """Handle the case where the outermost type of format is a dict.""" builder = None if args is None or not args[0]: # empty value: we need to call _create() to parse the subtype, # and specify the element type precisely re...
python
def _create_dict(self, format, args): """Handle the case where the outermost type of format is a dict.""" builder = None if args is None or not args[0]: # empty value: we need to call _create() to parse the subtype, # and specify the element type precisely re...
[ "def", "_create_dict", "(", "self", ",", "format", ",", "args", ")", ":", "builder", "=", "None", "if", "args", "is", "None", "or", "not", "args", "[", "0", "]", ":", "# empty value: we need to call _create() to parse the subtype,", "# and specify the element type p...
Handle the case where the outermost type of format is a dict.
[ "Handle", "the", "case", "where", "the", "outermost", "type", "of", "format", "is", "a", "dict", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L223-L254
pygobject/pgi
pgi/overrides/GLib.py
_VariantCreator._create_array
def _create_array(self, format, args): """Handle the case where the outermost type of format is an array.""" builder = None if args is None or not args[0]: # empty value: we need to call _create() to parse the subtype, # and specify the element type precisely ...
python
def _create_array(self, format, args): """Handle the case where the outermost type of format is an array.""" builder = None if args is None or not args[0]: # empty value: we need to call _create() to parse the subtype, # and specify the element type precisely ...
[ "def", "_create_array", "(", "self", ",", "format", ",", "args", ")", ":", "builder", "=", "None", "if", "args", "is", "None", "or", "not", "args", "[", "0", "]", ":", "# empty value: we need to call _create() to parse the subtype,", "# and specify the element type ...
Handle the case where the outermost type of format is an array.
[ "Handle", "the", "case", "where", "the", "outermost", "type", "of", "format", "is", "an", "array", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L256-L273
pygobject/pgi
pgi/overrides/GLib.py
Variant.unpack
def unpack(self): """Decompose a GVariant into a native Python object.""" LEAF_ACCESSORS = { 'b': self.get_boolean, 'y': self.get_byte, 'n': self.get_int16, 'q': self.get_uint16, 'i': self.get_int32, 'u': self.get_uint32, ...
python
def unpack(self): """Decompose a GVariant into a native Python object.""" LEAF_ACCESSORS = { 'b': self.get_boolean, 'y': self.get_byte, 'n': self.get_int16, 'q': self.get_uint16, 'i': self.get_int32, 'u': self.get_uint32, ...
[ "def", "unpack", "(", "self", ")", ":", "LEAF_ACCESSORS", "=", "{", "'b'", ":", "self", ".", "get_boolean", ",", "'y'", ":", "self", ".", "get_byte", ",", "'n'", ":", "self", ".", "get_int16", ",", "'q'", ":", "self", ".", "get_uint16", ",", "'i'", ...
Decompose a GVariant into a native Python object.
[ "Decompose", "a", "GVariant", "into", "a", "native", "Python", "object", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L342-L394
pygobject/pgi
pgi/overrides/GLib.py
Variant.split_signature
def split_signature(klass, signature): """Return a list of the element signatures of the topmost signature tuple. If the signature is not a tuple, it returns one element with the entire signature. If the signature is an empty tuple, the result is []. This is useful for e. g. iterating ...
python
def split_signature(klass, signature): """Return a list of the element signatures of the topmost signature tuple. If the signature is not a tuple, it returns one element with the entire signature. If the signature is an empty tuple, the result is []. This is useful for e. g. iterating ...
[ "def", "split_signature", "(", "klass", ",", "signature", ")", ":", "if", "signature", "==", "'()'", ":", "return", "[", "]", "if", "not", "signature", ".", "startswith", "(", "'('", ")", ":", "return", "[", "signature", "]", "result", "=", "[", "]", ...
Return a list of the element signatures of the topmost signature tuple. If the signature is not a tuple, it returns one element with the entire signature. If the signature is an empty tuple, the result is []. This is useful for e. g. iterating over method parameters which are passed as...
[ "Return", "a", "list", "of", "the", "element", "signatures", "of", "the", "topmost", "signature", "tuple", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GLib.py#L397-L444
pygobject/pgi
pgi/codegen/ctypes_backend/utils.py
typeinfo_to_ctypes
def typeinfo_to_ctypes(info, return_value=False): """Maps a GITypeInfo() to a ctypes type. The ctypes types have to be different in the case of return values since ctypes does 'auto unboxing' in some cases which gives us no chance to free memory if there is a ownership transfer. """ tag = info...
python
def typeinfo_to_ctypes(info, return_value=False): """Maps a GITypeInfo() to a ctypes type. The ctypes types have to be different in the case of return values since ctypes does 'auto unboxing' in some cases which gives us no chance to free memory if there is a ownership transfer. """ tag = info...
[ "def", "typeinfo_to_ctypes", "(", "info", ",", "return_value", "=", "False", ")", ":", "tag", "=", "info", ".", "tag", ".", "value", "ptr", "=", "info", ".", "is_pointer", "mapping", "=", "{", "GITypeTag", ".", "BOOLEAN", ":", "gboolean", ",", "GITypeTag...
Maps a GITypeInfo() to a ctypes type. The ctypes types have to be different in the case of return values since ctypes does 'auto unboxing' in some cases which gives us no chance to free memory if there is a ownership transfer.
[ "Maps", "a", "GITypeInfo", "()", "to", "a", "ctypes", "type", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/ctypes_backend/utils.py#L96-L168
pygobject/pgi
pgi/codegen/ctypes_backend/utils.py
BaseType.pack_pointer
def pack_pointer(self, name): """Returns a pointer containing the value. This only works for int32/uint32/utf-8.. """ return self.parse(""" raise $_.TypeError('Can\\'t convert %(type_name)s to pointer: %%r' %% $in_) """ % {"type_name": type(self).__name__}, in_=name)["in_"]
python
def pack_pointer(self, name): """Returns a pointer containing the value. This only works for int32/uint32/utf-8.. """ return self.parse(""" raise $_.TypeError('Can\\'t convert %(type_name)s to pointer: %%r' %% $in_) """ % {"type_name": type(self).__name__}, in_=name)["in_"]
[ "def", "pack_pointer", "(", "self", ",", "name", ")", ":", "return", "self", ".", "parse", "(", "\"\"\"\nraise $_.TypeError('Can\\\\'t convert %(type_name)s to pointer: %%r' %% $in_)\n\"\"\"", "%", "{", "\"type_name\"", ":", "type", "(", "self", ")", ".", "__name__", ...
Returns a pointer containing the value. This only works for int32/uint32/utf-8..
[ "Returns", "a", "pointer", "containing", "the", "value", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/ctypes_backend/utils.py#L78-L86
pygobject/pgi
pgi/clib/gir/gitypelib.py
GITypelib.new_from_memory
def new_from_memory(cls, data): """Takes bytes and returns a GITypelib, or raises GIError""" size = len(data) copy = g_memdup(data, size) ptr = cast(copy, POINTER(guint8)) try: with gerror(GIError) as error: return GITypelib._new_from_memory(ptr, size...
python
def new_from_memory(cls, data): """Takes bytes and returns a GITypelib, or raises GIError""" size = len(data) copy = g_memdup(data, size) ptr = cast(copy, POINTER(guint8)) try: with gerror(GIError) as error: return GITypelib._new_from_memory(ptr, size...
[ "def", "new_from_memory", "(", "cls", ",", "data", ")", ":", "size", "=", "len", "(", "data", ")", "copy", "=", "g_memdup", "(", "data", ",", "size", ")", "ptr", "=", "cast", "(", "copy", ",", "POINTER", "(", "guint8", ")", ")", "try", ":", "with...
Takes bytes and returns a GITypelib, or raises GIError
[ "Takes", "bytes", "and", "returns", "a", "GITypelib", "or", "raises", "GIError" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/gir/gitypelib.py#L28-L39
pygobject/pgi
pgi/cffilib/gir/gibaseinfo.py
GIBaseInfo._get_type
def _get_type(cls, ptr): """Get the subtype class for a pointer""" # fall back to the base class if unknown return cls.__types.get(lib.g_base_info_get_type(ptr), cls)
python
def _get_type(cls, ptr): """Get the subtype class for a pointer""" # fall back to the base class if unknown return cls.__types.get(lib.g_base_info_get_type(ptr), cls)
[ "def", "_get_type", "(", "cls", ",", "ptr", ")", ":", "# fall back to the base class if unknown", "return", "cls", ".", "__types", ".", "get", "(", "lib", ".", "g_base_info_get_type", "(", "ptr", ")", ",", "cls", ")" ]
Get the subtype class for a pointer
[ "Get", "the", "subtype", "class", "for", "a", "pointer" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/cffilib/gir/gibaseinfo.py#L42-L46
pygobject/pgi
pgi/obj.py
add_method
def add_method(info, target_cls, virtual=False, dont_replace=False): """Add a method to the target class""" # escape before prefixing, like pygobject name = escape_identifier(info.name) if virtual: name = "do_" + name attr = VirtualMethodAttribute(info, target_cls, name) else: ...
python
def add_method(info, target_cls, virtual=False, dont_replace=False): """Add a method to the target class""" # escape before prefixing, like pygobject name = escape_identifier(info.name) if virtual: name = "do_" + name attr = VirtualMethodAttribute(info, target_cls, name) else: ...
[ "def", "add_method", "(", "info", ",", "target_cls", ",", "virtual", "=", "False", ",", "dont_replace", "=", "False", ")", ":", "# escape before prefixing, like pygobject", "name", "=", "escape_identifier", "(", "info", ".", "name", ")", "if", "virtual", ":", ...
Add a method to the target class
[ "Add", "a", "method", "to", "the", "target", "class" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L308-L322
pygobject/pgi
pgi/obj.py
InterfaceAttribute
def InterfaceAttribute(iface_info): """Creates a GInterface class""" # Create a new class cls = type(iface_info.name, (InterfaceBase,), dict(_Interface.__dict__)) cls.__module__ = iface_info.namespace # GType cls.__gtype__ = PGType(iface_info.g_type) # Properties cls.props = PropertyA...
python
def InterfaceAttribute(iface_info): """Creates a GInterface class""" # Create a new class cls = type(iface_info.name, (InterfaceBase,), dict(_Interface.__dict__)) cls.__module__ = iface_info.namespace # GType cls.__gtype__ = PGType(iface_info.g_type) # Properties cls.props = PropertyA...
[ "def", "InterfaceAttribute", "(", "iface_info", ")", ":", "# Create a new class", "cls", "=", "type", "(", "iface_info", ".", "name", ",", "(", "InterfaceBase", ",", ")", ",", "dict", "(", "_Interface", ".", "__dict__", ")", ")", "cls", ".", "__module__", ...
Creates a GInterface class
[ "Creates", "a", "GInterface", "class" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L341-L390
pygobject/pgi
pgi/obj.py
new_class_from_gtype
def new_class_from_gtype(gtype): """Create a new class for a gtype not in the gir. The caller is responsible for caching etc. """ if gtype.is_a(PGType.from_name("GObject")): parent = gtype.parent.pytype if parent is None or parent == PGType.from_name("void"): return ...
python
def new_class_from_gtype(gtype): """Create a new class for a gtype not in the gir. The caller is responsible for caching etc. """ if gtype.is_a(PGType.from_name("GObject")): parent = gtype.parent.pytype if parent is None or parent == PGType.from_name("void"): return ...
[ "def", "new_class_from_gtype", "(", "gtype", ")", ":", "if", "gtype", ".", "is_a", "(", "PGType", ".", "from_name", "(", "\"GObject\"", ")", ")", ":", "parent", "=", "gtype", ".", "parent", ".", "pytype", "if", "parent", "is", "None", "or", "parent", "...
Create a new class for a gtype not in the gir. The caller is responsible for caching etc.
[ "Create", "a", "new", "class", "for", "a", "gtype", "not", "in", "the", "gir", ".", "The", "caller", "is", "responsible", "for", "caching", "etc", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L393-L411
pygobject/pgi
pgi/obj.py
ObjectAttribute
def ObjectAttribute(obj_info): """Creates a GObject class. It inherits from the base class and all interfaces it implements. """ if obj_info.name == "Object" and obj_info.namespace == "GObject": cls = Object else: # Get the parent class parent_obj = obj_info.get_parent() ...
python
def ObjectAttribute(obj_info): """Creates a GObject class. It inherits from the base class and all interfaces it implements. """ if obj_info.name == "Object" and obj_info.namespace == "GObject": cls = Object else: # Get the parent class parent_obj = obj_info.get_parent() ...
[ "def", "ObjectAttribute", "(", "obj_info", ")", ":", "if", "obj_info", ".", "name", "==", "\"Object\"", "and", "obj_info", ".", "namespace", "==", "\"GObject\"", ":", "cls", "=", "Object", "else", ":", "# Get the parent class", "parent_obj", "=", "obj_info", "...
Creates a GObject class. It inherits from the base class and all interfaces it implements.
[ "Creates", "a", "GObject", "class", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L414-L519
pygobject/pgi
pgi/obj.py
Object._generate_constructor
def _generate_constructor(cls, names): """Get a hopefully cache constructor""" cache = cls._constructors if names in cache: return cache[names] elif len(cache) > 3: cache.clear() func = generate_constructor(cls, names) cache[names] = func ...
python
def _generate_constructor(cls, names): """Get a hopefully cache constructor""" cache = cls._constructors if names in cache: return cache[names] elif len(cache) > 3: cache.clear() func = generate_constructor(cls, names) cache[names] = func ...
[ "def", "_generate_constructor", "(", "cls", ",", "names", ")", ":", "cache", "=", "cls", ".", "_constructors", "if", "names", "in", "cache", ":", "return", "cache", "[", "names", "]", "elif", "len", "(", "cache", ")", ">", "3", ":", "cache", ".", "cl...
Get a hopefully cache constructor
[ "Get", "a", "hopefully", "cache", "constructor" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L55-L66
pygobject/pgi
pgi/obj.py
Object.set_property
def set_property(self, name, value): """set_property(property_name: str, value: object) Set property *property_name* to *value*. """ if not hasattr(self.props, name): raise TypeError("Unknown property: %r" % name) setattr(self.props, name, value)
python
def set_property(self, name, value): """set_property(property_name: str, value: object) Set property *property_name* to *value*. """ if not hasattr(self.props, name): raise TypeError("Unknown property: %r" % name) setattr(self.props, name, value)
[ "def", "set_property", "(", "self", ",", "name", ",", "value", ")", ":", "if", "not", "hasattr", "(", "self", ".", "props", ",", "name", ")", ":", "raise", "TypeError", "(", "\"Unknown property: %r\"", "%", "name", ")", "setattr", "(", "self", ".", "pr...
set_property(property_name: str, value: object) Set property *property_name* to *value*.
[ "set_property", "(", "property_name", ":", "str", "value", ":", "object", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L68-L76
pygobject/pgi
pgi/obj.py
Object.get_property
def get_property(self, name): """get_property(property_name: str) -> object Retrieves a property value. """ if not hasattr(self.props, name): raise TypeError("Unknown property: %r" % name) return getattr(self.props, name)
python
def get_property(self, name): """get_property(property_name: str) -> object Retrieves a property value. """ if not hasattr(self.props, name): raise TypeError("Unknown property: %r" % name) return getattr(self.props, name)
[ "def", "get_property", "(", "self", ",", "name", ")", ":", "if", "not", "hasattr", "(", "self", ".", "props", ",", "name", ")", ":", "raise", "TypeError", "(", "\"Unknown property: %r\"", "%", "name", ")", "return", "getattr", "(", "self", ".", "props", ...
get_property(property_name: str) -> object Retrieves a property value.
[ "get_property", "(", "property_name", ":", "str", ")", "-", ">", "object" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L78-L86
pygobject/pgi
pgi/obj.py
Object.connect
def connect(self, detailed_signal, handler, *args): """connect(detailed_signal: str, handler: function, *args) -> handler_id: int The connect() method adds a function or method (handler) to the end of the list of signal handlers for the named detailed_signal but before the default class...
python
def connect(self, detailed_signal, handler, *args): """connect(detailed_signal: str, handler: function, *args) -> handler_id: int The connect() method adds a function or method (handler) to the end of the list of signal handlers for the named detailed_signal but before the default class...
[ "def", "connect", "(", "self", ",", "detailed_signal", ",", "handler", ",", "*", "args", ")", ":", "return", "self", ".", "__connect", "(", "0", ",", "detailed_signal", ",", "handler", ",", "*", "args", ")" ]
connect(detailed_signal: str, handler: function, *args) -> handler_id: int The connect() method adds a function or method (handler) to the end of the list of signal handlers for the named detailed_signal but before the default class signal handler. An optional set of parameters may be s...
[ "connect", "(", "detailed_signal", ":", "str", "handler", ":", "function", "*", "args", ")", "-", ">", "handler_id", ":", "int" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L127-L156
pygobject/pgi
pgi/obj.py
Object.connect_after
def connect_after(self, detailed_signal, handler, *args): """connect_after(detailed_signal: str, handler: function, *args) -> handler_id: int The connect_after() method is similar to the connect() method except that the handler is added to the signal handler list after the default class...
python
def connect_after(self, detailed_signal, handler, *args): """connect_after(detailed_signal: str, handler: function, *args) -> handler_id: int The connect_after() method is similar to the connect() method except that the handler is added to the signal handler list after the default class...
[ "def", "connect_after", "(", "self", ",", "detailed_signal", ",", "handler", ",", "*", "args", ")", ":", "flags", "=", "GConnectFlags", ".", "CONNECT_AFTER", "return", "self", ".", "__connect", "(", "flags", ",", "detailed_signal", ",", "handler", ",", "*", ...
connect_after(detailed_signal: str, handler: function, *args) -> handler_id: int The connect_after() method is similar to the connect() method except that the handler is added to the signal handler list after the default class signal handler. Otherwise the details of handler definition ...
[ "connect_after", "(", "detailed_signal", ":", "str", "handler", ":", "function", "*", "args", ")", "-", ">", "handler_id", ":", "int" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/obj.py#L158-L168
pygobject/pgi
pgi/clib/gir/gibaseinfo.py
GIBaseInfo._take_ownership
def _take_ownership(self): """Make the Python instance take ownership of the GIBaseInfo. i.e. unref if the python instance gets gc'ed. """ if self: ptr = cast(self.value, GIBaseInfo) _UnrefFinalizer.track(self, ptr) self.__owns = True
python
def _take_ownership(self): """Make the Python instance take ownership of the GIBaseInfo. i.e. unref if the python instance gets gc'ed. """ if self: ptr = cast(self.value, GIBaseInfo) _UnrefFinalizer.track(self, ptr) self.__owns = True
[ "def", "_take_ownership", "(", "self", ")", ":", "if", "self", ":", "ptr", "=", "cast", "(", "self", ".", "value", ",", "GIBaseInfo", ")", "_UnrefFinalizer", ".", "track", "(", "self", ",", "ptr", ")", "self", ".", "__owns", "=", "True" ]
Make the Python instance take ownership of the GIBaseInfo. i.e. unref if the python instance gets gc'ed.
[ "Make", "the", "Python", "instance", "take", "ownership", "of", "the", "GIBaseInfo", ".", "i", ".", "e", ".", "unref", "if", "the", "python", "instance", "gets", "gc", "ed", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/gir/gibaseinfo.py#L61-L69
pygobject/pgi
pgi/clib/gir/gibaseinfo.py
GIBaseInfo._cast
def _cast(cls, base_info, take_ownership=True): """Casts a GIBaseInfo instance to the right sub type. The original GIBaseInfo can't have ownership. Will take ownership. """ type_value = base_info.type.value try: new_obj = cast(base_info, cls.__types[type_val...
python
def _cast(cls, base_info, take_ownership=True): """Casts a GIBaseInfo instance to the right sub type. The original GIBaseInfo can't have ownership. Will take ownership. """ type_value = base_info.type.value try: new_obj = cast(base_info, cls.__types[type_val...
[ "def", "_cast", "(", "cls", ",", "base_info", ",", "take_ownership", "=", "True", ")", ":", "type_value", "=", "base_info", ".", "type", ".", "value", "try", ":", "new_obj", "=", "cast", "(", "base_info", ",", "cls", ".", "__types", "[", "type_value", ...
Casts a GIBaseInfo instance to the right sub type. The original GIBaseInfo can't have ownership. Will take ownership.
[ "Casts", "a", "GIBaseInfo", "instance", "to", "the", "right", "sub", "type", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/gir/gibaseinfo.py#L72-L89
pygobject/pgi
pgi/util.py
decode_return
def decode_return(codec="ascii"): """Decodes the return value of it isn't None""" def outer(f): def wrap(*args, **kwargs): res = f(*args, **kwargs) if res is not None: return res.decode(codec) return res return wrap return outer
python
def decode_return(codec="ascii"): """Decodes the return value of it isn't None""" def outer(f): def wrap(*args, **kwargs): res = f(*args, **kwargs) if res is not None: return res.decode(codec) return res return wrap return outer
[ "def", "decode_return", "(", "codec", "=", "\"ascii\"", ")", ":", "def", "outer", "(", "f", ")", ":", "def", "wrap", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "res", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "...
Decodes the return value of it isn't None
[ "Decodes", "the", "return", "value", "of", "it", "isn", "t", "None" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L27-L37
pygobject/pgi
pgi/util.py
load_ctypes_library
def load_ctypes_library(name): """Takes a library name and calls find_library in case loading fails, since some girs don't include the real .so name. Raises OSError like LoadLibrary if loading fails. e.g. javascriptcoregtk-3.0 should be libjavascriptcoregtk-3.0.so on unix """ try: ret...
python
def load_ctypes_library(name): """Takes a library name and calls find_library in case loading fails, since some girs don't include the real .so name. Raises OSError like LoadLibrary if loading fails. e.g. javascriptcoregtk-3.0 should be libjavascriptcoregtk-3.0.so on unix """ try: ret...
[ "def", "load_ctypes_library", "(", "name", ")", ":", "try", ":", "return", "cdll", ".", "LoadLibrary", "(", "name", ")", "except", "OSError", ":", "name", "=", "find_library", "(", "name", ")", "if", "name", "is", "None", ":", "raise", "return", "cdll", ...
Takes a library name and calls find_library in case loading fails, since some girs don't include the real .so name. Raises OSError like LoadLibrary if loading fails. e.g. javascriptcoregtk-3.0 should be libjavascriptcoregtk-3.0.so on unix
[ "Takes", "a", "library", "name", "and", "calls", "find_library", "in", "case", "loading", "fails", "since", "some", "girs", "don", "t", "include", "the", "real", ".", "so", "name", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L50-L65
pygobject/pgi
pgi/util.py
escape_identifier
def escape_identifier(text, reg=KWD_RE): """Escape partial C identifiers so they can be used as attributes/arguments""" # see http://docs.python.org/reference/lexical_analysis.html#identifiers if not text: return "_" if text[0].isdigit(): text = "_" + text return reg.sub(r"\1_",...
python
def escape_identifier(text, reg=KWD_RE): """Escape partial C identifiers so they can be used as attributes/arguments""" # see http://docs.python.org/reference/lexical_analysis.html#identifiers if not text: return "_" if text[0].isdigit(): text = "_" + text return reg.sub(r"\1_",...
[ "def", "escape_identifier", "(", "text", ",", "reg", "=", "KWD_RE", ")", ":", "# see http://docs.python.org/reference/lexical_analysis.html#identifiers", "if", "not", "text", ":", "return", "\"_\"", "if", "text", "[", "0", "]", ".", "isdigit", "(", ")", ":", "te...
Escape partial C identifiers so they can be used as attributes/arguments
[ "Escape", "partial", "C", "identifiers", "so", "they", "can", "be", "used", "as", "attributes", "/", "arguments" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L226-L235
pygobject/pgi
pgi/util.py
cache_return
def cache_return(func): """Cache the return value of a function without arguments""" _cache = [] def wrap(): if not _cache: _cache.append(func()) return _cache[0] return wrap
python
def cache_return(func): """Cache the return value of a function without arguments""" _cache = [] def wrap(): if not _cache: _cache.append(func()) return _cache[0] return wrap
[ "def", "cache_return", "(", "func", ")", ":", "_cache", "=", "[", "]", "def", "wrap", "(", ")", ":", "if", "not", "_cache", ":", "_cache", ".", "append", "(", "func", "(", ")", ")", "return", "_cache", "[", "0", "]", "return", "wrap" ]
Cache the return value of a function without arguments
[ "Cache", "the", "return", "value", "of", "a", "function", "without", "arguments" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L263-L272
pygobject/pgi
pgi/util.py
InfoIterWrapper.lookup_name_fast
def lookup_name_fast(self, name): """Might return a struct""" if name in self.__names: return self.__names[name] count = self.__get_count_cached() lo = 0 hi = count while lo < hi: mid = (lo + hi) // 2 if self.__get_name_cached(mid) < ...
python
def lookup_name_fast(self, name): """Might return a struct""" if name in self.__names: return self.__names[name] count = self.__get_count_cached() lo = 0 hi = count while lo < hi: mid = (lo + hi) // 2 if self.__get_name_cached(mid) < ...
[ "def", "lookup_name_fast", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "__names", ":", "return", "self", ".", "__names", "[", "name", "]", "count", "=", "self", ".", "__get_count_cached", "(", ")", "lo", "=", "0", "hi", "=", ...
Might return a struct
[ "Might", "return", "a", "struct" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L115-L132
pygobject/pgi
pgi/util.py
InfoIterWrapper.lookup_name_slow
def lookup_name_slow(self, name): """Returns a struct if one exists""" for index in xrange(self.__get_count_cached()): if self.__get_name_cached(index) == name: return self.__get_info_cached(index)
python
def lookup_name_slow(self, name): """Returns a struct if one exists""" for index in xrange(self.__get_count_cached()): if self.__get_name_cached(index) == name: return self.__get_info_cached(index)
[ "def", "lookup_name_slow", "(", "self", ",", "name", ")", ":", "for", "index", "in", "xrange", "(", "self", ".", "__get_count_cached", "(", ")", ")", ":", "if", "self", ".", "__get_name_cached", "(", "index", ")", "==", "name", ":", "return", "self", "...
Returns a struct if one exists
[ "Returns", "a", "struct", "if", "one", "exists" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L134-L139
pygobject/pgi
pgi/util.py
InfoIterWrapper.lookup_name
def lookup_name(self, name): """Returns a struct if one exists""" try: info = self._get_by_name(self._source, name) except NotImplementedError: pass else: if info: return info return info = self.lookup_name_fast(na...
python
def lookup_name(self, name): """Returns a struct if one exists""" try: info = self._get_by_name(self._source, name) except NotImplementedError: pass else: if info: return info return info = self.lookup_name_fast(na...
[ "def", "lookup_name", "(", "self", ",", "name", ")", ":", "try", ":", "info", "=", "self", ".", "_get_by_name", "(", "self", ".", "_source", ",", "name", ")", "except", "NotImplementedError", ":", "pass", "else", ":", "if", "info", ":", "return", "info...
Returns a struct if one exists
[ "Returns", "a", "struct", "if", "one", "exists" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L141-L156
pygobject/pgi
pgi/util.py
ResultTuple._new_type
def _new_type(cls, args): """Creates a new class similar to namedtuple. Pass a list of field names or None for no field name. >>> x = ResultTuple._new_type([None, "bar"]) >>> x((1, 3)) ResultTuple(1, bar=3) """ fformat = ["%r" if f is None else "%s=%%r" % f for...
python
def _new_type(cls, args): """Creates a new class similar to namedtuple. Pass a list of field names or None for no field name. >>> x = ResultTuple._new_type([None, "bar"]) >>> x((1, 3)) ResultTuple(1, bar=3) """ fformat = ["%r" if f is None else "%s=%%r" % f for...
[ "def", "_new_type", "(", "cls", ",", "args", ")", ":", "fformat", "=", "[", "\"%r\"", "if", "f", "is", "None", "else", "\"%s=%%r\"", "%", "f", "for", "f", "in", "args", "]", "fformat", "=", "\"(%s)\"", "%", "\", \"", ".", "join", "(", "fformat", ")...
Creates a new class similar to namedtuple. Pass a list of field names or None for no field name. >>> x = ResultTuple._new_type([None, "bar"]) >>> x((1, 3)) ResultTuple(1, bar=3)
[ "Creates", "a", "new", "class", "similar", "to", "namedtuple", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/util.py#L320-L342
pygobject/pgi
pgi/overrides/GObject.py
signal_list_names
def signal_list_names(type_): """Returns a list of signal names for the given type :param type\\_: :type type\\_: :obj:`GObject.GType` :returns: A list of signal names :rtype: :obj:`list` """ ids = signal_list_ids(type_) return tuple(GObjectModule.signal_name(i) for i in ids)
python
def signal_list_names(type_): """Returns a list of signal names for the given type :param type\\_: :type type\\_: :obj:`GObject.GType` :returns: A list of signal names :rtype: :obj:`list` """ ids = signal_list_ids(type_) return tuple(GObjectModule.signal_name(i) for i in ids)
[ "def", "signal_list_names", "(", "type_", ")", ":", "ids", "=", "signal_list_ids", "(", "type_", ")", "return", "tuple", "(", "GObjectModule", ".", "signal_name", "(", "i", ")", "for", "i", "in", "ids", ")" ]
Returns a list of signal names for the given type :param type\\_: :type type\\_: :obj:`GObject.GType` :returns: A list of signal names :rtype: :obj:`list`
[ "Returns", "a", "list", "of", "signal", "names", "for", "the", "given", "type" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GObject.py#L392-L402
pygobject/pgi
pgi/overrides/GObject.py
signal_handler_block
def signal_handler_block(obj, handler_id): """Blocks the signal handler from being invoked until handler_unblock() is called. :param GObject.Object obj: Object instance to block handlers for. :param int handler_id: Id of signal to block. :returns: A context manager which opt...
python
def signal_handler_block(obj, handler_id): """Blocks the signal handler from being invoked until handler_unblock() is called. :param GObject.Object obj: Object instance to block handlers for. :param int handler_id: Id of signal to block. :returns: A context manager which opt...
[ "def", "signal_handler_block", "(", "obj", ",", "handler_id", ")", ":", "GObjectModule", ".", "signal_handler_block", "(", "obj", ",", "handler_id", ")", "return", "_HandlerBlockManager", "(", "obj", ",", "handler_id", ")" ]
Blocks the signal handler from being invoked until handler_unblock() is called. :param GObject.Object obj: Object instance to block handlers for. :param int handler_id: Id of signal to block. :returns: A context manager which optionally can be used to automatically unblo...
[ "Blocks", "the", "signal", "handler", "from", "being", "invoked", "until", "handler_unblock", "()", "is", "called", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GObject.py#L458-L476
pygobject/pgi
pgi/overrides/GObject.py
signal_parse_name
def signal_parse_name(detailed_signal, itype, force_detail_quark): """Parse a detailed signal name into (signal_id, detail). :param str detailed_signal: Signal name which can include detail. For example: "notify:prop_name" :returns: Tuple of (signal_id, detail) :raises ValueErro...
python
def signal_parse_name(detailed_signal, itype, force_detail_quark): """Parse a detailed signal name into (signal_id, detail). :param str detailed_signal: Signal name which can include detail. For example: "notify:prop_name" :returns: Tuple of (signal_id, detail) :raises ValueErro...
[ "def", "signal_parse_name", "(", "detailed_signal", ",", "itype", ",", "force_detail_quark", ")", ":", "res", ",", "signal_id", ",", "detail", "=", "GObjectModule", ".", "signal_parse_name", "(", "detailed_signal", ",", "itype", ",", "force_detail_quark", ")", "if...
Parse a detailed signal name into (signal_id, detail). :param str detailed_signal: Signal name which can include detail. For example: "notify:prop_name" :returns: Tuple of (signal_id, detail) :raises ValueError: If the given signal is unknown.
[ "Parse", "a", "detailed", "signal", "name", "into", "(", "signal_id", "detail", ")", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/GObject.py#L481-L497
pygobject/pgi
pgi/clib/_utils.py
find_library
def find_library(name, cached=True, internal=True): """ cached: Return a new instance internal: return a shared instance that's not the ctypes cached one """ # a new one if not cached: return cdll.LoadLibrary(_so_mapping[name]) # from the shared internal set or a new one ...
python
def find_library(name, cached=True, internal=True): """ cached: Return a new instance internal: return a shared instance that's not the ctypes cached one """ # a new one if not cached: return cdll.LoadLibrary(_so_mapping[name]) # from the shared internal set or a new one ...
[ "def", "find_library", "(", "name", ",", "cached", "=", "True", ",", "internal", "=", "True", ")", ":", "# a new one", "if", "not", "cached", ":", "return", "cdll", ".", "LoadLibrary", "(", "_so_mapping", "[", "name", "]", ")", "# from the shared internal se...
cached: Return a new instance internal: return a shared instance that's not the ctypes cached one
[ "cached", ":", "Return", "a", "new", "instance", "internal", ":", "return", "a", "shared", "instance", "that", "s", "not", "the", "ctypes", "cached", "one" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/_utils.py#L86-L103
pygobject/pgi
pgi/clib/_utils.py
_BaseFinalizer.track
def track(cls, obj, ptr): """ Track an object which needs destruction when it is garbage collected. """ cls._objects.add(cls(obj, ptr))
python
def track(cls, obj, ptr): """ Track an object which needs destruction when it is garbage collected. """ cls._objects.add(cls(obj, ptr))
[ "def", "track", "(", "cls", ",", "obj", ",", "ptr", ")", ":", "cls", ".", "_objects", ".", "add", "(", "cls", "(", "obj", ",", "ptr", ")", ")" ]
Track an object which needs destruction when it is garbage collected.
[ "Track", "an", "object", "which", "needs", "destruction", "when", "it", "is", "garbage", "collected", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/_utils.py#L23-L27
pygobject/pgi
pgi/overrides/Gio.py
_DBusProxyMethodCall._unpack_result
def _unpack_result(klass, result): '''Convert a D-BUS return variant into an appropriate return value''' result = result.unpack() # to be compatible with standard Python behaviour, unbox # single-element tuples and return None for empty result tuples if len(result) == 1: ...
python
def _unpack_result(klass, result): '''Convert a D-BUS return variant into an appropriate return value''' result = result.unpack() # to be compatible with standard Python behaviour, unbox # single-element tuples and return None for empty result tuples if len(result) == 1: ...
[ "def", "_unpack_result", "(", "klass", ",", "result", ")", ":", "result", "=", "result", ".", "unpack", "(", ")", "# to be compatible with standard Python behaviour, unbox", "# single-element tuples and return None for empty result tuples", "if", "len", "(", "result", ")", ...
Convert a D-BUS return variant into an appropriate return value
[ "Convert", "a", "D", "-", "BUS", "return", "variant", "into", "an", "appropriate", "return", "value" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/Gio.py#L173-L185
pygobject/pgi
pgi/properties.py
list_properties
def list_properties(type): """ :param type: a Python GObject instance or type that the signal is associated with :type type: :obj:`GObject.Object` :returns: a list of :obj:`GObject.ParamSpec` :rtype: [:obj:`GObject.ParamSpec`] Takes a GObject/GInterface subclass or a GType and returns a list o...
python
def list_properties(type): """ :param type: a Python GObject instance or type that the signal is associated with :type type: :obj:`GObject.Object` :returns: a list of :obj:`GObject.ParamSpec` :rtype: [:obj:`GObject.ParamSpec`] Takes a GObject/GInterface subclass or a GType and returns a list o...
[ "def", "list_properties", "(", "type", ")", ":", "if", "isinstance", "(", "type", ",", "PGType", ")", ":", "type", "=", "type", ".", "pytype", "from", "pgi", ".", "obj", "import", "Object", ",", "InterfaceBase", "if", "not", "issubclass", "(", "type", ...
:param type: a Python GObject instance or type that the signal is associated with :type type: :obj:`GObject.Object` :returns: a list of :obj:`GObject.ParamSpec` :rtype: [:obj:`GObject.ParamSpec`] Takes a GObject/GInterface subclass or a GType and returns a list of GParamSpecs for all properties of...
[ ":", "param", "type", ":", "a", "Python", "GObject", "instance", "or", "type", "that", "the", "signal", "is", "associated", "with", ":", "type", "type", ":", ":", "obj", ":", "GObject", ".", "Object" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/properties.py#L282-L307
pygobject/pgi
pgi/overrides/__init__.py
load_overrides
def load_overrides(introspection_module): """Loads overrides for an introspection module. Either returns the same module again in case there are no overrides or a proxy module including overrides. Doesn't cache the result. """ namespace = introspection_module.__name__.rsplit(".", 1)[-1] module...
python
def load_overrides(introspection_module): """Loads overrides for an introspection module. Either returns the same module again in case there are no overrides or a proxy module including overrides. Doesn't cache the result. """ namespace = introspection_module.__name__.rsplit(".", 1)[-1] module...
[ "def", "load_overrides", "(", "introspection_module", ")", ":", "namespace", "=", "introspection_module", ".", "__name__", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "-", "1", "]", "module_keys", "=", "[", "prefix", "+", "\".\"", "+", "namespace", "f...
Loads overrides for an introspection module. Either returns the same module again in case there are no overrides or a proxy module including overrides. Doesn't cache the result.
[ "Loads", "overrides", "for", "an", "introspection", "module", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/__init__.py#L82-L160
pygobject/pgi
pgi/overrides/__init__.py
override
def override(klass): """Takes a override class or function and assigns it dunder arguments form the overidden one. """ namespace = klass.__module__.rsplit(".", 1)[-1] mod_name = const.PREFIX[-1] + "." + namespace module = sys.modules[mod_name] if isinstance(klass, types.FunctionType): ...
python
def override(klass): """Takes a override class or function and assigns it dunder arguments form the overidden one. """ namespace = klass.__module__.rsplit(".", 1)[-1] mod_name = const.PREFIX[-1] + "." + namespace module = sys.modules[mod_name] if isinstance(klass, types.FunctionType): ...
[ "def", "override", "(", "klass", ")", ":", "namespace", "=", "klass", ".", "__module__", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "-", "1", "]", "mod_name", "=", "const", ".", "PREFIX", "[", "-", "1", "]", "+", "\".\"", "+", "namespace", ...
Takes a override class or function and assigns it dunder arguments form the overidden one.
[ "Takes", "a", "override", "class", "or", "function", "and", "assigns", "it", "dunder", "arguments", "form", "the", "overidden", "one", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/__init__.py#L163-L185
pygobject/pgi
pgi/overrides/__init__.py
deprecated
def deprecated(function, instead): """Mark a function deprecated so calling it issues a warning""" # skip for classes, breaks doc generation if not isinstance(function, types.FunctionType): return function @wraps(function) def wrap(*args, **kwargs): warnings.warn("Deprecated, use %...
python
def deprecated(function, instead): """Mark a function deprecated so calling it issues a warning""" # skip for classes, breaks doc generation if not isinstance(function, types.FunctionType): return function @wraps(function) def wrap(*args, **kwargs): warnings.warn("Deprecated, use %...
[ "def", "deprecated", "(", "function", ",", "instead", ")", ":", "# skip for classes, breaks doc generation", "if", "not", "isinstance", "(", "function", ",", "types", ".", "FunctionType", ")", ":", "return", "function", "@", "wraps", "(", "function", ")", "def",...
Mark a function deprecated so calling it issues a warning
[ "Mark", "a", "function", "deprecated", "so", "calling", "it", "issues", "a", "warning" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/__init__.py#L188-L201
pygobject/pgi
pgi/overrides/__init__.py
deprecated_attr
def deprecated_attr(namespace, attr, replacement): """Marks a module level attribute as deprecated. Accessing it will emit a PyGIDeprecationWarning warning. e.g. for ``deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")`` accessing GObject.STATUS_FOO will emit: "GObject.STATUS_FOO is d...
python
def deprecated_attr(namespace, attr, replacement): """Marks a module level attribute as deprecated. Accessing it will emit a PyGIDeprecationWarning warning. e.g. for ``deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")`` accessing GObject.STATUS_FOO will emit: "GObject.STATUS_FOO is d...
[ "def", "deprecated_attr", "(", "namespace", ",", "attr", ",", "replacement", ")", ":", "_deprecated_attrs", ".", "setdefault", "(", "namespace", ",", "[", "]", ")", ".", "append", "(", "(", "attr", ",", "replacement", ")", ")" ]
Marks a module level attribute as deprecated. Accessing it will emit a PyGIDeprecationWarning warning. e.g. for ``deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")`` accessing GObject.STATUS_FOO will emit: "GObject.STATUS_FOO is deprecated; use GLib.Status.FOO instead" :param str na...
[ "Marks", "a", "module", "level", "attribute", "as", "deprecated", ".", "Accessing", "it", "will", "emit", "a", "PyGIDeprecationWarning", "warning", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/__init__.py#L204-L221
pygobject/pgi
pgi/overrides/__init__.py
deprecated_init
def deprecated_init(super_init_func, arg_names, ignore=tuple(), deprecated_aliases={}, deprecated_defaults={}, category=PyGIDeprecationWarning, stacklevel=2): """Wrapper for deprecating GObject based __init__ methods which specify defaults already avai...
python
def deprecated_init(super_init_func, arg_names, ignore=tuple(), deprecated_aliases={}, deprecated_defaults={}, category=PyGIDeprecationWarning, stacklevel=2): """Wrapper for deprecating GObject based __init__ methods which specify defaults already avai...
[ "def", "deprecated_init", "(", "super_init_func", ",", "arg_names", ",", "ignore", "=", "tuple", "(", ")", ",", "deprecated_aliases", "=", "{", "}", ",", "deprecated_defaults", "=", "{", "}", ",", "category", "=", "PyGIDeprecationWarning", ",", "stacklevel", "...
Wrapper for deprecating GObject based __init__ methods which specify defaults already available or non-standard defaults. :param callable super_init_func: Initializer to wrap. :param list arg_names: Ordered argument name list. :param list ignore: List of argument names to ignore...
[ "Wrapper", "for", "deprecating", "GObject", "based", "__init__", "methods", "which", "specify", "defaults", "already", "available", "or", "non", "-", "standard", "defaults", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/__init__.py#L224-L305
pygobject/pgi
pgi/overrides/__init__.py
strip_boolean_result
def strip_boolean_result(method, exc_type=None, exc_str=None, fail_ret=None): """Translate method's return value for stripping off success flag. There are a lot of methods which return a "success" boolean and have several out arguments. Translate such a method to return the out arguments on success and...
python
def strip_boolean_result(method, exc_type=None, exc_str=None, fail_ret=None): """Translate method's return value for stripping off success flag. There are a lot of methods which return a "success" boolean and have several out arguments. Translate such a method to return the out arguments on success and...
[ "def", "strip_boolean_result", "(", "method", ",", "exc_type", "=", "None", ",", "exc_str", "=", "None", ",", "fail_ret", "=", "None", ")", ":", "@", "wraps", "(", "method", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", ...
Translate method's return value for stripping off success flag. There are a lot of methods which return a "success" boolean and have several out arguments. Translate such a method to return the out arguments on success and None on failure.
[ "Translate", "method", "s", "return", "value", "for", "stripping", "off", "success", "flag", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/overrides/__init__.py#L308-L327
pygobject/pgi
pgi/module.py
get_introspection_module
def get_introspection_module(namespace): """Raises ImportError""" if namespace in _introspection_modules: return _introspection_modules[namespace] from . import get_required_version repository = GIRepository() version = get_required_version(namespace) try: repository.require(...
python
def get_introspection_module(namespace): """Raises ImportError""" if namespace in _introspection_modules: return _introspection_modules[namespace] from . import get_required_version repository = GIRepository() version = get_required_version(namespace) try: repository.require(...
[ "def", "get_introspection_module", "(", "namespace", ")", ":", "if", "namespace", "in", "_introspection_modules", ":", "return", "_introspection_modules", "[", "namespace", "]", "from", ".", "import", "get_required_version", "repository", "=", "GIRepository", "(", ")"...
Raises ImportError
[ "Raises", "ImportError" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/module.py#L100-L135
pygobject/pgi
pgi/codegen/returnvalues.py
ReturnValue.get_param_type
def get_param_type(self, index): """Returns a ReturnValue instance for param type 'index'""" assert index in (0, 1) type_info = self.type.get_param_type(index) type_cls = get_return_class(type_info) instance = type_cls(None, type_info, [], self.backend) instance.setup()...
python
def get_param_type(self, index): """Returns a ReturnValue instance for param type 'index'""" assert index in (0, 1) type_info = self.type.get_param_type(index) type_cls = get_return_class(type_info) instance = type_cls(None, type_info, [], self.backend) instance.setup()...
[ "def", "get_param_type", "(", "self", ",", "index", ")", ":", "assert", "index", "in", "(", "0", ",", "1", ")", "type_info", "=", "self", ".", "type", ".", "get_param_type", "(", "index", ")", "type_cls", "=", "get_return_class", "(", "type_info", ")", ...
Returns a ReturnValue instance for param type 'index
[ "Returns", "a", "ReturnValue", "instance", "for", "param", "type", "index" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/returnvalues.py#L45-L54
pygobject/pgi
pgi/codegen/utils.py
parse_code
def parse_code(code, var_factory, **kwargs): """Parse a piece of text and substitude $var by either unique variable names or by the given kwargs mapping. Use $$ to escape $. Returns a CodeBlock and the resulting variable mapping. parse("$foo = $foo + $bar", bar="1") ("t1 = t1 + 1", {'foo': 't1', '...
python
def parse_code(code, var_factory, **kwargs): """Parse a piece of text and substitude $var by either unique variable names or by the given kwargs mapping. Use $$ to escape $. Returns a CodeBlock and the resulting variable mapping. parse("$foo = $foo + $bar", bar="1") ("t1 = t1 + 1", {'foo': 't1', '...
[ "def", "parse_code", "(", "code", ",", "var_factory", ",", "*", "*", "kwargs", ")", ":", "block", "=", "CodeBlock", "(", ")", "defdict", "=", "collections", ".", "defaultdict", "(", "var_factory", ")", "defdict", ".", "update", "(", "kwargs", ")", "inden...
Parse a piece of text and substitude $var by either unique variable names or by the given kwargs mapping. Use $$ to escape $. Returns a CodeBlock and the resulting variable mapping. parse("$foo = $foo + $bar", bar="1") ("t1 = t1 + 1", {'foo': 't1', 'bar': '1'})
[ "Parse", "a", "piece", "of", "text", "and", "substitude", "$var", "by", "either", "unique", "variable", "names", "or", "by", "the", "given", "kwargs", "mapping", ".", "Use", "$$", "to", "escape", "$", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L179-L217
pygobject/pgi
pgi/codegen/utils.py
parse_with_objects
def parse_with_objects(code, var, **kwargs): """Parse code and include non string/codeblock kwargs as dependencies. int/long will be inlined. Returns a CodeBlock and the resulting variable mapping. """ deps = {} for key, value in kwargs.items(): if isinstance(value, _compat.intege...
python
def parse_with_objects(code, var, **kwargs): """Parse code and include non string/codeblock kwargs as dependencies. int/long will be inlined. Returns a CodeBlock and the resulting variable mapping. """ deps = {} for key, value in kwargs.items(): if isinstance(value, _compat.intege...
[ "def", "parse_with_objects", "(", "code", ",", "var", ",", "*", "*", "kwargs", ")", ":", "deps", "=", "{", "}", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "_compat", ".", "integer...
Parse code and include non string/codeblock kwargs as dependencies. int/long will be inlined. Returns a CodeBlock and the resulting variable mapping.
[ "Parse", "code", "and", "include", "non", "string", "/", "codeblock", "kwargs", "as", "dependencies", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L220-L248
pygobject/pgi
pgi/codegen/utils.py
VariableFactory.request_name
def request_name(self, name): """Request a name, might return the name or a similar one if already used or reserved """ while name in self._blacklist: name += "_" self._blacklist.add(name) return name
python
def request_name(self, name): """Request a name, might return the name or a similar one if already used or reserved """ while name in self._blacklist: name += "_" self._blacklist.add(name) return name
[ "def", "request_name", "(", "self", ",", "name", ")", ":", "while", "name", "in", "self", ".", "_blacklist", ":", "name", "+=", "\"_\"", "self", ".", "_blacklist", ".", "add", "(", "name", ")", "return", "name" ]
Request a name, might return the name or a similar one if already used or reserved
[ "Request", "a", "name", "might", "return", "the", "name", "or", "a", "similar", "one", "if", "already", "used", "or", "reserved" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L68-L76
pygobject/pgi
pgi/codegen/utils.py
CodeBlock.add_dependency
def add_dependency(self, name, obj): """Add a code dependency so it gets inserted into globals""" if name in self._deps: if self._deps[name] is obj: return raise ValueError( "There exists a different dep with the same name : %r" % name) se...
python
def add_dependency(self, name, obj): """Add a code dependency so it gets inserted into globals""" if name in self._deps: if self._deps[name] is obj: return raise ValueError( "There exists a different dep with the same name : %r" % name) se...
[ "def", "add_dependency", "(", "self", ",", "name", ",", "obj", ")", ":", "if", "name", "in", "self", ".", "_deps", ":", "if", "self", ".", "_deps", "[", "name", "]", "is", "obj", ":", "return", "raise", "ValueError", "(", "\"There exists a different dep ...
Add a code dependency so it gets inserted into globals
[ "Add", "a", "code", "dependency", "so", "it", "gets", "inserted", "into", "globals" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L94-L102
pygobject/pgi
pgi/codegen/utils.py
CodeBlock.write_into
def write_into(self, block, level=0): """Append this block to another one, passing all dependencies""" for line, l in self._lines: block.write_line(line, level + l) for name, obj in _compat.iteritems(self._deps): block.add_dependency(name, obj)
python
def write_into(self, block, level=0): """Append this block to another one, passing all dependencies""" for line, l in self._lines: block.write_line(line, level + l) for name, obj in _compat.iteritems(self._deps): block.add_dependency(name, obj)
[ "def", "write_into", "(", "self", ",", "block", ",", "level", "=", "0", ")", ":", "for", "line", ",", "l", "in", "self", ".", "_lines", ":", "block", ".", "write_line", "(", "line", ",", "level", "+", "l", ")", "for", "name", ",", "obj", "in", ...
Append this block to another one, passing all dependencies
[ "Append", "this", "block", "to", "another", "one", "passing", "all", "dependencies" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L104-L111
pygobject/pgi
pgi/codegen/utils.py
CodeBlock.write_lines
def write_lines(self, lines, level=0): """Append multiple new lines""" for line in lines: self.write_line(line, level)
python
def write_lines(self, lines, level=0): """Append multiple new lines""" for line in lines: self.write_line(line, level)
[ "def", "write_lines", "(", "self", ",", "lines", ",", "level", "=", "0", ")", ":", "for", "line", "in", "lines", ":", "self", ".", "write_line", "(", "line", ",", "level", ")" ]
Append multiple new lines
[ "Append", "multiple", "new", "lines" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L118-L122
pygobject/pgi
pgi/codegen/utils.py
CodeBlock.compile
def compile(self, **kwargs): """Execute the python code and returns the global dict. kwargs can contain extra dependencies that get only used at compile time. """ code = compile(str(self), "<string>", "exec") global_dict = dict(self._deps) global_dict.update(kwar...
python
def compile(self, **kwargs): """Execute the python code and returns the global dict. kwargs can contain extra dependencies that get only used at compile time. """ code = compile(str(self), "<string>", "exec") global_dict = dict(self._deps) global_dict.update(kwar...
[ "def", "compile", "(", "self", ",", "*", "*", "kwargs", ")", ":", "code", "=", "compile", "(", "str", "(", "self", ")", ",", "\"<string>\"", ",", "\"exec\"", ")", "global_dict", "=", "dict", "(", "self", ".", "_deps", ")", "global_dict", ".", "update...
Execute the python code and returns the global dict. kwargs can contain extra dependencies that get only used at compile time.
[ "Execute", "the", "python", "code", "and", "returns", "the", "global", "dict", ".", "kwargs", "can", "contain", "extra", "dependencies", "that", "get", "only", "used", "at", "compile", "time", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L124-L134
pygobject/pgi
pgi/codegen/utils.py
CodeBlock.pprint
def pprint(self, file_=sys.stdout): """Print the code block to stdout. Does syntax highlighting if possible. """ code = [] if self._deps: code.append("# dependencies:") for k, v in _compat.iteritems(self._deps): code.append("# %s: %r" % (k, v)) ...
python
def pprint(self, file_=sys.stdout): """Print the code block to stdout. Does syntax highlighting if possible. """ code = [] if self._deps: code.append("# dependencies:") for k, v in _compat.iteritems(self._deps): code.append("# %s: %r" % (k, v)) ...
[ "def", "pprint", "(", "self", ",", "file_", "=", "sys", ".", "stdout", ")", ":", "code", "=", "[", "]", "if", "self", ".", "_deps", ":", "code", ".", "append", "(", "\"# dependencies:\"", ")", "for", "k", ",", "v", "in", "_compat", ".", "iteritems"...
Print the code block to stdout. Does syntax highlighting if possible.
[ "Print", "the", "code", "block", "to", "stdout", ".", "Does", "syntax", "highlighting", "if", "possible", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/utils.py#L136-L161
pygobject/pgi
pgi/foreign/_base.py
ForeignStruct.register
def register(cls, namespace, name): """Class decorator""" def func(kind): cls._FOREIGN[(namespace, name)] = kind() return kind return func
python
def register(cls, namespace, name): """Class decorator""" def func(kind): cls._FOREIGN[(namespace, name)] = kind() return kind return func
[ "def", "register", "(", "cls", ",", "namespace", ",", "name", ")", ":", "def", "func", "(", "kind", ")", ":", "cls", ".", "_FOREIGN", "[", "(", "namespace", ",", "name", ")", "]", "=", "kind", "(", ")", "return", "kind", "return", "func" ]
Class decorator
[ "Class", "decorator" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/foreign/_base.py#L27-L33
pygobject/pgi
pgi/codegen/funcgen.py
may_be_null_is_nullable
def may_be_null_is_nullable(): """If may_be_null returns nullable or if NULL can be passed in. This can still be wrong if the specific typelib is older than the linked libgirepository. https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47 """ repo = GIRepository() repo.require("GLib", "2....
python
def may_be_null_is_nullable(): """If may_be_null returns nullable or if NULL can be passed in. This can still be wrong if the specific typelib is older than the linked libgirepository. https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47 """ repo = GIRepository() repo.require("GLib", "2....
[ "def", "may_be_null_is_nullable", "(", ")", ":", "repo", "=", "GIRepository", "(", ")", "repo", ".", "require", "(", "\"GLib\"", ",", "\"2.0\"", ",", "0", ")", "info", "=", "repo", ".", "find_by_name", "(", "\"GLib\"", ",", "\"spawn_sync\"", ")", "# this a...
If may_be_null returns nullable or if NULL can be passed in. This can still be wrong if the specific typelib is older than the linked libgirepository. https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47
[ "If", "may_be_null", "returns", "nullable", "or", "if", "NULL", "can", "be", "passed", "in", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L23-L36
pygobject/pgi
pgi/codegen/funcgen.py
get_type_name
def get_type_name(type_): """Gives a name for a type that is suitable for a docstring. int -> "int" Gtk.Window -> "Gtk.Window" [int] -> "[int]" {int: Gtk.Button} -> "{int: Gtk.Button}" """ if type_ is None: return "" if isinstance(type_, string_types): return type_ ...
python
def get_type_name(type_): """Gives a name for a type that is suitable for a docstring. int -> "int" Gtk.Window -> "Gtk.Window" [int] -> "[int]" {int: Gtk.Button} -> "{int: Gtk.Button}" """ if type_ is None: return "" if isinstance(type_, string_types): return type_ ...
[ "def", "get_type_name", "(", "type_", ")", ":", "if", "type_", "is", "None", ":", "return", "\"\"", "if", "isinstance", "(", "type_", ",", "string_types", ")", ":", "return", "type_", "elif", "isinstance", "(", "type_", ",", "list", ")", ":", "assert", ...
Gives a name for a type that is suitable for a docstring. int -> "int" Gtk.Window -> "Gtk.Window" [int] -> "[int]" {int: Gtk.Button} -> "{int: Gtk.Button}"
[ "Gives", "a", "name", "for", "a", "type", "that", "is", "suitable", "for", "a", "docstring", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L39-L62
pygobject/pgi
pgi/codegen/funcgen.py
build_docstring
def build_docstring(func_name, args, ret, throws, signal_owner_type=None): """Create a docstring in the form: name(in_name: type) -> (ret_type, out_name: type) """ out_args = [] if ret and not ret.ignore: if ret.py_type is None: out_args.append("unknown") else: ...
python
def build_docstring(func_name, args, ret, throws, signal_owner_type=None): """Create a docstring in the form: name(in_name: type) -> (ret_type, out_name: type) """ out_args = [] if ret and not ret.ignore: if ret.py_type is None: out_args.append("unknown") else: ...
[ "def", "build_docstring", "(", "func_name", ",", "args", ",", "ret", ",", "throws", ",", "signal_owner_type", "=", "None", ")", ":", "out_args", "=", "[", "]", "if", "ret", "and", "not", "ret", ".", "ignore", ":", "if", "ret", ".", "py_type", "is", "...
Create a docstring in the form: name(in_name: type) -> (ret_type, out_name: type)
[ "Create", "a", "docstring", "in", "the", "form", ":", "name", "(", "in_name", ":", "type", ")", "-", ">", "(", "ret_type", "out_name", ":", "type", ")" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L71-L132
pygobject/pgi
pgi/codegen/funcgen.py
generate_function
def generate_function(info, method=False): """Creates a Python callable for a GIFunctionInfo instance""" assert isinstance(info, GIFunctionInfo) arg_infos = list(info.get_args()) arg_types = [a.get_type() for a in arg_infos] return_type = info.get_return_type() func = None messages = [] ...
python
def generate_function(info, method=False): """Creates a Python callable for a GIFunctionInfo instance""" assert isinstance(info, GIFunctionInfo) arg_infos = list(info.get_args()) arg_types = [a.get_type() for a in arg_infos] return_type = info.get_return_type() func = None messages = [] ...
[ "def", "generate_function", "(", "info", ",", "method", "=", "False", ")", ":", "assert", "isinstance", "(", "info", ",", "GIFunctionInfo", ")", "arg_infos", "=", "list", "(", "info", ".", "get_args", "(", ")", ")", "arg_types", "=", "[", "a", ".", "ge...
Creates a Python callable for a GIFunctionInfo instance
[ "Creates", "a", "Python", "callable", "for", "a", "GIFunctionInfo", "instance" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L287-L311
pygobject/pgi
pgi/codegen/funcgen.py
generate_dummy_callable
def generate_dummy_callable(info, func_name, method=False, signal_owner_type=None): """Takes a GICallableInfo and generates a dummy callback function which just raises but has a correct docstring. They are mainly accessible for documentation, so the API reference can reference a ...
python
def generate_dummy_callable(info, func_name, method=False, signal_owner_type=None): """Takes a GICallableInfo and generates a dummy callback function which just raises but has a correct docstring. They are mainly accessible for documentation, so the API reference can reference a ...
[ "def", "generate_dummy_callable", "(", "info", ",", "func_name", ",", "method", "=", "False", ",", "signal_owner_type", "=", "None", ")", ":", "assert", "isinstance", "(", "info", ",", "GICallableInfo", ")", "# FIXME: handle out args and trailing user_data ?", "arg_in...
Takes a GICallableInfo and generates a dummy callback function which just raises but has a correct docstring. They are mainly accessible for documentation, so the API reference can reference a real thing. func_name can be different than info.name because vfuncs, for example, get prefixed with 'do_' whe...
[ "Takes", "a", "GICallableInfo", "and", "generates", "a", "dummy", "callback", "function", "which", "just", "raises", "but", "has", "a", "correct", "docstring", ".", "They", "are", "mainly", "accessible", "for", "documentation", "so", "the", "API", "reference", ...
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L314-L382
pygobject/pgi
pgi/cffilib/_utils.py
_create_enum_class
def _create_enum_class(ffi, type_name, prefix, flags=False): """Returns a new shiny class for the given enum type""" class _template(int): _map = {} @property def value(self): return int(self) def __str__(self): return self._map.get(self, "Unknown") ...
python
def _create_enum_class(ffi, type_name, prefix, flags=False): """Returns a new shiny class for the given enum type""" class _template(int): _map = {} @property def value(self): return int(self) def __str__(self): return self._map.get(self, "Unknown") ...
[ "def", "_create_enum_class", "(", "ffi", ",", "type_name", ",", "prefix", ",", "flags", "=", "False", ")", ":", "class", "_template", "(", "int", ")", ":", "_map", "=", "{", "}", "@", "property", "def", "value", "(", "self", ")", ":", "return", "int"...
Returns a new shiny class for the given enum type
[ "Returns", "a", "new", "shiny", "class", "for", "the", "given", "enum", "type" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/cffilib/_utils.py#L58-L108
pygobject/pgi
pgi/cffilib/_utils.py
_fixup_cdef_enums
def _fixup_cdef_enums(string, reg=re.compile(r"=\s*(\d+)\s*<<\s*(\d+)")): """Converts some common enum expressions to constants""" def repl_shift(match): shift_by = int(match.group(2)) value = int(match.group(1)) int_value = ctypes.c_int(value << shift_by).value return "= %s" % ...
python
def _fixup_cdef_enums(string, reg=re.compile(r"=\s*(\d+)\s*<<\s*(\d+)")): """Converts some common enum expressions to constants""" def repl_shift(match): shift_by = int(match.group(2)) value = int(match.group(1)) int_value = ctypes.c_int(value << shift_by).value return "= %s" % ...
[ "def", "_fixup_cdef_enums", "(", "string", ",", "reg", "=", "re", ".", "compile", "(", "r\"=\\s*(\\d+)\\s*<<\\s*(\\d+)\"", ")", ")", ":", "def", "repl_shift", "(", "match", ")", ":", "shift_by", "=", "int", "(", "match", ".", "group", "(", "2", ")", ")",...
Converts some common enum expressions to constants
[ "Converts", "some", "common", "enum", "expressions", "to", "constants" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/cffilib/_utils.py#L111-L119
pygobject/pgi
pgi/clib/glib.py
unpack_glist
def unpack_glist(g, type_, transfer_full=True): """Takes a glist, copies the values casted to type_ in to a list and frees all items and the list. """ values = [] item = g while item: ptr = item.contents.data value = cast(ptr, type_).value values.append(value) if...
python
def unpack_glist(g, type_, transfer_full=True): """Takes a glist, copies the values casted to type_ in to a list and frees all items and the list. """ values = [] item = g while item: ptr = item.contents.data value = cast(ptr, type_).value values.append(value) if...
[ "def", "unpack_glist", "(", "g", ",", "type_", ",", "transfer_full", "=", "True", ")", ":", "values", "=", "[", "]", "item", "=", "g", "while", "item", ":", "ptr", "=", "item", ".", "contents", ".", "data", "value", "=", "cast", "(", "ptr", ",", ...
Takes a glist, copies the values casted to type_ in to a list and frees all items and the list.
[ "Takes", "a", "glist", "copies", "the", "values", "casted", "to", "type_", "in", "to", "a", "list", "and", "frees", "all", "items", "and", "the", "list", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/glib.py#L281-L297
pygobject/pgi
pgi/clib/glib.py
unpack_nullterm_array
def unpack_nullterm_array(array): """Takes a null terminated array, copies the values into a list and frees each value and the list. """ addrs = cast(array, POINTER(ctypes.c_void_p)) l = [] i = 0 value = array[i] while value: l.append(value) free(addrs[i]) i += 1...
python
def unpack_nullterm_array(array): """Takes a null terminated array, copies the values into a list and frees each value and the list. """ addrs = cast(array, POINTER(ctypes.c_void_p)) l = [] i = 0 value = array[i] while value: l.append(value) free(addrs[i]) i += 1...
[ "def", "unpack_nullterm_array", "(", "array", ")", ":", "addrs", "=", "cast", "(", "array", ",", "POINTER", "(", "ctypes", ".", "c_void_p", ")", ")", "l", "=", "[", "]", "i", "=", "0", "value", "=", "array", "[", "i", "]", "while", "value", ":", ...
Takes a null terminated array, copies the values into a list and frees each value and the list.
[ "Takes", "a", "null", "terminated", "array", "copies", "the", "values", "into", "a", "list", "and", "frees", "each", "value", "and", "the", "list", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/clib/glib.py#L300-L315
pygobject/pgi
pgi/importer.py
require_version
def require_version(namespace, version): """Set a version for the namespace to be loaded. This needs to be called before importing the namespace or any namespace that depends on it. """ global _versions repo = GIRepository() namespaces = repo.get_loaded_namespaces() if namespace in na...
python
def require_version(namespace, version): """Set a version for the namespace to be loaded. This needs to be called before importing the namespace or any namespace that depends on it. """ global _versions repo = GIRepository() namespaces = repo.get_loaded_namespaces() if namespace in na...
[ "def", "require_version", "(", "namespace", ",", "version", ")", ":", "global", "_versions", "repo", "=", "GIRepository", "(", ")", "namespaces", "=", "repo", ".", "get_loaded_namespaces", "(", ")", "if", "namespace", "in", "namespaces", ":", "loaded_version", ...
Set a version for the namespace to be loaded. This needs to be called before importing the namespace or any namespace that depends on it.
[ "Set", "a", "version", "for", "the", "namespace", "to", "be", "loaded", ".", "This", "needs", "to", "be", "called", "before", "importing", "the", "namespace", "or", "any", "namespace", "that", "depends", "on", "it", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/importer.py#L23-L52
pygobject/pgi
pgi/importer.py
_check_require_version
def _check_require_version(namespace, stacklevel): """A context manager which tries to give helpful warnings about missing gi.require_version() which could potentially break code if only an older version than expected is installed or a new version gets introduced. :: with _check_require_ve...
python
def _check_require_version(namespace, stacklevel): """A context manager which tries to give helpful warnings about missing gi.require_version() which could potentially break code if only an older version than expected is installed or a new version gets introduced. :: with _check_require_ve...
[ "def", "_check_require_version", "(", "namespace", ",", "stacklevel", ")", ":", "repository", "=", "GIRepository", "(", ")", "was_loaded", "=", "repository", ".", "is_registered", "(", "namespace", ")", "yield", "if", "was_loaded", ":", "# it was loaded before by an...
A context manager which tries to give helpful warnings about missing gi.require_version() which could potentially break code if only an older version than expected is installed or a new version gets introduced. :: with _check_require_version("Gtk", stacklevel): load_namespace_and_o...
[ "A", "context", "manager", "which", "tries", "to", "give", "helpful", "warnings", "about", "missing", "gi", ".", "require_version", "()", "which", "could", "potentially", "break", "code", "if", "only", "an", "older", "version", "than", "expected", "is", "insta...
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/importer.py#L78-L114
pygobject/pgi
pgi/importer.py
get_import_stacklevel
def get_import_stacklevel(import_hook): """Returns the stacklevel value for warnings.warn() for when the warning gets emitted by an imported module, but the warning should point at the code doing the import. Pass import_hook=True if the warning gets generated by an import hook (warn() gets called i...
python
def get_import_stacklevel(import_hook): """Returns the stacklevel value for warnings.warn() for when the warning gets emitted by an imported module, but the warning should point at the code doing the import. Pass import_hook=True if the warning gets generated by an import hook (warn() gets called i...
[ "def", "get_import_stacklevel", "(", "import_hook", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", ":", "2", "]", "if", "py_version", "<=", "(", "3", ",", "2", ")", ":", "# 2.7 included", "return", "4", "if", "import_hook", "else", "2", "e...
Returns the stacklevel value for warnings.warn() for when the warning gets emitted by an imported module, but the warning should point at the code doing the import. Pass import_hook=True if the warning gets generated by an import hook (warn() gets called in load_module(), see PEP302)
[ "Returns", "the", "stacklevel", "value", "for", "warnings", ".", "warn", "()", "for", "when", "the", "warning", "gets", "emitted", "by", "an", "imported", "module", "but", "the", "warning", "should", "point", "at", "the", "code", "doing", "the", "import", ...
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/importer.py#L117-L136
pygobject/pgi
pgi/cffilib/glib/glib.py
unpack_glist
def unpack_glist(glist_ptr, cffi_type, transfer_full=True): """Takes a glist ptr, copies the values casted to type_ in to a list and frees all items and the list. If an item is returned all yielded before are invalid. """ current = glist_ptr while current: yield ffi.cast(cffi_type, cur...
python
def unpack_glist(glist_ptr, cffi_type, transfer_full=True): """Takes a glist ptr, copies the values casted to type_ in to a list and frees all items and the list. If an item is returned all yielded before are invalid. """ current = glist_ptr while current: yield ffi.cast(cffi_type, cur...
[ "def", "unpack_glist", "(", "glist_ptr", ",", "cffi_type", ",", "transfer_full", "=", "True", ")", ":", "current", "=", "glist_ptr", "while", "current", ":", "yield", "ffi", ".", "cast", "(", "cffi_type", ",", "current", ".", "data", ")", "if", "transfer_f...
Takes a glist ptr, copies the values casted to type_ in to a list and frees all items and the list. If an item is returned all yielded before are invalid.
[ "Takes", "a", "glist", "ptr", "copies", "the", "values", "casted", "to", "type_", "in", "to", "a", "list", "and", "frees", "all", "items", "and", "the", "list", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/cffilib/glib/glib.py#L227-L241
pygobject/pgi
pgi/cffilib/glib/glib.py
unpack_zeroterm_array
def unpack_zeroterm_array(ptr): """Converts a zero terminated array to a list and frees each element and the list itself. If an item is returned all yielded before are invalid. """ assert ptr index = 0 current = ptr[index] while current: yield current free(ffi.cast("gp...
python
def unpack_zeroterm_array(ptr): """Converts a zero terminated array to a list and frees each element and the list itself. If an item is returned all yielded before are invalid. """ assert ptr index = 0 current = ptr[index] while current: yield current free(ffi.cast("gp...
[ "def", "unpack_zeroterm_array", "(", "ptr", ")", ":", "assert", "ptr", "index", "=", "0", "current", "=", "ptr", "[", "index", "]", "while", "current", ":", "yield", "current", "free", "(", "ffi", ".", "cast", "(", "\"gpointer\"", ",", "current", ")", ...
Converts a zero terminated array to a list and frees each element and the list itself. If an item is returned all yielded before are invalid.
[ "Converts", "a", "zero", "terminated", "array", "to", "a", "list", "and", "frees", "each", "element", "and", "the", "list", "itself", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/cffilib/glib/glib.py#L244-L260
pygobject/pgi
pgi/structure.py
StructureAttribute
def StructureAttribute(struct_info): """Creates a new struct class.""" # Copy the template and add the gtype cls_dict = dict(_Structure.__dict__) cls = type(struct_info.name, _Structure.__bases__, cls_dict) cls.__module__ = struct_info.namespace cls.__gtype__ = PGType(struct_info.g_type) cl...
python
def StructureAttribute(struct_info): """Creates a new struct class.""" # Copy the template and add the gtype cls_dict = dict(_Structure.__dict__) cls = type(struct_info.name, _Structure.__bases__, cls_dict) cls.__module__ = struct_info.namespace cls.__gtype__ = PGType(struct_info.g_type) cl...
[ "def", "StructureAttribute", "(", "struct_info", ")", ":", "# Copy the template and add the gtype", "cls_dict", "=", "dict", "(", "_Structure", ".", "__dict__", ")", "cls", "=", "type", "(", "struct_info", ".", "name", ",", "_Structure", ".", "__bases__", ",", "...
Creates a new struct class.
[ "Creates", "a", "new", "struct", "class", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/structure.py#L110-L131
pygobject/pgi
pgi/gerror.py
PGError._from_gerror
def _from_gerror(cls, error, own=True): """Creates a GError exception and takes ownership if own is True""" if not own: error = error.copy() self = cls() self._error = error return self
python
def _from_gerror(cls, error, own=True): """Creates a GError exception and takes ownership if own is True""" if not own: error = error.copy() self = cls() self._error = error return self
[ "def", "_from_gerror", "(", "cls", ",", "error", ",", "own", "=", "True", ")", ":", "if", "not", "own", ":", "error", "=", "error", ".", "copy", "(", ")", "self", "=", "cls", "(", ")", "self", ".", "_error", "=", "error", "return", "self" ]
Creates a GError exception and takes ownership if own is True
[ "Creates", "a", "GError", "exception", "and", "takes", "ownership", "if", "own", "is", "True" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/gerror.py#L17-L25
pygobject/pgi
pgi/__init__.py
check_version
def check_version(version): """Takes a version string or tuple and raises ValueError in case the passed version is newer than the current version of pgi. Keep in mind that the pgi version is different from the pygobject one. """ if isinstance(version, string_types): version = tuple(map(int...
python
def check_version(version): """Takes a version string or tuple and raises ValueError in case the passed version is newer than the current version of pgi. Keep in mind that the pgi version is different from the pygobject one. """ if isinstance(version, string_types): version = tuple(map(int...
[ "def", "check_version", "(", "version", ")", ":", "if", "isinstance", "(", "version", ",", "string_types", ")", ":", "version", "=", "tuple", "(", "map", "(", "int", ",", "version", ".", "split", "(", "\".\"", ")", ")", ")", "if", "version", ">", "ve...
Takes a version string or tuple and raises ValueError in case the passed version is newer than the current version of pgi. Keep in mind that the pgi version is different from the pygobject one.
[ "Takes", "a", "version", "string", "or", "tuple", "and", "raises", "ValueError", "in", "case", "the", "passed", "version", "is", "newer", "than", "the", "current", "version", "of", "pgi", "." ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/__init__.py#L27-L40
pygobject/pgi
pgi/__init__.py
install_as_gi
def install_as_gi(): """Call before the first gi import to redirect gi imports to pgi""" import sys # check if gi has already been replaces if "gi.repository" in const.PREFIX: return # make sure gi isn't loaded first for mod in iterkeys(sys.modules): if mod == "gi" or mod.star...
python
def install_as_gi(): """Call before the first gi import to redirect gi imports to pgi""" import sys # check if gi has already been replaces if "gi.repository" in const.PREFIX: return # make sure gi isn't loaded first for mod in iterkeys(sys.modules): if mod == "gi" or mod.star...
[ "def", "install_as_gi", "(", ")", ":", "import", "sys", "# check if gi has already been replaces", "if", "\"gi.repository\"", "in", "const", ".", "PREFIX", ":", "return", "# make sure gi isn't loaded first", "for", "mod", "in", "iterkeys", "(", "sys", ".", "modules", ...
Call before the first gi import to redirect gi imports to pgi
[ "Call", "before", "the", "first", "gi", "import", "to", "redirect", "gi", "imports", "to", "pgi" ]
train
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/__init__.py#L43-L62