repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
heitzmann/gdspy
gdspy/__init__.py
PolygonSet.translate
def translate(self, dx, dy): """ Move the polygons from one place to another Parameters ---------- dx : number distance to move in the x-direction dy : number distance to move in the y-direction Returns ------- out : ``PolygonSet`` This object. """ vec = numpy.array((dx, dy)) self.polygons = [points + vec for points in self.polygons] return self
python
def translate(self, dx, dy): """ Move the polygons from one place to another Parameters ---------- dx : number distance to move in the x-direction dy : number distance to move in the y-direction Returns ------- out : ``PolygonSet`` This object. """ vec = numpy.array((dx, dy)) self.polygons = [points + vec for points in self.polygons] return self
[ "def", "translate", "(", "self", ",", "dx", ",", "dy", ")", ":", "vec", "=", "numpy", ".", "array", "(", "(", "dx", ",", "dy", ")", ")", "self", ".", "polygons", "=", "[", "points", "+", "vec", "for", "points", "in", "self", ".", "polygons", "]...
Move the polygons from one place to another Parameters ---------- dx : number distance to move in the x-direction dy : number distance to move in the y-direction Returns ------- out : ``PolygonSet`` This object.
[ "Move", "the", "polygons", "from", "one", "place", "to", "another" ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L470-L488
train
206,000
heitzmann/gdspy
gdspy/__init__.py
Label.to_gds
def to_gds(self, multiplier): """ Convert this label to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. Returns ------- out : string The GDSII binary string that represents this label. """ text = self.text if len(text) % 2 != 0: text = text + '\0' data = struct.pack('>11h', 4, 0x0C00, 6, 0x0D02, self.layer, 6, 0x1602, self.texttype, 6, 0x1701, self.anchor) if (self.rotation is not None) or (self.magnification is not None) or self.x_reflection: word = 0 values = b'' if self.x_reflection: word += 0x8000 if not (self.magnification is None): # This flag indicates that the magnification is absolute, not # relative (not supported). #word += 0x0004 values += struct.pack('>2h', 12, 0x1B05) + _eight_byte_real( self.magnification) if not (self.rotation is None): # This flag indicates that the rotation is absolute, not # relative (not supported). #word += 0x0002 values += struct.pack('>2h', 12, 0x1C05) + _eight_byte_real( self.rotation) data += struct.pack('>2hH', 6, 0x1A01, word) + values return data + struct.pack( '>2h2l2h', 12, 0x1003, int(round(self.position[0] * multiplier)), int(round(self.position[1] * multiplier)), 4 + len(text), 0x1906) + text.encode('ascii') + struct.pack('>2h', 4, 0x1100)
python
def to_gds(self, multiplier): """ Convert this label to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. Returns ------- out : string The GDSII binary string that represents this label. """ text = self.text if len(text) % 2 != 0: text = text + '\0' data = struct.pack('>11h', 4, 0x0C00, 6, 0x0D02, self.layer, 6, 0x1602, self.texttype, 6, 0x1701, self.anchor) if (self.rotation is not None) or (self.magnification is not None) or self.x_reflection: word = 0 values = b'' if self.x_reflection: word += 0x8000 if not (self.magnification is None): # This flag indicates that the magnification is absolute, not # relative (not supported). #word += 0x0004 values += struct.pack('>2h', 12, 0x1B05) + _eight_byte_real( self.magnification) if not (self.rotation is None): # This flag indicates that the rotation is absolute, not # relative (not supported). #word += 0x0002 values += struct.pack('>2h', 12, 0x1C05) + _eight_byte_real( self.rotation) data += struct.pack('>2hH', 6, 0x1A01, word) + values return data + struct.pack( '>2h2l2h', 12, 0x1003, int(round(self.position[0] * multiplier)), int(round(self.position[1] * multiplier)), 4 + len(text), 0x1906) + text.encode('ascii') + struct.pack('>2h', 4, 0x1100)
[ "def", "to_gds", "(", "self", ",", "multiplier", ")", ":", "text", "=", "self", ".", "text", "if", "len", "(", "text", ")", "%", "2", "!=", "0", ":", "text", "=", "text", "+", "'\\0'", "data", "=", "struct", ".", "pack", "(", "'>11h'", ",", "4"...
Convert this label to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. Returns ------- out : string The GDSII binary string that represents this label.
[ "Convert", "this", "label", "to", "a", "GDSII", "structure", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2043-L2085
train
206,001
heitzmann/gdspy
gdspy/__init__.py
Label.translate
def translate(self, dx, dy): """ Move the text from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``Label`` This object. Examples -------- >>> text = gdspy.Label((0, 0), (10, 20)) >>> text = text.translate(2, 0) >>> myCell.add(text) """ self.position = numpy.array((dx + self.position[0], dy + self.position[1])) return self
python
def translate(self, dx, dy): """ Move the text from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``Label`` This object. Examples -------- >>> text = gdspy.Label((0, 0), (10, 20)) >>> text = text.translate(2, 0) >>> myCell.add(text) """ self.position = numpy.array((dx + self.position[0], dy + self.position[1])) return self
[ "def", "translate", "(", "self", ",", "dx", ",", "dy", ")", ":", "self", ".", "position", "=", "numpy", ".", "array", "(", "(", "dx", "+", "self", ".", "position", "[", "0", "]", ",", "dy", "+", "self", ".", "position", "[", "1", "]", ")", ")...
Move the text from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``Label`` This object. Examples -------- >>> text = gdspy.Label((0, 0), (10, 20)) >>> text = text.translate(2, 0) >>> myCell.add(text)
[ "Move", "the", "text", "from", "one", "place", "to", "another" ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2087-L2112
train
206,002
heitzmann/gdspy
gdspy/__init__.py
Cell.to_gds
def to_gds(self, multiplier, timestamp=None): """ Convert this cell to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Returns ------- out : string The GDSII binary string that represents this cell. """ now = datetime.datetime.today() if timestamp is None else timestamp name = self.name if len(name) % 2 != 0: name = name + '\0' return struct.pack( '>16h', 28, 0x0502, now.year, now.month, now.day, now.hour, now.minute, now.second, now.year, now.month, now.day, now.hour, now.minute, now.second, 4 + len(name), 0x0606) + name.encode('ascii') + b''.join( element.to_gds(multiplier) for element in self.elements) + b''.join( label.to_gds(multiplier) for label in self.labels) + struct.pack('>2h', 4, 0x0700)
python
def to_gds(self, multiplier, timestamp=None): """ Convert this cell to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Returns ------- out : string The GDSII binary string that represents this cell. """ now = datetime.datetime.today() if timestamp is None else timestamp name = self.name if len(name) % 2 != 0: name = name + '\0' return struct.pack( '>16h', 28, 0x0502, now.year, now.month, now.day, now.hour, now.minute, now.second, now.year, now.month, now.day, now.hour, now.minute, now.second, 4 + len(name), 0x0606) + name.encode('ascii') + b''.join( element.to_gds(multiplier) for element in self.elements) + b''.join( label.to_gds(multiplier) for label in self.labels) + struct.pack('>2h', 4, 0x0700)
[ "def", "to_gds", "(", "self", ",", "multiplier", ",", "timestamp", "=", "None", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "today", "(", ")", "if", "timestamp", "is", "None", "else", "timestamp", "name", "=", "self", ".", "name", "if", "...
Convert this cell to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Returns ------- out : string The GDSII binary string that represents this cell.
[ "Convert", "this", "cell", "to", "a", "GDSII", "structure", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2152-L2182
train
206,003
heitzmann/gdspy
gdspy/__init__.py
Cell.copy
def copy(self, name, exclude_from_current=False, deep_copy=False): """ Creates a copy of this cell. Parameters ---------- name : string The name of the cell. exclude_from_current : bool If ``True``, the cell will not be included in the global list of cells maintained by ``gdspy``. deep_copy : bool If ``False``, the new cell will contain only references to the existing elements. If ``True``, copies of all elements are also created. Returns ------- out : ``Cell`` The new copy of this cell. """ new_cell = Cell(name, exclude_from_current) if deep_copy: new_cell.elements = libCopy.deepcopy(self.elements) new_cell.labels = libCopy.deepcopy(self.labels) for ref in new_cell.get_dependencies(True): if ref._bb_valid: ref._bb_valid = False else: new_cell.elements = list(self.elements) new_cell.labels = list(self.labels) return new_cell
python
def copy(self, name, exclude_from_current=False, deep_copy=False): """ Creates a copy of this cell. Parameters ---------- name : string The name of the cell. exclude_from_current : bool If ``True``, the cell will not be included in the global list of cells maintained by ``gdspy``. deep_copy : bool If ``False``, the new cell will contain only references to the existing elements. If ``True``, copies of all elements are also created. Returns ------- out : ``Cell`` The new copy of this cell. """ new_cell = Cell(name, exclude_from_current) if deep_copy: new_cell.elements = libCopy.deepcopy(self.elements) new_cell.labels = libCopy.deepcopy(self.labels) for ref in new_cell.get_dependencies(True): if ref._bb_valid: ref._bb_valid = False else: new_cell.elements = list(self.elements) new_cell.labels = list(self.labels) return new_cell
[ "def", "copy", "(", "self", ",", "name", ",", "exclude_from_current", "=", "False", ",", "deep_copy", "=", "False", ")", ":", "new_cell", "=", "Cell", "(", "name", ",", "exclude_from_current", ")", "if", "deep_copy", ":", "new_cell", ".", "elements", "=", ...
Creates a copy of this cell. Parameters ---------- name : string The name of the cell. exclude_from_current : bool If ``True``, the cell will not be included in the global list of cells maintained by ``gdspy``. deep_copy : bool If ``False``, the new cell will contain only references to the existing elements. If ``True``, copies of all elements are also created. Returns ------- out : ``Cell`` The new copy of this cell.
[ "Creates", "a", "copy", "of", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2184-L2215
train
206,004
heitzmann/gdspy
gdspy/__init__.py
Cell.add
def add(self, element): """ Add a new element or list of elements to this cell. Parameters ---------- element : object, list The element or list of elements to be inserted in this cell. Returns ------- out : ``Cell`` This cell. """ if isinstance(element, list): for e in element: if isinstance(e, Label): self.labels.append(e) else: self.elements.append(e) else: if isinstance(element, Label): self.labels.append(element) else: self.elements.append(element) self._bb_valid = False return self
python
def add(self, element): """ Add a new element or list of elements to this cell. Parameters ---------- element : object, list The element or list of elements to be inserted in this cell. Returns ------- out : ``Cell`` This cell. """ if isinstance(element, list): for e in element: if isinstance(e, Label): self.labels.append(e) else: self.elements.append(e) else: if isinstance(element, Label): self.labels.append(element) else: self.elements.append(element) self._bb_valid = False return self
[ "def", "add", "(", "self", ",", "element", ")", ":", "if", "isinstance", "(", "element", ",", "list", ")", ":", "for", "e", "in", "element", ":", "if", "isinstance", "(", "e", ",", "Label", ")", ":", "self", ".", "labels", ".", "append", "(", "e"...
Add a new element or list of elements to this cell. Parameters ---------- element : object, list The element or list of elements to be inserted in this cell. Returns ------- out : ``Cell`` This cell.
[ "Add", "a", "new", "element", "or", "list", "of", "elements", "to", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2217-L2243
train
206,005
heitzmann/gdspy
gdspy/__init__.py
Cell.remove_polygons
def remove_polygons(self, test): """ Remove polygons from this cell. The function or callable ``test`` is called for each polygon in the cell. If its return value evaluates to ``True``, the corresponding polygon is removed from the cell. Parameters ---------- test : callable Test function to query whether a polygon should be removed. The function is called with arguments: ``(points, layer, datatype)`` Returns ------- out : ``Cell`` This cell. Examples -------- Remove polygons in layer 1: >>> cell.remove_polygons(lambda pts, layer, datatype: ... layer == 1) Remove polygons with negative x coordinates: >>> cell.remove_polygons(lambda pts, layer, datatype: ... any(pts[:, 0] < 0)) """ empty = [] for element in self.elements: if isinstance(element, PolygonSet): ii = 0 while ii < len(element.polygons): if test(element.polygons[ii], element.layers[ii], element.datatypes[ii]): element.polygons.pop(ii) element.layers.pop(ii) element.datatypes.pop(ii) else: ii += 1 if len(element.polygons) == 0: empty.append(element) for element in empty: self.elements.remove(element) return self
python
def remove_polygons(self, test): """ Remove polygons from this cell. The function or callable ``test`` is called for each polygon in the cell. If its return value evaluates to ``True``, the corresponding polygon is removed from the cell. Parameters ---------- test : callable Test function to query whether a polygon should be removed. The function is called with arguments: ``(points, layer, datatype)`` Returns ------- out : ``Cell`` This cell. Examples -------- Remove polygons in layer 1: >>> cell.remove_polygons(lambda pts, layer, datatype: ... layer == 1) Remove polygons with negative x coordinates: >>> cell.remove_polygons(lambda pts, layer, datatype: ... any(pts[:, 0] < 0)) """ empty = [] for element in self.elements: if isinstance(element, PolygonSet): ii = 0 while ii < len(element.polygons): if test(element.polygons[ii], element.layers[ii], element.datatypes[ii]): element.polygons.pop(ii) element.layers.pop(ii) element.datatypes.pop(ii) else: ii += 1 if len(element.polygons) == 0: empty.append(element) for element in empty: self.elements.remove(element) return self
[ "def", "remove_polygons", "(", "self", ",", "test", ")", ":", "empty", "=", "[", "]", "for", "element", "in", "self", ".", "elements", ":", "if", "isinstance", "(", "element", ",", "PolygonSet", ")", ":", "ii", "=", "0", "while", "ii", "<", "len", ...
Remove polygons from this cell. The function or callable ``test`` is called for each polygon in the cell. If its return value evaluates to ``True``, the corresponding polygon is removed from the cell. Parameters ---------- test : callable Test function to query whether a polygon should be removed. The function is called with arguments: ``(points, layer, datatype)`` Returns ------- out : ``Cell`` This cell. Examples -------- Remove polygons in layer 1: >>> cell.remove_polygons(lambda pts, layer, datatype: ... layer == 1) Remove polygons with negative x coordinates: >>> cell.remove_polygons(lambda pts, layer, datatype: ... any(pts[:, 0] < 0))
[ "Remove", "polygons", "from", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2245-L2293
train
206,006
heitzmann/gdspy
gdspy/__init__.py
Cell.remove_labels
def remove_labels(self, test): """ Remove labels from this cell. The function or callable ``test`` is called for each label in the cell. If its return value evaluates to ``True``, the corresponding label is removed from the cell. Parameters ---------- test : callable Test function to query whether a label should be removed. The function is called with the label as the only argument. Returns ------- out : ``Cell`` This cell. Examples -------- Remove labels in layer 1: >>> cell.remove_labels(lambda lbl: lbl.layer == 1) """ ii = 0 while ii < len(self.labels): if test(self.labels[ii]): self.labels.pop(ii) else: ii += 1 return self
python
def remove_labels(self, test): """ Remove labels from this cell. The function or callable ``test`` is called for each label in the cell. If its return value evaluates to ``True``, the corresponding label is removed from the cell. Parameters ---------- test : callable Test function to query whether a label should be removed. The function is called with the label as the only argument. Returns ------- out : ``Cell`` This cell. Examples -------- Remove labels in layer 1: >>> cell.remove_labels(lambda lbl: lbl.layer == 1) """ ii = 0 while ii < len(self.labels): if test(self.labels[ii]): self.labels.pop(ii) else: ii += 1 return self
[ "def", "remove_labels", "(", "self", ",", "test", ")", ":", "ii", "=", "0", "while", "ii", "<", "len", "(", "self", ".", "labels", ")", ":", "if", "test", "(", "self", ".", "labels", "[", "ii", "]", ")", ":", "self", ".", "labels", ".", "pop", ...
Remove labels from this cell. The function or callable ``test`` is called for each label in the cell. If its return value evaluates to ``True``, the corresponding label is removed from the cell. Parameters ---------- test : callable Test function to query whether a label should be removed. The function is called with the label as the only argument. Returns ------- out : ``Cell`` This cell. Examples -------- Remove labels in layer 1: >>> cell.remove_labels(lambda lbl: lbl.layer == 1)
[ "Remove", "labels", "from", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2295-L2326
train
206,007
heitzmann/gdspy
gdspy/__init__.py
Cell.area
def area(self, by_spec=False): """ Calculate the total area of the elements on this cell, including cell references and arrays. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell. """ if by_spec: cell_area = {} for element in self.elements: element_area = element.area(True) for ll in element_area.keys(): if ll in cell_area: cell_area[ll] += element_area[ll] else: cell_area[ll] = element_area[ll] else: cell_area = 0 for element in self.elements: cell_area += element.area() return cell_area
python
def area(self, by_spec=False): """ Calculate the total area of the elements on this cell, including cell references and arrays. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell. """ if by_spec: cell_area = {} for element in self.elements: element_area = element.area(True) for ll in element_area.keys(): if ll in cell_area: cell_area[ll] += element_area[ll] else: cell_area[ll] = element_area[ll] else: cell_area = 0 for element in self.elements: cell_area += element.area() return cell_area
[ "def", "area", "(", "self", ",", "by_spec", "=", "False", ")", ":", "if", "by_spec", ":", "cell_area", "=", "{", "}", "for", "element", "in", "self", ".", "elements", ":", "element_area", "=", "element", ".", "area", "(", "True", ")", "for", "ll", ...
Calculate the total area of the elements on this cell, including cell references and arrays. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell.
[ "Calculate", "the", "total", "area", "of", "the", "elements", "on", "this", "cell", "including", "cell", "references", "and", "arrays", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2328-L2357
train
206,008
heitzmann/gdspy
gdspy/__init__.py
Cell.get_layers
def get_layers(self): """ Returns a set of layers in this cell. Returns ------- out : set Set of the layers used in this cell. """ layers = set() for element in self.elements: if isinstance(element, PolygonSet): layers.update(element.layers) elif isinstance(element, CellReference) or isinstance( element, CellArray): layers.update(element.ref_cell.get_layers()) for label in self.labels: layers.add(label.layer) return layers
python
def get_layers(self): """ Returns a set of layers in this cell. Returns ------- out : set Set of the layers used in this cell. """ layers = set() for element in self.elements: if isinstance(element, PolygonSet): layers.update(element.layers) elif isinstance(element, CellReference) or isinstance( element, CellArray): layers.update(element.ref_cell.get_layers()) for label in self.labels: layers.add(label.layer) return layers
[ "def", "get_layers", "(", "self", ")", ":", "layers", "=", "set", "(", ")", "for", "element", "in", "self", ".", "elements", ":", "if", "isinstance", "(", "element", ",", "PolygonSet", ")", ":", "layers", ".", "update", "(", "element", ".", "layers", ...
Returns a set of layers in this cell. Returns ------- out : set Set of the layers used in this cell.
[ "Returns", "a", "set", "of", "layers", "in", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2359-L2377
train
206,009
heitzmann/gdspy
gdspy/__init__.py
Cell.get_datatypes
def get_datatypes(self): """ Returns a set of datatypes in this cell. Returns ------- out : set Set of the datatypes used in this cell. """ datatypes = set() for element in self.elements: if isinstance(element, PolygonSet): datatypes.update(element.datatypes) elif isinstance(element, CellReference) or isinstance( element, CellArray): datatypes.update(element.ref_cell.get_datatypes()) return datatypes
python
def get_datatypes(self): """ Returns a set of datatypes in this cell. Returns ------- out : set Set of the datatypes used in this cell. """ datatypes = set() for element in self.elements: if isinstance(element, PolygonSet): datatypes.update(element.datatypes) elif isinstance(element, CellReference) or isinstance( element, CellArray): datatypes.update(element.ref_cell.get_datatypes()) return datatypes
[ "def", "get_datatypes", "(", "self", ")", ":", "datatypes", "=", "set", "(", ")", "for", "element", "in", "self", ".", "elements", ":", "if", "isinstance", "(", "element", ",", "PolygonSet", ")", ":", "datatypes", ".", "update", "(", "element", ".", "d...
Returns a set of datatypes in this cell. Returns ------- out : set Set of the datatypes used in this cell.
[ "Returns", "a", "set", "of", "datatypes", "in", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2379-L2395
train
206,010
heitzmann/gdspy
gdspy/__init__.py
Cell.get_bounding_box
def get_bounding_box(self): """ Returns the bounding box for this cell. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty. """ if len(self.elements) == 0: return None if not (self._bb_valid and all(ref._bb_valid for ref in self.get_dependencies(True))): bb = numpy.array(((1e300, 1e300), (-1e300, -1e300))) all_polygons = [] for element in self.elements: if isinstance(element, PolygonSet): all_polygons.extend(element.polygons) elif isinstance(element, CellReference) or isinstance( element, CellArray): element_bb = element.get_bounding_box() if element_bb is not None: bb[0, 0] = min(bb[0, 0], element_bb[0, 0]) bb[0, 1] = min(bb[0, 1], element_bb[0, 1]) bb[1, 0] = max(bb[1, 0], element_bb[1, 0]) bb[1, 1] = max(bb[1, 1], element_bb[1, 1]) if len(all_polygons) > 0: all_points = numpy.concatenate(all_polygons).transpose() bb[0, 0] = min(bb[0, 0], all_points[0].min()) bb[0, 1] = min(bb[0, 1], all_points[1].min()) bb[1, 0] = max(bb[1, 0], all_points[0].max()) bb[1, 1] = max(bb[1, 1], all_points[1].max()) self._bb_valid = True _bounding_boxes[self] = bb return _bounding_boxes[self]
python
def get_bounding_box(self): """ Returns the bounding box for this cell. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty. """ if len(self.elements) == 0: return None if not (self._bb_valid and all(ref._bb_valid for ref in self.get_dependencies(True))): bb = numpy.array(((1e300, 1e300), (-1e300, -1e300))) all_polygons = [] for element in self.elements: if isinstance(element, PolygonSet): all_polygons.extend(element.polygons) elif isinstance(element, CellReference) or isinstance( element, CellArray): element_bb = element.get_bounding_box() if element_bb is not None: bb[0, 0] = min(bb[0, 0], element_bb[0, 0]) bb[0, 1] = min(bb[0, 1], element_bb[0, 1]) bb[1, 0] = max(bb[1, 0], element_bb[1, 0]) bb[1, 1] = max(bb[1, 1], element_bb[1, 1]) if len(all_polygons) > 0: all_points = numpy.concatenate(all_polygons).transpose() bb[0, 0] = min(bb[0, 0], all_points[0].min()) bb[0, 1] = min(bb[0, 1], all_points[1].min()) bb[1, 0] = max(bb[1, 0], all_points[0].max()) bb[1, 1] = max(bb[1, 1], all_points[1].max()) self._bb_valid = True _bounding_boxes[self] = bb return _bounding_boxes[self]
[ "def", "get_bounding_box", "(", "self", ")", ":", "if", "len", "(", "self", ".", "elements", ")", "==", "0", ":", "return", "None", "if", "not", "(", "self", ".", "_bb_valid", "and", "all", "(", "ref", ".", "_bb_valid", "for", "ref", "in", "self", ...
Returns the bounding box for this cell. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty.
[ "Returns", "the", "bounding", "box", "for", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2397-L2432
train
206,011
heitzmann/gdspy
gdspy/__init__.py
Cell.get_polygons
def get_polygons(self, by_spec=False, depth=None): """ Returns a list of polygons in this cell. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If ``by_spec`` is ``True`` the key will be the name of this cell. Returns ------- out : list of array-like[N][2] or dictionary List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if ``by_spec`` is ``True``). """ if depth is not None and depth < 0: bb = self.get_bounding_box() if bb is None: return {} if by_spec else [] pts = [ numpy.array([(bb[0, 0], bb[0, 1]), (bb[0, 0], bb[1, 1]), (bb[1, 0], bb[1, 1]), (bb[1, 0], bb[0, 1])]) ] polygons = {self.name: pts} if by_spec else pts else: if by_spec: polygons = {} for element in self.elements: if isinstance(element, PolygonSet): for ii in range(len(element.polygons)): key = (element.layers[ii], element.datatypes[ii]) if key in polygons: polygons[key].append( numpy.array(element.polygons[ii])) else: polygons[key] = [ numpy.array(element.polygons[ii]) ] else: cell_polygons = element.get_polygons( True, None if depth is None else depth - 1) for kk in cell_polygons.keys(): if kk in polygons: polygons[kk].extend(cell_polygons[kk]) else: polygons[kk] = cell_polygons[kk] else: polygons = [] for element in self.elements: if isinstance(element, PolygonSet): for points in element.polygons: polygons.append(numpy.array(points)) else: polygons.extend( element.get_polygons( depth=None if depth is None else depth - 1)) return polygons
python
def get_polygons(self, by_spec=False, depth=None): """ Returns a list of polygons in this cell. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If ``by_spec`` is ``True`` the key will be the name of this cell. Returns ------- out : list of array-like[N][2] or dictionary List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if ``by_spec`` is ``True``). """ if depth is not None and depth < 0: bb = self.get_bounding_box() if bb is None: return {} if by_spec else [] pts = [ numpy.array([(bb[0, 0], bb[0, 1]), (bb[0, 0], bb[1, 1]), (bb[1, 0], bb[1, 1]), (bb[1, 0], bb[0, 1])]) ] polygons = {self.name: pts} if by_spec else pts else: if by_spec: polygons = {} for element in self.elements: if isinstance(element, PolygonSet): for ii in range(len(element.polygons)): key = (element.layers[ii], element.datatypes[ii]) if key in polygons: polygons[key].append( numpy.array(element.polygons[ii])) else: polygons[key] = [ numpy.array(element.polygons[ii]) ] else: cell_polygons = element.get_polygons( True, None if depth is None else depth - 1) for kk in cell_polygons.keys(): if kk in polygons: polygons[kk].extend(cell_polygons[kk]) else: polygons[kk] = cell_polygons[kk] else: polygons = [] for element in self.elements: if isinstance(element, PolygonSet): for points in element.polygons: polygons.append(numpy.array(points)) else: polygons.extend( element.get_polygons( depth=None if depth is None else depth - 1)) return polygons
[ "def", "get_polygons", "(", "self", ",", "by_spec", "=", "False", ",", "depth", "=", "None", ")", ":", "if", "depth", "is", "not", "None", "and", "depth", "<", "0", ":", "bb", "=", "self", ".", "get_bounding_box", "(", ")", "if", "bb", "is", "None"...
Returns a list of polygons in this cell. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If ``by_spec`` is ``True`` the key will be the name of this cell. Returns ------- out : list of array-like[N][2] or dictionary List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if ``by_spec`` is ``True``).
[ "Returns", "a", "list", "of", "polygons", "in", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2434-L2497
train
206,012
heitzmann/gdspy
gdspy/__init__.py
Cell.get_labels
def get_labels(self, depth=None): """ Returns a list with a copy of the labels in this cell. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List containing the labels in this cell and its references. """ labels = libCopy.deepcopy(self.labels) if depth is None or depth > 0: for element in self.elements: if isinstance(element, CellReference): labels.extend( element.get_labels(None if depth is None else depth - 1)) elif isinstance(element, CellArray): labels.extend( element.get_labels(None if depth is None else depth - 1)) return labels
python
def get_labels(self, depth=None): """ Returns a list with a copy of the labels in this cell. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List containing the labels in this cell and its references. """ labels = libCopy.deepcopy(self.labels) if depth is None or depth > 0: for element in self.elements: if isinstance(element, CellReference): labels.extend( element.get_labels(None if depth is None else depth - 1)) elif isinstance(element, CellArray): labels.extend( element.get_labels(None if depth is None else depth - 1)) return labels
[ "def", "get_labels", "(", "self", ",", "depth", "=", "None", ")", ":", "labels", "=", "libCopy", ".", "deepcopy", "(", "self", ".", "labels", ")", "if", "depth", "is", "None", "or", "depth", ">", "0", ":", "for", "element", "in", "self", ".", "elem...
Returns a list with a copy of the labels in this cell. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List containing the labels in this cell and its references.
[ "Returns", "a", "list", "with", "a", "copy", "of", "the", "labels", "in", "this", "cell", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2499-L2525
train
206,013
heitzmann/gdspy
gdspy/__init__.py
Cell.get_dependencies
def get_dependencies(self, recursive=False): """ Returns a list of the cells included in this cell as references. Parameters ---------- recursive : bool If True returns cascading dependencies. Returns ------- out : set of ``Cell`` List of the cells referenced by this cell. """ dependencies = set() for element in self.elements: if isinstance(element, CellReference) or isinstance( element, CellArray): if recursive: dependencies.update( element.ref_cell.get_dependencies(True)) dependencies.add(element.ref_cell) return dependencies
python
def get_dependencies(self, recursive=False): """ Returns a list of the cells included in this cell as references. Parameters ---------- recursive : bool If True returns cascading dependencies. Returns ------- out : set of ``Cell`` List of the cells referenced by this cell. """ dependencies = set() for element in self.elements: if isinstance(element, CellReference) or isinstance( element, CellArray): if recursive: dependencies.update( element.ref_cell.get_dependencies(True)) dependencies.add(element.ref_cell) return dependencies
[ "def", "get_dependencies", "(", "self", ",", "recursive", "=", "False", ")", ":", "dependencies", "=", "set", "(", ")", "for", "element", "in", "self", ".", "elements", ":", "if", "isinstance", "(", "element", ",", "CellReference", ")", "or", "isinstance",...
Returns a list of the cells included in this cell as references. Parameters ---------- recursive : bool If True returns cascading dependencies. Returns ------- out : set of ``Cell`` List of the cells referenced by this cell.
[ "Returns", "a", "list", "of", "the", "cells", "included", "in", "this", "cell", "as", "references", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2527-L2549
train
206,014
heitzmann/gdspy
gdspy/__init__.py
Cell.flatten
def flatten(self, single_layer=None, single_datatype=None, single_texttype=None): """ Flatten all ``CellReference`` and ``CellArray`` elements in this cell into real polygons and labels, instead of references. Parameters ---------- single_layer : integer or None If not ``None``, all polygons will be transfered to the layer indicated by this number. single_datatype : integer or None If not ``None``, all polygons will be transfered to the datatype indicated by this number. single_datatype : integer or None If not ``None``, all labels will be transfered to the texttype indicated by this number. Returns ------- out : ``Cell`` This cell. """ self.labels = self.get_labels() if single_layer is not None: for lbl in self.labels: lbl.layer = single_layer if single_texttype is not None: for lbl in self.labels: lbl.texttype = single_texttype if single_layer is None or single_datatype is None: poly_dic = self.get_polygons(True) self.elements = [] if single_layer is None and single_datatype is None: for ld in poly_dic.keys(): self.add(PolygonSet(poly_dic[ld], *ld, verbose=False)) elif single_layer is None: for ld in poly_dic.keys(): self.add( PolygonSet( poly_dic[ld], ld[0], single_datatype, verbose=False)) else: for ld in poly_dic.keys(): self.add( PolygonSet( poly_dic[ld], single_layer, ld[1], verbose=False)) else: polygons = self.get_polygons() self.elements = [] self.add( PolygonSet( polygons, single_layer, single_datatype, verbose=False)) return self
python
def flatten(self, single_layer=None, single_datatype=None, single_texttype=None): """ Flatten all ``CellReference`` and ``CellArray`` elements in this cell into real polygons and labels, instead of references. Parameters ---------- single_layer : integer or None If not ``None``, all polygons will be transfered to the layer indicated by this number. single_datatype : integer or None If not ``None``, all polygons will be transfered to the datatype indicated by this number. single_datatype : integer or None If not ``None``, all labels will be transfered to the texttype indicated by this number. Returns ------- out : ``Cell`` This cell. """ self.labels = self.get_labels() if single_layer is not None: for lbl in self.labels: lbl.layer = single_layer if single_texttype is not None: for lbl in self.labels: lbl.texttype = single_texttype if single_layer is None or single_datatype is None: poly_dic = self.get_polygons(True) self.elements = [] if single_layer is None and single_datatype is None: for ld in poly_dic.keys(): self.add(PolygonSet(poly_dic[ld], *ld, verbose=False)) elif single_layer is None: for ld in poly_dic.keys(): self.add( PolygonSet( poly_dic[ld], ld[0], single_datatype, verbose=False)) else: for ld in poly_dic.keys(): self.add( PolygonSet( poly_dic[ld], single_layer, ld[1], verbose=False)) else: polygons = self.get_polygons() self.elements = [] self.add( PolygonSet( polygons, single_layer, single_datatype, verbose=False)) return self
[ "def", "flatten", "(", "self", ",", "single_layer", "=", "None", ",", "single_datatype", "=", "None", ",", "single_texttype", "=", "None", ")", ":", "self", ".", "labels", "=", "self", ".", "get_labels", "(", ")", "if", "single_layer", "is", "not", "None...
Flatten all ``CellReference`` and ``CellArray`` elements in this cell into real polygons and labels, instead of references. Parameters ---------- single_layer : integer or None If not ``None``, all polygons will be transfered to the layer indicated by this number. single_datatype : integer or None If not ``None``, all polygons will be transfered to the datatype indicated by this number. single_datatype : integer or None If not ``None``, all labels will be transfered to the texttype indicated by this number. Returns ------- out : ``Cell`` This cell.
[ "Flatten", "all", "CellReference", "and", "CellArray", "elements", "in", "this", "cell", "into", "real", "polygons", "and", "labels", "instead", "of", "references", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2551-L2608
train
206,015
heitzmann/gdspy
gdspy/__init__.py
CellReference.area
def area(self, by_spec=False): """ Calculate the total area of the referenced cell with the magnification factor included. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell. """ if not isinstance(self.ref_cell, Cell): return dict() if by_spec else 0 if self.magnification is None: return self.ref_cell.area(by_spec) else: if by_spec: factor = self.magnification**2 cell_area = self.ref_cell.area(True) for kk in cell_area.keys(): cell_area[kk] *= factor return cell_area else: return self.ref_cell.area() * self.magnification**2
python
def area(self, by_spec=False): """ Calculate the total area of the referenced cell with the magnification factor included. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell. """ if not isinstance(self.ref_cell, Cell): return dict() if by_spec else 0 if self.magnification is None: return self.ref_cell.area(by_spec) else: if by_spec: factor = self.magnification**2 cell_area = self.ref_cell.area(True) for kk in cell_area.keys(): cell_area[kk] *= factor return cell_area else: return self.ref_cell.area() * self.magnification**2
[ "def", "area", "(", "self", ",", "by_spec", "=", "False", ")", ":", "if", "not", "isinstance", "(", "self", ".", "ref_cell", ",", "Cell", ")", ":", "return", "dict", "(", ")", "if", "by_spec", "else", "0", "if", "self", ".", "magnification", "is", ...
Calculate the total area of the referenced cell with the magnification factor included. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell.
[ "Calculate", "the", "total", "area", "of", "the", "referenced", "cell", "with", "the", "magnification", "factor", "included", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2713-L2741
train
206,016
heitzmann/gdspy
gdspy/__init__.py
CellReference.get_bounding_box
def get_bounding_box(self): """ Returns the bounding box for this reference. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty. """ if not isinstance(self.ref_cell, Cell): return None if (self.rotation is None and self.magnification is None and self.x_reflection is None): key = self else: key = (self.ref_cell, self.rotation, self.magnification, self.x_reflection) deps = self.ref_cell.get_dependencies(True) if not (self.ref_cell._bb_valid and all(ref._bb_valid for ref in deps) and key in _bounding_boxes): for ref in deps: ref.get_bounding_box() self.ref_cell.get_bounding_box() tmp = self.origin self.origin = None polygons = self.get_polygons() self.origin = tmp if len(polygons) == 0: bb = None else: all_points = numpy.concatenate(polygons).transpose() bb = numpy.array(((all_points[0].min(), all_points[1].min()), (all_points[0].max(), all_points[1].max()))) _bounding_boxes[key] = bb else: bb = _bounding_boxes[key] if self.origin is None or bb is None: return bb else: return bb + numpy.array(((self.origin[0], self.origin[1]), (self.origin[0], self.origin[1])))
python
def get_bounding_box(self): """ Returns the bounding box for this reference. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty. """ if not isinstance(self.ref_cell, Cell): return None if (self.rotation is None and self.magnification is None and self.x_reflection is None): key = self else: key = (self.ref_cell, self.rotation, self.magnification, self.x_reflection) deps = self.ref_cell.get_dependencies(True) if not (self.ref_cell._bb_valid and all(ref._bb_valid for ref in deps) and key in _bounding_boxes): for ref in deps: ref.get_bounding_box() self.ref_cell.get_bounding_box() tmp = self.origin self.origin = None polygons = self.get_polygons() self.origin = tmp if len(polygons) == 0: bb = None else: all_points = numpy.concatenate(polygons).transpose() bb = numpy.array(((all_points[0].min(), all_points[1].min()), (all_points[0].max(), all_points[1].max()))) _bounding_boxes[key] = bb else: bb = _bounding_boxes[key] if self.origin is None or bb is None: return bb else: return bb + numpy.array(((self.origin[0], self.origin[1]), (self.origin[0], self.origin[1])))
[ "def", "get_bounding_box", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "ref_cell", ",", "Cell", ")", ":", "return", "None", "if", "(", "self", ".", "rotation", "is", "None", "and", "self", ".", "magnification", "is", "None", "an...
Returns the bounding box for this reference. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty.
[ "Returns", "the", "bounding", "box", "for", "this", "reference", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2843-L2884
train
206,017
heitzmann/gdspy
gdspy/__init__.py
CellReference.translate
def translate(self, dx, dy): """ Move the reference from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``CellReference`` This object. """ self.origin = (self.origin[0] + dx, self.origin[1] + dy) return self
python
def translate(self, dx, dy): """ Move the reference from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``CellReference`` This object. """ self.origin = (self.origin[0] + dx, self.origin[1] + dy) return self
[ "def", "translate", "(", "self", ",", "dx", ",", "dy", ")", ":", "self", ".", "origin", "=", "(", "self", ".", "origin", "[", "0", "]", "+", "dx", ",", "self", ".", "origin", "[", "1", "]", "+", "dy", ")", "return", "self" ]
Move the reference from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``CellReference`` This object.
[ "Move", "the", "reference", "from", "one", "place", "to", "another" ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2886-L2903
train
206,018
heitzmann/gdspy
gdspy/__init__.py
GdsLibrary.add
def add(self, cell, overwrite_duplicate=False): """ Add one or more cells to the library. Parameters ---------- cell : ``Cell`` of list of ``Cell`` Cells to be included in the library. overwrite_duplicate : bool If True an existing cell with the same name in the library will be overwritten. Returns ------- out : ``GdsLibrary`` This object. """ if isinstance(cell, Cell): if (not overwrite_duplicate and cell.name in self.cell_dict and self.cell_dict[cell.name] is not cell): raise ValueError("[GDSPY] cell named {0} already present in " "library.".format(cell.name)) self.cell_dict[cell.name] = cell else: for c in cell: if (not overwrite_duplicate and c.name in self.cell_dict and self.cell_dict[c.name] is not c): raise ValueError("[GDSPY] cell named {0} already present " "in library.".format(c.name)) self.cell_dict[c.name] = c return self
python
def add(self, cell, overwrite_duplicate=False): """ Add one or more cells to the library. Parameters ---------- cell : ``Cell`` of list of ``Cell`` Cells to be included in the library. overwrite_duplicate : bool If True an existing cell with the same name in the library will be overwritten. Returns ------- out : ``GdsLibrary`` This object. """ if isinstance(cell, Cell): if (not overwrite_duplicate and cell.name in self.cell_dict and self.cell_dict[cell.name] is not cell): raise ValueError("[GDSPY] cell named {0} already present in " "library.".format(cell.name)) self.cell_dict[cell.name] = cell else: for c in cell: if (not overwrite_duplicate and c.name in self.cell_dict and self.cell_dict[c.name] is not c): raise ValueError("[GDSPY] cell named {0} already present " "in library.".format(c.name)) self.cell_dict[c.name] = c return self
[ "def", "add", "(", "self", ",", "cell", ",", "overwrite_duplicate", "=", "False", ")", ":", "if", "isinstance", "(", "cell", ",", "Cell", ")", ":", "if", "(", "not", "overwrite_duplicate", "and", "cell", ".", "name", "in", "self", ".", "cell_dict", "an...
Add one or more cells to the library. Parameters ---------- cell : ``Cell`` of list of ``Cell`` Cells to be included in the library. overwrite_duplicate : bool If True an existing cell with the same name in the library will be overwritten. Returns ------- out : ``GdsLibrary`` This object.
[ "Add", "one", "or", "more", "cells", "to", "the", "library", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3322-L3352
train
206,019
heitzmann/gdspy
gdspy/__init__.py
GdsLibrary.write_gds
def write_gds(self, outfile, cells=None, timestamp=None): """ Write the GDSII library to a file. The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio ``unit/precision``. For example, if a circle with radius 1.5 is created and we set ``unit=1.0e-6`` (1 um) and ``precision=1.0e-9`` (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. Parameters ---------- outfile : file or string The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. cells : array-like The list of cells or cell names to be included in the library. If ``None``, all cells are used. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Notes ----- Only the specified cells are written. The user is responsible for ensuring all cell dependencies are satisfied. """ if isinstance(outfile, basestring): outfile = open(outfile, 'wb') close = True else: close = False now = datetime.datetime.today() if timestamp is None else timestamp name = self.name if len(self.name) % 2 == 0 else (self.name + '\0') outfile.write( struct.pack('>19h', 6, 0x0002, 0x0258, 28, 0x0102, now.year, now.month, now.day, now.hour, now.minute, now.second, now.year, now.month, now.day, now.hour, now.minute, now.second, 4 + len(name), 0x0206) + name.encode('ascii') + struct.pack('>2h', 20, 0x0305) + _eight_byte_real(self.precision / self.unit) + _eight_byte_real(self.precision)) if cells is None: cells = self.cell_dict.values() else: cells = [self.cell_dict.get(c, c) for c in cells] for cell in cells: outfile.write(cell.to_gds(self.unit / self.precision)) outfile.write(struct.pack('>2h', 4, 0x0400)) if close: outfile.close()
python
def write_gds(self, outfile, cells=None, timestamp=None): """ Write the GDSII library to a file. The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio ``unit/precision``. For example, if a circle with radius 1.5 is created and we set ``unit=1.0e-6`` (1 um) and ``precision=1.0e-9`` (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. Parameters ---------- outfile : file or string The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. cells : array-like The list of cells or cell names to be included in the library. If ``None``, all cells are used. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Notes ----- Only the specified cells are written. The user is responsible for ensuring all cell dependencies are satisfied. """ if isinstance(outfile, basestring): outfile = open(outfile, 'wb') close = True else: close = False now = datetime.datetime.today() if timestamp is None else timestamp name = self.name if len(self.name) % 2 == 0 else (self.name + '\0') outfile.write( struct.pack('>19h', 6, 0x0002, 0x0258, 28, 0x0102, now.year, now.month, now.day, now.hour, now.minute, now.second, now.year, now.month, now.day, now.hour, now.minute, now.second, 4 + len(name), 0x0206) + name.encode('ascii') + struct.pack('>2h', 20, 0x0305) + _eight_byte_real(self.precision / self.unit) + _eight_byte_real(self.precision)) if cells is None: cells = self.cell_dict.values() else: cells = [self.cell_dict.get(c, c) for c in cells] for cell in cells: outfile.write(cell.to_gds(self.unit / self.precision)) outfile.write(struct.pack('>2h', 4, 0x0400)) if close: outfile.close()
[ "def", "write_gds", "(", "self", ",", "outfile", ",", "cells", "=", "None", ",", "timestamp", "=", "None", ")", ":", "if", "isinstance", "(", "outfile", ",", "basestring", ")", ":", "outfile", "=", "open", "(", "outfile", ",", "'wb'", ")", "close", "...
Write the GDSII library to a file. The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio ``unit/precision``. For example, if a circle with radius 1.5 is created and we set ``unit=1.0e-6`` (1 um) and ``precision=1.0e-9`` (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. Parameters ---------- outfile : file or string The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. cells : array-like The list of cells or cell names to be included in the library. If ``None``, all cells are used. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Notes ----- Only the specified cells are written. The user is responsible for ensuring all cell dependencies are satisfied.
[ "Write", "the", "GDSII", "library", "to", "a", "file", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3354-L3405
train
206,020
heitzmann/gdspy
gdspy/__init__.py
GdsLibrary._read_record
def _read_record(self, stream): """ Read a complete record from a GDSII stream file. Parameters ---------- stream : file GDSII stream file to be imported. Returns ------- out : 2-tuple Record type and data (as a numpy.array) """ header = stream.read(4) if len(header) < 4: return None size, rec_type = struct.unpack('>HH', header) data_type = (rec_type & 0x00ff) rec_type = rec_type // 256 data = None if size > 4: if data_type == 0x01: data = numpy.array( struct.unpack('>{0}H'.format((size - 4) // 2), stream.read(size - 4)), dtype='uint') elif data_type == 0x02: data = numpy.array( struct.unpack('>{0}h'.format((size - 4) // 2), stream.read(size - 4)), dtype='int') elif data_type == 0x03: data = numpy.array( struct.unpack('>{0}l'.format((size - 4) // 4), stream.read(size - 4)), dtype='int') elif data_type == 0x05: data = numpy.array([ _eight_byte_real_to_float(stream.read(8)) for _ in range((size - 4) // 8) ]) else: data = stream.read(size - 4) if str is not bytes: if data[-1] == 0: data = data[:-1].decode('ascii') else: data = data.decode('ascii') elif data[-1] == '\0': data = data[:-1] return [rec_type, data]
python
def _read_record(self, stream): """ Read a complete record from a GDSII stream file. Parameters ---------- stream : file GDSII stream file to be imported. Returns ------- out : 2-tuple Record type and data (as a numpy.array) """ header = stream.read(4) if len(header) < 4: return None size, rec_type = struct.unpack('>HH', header) data_type = (rec_type & 0x00ff) rec_type = rec_type // 256 data = None if size > 4: if data_type == 0x01: data = numpy.array( struct.unpack('>{0}H'.format((size - 4) // 2), stream.read(size - 4)), dtype='uint') elif data_type == 0x02: data = numpy.array( struct.unpack('>{0}h'.format((size - 4) // 2), stream.read(size - 4)), dtype='int') elif data_type == 0x03: data = numpy.array( struct.unpack('>{0}l'.format((size - 4) // 4), stream.read(size - 4)), dtype='int') elif data_type == 0x05: data = numpy.array([ _eight_byte_real_to_float(stream.read(8)) for _ in range((size - 4) // 8) ]) else: data = stream.read(size - 4) if str is not bytes: if data[-1] == 0: data = data[:-1].decode('ascii') else: data = data.decode('ascii') elif data[-1] == '\0': data = data[:-1] return [rec_type, data]
[ "def", "_read_record", "(", "self", ",", "stream", ")", ":", "header", "=", "stream", ".", "read", "(", "4", ")", "if", "len", "(", "header", ")", "<", "4", ":", "return", "None", "size", ",", "rec_type", "=", "struct", ".", "unpack", "(", "'>HH'",...
Read a complete record from a GDSII stream file. Parameters ---------- stream : file GDSII stream file to be imported. Returns ------- out : 2-tuple Record type and data (as a numpy.array)
[ "Read", "a", "complete", "record", "from", "a", "GDSII", "stream", "file", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3599-L3650
train
206,021
heitzmann/gdspy
gdspy/__init__.py
GdsLibrary.extract
def extract(self, cell): """ Extract a cell from the this GDSII file and include it in the current global library, including referenced dependencies. Parameters ---------- cell : ``Cell`` or string Cell or name of the cell to be extracted from the imported file. Referenced cells will be automatically extracted as well. Returns ------- out : ``Cell`` The extracted cell. """ cell = self.cell_dict.get(cell, cell) current_library.add(cell) current_library.add(cell.get_dependencies(True)) return cell
python
def extract(self, cell): """ Extract a cell from the this GDSII file and include it in the current global library, including referenced dependencies. Parameters ---------- cell : ``Cell`` or string Cell or name of the cell to be extracted from the imported file. Referenced cells will be automatically extracted as well. Returns ------- out : ``Cell`` The extracted cell. """ cell = self.cell_dict.get(cell, cell) current_library.add(cell) current_library.add(cell.get_dependencies(True)) return cell
[ "def", "extract", "(", "self", ",", "cell", ")", ":", "cell", "=", "self", ".", "cell_dict", ".", "get", "(", "cell", ",", "cell", ")", "current_library", ".", "add", "(", "cell", ")", "current_library", ".", "add", "(", "cell", ".", "get_dependencies"...
Extract a cell from the this GDSII file and include it in the current global library, including referenced dependencies. Parameters ---------- cell : ``Cell`` or string Cell or name of the cell to be extracted from the imported file. Referenced cells will be automatically extracted as well. Returns ------- out : ``Cell`` The extracted cell.
[ "Extract", "a", "cell", "from", "the", "this", "GDSII", "file", "and", "include", "it", "in", "the", "current", "global", "library", "including", "referenced", "dependencies", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3697-L3717
train
206,022
heitzmann/gdspy
gdspy/__init__.py
GdsLibrary.top_level
def top_level(self): """ Output the top level cells from the GDSII data. Top level cells are those that are not referenced by any other cells. Returns ------- out : list List of top level cells. """ top = list(self.cell_dict.values()) for cell in self.cell_dict.values(): for dependency in cell.get_dependencies(): if dependency in top: top.remove(dependency) return top
python
def top_level(self): """ Output the top level cells from the GDSII data. Top level cells are those that are not referenced by any other cells. Returns ------- out : list List of top level cells. """ top = list(self.cell_dict.values()) for cell in self.cell_dict.values(): for dependency in cell.get_dependencies(): if dependency in top: top.remove(dependency) return top
[ "def", "top_level", "(", "self", ")", ":", "top", "=", "list", "(", "self", ".", "cell_dict", ".", "values", "(", ")", ")", "for", "cell", "in", "self", ".", "cell_dict", ".", "values", "(", ")", ":", "for", "dependency", "in", "cell", ".", "get_de...
Output the top level cells from the GDSII data. Top level cells are those that are not referenced by any other cells. Returns ------- out : list List of top level cells.
[ "Output", "the", "top", "level", "cells", "from", "the", "GDSII", "data", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3719-L3736
train
206,023
heitzmann/gdspy
gdspy/__init__.py
GdsWriter.write_cell
def write_cell(self, cell): """ Write the specified cell to the file. Parameters ---------- cell : ``Cell`` Cell to be written. Notes ----- Only the specified cell is written. Dependencies must be manually included. Returns ------- out : ``GdsWriter`` This object. """ self._outfile.write(cell.to_gds(self._res)) return self
python
def write_cell(self, cell): """ Write the specified cell to the file. Parameters ---------- cell : ``Cell`` Cell to be written. Notes ----- Only the specified cell is written. Dependencies must be manually included. Returns ------- out : ``GdsWriter`` This object. """ self._outfile.write(cell.to_gds(self._res)) return self
[ "def", "write_cell", "(", "self", ",", "cell", ")", ":", "self", ".", "_outfile", ".", "write", "(", "cell", ".", "to_gds", "(", "self", ".", "_res", ")", ")", "return", "self" ]
Write the specified cell to the file. Parameters ---------- cell : ``Cell`` Cell to be written. Notes ----- Only the specified cell is written. Dependencies must be manually included. Returns ------- out : ``GdsWriter`` This object.
[ "Write", "the", "specified", "cell", "to", "the", "file", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3812-L3832
train
206,024
heitzmann/gdspy
gdspy/__init__.py
GdsWriter.close
def close(self): """ Finalize the GDSII stream library. """ self._outfile.write(struct.pack('>2h', 4, 0x0400)) if self._close: self._outfile.close()
python
def close(self): """ Finalize the GDSII stream library. """ self._outfile.write(struct.pack('>2h', 4, 0x0400)) if self._close: self._outfile.close()
[ "def", "close", "(", "self", ")", ":", "self", ".", "_outfile", ".", "write", "(", "struct", ".", "pack", "(", "'>2h'", ",", "4", ",", "0x0400", ")", ")", "if", "self", ".", "_close", ":", "self", ".", "_outfile", ".", "close", "(", ")" ]
Finalize the GDSII stream library.
[ "Finalize", "the", "GDSII", "stream", "library", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3834-L3840
train
206,025
heitzmann/gdspy
examples/photonics.py
waveguide
def waveguide(path, points, finish, bend_radius, number_of_points=0.01, direction=None, layer=0, datatype=0): ''' Easy waveguide creation tool with absolute positioning. path : starting `gdspy.Path` points : coordinates along which the waveguide will travel finish : end point of the waveguide bend_radius : radius of the turns in the waveguide number_of_points : same as in `path.turn` direction : starting direction layer : GDSII layer number datatype : GDSII datatype number Return `path`. ''' if direction is not None: path.direction = direction axis = 0 if path.direction[1] == 'x' else 1 points.append(finish[(axis + len(points)) % 2]) n = len(points) if points[0] > (path.x, path.y)[axis]: path.direction = ['+x', '+y'][axis] else: path.direction = ['-x', '-y'][axis] for i in range(n): path.segment( abs(points[i] - (path.x, path.y)[axis]) - bend_radius, layer=layer, datatype=datatype) axis = 1 - axis if i < n - 1: goto = points[i + 1] else: goto = finish[axis] if (goto > (path.x, path.y)[axis]) ^ ((path.direction[0] == '+') ^ (path.direction[1] == 'x')): bend = 'l' else: bend = 'r' path.turn( bend_radius, bend, number_of_points=number_of_points, layer=layer, datatype=datatype) return path.segment( abs(finish[axis] - (path.x, path.y)[axis]), layer=layer, datatype=datatype)
python
def waveguide(path, points, finish, bend_radius, number_of_points=0.01, direction=None, layer=0, datatype=0): ''' Easy waveguide creation tool with absolute positioning. path : starting `gdspy.Path` points : coordinates along which the waveguide will travel finish : end point of the waveguide bend_radius : radius of the turns in the waveguide number_of_points : same as in `path.turn` direction : starting direction layer : GDSII layer number datatype : GDSII datatype number Return `path`. ''' if direction is not None: path.direction = direction axis = 0 if path.direction[1] == 'x' else 1 points.append(finish[(axis + len(points)) % 2]) n = len(points) if points[0] > (path.x, path.y)[axis]: path.direction = ['+x', '+y'][axis] else: path.direction = ['-x', '-y'][axis] for i in range(n): path.segment( abs(points[i] - (path.x, path.y)[axis]) - bend_radius, layer=layer, datatype=datatype) axis = 1 - axis if i < n - 1: goto = points[i + 1] else: goto = finish[axis] if (goto > (path.x, path.y)[axis]) ^ ((path.direction[0] == '+') ^ (path.direction[1] == 'x')): bend = 'l' else: bend = 'r' path.turn( bend_radius, bend, number_of_points=number_of_points, layer=layer, datatype=datatype) return path.segment( abs(finish[axis] - (path.x, path.y)[axis]), layer=layer, datatype=datatype)
[ "def", "waveguide", "(", "path", ",", "points", ",", "finish", ",", "bend_radius", ",", "number_of_points", "=", "0.01", ",", "direction", "=", "None", ",", "layer", "=", "0", ",", "datatype", "=", "0", ")", ":", "if", "direction", "is", "not", "None",...
Easy waveguide creation tool with absolute positioning. path : starting `gdspy.Path` points : coordinates along which the waveguide will travel finish : end point of the waveguide bend_radius : radius of the turns in the waveguide number_of_points : same as in `path.turn` direction : starting direction layer : GDSII layer number datatype : GDSII datatype number Return `path`.
[ "Easy", "waveguide", "creation", "tool", "with", "absolute", "positioning", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/examples/photonics.py#L14-L69
train
206,026
heitzmann/gdspy
examples/photonics.py
taper
def taper(path, length, final_width, final_distance, direction=None, layer=0, datatype=0): ''' Linear tapers for the lazy. path : `gdspy.Path` to append the taper length : total length final_width : final width of th taper direction : taper direction layer : GDSII layer number (int or list) datatype : GDSII datatype number (int or list) Parameters `layer` and `datatype` must be of the same type. If they are lists, they must have the same length. Their length indicate the number of pieces that compose the taper. Return `path`. ''' if layer.__class__ == datatype.__class__ == [].__class__: assert len(layer) == len(datatype) elif isinstance(layer, int) and isinstance(datatype, int): layer = [layer] datatype = [datatype] else: raise ValueError('Parameters layer and datatype must have the same ' 'type (either int or list) and length.') n = len(layer) w = numpy.linspace(2 * path.w, final_width, n + 1)[1:] d = numpy.linspace(path.distance, final_distance, n + 1)[1:] l = float(length) / n for i in range(n): path.segment( l, direction, w[i], d[i], layer=layer[i], datatype=datatype[i]) return path
python
def taper(path, length, final_width, final_distance, direction=None, layer=0, datatype=0): ''' Linear tapers for the lazy. path : `gdspy.Path` to append the taper length : total length final_width : final width of th taper direction : taper direction layer : GDSII layer number (int or list) datatype : GDSII datatype number (int or list) Parameters `layer` and `datatype` must be of the same type. If they are lists, they must have the same length. Their length indicate the number of pieces that compose the taper. Return `path`. ''' if layer.__class__ == datatype.__class__ == [].__class__: assert len(layer) == len(datatype) elif isinstance(layer, int) and isinstance(datatype, int): layer = [layer] datatype = [datatype] else: raise ValueError('Parameters layer and datatype must have the same ' 'type (either int or list) and length.') n = len(layer) w = numpy.linspace(2 * path.w, final_width, n + 1)[1:] d = numpy.linspace(path.distance, final_distance, n + 1)[1:] l = float(length) / n for i in range(n): path.segment( l, direction, w[i], d[i], layer=layer[i], datatype=datatype[i]) return path
[ "def", "taper", "(", "path", ",", "length", ",", "final_width", ",", "final_distance", ",", "direction", "=", "None", ",", "layer", "=", "0", ",", "datatype", "=", "0", ")", ":", "if", "layer", ".", "__class__", "==", "datatype", ".", "__class__", "=="...
Linear tapers for the lazy. path : `gdspy.Path` to append the taper length : total length final_width : final width of th taper direction : taper direction layer : GDSII layer number (int or list) datatype : GDSII datatype number (int or list) Parameters `layer` and `datatype` must be of the same type. If they are lists, they must have the same length. Their length indicate the number of pieces that compose the taper. Return `path`.
[ "Linear", "tapers", "for", "the", "lazy", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/examples/photonics.py#L72-L110
train
206,027
heitzmann/gdspy
examples/photonics.py
grating
def grating(period, number_of_teeth, fill_frac, width, position, direction, lda=1, sin_theta=0, focus_distance=-1, focus_width=-1, evaluations=99, layer=0, datatype=0): ''' Straight or focusing grating. period : grating period number_of_teeth : number of teeth in the grating fill_frac : filling fraction of the teeth (w.r.t. the period) width : width of the grating position : grating position (feed point) direction : one of {'+x', '-x', '+y', '-y'} lda : free-space wavelength sin_theta : sine of incidence angle focus_distance : focus distance (negative for straight grating) focus_width : if non-negative, the focusing area is included in the result (usually for negative resists) and this is the width of the waveguide connecting to the grating evaluations : number of evaluations of `path.parametric` layer : GDSII layer number datatype : GDSII datatype number Return `PolygonSet` ''' if focus_distance < 0: path = gdspy.L1Path( (position[0] - 0.5 * width, position[1] + 0.5 * (number_of_teeth - 1 + fill_frac) * period), '+x', period * fill_frac, [width], [], number_of_teeth, period, layer=layer, datatype=datatype) else: neff = lda / float(period) + sin_theta qmin = int(focus_distance / float(period) + 0.5) path = gdspy.Path(period * fill_frac, position) max_points = 199 if focus_width < 0 else 2 * evaluations c3 = neff**2 - sin_theta**2 w = 0.5 * width for q in range(qmin, qmin + number_of_teeth): c1 = q * lda * sin_theta c2 = (q * lda)**2 path.parametric( lambda t: (width * t - w, (c1 + neff * numpy.sqrt(c2 - c3 * ( width * t - w)**2)) / c3), number_of_evaluations=evaluations, max_points=max_points, layer=layer, datatype=datatype) path.x = position[0] path.y = position[1] if focus_width >= 0: path.polygons[0] = numpy.vstack( (path.polygons[0][:evaluations, :], ([position] if focus_width == 0 else [(position[0] + 0.5 * focus_width, position[1]), (position[0] - 0.5 * focus_width, position[1])]))) path.fracture() if direction == '-x': return path.rotate(0.5 * numpy.pi, position) elif direction == '+x': return path.rotate(-0.5 * numpy.pi, position) elif direction == '-y': return path.rotate(numpy.pi, position) else: return path
python
def grating(period, number_of_teeth, fill_frac, width, position, direction, lda=1, sin_theta=0, focus_distance=-1, focus_width=-1, evaluations=99, layer=0, datatype=0): ''' Straight or focusing grating. period : grating period number_of_teeth : number of teeth in the grating fill_frac : filling fraction of the teeth (w.r.t. the period) width : width of the grating position : grating position (feed point) direction : one of {'+x', '-x', '+y', '-y'} lda : free-space wavelength sin_theta : sine of incidence angle focus_distance : focus distance (negative for straight grating) focus_width : if non-negative, the focusing area is included in the result (usually for negative resists) and this is the width of the waveguide connecting to the grating evaluations : number of evaluations of `path.parametric` layer : GDSII layer number datatype : GDSII datatype number Return `PolygonSet` ''' if focus_distance < 0: path = gdspy.L1Path( (position[0] - 0.5 * width, position[1] + 0.5 * (number_of_teeth - 1 + fill_frac) * period), '+x', period * fill_frac, [width], [], number_of_teeth, period, layer=layer, datatype=datatype) else: neff = lda / float(period) + sin_theta qmin = int(focus_distance / float(period) + 0.5) path = gdspy.Path(period * fill_frac, position) max_points = 199 if focus_width < 0 else 2 * evaluations c3 = neff**2 - sin_theta**2 w = 0.5 * width for q in range(qmin, qmin + number_of_teeth): c1 = q * lda * sin_theta c2 = (q * lda)**2 path.parametric( lambda t: (width * t - w, (c1 + neff * numpy.sqrt(c2 - c3 * ( width * t - w)**2)) / c3), number_of_evaluations=evaluations, max_points=max_points, layer=layer, datatype=datatype) path.x = position[0] path.y = position[1] if focus_width >= 0: path.polygons[0] = numpy.vstack( (path.polygons[0][:evaluations, :], ([position] if focus_width == 0 else [(position[0] + 0.5 * focus_width, position[1]), (position[0] - 0.5 * focus_width, position[1])]))) path.fracture() if direction == '-x': return path.rotate(0.5 * numpy.pi, position) elif direction == '+x': return path.rotate(-0.5 * numpy.pi, position) elif direction == '-y': return path.rotate(numpy.pi, position) else: return path
[ "def", "grating", "(", "period", ",", "number_of_teeth", ",", "fill_frac", ",", "width", ",", "position", ",", "direction", ",", "lda", "=", "1", ",", "sin_theta", "=", "0", ",", "focus_distance", "=", "-", "1", ",", "focus_width", "=", "-", "1", ",", ...
Straight or focusing grating. period : grating period number_of_teeth : number of teeth in the grating fill_frac : filling fraction of the teeth (w.r.t. the period) width : width of the grating position : grating position (feed point) direction : one of {'+x', '-x', '+y', '-y'} lda : free-space wavelength sin_theta : sine of incidence angle focus_distance : focus distance (negative for straight grating) focus_width : if non-negative, the focusing area is included in the result (usually for negative resists) and this is the width of the waveguide connecting to the grating evaluations : number of evaluations of `path.parametric` layer : GDSII layer number datatype : GDSII datatype number Return `PolygonSet`
[ "Straight", "or", "focusing", "grating", "." ]
2c8d1313248c544e2066d19095b7ad7158c79bc9
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/examples/photonics.py#L113-L191
train
206,028
Kozea/Flask-WeasyPrint
flask_weasyprint/__init__.py
render_pdf
def render_pdf(html, stylesheets=None, download_filename=None, automatic_download=True): """Render a PDF to a response with the correct ``Content-Type`` header. :param html: Either a :class:`weasyprint.HTML` object or an URL to be passed to :func:`flask_weasyprint.HTML`. The latter case requires a request context. :param stylesheets: A list of user stylesheets, passed to :meth:`~weasyprint.HTML.write_pdf` :param download_filename: If provided, the ``Content-Disposition`` header is set so that most web browser will show the "Save as…" dialog with the value as the default filename. :param automatic_download: If True, the browser will automatic download file. :returns: a :class:`flask.Response` object. """ if not hasattr(html, 'write_pdf'): html = HTML(html) pdf = html.write_pdf(stylesheets=stylesheets) response = current_app.response_class(pdf, mimetype='application/pdf') if download_filename: if automatic_download: value = 'attachment' else: value = 'inline' response.headers.add('Content-Disposition', value, filename=download_filename) return response
python
def render_pdf(html, stylesheets=None, download_filename=None, automatic_download=True): """Render a PDF to a response with the correct ``Content-Type`` header. :param html: Either a :class:`weasyprint.HTML` object or an URL to be passed to :func:`flask_weasyprint.HTML`. The latter case requires a request context. :param stylesheets: A list of user stylesheets, passed to :meth:`~weasyprint.HTML.write_pdf` :param download_filename: If provided, the ``Content-Disposition`` header is set so that most web browser will show the "Save as…" dialog with the value as the default filename. :param automatic_download: If True, the browser will automatic download file. :returns: a :class:`flask.Response` object. """ if not hasattr(html, 'write_pdf'): html = HTML(html) pdf = html.write_pdf(stylesheets=stylesheets) response = current_app.response_class(pdf, mimetype='application/pdf') if download_filename: if automatic_download: value = 'attachment' else: value = 'inline' response.headers.add('Content-Disposition', value, filename=download_filename) return response
[ "def", "render_pdf", "(", "html", ",", "stylesheets", "=", "None", ",", "download_filename", "=", "None", ",", "automatic_download", "=", "True", ")", ":", "if", "not", "hasattr", "(", "html", ",", "'write_pdf'", ")", ":", "html", "=", "HTML", "(", "html...
Render a PDF to a response with the correct ``Content-Type`` header. :param html: Either a :class:`weasyprint.HTML` object or an URL to be passed to :func:`flask_weasyprint.HTML`. The latter case requires a request context. :param stylesheets: A list of user stylesheets, passed to :meth:`~weasyprint.HTML.write_pdf` :param download_filename: If provided, the ``Content-Disposition`` header is set so that most web browser will show the "Save as…" dialog with the value as the default filename. :param automatic_download: If True, the browser will automatic download file. :returns: a :class:`flask.Response` object.
[ "Render", "a", "PDF", "to", "a", "response", "with", "the", "correct", "Content", "-", "Type", "header", "." ]
ec0403a2b96c10a09159f75409ecb63342ce7518
https://github.com/Kozea/Flask-WeasyPrint/blob/ec0403a2b96c10a09159f75409ecb63342ce7518/flask_weasyprint/__init__.py#L190-L221
train
206,029
samuraisam/django-json-rpc
jsonrpc/__init__.py
_inject_args
def _inject_args(sig, types): """ A function to inject arguments manually into a method signature before it's been parsed. If using keyword arguments use 'kw=type' instead in the types array. sig the string signature types a list of types to be inserted Returns the altered signature. """ if '(' in sig: parts = sig.split('(') sig = '%s(%s%s%s' % ( parts[0], ', '.join(types), (', ' if parts[1].index(')') > 0 else ''), parts[1]) else: sig = '%s(%s)' % (sig, ', '.join(types)) return sig
python
def _inject_args(sig, types): """ A function to inject arguments manually into a method signature before it's been parsed. If using keyword arguments use 'kw=type' instead in the types array. sig the string signature types a list of types to be inserted Returns the altered signature. """ if '(' in sig: parts = sig.split('(') sig = '%s(%s%s%s' % ( parts[0], ', '.join(types), (', ' if parts[1].index(')') > 0 else ''), parts[1]) else: sig = '%s(%s)' % (sig, ', '.join(types)) return sig
[ "def", "_inject_args", "(", "sig", ",", "types", ")", ":", "if", "'('", "in", "sig", ":", "parts", "=", "sig", ".", "split", "(", "'('", ")", "sig", "=", "'%s(%s%s%s'", "%", "(", "parts", "[", "0", "]", ",", "', '", ".", "join", "(", "types", "...
A function to inject arguments manually into a method signature before it's been parsed. If using keyword arguments use 'kw=type' instead in the types array. sig the string signature types a list of types to be inserted Returns the altered signature.
[ "A", "function", "to", "inject", "arguments", "manually", "into", "a", "method", "signature", "before", "it", "s", "been", "parsed", ".", "If", "using", "keyword", "arguments", "use", "kw", "=", "type", "instead", "in", "the", "types", "array", "." ]
a88d744d960e828f3eb21265da0f10a694b8ebcf
https://github.com/samuraisam/django-json-rpc/blob/a88d744d960e828f3eb21265da0f10a694b8ebcf/jsonrpc/__init__.py#L120-L138
train
206,030
samuraisam/django-json-rpc
jsonrpc/__init__.py
jsonrpc_method
def jsonrpc_method(name, authenticated=False, authentication_arguments=['username', 'password'], safe=False, validate=False, site=default_site): """ Wraps a function turns it into a json-rpc method. Adds several attributes to the function specific to the JSON-RPC machinery and adds it to the default jsonrpc_site if one isn't provided. You must import the module containing these functions in your urls.py. name The name of your method. IE: `namespace.methodName` The method name can include type information, like `ns.method(String, Array) -> Nil`. authenticated=False Adds `username` and `password` arguments to the beginning of your method if the user hasn't already been authenticated. These will be used to authenticate the user against `django.contrib.authenticate` If you use HTTP auth or other authentication middleware, `username` and `password` will not be added, and this method will only check against `request.user.is_authenticated`. You may pass a callable to replace `django.contrib.auth.authenticate` as the authentication method. It must return either a User or `None` and take the keyword arguments `username` and `password`. safe=False Designates whether or not your method may be accessed by HTTP GET. By default this is turned off. validate=False Validates the arguments passed to your method based on type information provided in the signature. Supply type information by including types in your method declaration. Like so: @jsonrpc_method('myapp.specialSauce(Array, String)', validate=True) def special_sauce(self, ingredients, instructions): return SpecialSauce(ingredients, instructions) Calls to `myapp.specialSauce` will now check each arguments type before calling `special_sauce`, throwing an `InvalidParamsError` when it encounters a discrepancy. This can significantly reduce the amount of code required to write JSON-RPC services. site=default_site Defines which site the jsonrpc method will be added to. Can be any object that provides a `register(name, func)` method. """ def decorator(func): arg_names = getargspec(func)[0][1:] X = {'name': name, 'arg_names': arg_names} if authenticated: if authenticated is True or six.callable(authenticated): # TODO: this is an assumption X['arg_names'] = authentication_arguments + X['arg_names'] X['name'] = _inject_args(X['name'], ('String', 'String')) from django.contrib.auth import authenticate as _authenticate from django.contrib.auth.models import User else: authenticate = authenticated @six.wraps(func) def _func(request, *args, **kwargs): user = getattr(request, 'user', None) is_authenticated = getattr(user, 'is_authenticated', lambda: False) if ((user is not None and six.callable(is_authenticated) and not is_authenticated()) or user is None): user = None try: creds = args[:len(authentication_arguments)] if len(creds) == 0: raise IndexError # Django's authenticate() method takes arguments as dict user = _authenticate(username=creds[0], password=creds[1], *creds[2:]) if user is not None: args = args[len(authentication_arguments):] except IndexError: auth_kwargs = {} try: for auth_kwarg in authentication_arguments: auth_kwargs[auth_kwarg] = kwargs[auth_kwarg] except KeyError: raise InvalidParamsError( 'Authenticated methods require at least ' '[%(arguments)s] or {%(arguments)s} arguments' % {'arguments': ', '.join(authentication_arguments)}) user = _authenticate(**auth_kwargs) if user is not None: for auth_kwarg in authentication_arguments: kwargs.pop(auth_kwarg) if user is None: raise InvalidCredentialsError request.user = user return func(request, *args, **kwargs) else: _func = func @six.wraps(_func) def exc_printer(*a, **kw): try: return _func(*a, **kw) except Exception as e: try: print('JSONRPC SERVICE EXCEPTION') import traceback traceback.print_exc() except: pass six.reraise(*sys.exc_info()) ret_func = exc_printer method, arg_types, return_type = \ _parse_sig(X['name'], X['arg_names'], validate) ret_func.json_args = X['arg_names'] ret_func.json_arg_types = arg_types ret_func.json_return_type = return_type ret_func.json_method = method ret_func.json_safe = safe ret_func.json_sig = X['name'] ret_func.json_validate = validate site.register(method, ret_func) return ret_func return decorator
python
def jsonrpc_method(name, authenticated=False, authentication_arguments=['username', 'password'], safe=False, validate=False, site=default_site): """ Wraps a function turns it into a json-rpc method. Adds several attributes to the function specific to the JSON-RPC machinery and adds it to the default jsonrpc_site if one isn't provided. You must import the module containing these functions in your urls.py. name The name of your method. IE: `namespace.methodName` The method name can include type information, like `ns.method(String, Array) -> Nil`. authenticated=False Adds `username` and `password` arguments to the beginning of your method if the user hasn't already been authenticated. These will be used to authenticate the user against `django.contrib.authenticate` If you use HTTP auth or other authentication middleware, `username` and `password` will not be added, and this method will only check against `request.user.is_authenticated`. You may pass a callable to replace `django.contrib.auth.authenticate` as the authentication method. It must return either a User or `None` and take the keyword arguments `username` and `password`. safe=False Designates whether or not your method may be accessed by HTTP GET. By default this is turned off. validate=False Validates the arguments passed to your method based on type information provided in the signature. Supply type information by including types in your method declaration. Like so: @jsonrpc_method('myapp.specialSauce(Array, String)', validate=True) def special_sauce(self, ingredients, instructions): return SpecialSauce(ingredients, instructions) Calls to `myapp.specialSauce` will now check each arguments type before calling `special_sauce`, throwing an `InvalidParamsError` when it encounters a discrepancy. This can significantly reduce the amount of code required to write JSON-RPC services. site=default_site Defines which site the jsonrpc method will be added to. Can be any object that provides a `register(name, func)` method. """ def decorator(func): arg_names = getargspec(func)[0][1:] X = {'name': name, 'arg_names': arg_names} if authenticated: if authenticated is True or six.callable(authenticated): # TODO: this is an assumption X['arg_names'] = authentication_arguments + X['arg_names'] X['name'] = _inject_args(X['name'], ('String', 'String')) from django.contrib.auth import authenticate as _authenticate from django.contrib.auth.models import User else: authenticate = authenticated @six.wraps(func) def _func(request, *args, **kwargs): user = getattr(request, 'user', None) is_authenticated = getattr(user, 'is_authenticated', lambda: False) if ((user is not None and six.callable(is_authenticated) and not is_authenticated()) or user is None): user = None try: creds = args[:len(authentication_arguments)] if len(creds) == 0: raise IndexError # Django's authenticate() method takes arguments as dict user = _authenticate(username=creds[0], password=creds[1], *creds[2:]) if user is not None: args = args[len(authentication_arguments):] except IndexError: auth_kwargs = {} try: for auth_kwarg in authentication_arguments: auth_kwargs[auth_kwarg] = kwargs[auth_kwarg] except KeyError: raise InvalidParamsError( 'Authenticated methods require at least ' '[%(arguments)s] or {%(arguments)s} arguments' % {'arguments': ', '.join(authentication_arguments)}) user = _authenticate(**auth_kwargs) if user is not None: for auth_kwarg in authentication_arguments: kwargs.pop(auth_kwarg) if user is None: raise InvalidCredentialsError request.user = user return func(request, *args, **kwargs) else: _func = func @six.wraps(_func) def exc_printer(*a, **kw): try: return _func(*a, **kw) except Exception as e: try: print('JSONRPC SERVICE EXCEPTION') import traceback traceback.print_exc() except: pass six.reraise(*sys.exc_info()) ret_func = exc_printer method, arg_types, return_type = \ _parse_sig(X['name'], X['arg_names'], validate) ret_func.json_args = X['arg_names'] ret_func.json_arg_types = arg_types ret_func.json_return_type = return_type ret_func.json_method = method ret_func.json_safe = safe ret_func.json_sig = X['name'] ret_func.json_validate = validate site.register(method, ret_func) return ret_func return decorator
[ "def", "jsonrpc_method", "(", "name", ",", "authenticated", "=", "False", ",", "authentication_arguments", "=", "[", "'username'", ",", "'password'", "]", ",", "safe", "=", "False", ",", "validate", "=", "False", ",", "site", "=", "default_site", ")", ":", ...
Wraps a function turns it into a json-rpc method. Adds several attributes to the function specific to the JSON-RPC machinery and adds it to the default jsonrpc_site if one isn't provided. You must import the module containing these functions in your urls.py. name The name of your method. IE: `namespace.methodName` The method name can include type information, like `ns.method(String, Array) -> Nil`. authenticated=False Adds `username` and `password` arguments to the beginning of your method if the user hasn't already been authenticated. These will be used to authenticate the user against `django.contrib.authenticate` If you use HTTP auth or other authentication middleware, `username` and `password` will not be added, and this method will only check against `request.user.is_authenticated`. You may pass a callable to replace `django.contrib.auth.authenticate` as the authentication method. It must return either a User or `None` and take the keyword arguments `username` and `password`. safe=False Designates whether or not your method may be accessed by HTTP GET. By default this is turned off. validate=False Validates the arguments passed to your method based on type information provided in the signature. Supply type information by including types in your method declaration. Like so: @jsonrpc_method('myapp.specialSauce(Array, String)', validate=True) def special_sauce(self, ingredients, instructions): return SpecialSauce(ingredients, instructions) Calls to `myapp.specialSauce` will now check each arguments type before calling `special_sauce`, throwing an `InvalidParamsError` when it encounters a discrepancy. This can significantly reduce the amount of code required to write JSON-RPC services. site=default_site Defines which site the jsonrpc method will be added to. Can be any object that provides a `register(name, func)` method.
[ "Wraps", "a", "function", "turns", "it", "into", "a", "json", "-", "rpc", "method", ".", "Adds", "several", "attributes", "to", "the", "function", "specific", "to", "the", "JSON", "-", "RPC", "machinery", "and", "adds", "it", "to", "the", "default", "jso...
a88d744d960e828f3eb21265da0f10a694b8ebcf
https://github.com/samuraisam/django-json-rpc/blob/a88d744d960e828f3eb21265da0f10a694b8ebcf/jsonrpc/__init__.py#L141-L277
train
206,031
samuraisam/django-json-rpc
jsonrpc/proxy.py
ServiceProxy.send_payload
def send_payload(self, params): """Performs the actual sending action and returns the result""" data = dumps({ 'jsonrpc': self.version, 'method': self.service_name, 'params': params, 'id': str(uuid.uuid1()) }).encode('utf-8') headers = { 'Content-Type': 'application/json-rpc', 'Accept': 'application/json-rpc', 'Content-Length': len(data) } try: req = urllib_request.Request(self.service_url, data, headers) resp = urllib_request.urlopen(req) except IOError as e: if isinstance(e, urllib_error.HTTPError): if e.code not in ( 401, 403 ) and e.headers['Content-Type'] == 'application/json-rpc': return e.read().decode('utf-8') # we got a jsonrpc-formatted respnose raise ServiceProxyException(e.code, e.headers, req) else: raise e return resp.read().decode('utf-8')
python
def send_payload(self, params): """Performs the actual sending action and returns the result""" data = dumps({ 'jsonrpc': self.version, 'method': self.service_name, 'params': params, 'id': str(uuid.uuid1()) }).encode('utf-8') headers = { 'Content-Type': 'application/json-rpc', 'Accept': 'application/json-rpc', 'Content-Length': len(data) } try: req = urllib_request.Request(self.service_url, data, headers) resp = urllib_request.urlopen(req) except IOError as e: if isinstance(e, urllib_error.HTTPError): if e.code not in ( 401, 403 ) and e.headers['Content-Type'] == 'application/json-rpc': return e.read().decode('utf-8') # we got a jsonrpc-formatted respnose raise ServiceProxyException(e.code, e.headers, req) else: raise e return resp.read().decode('utf-8')
[ "def", "send_payload", "(", "self", ",", "params", ")", ":", "data", "=", "dumps", "(", "{", "'jsonrpc'", ":", "self", ".", "version", ",", "'method'", ":", "self", ".", "service_name", ",", "'params'", ":", "params", ",", "'id'", ":", "str", "(", "u...
Performs the actual sending action and returns the result
[ "Performs", "the", "actual", "sending", "action", "and", "returns", "the", "result" ]
a88d744d960e828f3eb21265da0f10a694b8ebcf
https://github.com/samuraisam/django-json-rpc/blob/a88d744d960e828f3eb21265da0f10a694b8ebcf/jsonrpc/proxy.py#L28-L53
train
206,032
samuraisam/django-json-rpc
jsonrpc/exceptions.py
Error.json_rpc_format
def json_rpc_format(self): """ return the Exception data in a format for JSON-RPC """ error = { 'name': smart_text(self.__class__.__name__), 'code': self.code, 'message': "%s: %s" % (smart_text(self.__class__.__name__), smart_text(self.message)), 'data': self.data } from django.conf import settings if settings.DEBUG: import sys, traceback error['stack'] = traceback.format_exc() error['executable'] = sys.executable return error
python
def json_rpc_format(self): """ return the Exception data in a format for JSON-RPC """ error = { 'name': smart_text(self.__class__.__name__), 'code': self.code, 'message': "%s: %s" % (smart_text(self.__class__.__name__), smart_text(self.message)), 'data': self.data } from django.conf import settings if settings.DEBUG: import sys, traceback error['stack'] = traceback.format_exc() error['executable'] = sys.executable return error
[ "def", "json_rpc_format", "(", "self", ")", ":", "error", "=", "{", "'name'", ":", "smart_text", "(", "self", ".", "__class__", ".", "__name__", ")", ",", "'code'", ":", "self", ".", "code", ",", "'message'", ":", "\"%s: %s\"", "%", "(", "smart_text", ...
return the Exception data in a format for JSON-RPC
[ "return", "the", "Exception", "data", "in", "a", "format", "for", "JSON", "-", "RPC" ]
a88d744d960e828f3eb21265da0f10a694b8ebcf
https://github.com/samuraisam/django-json-rpc/blob/a88d744d960e828f3eb21265da0f10a694b8ebcf/jsonrpc/exceptions.py#L31-L49
train
206,033
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.directory
def directory(self, query, **kwargs): """Search by users or channels on all server.""" if isinstance(query, dict): query = str(query).replace("'", '"') return self.__call_api_get('directory', query=query, kwargs=kwargs)
python
def directory(self, query, **kwargs): """Search by users or channels on all server.""" if isinstance(query, dict): query = str(query).replace("'", '"') return self.__call_api_get('directory', query=query, kwargs=kwargs)
[ "def", "directory", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "query", ",", "dict", ")", ":", "query", "=", "str", "(", "query", ")", ".", "replace", "(", "\"'\"", ",", "'\"'", ")", "return", "self", "...
Search by users or channels on all server.
[ "Search", "by", "users", "or", "channels", "on", "all", "server", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L113-L118
train
206,034
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.spotlight
def spotlight(self, query, **kwargs): """Searches for users or rooms that are visible to the user.""" return self.__call_api_get('spotlight', query=query, kwargs=kwargs)
python
def spotlight(self, query, **kwargs): """Searches for users or rooms that are visible to the user.""" return self.__call_api_get('spotlight', query=query, kwargs=kwargs)
[ "def", "spotlight", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'spotlight'", ",", "query", "=", "query", ",", "kwargs", "=", "kwargs", ")" ]
Searches for users or rooms that are visible to the user.
[ "Searches", "for", "users", "or", "rooms", "that", "are", "visible", "to", "the", "user", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L120-L122
train
206,035
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.users_get_presence
def users_get_presence(self, user_id=None, username=None, **kwargs): """Gets the online presence of the a user.""" if user_id: return self.__call_api_get('users.getPresence', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_get('users.getPresence', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
python
def users_get_presence(self, user_id=None, username=None, **kwargs): """Gets the online presence of the a user.""" if user_id: return self.__call_api_get('users.getPresence', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_get('users.getPresence', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
[ "def", "users_get_presence", "(", "self", ",", "user_id", "=", "None", ",", "username", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "user_id", ":", "return", "self", ".", "__call_api_get", "(", "'users.getPresence'", ",", "userId", "=", "user_id"...
Gets the online presence of the a user.
[ "Gets", "the", "online", "presence", "of", "the", "a", "user", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L147-L154
train
206,036
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.users_create
def users_create(self, email, name, password, username, **kwargs): """Creates a user""" return self.__call_api_post('users.create', email=email, name=name, password=password, username=username, kwargs=kwargs)
python
def users_create(self, email, name, password, username, **kwargs): """Creates a user""" return self.__call_api_post('users.create', email=email, name=name, password=password, username=username, kwargs=kwargs)
[ "def", "users_create", "(", "self", ",", "email", ",", "name", ",", "password", ",", "username", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'users.create'", ",", "email", "=", "email", ",", "name", "=", "name", "...
Creates a user
[ "Creates", "a", "user" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L156-L159
train
206,037
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.users_create_token
def users_create_token(self, user_id=None, username=None, **kwargs): """Create a user authentication token.""" if user_id: return self.__call_api_post('users.createToken', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('users.createToken', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
python
def users_create_token(self, user_id=None, username=None, **kwargs): """Create a user authentication token.""" if user_id: return self.__call_api_post('users.createToken', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('users.createToken', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
[ "def", "users_create_token", "(", "self", ",", "user_id", "=", "None", ",", "username", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "user_id", ":", "return", "self", ".", "__call_api_post", "(", "'users.createToken'", ",", "userId", "=", "user_id...
Create a user authentication token.
[ "Create", "a", "user", "authentication", "token", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L196-L203
train
206,038
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.users_forgot_password
def users_forgot_password(self, email, **kwargs): """Send email to reset your password.""" return self.__call_api_post('users.forgotPassword', email=email, data=kwargs)
python
def users_forgot_password(self, email, **kwargs): """Send email to reset your password.""" return self.__call_api_post('users.forgotPassword', email=email, data=kwargs)
[ "def", "users_forgot_password", "(", "self", ",", "email", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'users.forgotPassword'", ",", "email", "=", "email", ",", "data", "=", "kwargs", ")" ]
Send email to reset your password.
[ "Send", "email", "to", "reset", "your", "password", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L209-L211
train
206,039
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.chat_post_message
def chat_post_message(self, text, room_id=None, channel=None, **kwargs): """Posts a new chat message.""" if room_id: return self.__call_api_post('chat.postMessage', roomId=room_id, text=text, kwargs=kwargs) elif channel: return self.__call_api_post('chat.postMessage', channel=channel, text=text, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
python
def chat_post_message(self, text, room_id=None, channel=None, **kwargs): """Posts a new chat message.""" if room_id: return self.__call_api_post('chat.postMessage', roomId=room_id, text=text, kwargs=kwargs) elif channel: return self.__call_api_post('chat.postMessage', channel=channel, text=text, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
[ "def", "chat_post_message", "(", "self", ",", "text", ",", "room_id", "=", "None", ",", "channel", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "room_id", ":", "return", "self", ".", "__call_api_post", "(", "'chat.postMessage'", ",", "roomId", "...
Posts a new chat message.
[ "Posts", "a", "new", "chat", "message", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L215-L222
train
206,040
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.chat_delete
def chat_delete(self, room_id, msg_id, **kwargs): """Deletes a chat message.""" return self.__call_api_post('chat.delete', roomId=room_id, msgId=msg_id, kwargs=kwargs)
python
def chat_delete(self, room_id, msg_id, **kwargs): """Deletes a chat message.""" return self.__call_api_post('chat.delete', roomId=room_id, msgId=msg_id, kwargs=kwargs)
[ "def", "chat_delete", "(", "self", ",", "room_id", ",", "msg_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'chat.delete'", ",", "roomId", "=", "room_id", ",", "msgId", "=", "msg_id", ",", "kwargs", "=", "kwargs",...
Deletes a chat message.
[ "Deletes", "a", "chat", "message", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L239-L241
train
206,041
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.chat_search
def chat_search(self, room_id, search_text, **kwargs): """Search for messages in a channel by id and text message.""" return self.__call_api_get('chat.search', roomId=room_id, searchText=search_text, kwargs=kwargs)
python
def chat_search(self, room_id, search_text, **kwargs): """Search for messages in a channel by id and text message.""" return self.__call_api_get('chat.search', roomId=room_id, searchText=search_text, kwargs=kwargs)
[ "def", "chat_search", "(", "self", ",", "room_id", ",", "search_text", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'chat.search'", ",", "roomId", "=", "room_id", ",", "searchText", "=", "search_text", ",", "kwargs", "=...
Search for messages in a channel by id and text message.
[ "Search", "for", "messages", "in", "a", "channel", "by", "id", "and", "text", "message", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L251-L253
train
206,042
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.chat_get_message_read_receipts
def chat_get_message_read_receipts(self, message_id, **kwargs): """Get Message Read Receipts""" return self.__call_api_get('chat.getMessageReadReceipts', messageId=message_id, kwargs=kwargs)
python
def chat_get_message_read_receipts(self, message_id, **kwargs): """Get Message Read Receipts""" return self.__call_api_get('chat.getMessageReadReceipts', messageId=message_id, kwargs=kwargs)
[ "def", "chat_get_message_read_receipts", "(", "self", ",", "message_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'chat.getMessageReadReceipts'", ",", "messageId", "=", "message_id", ",", "kwargs", "=", "kwargs", ")" ]
Get Message Read Receipts
[ "Get", "Message", "Read", "Receipts" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L255-L257
train
206,043
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_history
def channels_history(self, room_id, **kwargs): """Retrieves the messages from a channel.""" return self.__call_api_get('channels.history', roomId=room_id, kwargs=kwargs)
python
def channels_history(self, room_id, **kwargs): """Retrieves the messages from a channel.""" return self.__call_api_get('channels.history', roomId=room_id, kwargs=kwargs)
[ "def", "channels_history", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'channels.history'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Retrieves the messages from a channel.
[ "Retrieves", "the", "messages", "from", "a", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L278-L280
train
206,044
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_add_all
def channels_add_all(self, room_id, **kwargs): """Adds all of the users of the Rocket.Chat server to the channel.""" return self.__call_api_post('channels.addAll', roomId=room_id, kwargs=kwargs)
python
def channels_add_all(self, room_id, **kwargs): """Adds all of the users of the Rocket.Chat server to the channel.""" return self.__call_api_post('channels.addAll', roomId=room_id, kwargs=kwargs)
[ "def", "channels_add_all", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.addAll'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Adds all of the users of the Rocket.Chat server to the channel.
[ "Adds", "all", "of", "the", "users", "of", "the", "Rocket", ".", "Chat", "server", "to", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L282-L284
train
206,045
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_add_moderator
def channels_add_moderator(self, room_id, user_id, **kwargs): """Gives the role of moderator for a user in the current channel.""" return self.__call_api_post('channels.addModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def channels_add_moderator(self, room_id, user_id, **kwargs): """Gives the role of moderator for a user in the current channel.""" return self.__call_api_post('channels.addModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "channels_add_moderator", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.addModerator'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwa...
Gives the role of moderator for a user in the current channel.
[ "Gives", "the", "role", "of", "moderator", "for", "a", "user", "in", "the", "current", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L286-L288
train
206,046
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_remove_moderator
def channels_remove_moderator(self, room_id, user_id, **kwargs): """Removes the role of moderator from a user in the current channel.""" return self.__call_api_post('channels.removeModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def channels_remove_moderator(self, room_id, user_id, **kwargs): """Removes the role of moderator from a user in the current channel.""" return self.__call_api_post('channels.removeModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "channels_remove_moderator", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.removeModerator'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", ...
Removes the role of moderator from a user in the current channel.
[ "Removes", "the", "role", "of", "moderator", "from", "a", "user", "in", "the", "current", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L290-L292
train
206,047
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_add_owner
def channels_add_owner(self, room_id, user_id=None, username=None, **kwargs): """Gives the role of owner for a user in the current channel.""" if user_id: return self.__call_api_post('channels.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('channels.addOwner', roomId=room_id, username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
python
def channels_add_owner(self, room_id, user_id=None, username=None, **kwargs): """Gives the role of owner for a user in the current channel.""" if user_id: return self.__call_api_post('channels.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('channels.addOwner', roomId=room_id, username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
[ "def", "channels_add_owner", "(", "self", ",", "room_id", ",", "user_id", "=", "None", ",", "username", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "user_id", ":", "return", "self", ".", "__call_api_post", "(", "'channels.addOwner'", ",", "roomId...
Gives the role of owner for a user in the current channel.
[ "Gives", "the", "role", "of", "owner", "for", "a", "user", "in", "the", "current", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L303-L310
train
206,048
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_remove_owner
def channels_remove_owner(self, room_id, user_id, **kwargs): """Removes the role of owner from a user in the current channel.""" return self.__call_api_post('channels.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def channels_remove_owner(self, room_id, user_id, **kwargs): """Removes the role of owner from a user in the current channel.""" return self.__call_api_post('channels.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "channels_remove_owner", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.removeOwner'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwarg...
Removes the role of owner from a user in the current channel.
[ "Removes", "the", "role", "of", "owner", "from", "a", "user", "in", "the", "current", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L312-L314
train
206,049
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_archive
def channels_archive(self, room_id, **kwargs): """Archives a channel.""" return self.__call_api_post('channels.archive', roomId=room_id, kwargs=kwargs)
python
def channels_archive(self, room_id, **kwargs): """Archives a channel.""" return self.__call_api_post('channels.archive', roomId=room_id, kwargs=kwargs)
[ "def", "channels_archive", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.archive'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Archives a channel.
[ "Archives", "a", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L316-L318
train
206,050
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_create
def channels_create(self, name, **kwargs): """Creates a new public channel, optionally including users.""" return self.__call_api_post('channels.create', name=name, kwargs=kwargs)
python
def channels_create(self, name, **kwargs): """Creates a new public channel, optionally including users.""" return self.__call_api_post('channels.create', name=name, kwargs=kwargs)
[ "def", "channels_create", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.create'", ",", "name", "=", "name", ",", "kwargs", "=", "kwargs", ")" ]
Creates a new public channel, optionally including users.
[ "Creates", "a", "new", "public", "channel", "optionally", "including", "users", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L332-L334
train
206,051
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_get_integrations
def channels_get_integrations(self, room_id, **kwargs): """Retrieves the integrations which the channel has""" return self.__call_api_get('channels.getIntegrations', roomId=room_id, kwargs=kwargs)
python
def channels_get_integrations(self, room_id, **kwargs): """Retrieves the integrations which the channel has""" return self.__call_api_get('channels.getIntegrations', roomId=room_id, kwargs=kwargs)
[ "def", "channels_get_integrations", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'channels.getIntegrations'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Retrieves the integrations which the channel has
[ "Retrieves", "the", "integrations", "which", "the", "channel", "has" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L336-L338
train
206,052
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_kick
def channels_kick(self, room_id, user_id, **kwargs): """Removes a user from the channel.""" return self.__call_api_post('channels.kick', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def channels_kick(self, room_id, user_id, **kwargs): """Removes a user from the channel.""" return self.__call_api_post('channels.kick', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "channels_kick", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.kick'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwargs", "=", "k...
Removes a user from the channel.
[ "Removes", "a", "user", "from", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L344-L346
train
206,053
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_leave
def channels_leave(self, room_id, **kwargs): """Causes the callee to be removed from the channel.""" return self.__call_api_post('channels.leave', roomId=room_id, kwargs=kwargs)
python
def channels_leave(self, room_id, **kwargs): """Causes the callee to be removed from the channel.""" return self.__call_api_post('channels.leave', roomId=room_id, kwargs=kwargs)
[ "def", "channels_leave", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.leave'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Causes the callee to be removed from the channel.
[ "Causes", "the", "callee", "to", "be", "removed", "from", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L348-L350
train
206,054
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_rename
def channels_rename(self, room_id, name, **kwargs): """Changes the name of the channel.""" return self.__call_api_post('channels.rename', roomId=room_id, name=name, kwargs=kwargs)
python
def channels_rename(self, room_id, name, **kwargs): """Changes the name of the channel.""" return self.__call_api_post('channels.rename', roomId=room_id, name=name, kwargs=kwargs)
[ "def", "channels_rename", "(", "self", ",", "room_id", ",", "name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.rename'", ",", "roomId", "=", "room_id", ",", "name", "=", "name", ",", "kwargs", "=", "kwarg...
Changes the name of the channel.
[ "Changes", "the", "name", "of", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L352-L354
train
206,055
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_set_description
def channels_set_description(self, room_id, description, **kwargs): """Sets the description for the channel.""" return self.__call_api_post('channels.setDescription', roomId=room_id, description=description, kwargs=kwargs)
python
def channels_set_description(self, room_id, description, **kwargs): """Sets the description for the channel.""" return self.__call_api_post('channels.setDescription', roomId=room_id, description=description, kwargs=kwargs)
[ "def", "channels_set_description", "(", "self", ",", "room_id", ",", "description", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.setDescription'", ",", "roomId", "=", "room_id", ",", "description", "=", "descriptio...
Sets the description for the channel.
[ "Sets", "the", "description", "for", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L356-L358
train
206,056
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_set_join_code
def channels_set_join_code(self, room_id, join_code, **kwargs): """Sets the code required to join the channel.""" return self.__call_api_post('channels.setJoinCode', roomId=room_id, joinCode=join_code, kwargs=kwargs)
python
def channels_set_join_code(self, room_id, join_code, **kwargs): """Sets the code required to join the channel.""" return self.__call_api_post('channels.setJoinCode', roomId=room_id, joinCode=join_code, kwargs=kwargs)
[ "def", "channels_set_join_code", "(", "self", ",", "room_id", ",", "join_code", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.setJoinCode'", ",", "roomId", "=", "room_id", ",", "joinCode", "=", "join_code", ",", ...
Sets the code required to join the channel.
[ "Sets", "the", "code", "required", "to", "join", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L360-L362
train
206,057
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_set_topic
def channels_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the channel.""" return self.__call_api_post('channels.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
python
def channels_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the channel.""" return self.__call_api_post('channels.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
[ "def", "channels_set_topic", "(", "self", ",", "room_id", ",", "topic", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.setTopic'", ",", "roomId", "=", "room_id", ",", "topic", "=", "topic", ",", "kwargs", "=", ...
Sets the topic for the channel.
[ "Sets", "the", "topic", "for", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L368-L370
train
206,058
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_set_type
def channels_set_type(self, room_id, a_type, **kwargs): """Sets the type of room this channel should be. The type of room this channel should be, either c or p.""" return self.__call_api_post('channels.setType', roomId=room_id, type=a_type, kwargs=kwargs)
python
def channels_set_type(self, room_id, a_type, **kwargs): """Sets the type of room this channel should be. The type of room this channel should be, either c or p.""" return self.__call_api_post('channels.setType', roomId=room_id, type=a_type, kwargs=kwargs)
[ "def", "channels_set_type", "(", "self", ",", "room_id", ",", "a_type", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.setType'", ",", "roomId", "=", "room_id", ",", "type", "=", "a_type", ",", "kwargs", "=", ...
Sets the type of room this channel should be. The type of room this channel should be, either c or p.
[ "Sets", "the", "type", "of", "room", "this", "channel", "should", "be", ".", "The", "type", "of", "room", "this", "channel", "should", "be", "either", "c", "or", "p", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L372-L374
train
206,059
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_set_announcement
def channels_set_announcement(self, room_id, announce, **kwargs): """Sets the announcement for the channel.""" return self.__call_api_post('channels.setAnnouncement', roomId=room_id, announcement=announce, kwargs=kwargs)
python
def channels_set_announcement(self, room_id, announce, **kwargs): """Sets the announcement for the channel.""" return self.__call_api_post('channels.setAnnouncement', roomId=room_id, announcement=announce, kwargs=kwargs)
[ "def", "channels_set_announcement", "(", "self", ",", "room_id", ",", "announce", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.setAnnouncement'", ",", "roomId", "=", "room_id", ",", "announcement", "=", "announce",...
Sets the announcement for the channel.
[ "Sets", "the", "announcement", "for", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L376-L378
train
206,060
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_set_custom_fields
def channels_set_custom_fields(self, rid, custom_fields): """Sets the custom fields for the channel.""" return self.__call_api_post('channels.setCustomFields', roomId=rid, customFields=custom_fields)
python
def channels_set_custom_fields(self, rid, custom_fields): """Sets the custom fields for the channel.""" return self.__call_api_post('channels.setCustomFields', roomId=rid, customFields=custom_fields)
[ "def", "channels_set_custom_fields", "(", "self", ",", "rid", ",", "custom_fields", ")", ":", "return", "self", ".", "__call_api_post", "(", "'channels.setCustomFields'", ",", "roomId", "=", "rid", ",", "customFields", "=", "custom_fields", ")" ]
Sets the custom fields for the channel.
[ "Sets", "the", "custom", "fields", "for", "the", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L380-L382
train
206,061
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_delete
def channels_delete(self, room_id=None, channel=None, **kwargs): """Delete a public channel.""" if room_id: return self.__call_api_post('channels.delete', roomId=room_id, kwargs=kwargs) elif channel: return self.__call_api_post('channels.delete', roomName=channel, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
python
def channels_delete(self, room_id=None, channel=None, **kwargs): """Delete a public channel.""" if room_id: return self.__call_api_post('channels.delete', roomId=room_id, kwargs=kwargs) elif channel: return self.__call_api_post('channels.delete', roomName=channel, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
[ "def", "channels_delete", "(", "self", ",", "room_id", "=", "None", ",", "channel", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "room_id", ":", "return", "self", ".", "__call_api_post", "(", "'channels.delete'", ",", "roomId", "=", "room_id", "...
Delete a public channel.
[ "Delete", "a", "public", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L384-L391
train
206,062
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.channels_get_all_user_mentions_by_channel
def channels_get_all_user_mentions_by_channel(self, room_id, **kwargs): """Gets all the mentions of a channel.""" return self.__call_api_get('channels.getAllUserMentionsByChannel', roomId=room_id, kwargs=kwargs)
python
def channels_get_all_user_mentions_by_channel(self, room_id, **kwargs): """Gets all the mentions of a channel.""" return self.__call_api_get('channels.getAllUserMentionsByChannel', roomId=room_id, kwargs=kwargs)
[ "def", "channels_get_all_user_mentions_by_channel", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'channels.getAllUserMentionsByChannel'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ...
Gets all the mentions of a channel.
[ "Gets", "all", "the", "mentions", "of", "a", "channel", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L420-L422
train
206,063
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_history
def groups_history(self, room_id, **kwargs): """Retrieves the messages from a private group.""" return self.__call_api_get('groups.history', roomId=room_id, kwargs=kwargs)
python
def groups_history(self, room_id, **kwargs): """Retrieves the messages from a private group.""" return self.__call_api_get('groups.history', roomId=room_id, kwargs=kwargs)
[ "def", "groups_history", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'groups.history'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Retrieves the messages from a private group.
[ "Retrieves", "the", "messages", "from", "a", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L437-L439
train
206,064
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_add_moderator
def groups_add_moderator(self, room_id, user_id, **kwargs): """Gives the role of moderator for a user in the current groups.""" return self.__call_api_post('groups.addModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def groups_add_moderator(self, room_id, user_id, **kwargs): """Gives the role of moderator for a user in the current groups.""" return self.__call_api_post('groups.addModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "groups_add_moderator", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.addModerator'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwargs"...
Gives the role of moderator for a user in the current groups.
[ "Gives", "the", "role", "of", "moderator", "for", "a", "user", "in", "the", "current", "groups", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L441-L443
train
206,065
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_remove_moderator
def groups_remove_moderator(self, room_id, user_id, **kwargs): """Removes the role of moderator from a user in the current groups.""" return self.__call_api_post('groups.removeModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def groups_remove_moderator(self, room_id, user_id, **kwargs): """Removes the role of moderator from a user in the current groups.""" return self.__call_api_post('groups.removeModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "groups_remove_moderator", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.removeModerator'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "k...
Removes the role of moderator from a user in the current groups.
[ "Removes", "the", "role", "of", "moderator", "from", "a", "user", "in", "the", "current", "groups", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L445-L447
train
206,066
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_moderators
def groups_moderators(self, room_id=None, group=None, **kwargs): """Lists all moderators of a group.""" if room_id: return self.__call_api_get('groups.moderators', roomId=room_id, kwargs=kwargs) elif group: return self.__call_api_get('groups.moderators', roomName=group, kwargs=kwargs) else: raise RocketMissingParamException('roomId or group required')
python
def groups_moderators(self, room_id=None, group=None, **kwargs): """Lists all moderators of a group.""" if room_id: return self.__call_api_get('groups.moderators', roomId=room_id, kwargs=kwargs) elif group: return self.__call_api_get('groups.moderators', roomName=group, kwargs=kwargs) else: raise RocketMissingParamException('roomId or group required')
[ "def", "groups_moderators", "(", "self", ",", "room_id", "=", "None", ",", "group", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "room_id", ":", "return", "self", ".", "__call_api_get", "(", "'groups.moderators'", ",", "roomId", "=", "room_id", ...
Lists all moderators of a group.
[ "Lists", "all", "moderators", "of", "a", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L449-L456
train
206,067
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_add_owner
def groups_add_owner(self, room_id, user_id, **kwargs): """Gives the role of owner for a user in the current Group.""" return self.__call_api_post('groups.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def groups_add_owner(self, room_id, user_id, **kwargs): """Gives the role of owner for a user in the current Group.""" return self.__call_api_post('groups.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "groups_add_owner", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.addOwner'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwargs", "=",...
Gives the role of owner for a user in the current Group.
[ "Gives", "the", "role", "of", "owner", "for", "a", "user", "in", "the", "current", "Group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L458-L460
train
206,068
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_remove_owner
def groups_remove_owner(self, room_id, user_id, **kwargs): """Removes the role of owner from a user in the current Group.""" return self.__call_api_post('groups.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def groups_remove_owner(self, room_id, user_id, **kwargs): """Removes the role of owner from a user in the current Group.""" return self.__call_api_post('groups.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "groups_remove_owner", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.removeOwner'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwargs", ...
Removes the role of owner from a user in the current Group.
[ "Removes", "the", "role", "of", "owner", "from", "a", "user", "in", "the", "current", "Group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L462-L464
train
206,069
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_unarchive
def groups_unarchive(self, room_id, **kwargs): """Unarchives a private group.""" return self.__call_api_post('groups.unarchive', roomId=room_id, kwargs=kwargs)
python
def groups_unarchive(self, room_id, **kwargs): """Unarchives a private group.""" return self.__call_api_post('groups.unarchive', roomId=room_id, kwargs=kwargs)
[ "def", "groups_unarchive", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.unarchive'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Unarchives a private group.
[ "Unarchives", "a", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L470-L472
train
206,070
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_get_integrations
def groups_get_integrations(self, room_id, **kwargs): """Retrieves the integrations which the group has""" return self.__call_api_get('groups.getIntegrations', roomId=room_id, kwargs=kwargs)
python
def groups_get_integrations(self, room_id, **kwargs): """Retrieves the integrations which the group has""" return self.__call_api_get('groups.getIntegrations', roomId=room_id, kwargs=kwargs)
[ "def", "groups_get_integrations", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'groups.getIntegrations'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Retrieves the integrations which the group has
[ "Retrieves", "the", "integrations", "which", "the", "group", "has" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L482-L484
train
206,071
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_invite
def groups_invite(self, room_id, user_id, **kwargs): """Adds a user to the private group.""" return self.__call_api_post('groups.invite', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def groups_invite(self, room_id, user_id, **kwargs): """Adds a user to the private group.""" return self.__call_api_post('groups.invite', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "groups_invite", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.invite'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwargs", "=", "k...
Adds a user to the private group.
[ "Adds", "a", "user", "to", "the", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L495-L497
train
206,072
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_kick
def groups_kick(self, room_id, user_id, **kwargs): """Removes a user from the private group.""" return self.__call_api_post('groups.kick', roomId=room_id, userId=user_id, kwargs=kwargs)
python
def groups_kick(self, room_id, user_id, **kwargs): """Removes a user from the private group.""" return self.__call_api_post('groups.kick', roomId=room_id, userId=user_id, kwargs=kwargs)
[ "def", "groups_kick", "(", "self", ",", "room_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.kick'", ",", "roomId", "=", "room_id", ",", "userId", "=", "user_id", ",", "kwargs", "=", "kwarg...
Removes a user from the private group.
[ "Removes", "a", "user", "from", "the", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L499-L501
train
206,073
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_rename
def groups_rename(self, room_id, name, **kwargs): """Changes the name of the private group.""" return self.__call_api_post('groups.rename', roomId=room_id, name=name, kwargs=kwargs)
python
def groups_rename(self, room_id, name, **kwargs): """Changes the name of the private group.""" return self.__call_api_post('groups.rename', roomId=room_id, name=name, kwargs=kwargs)
[ "def", "groups_rename", "(", "self", ",", "room_id", ",", "name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.rename'", ",", "roomId", "=", "room_id", ",", "name", "=", "name", ",", "kwargs", "=", "kwargs", ...
Changes the name of the private group.
[ "Changes", "the", "name", "of", "the", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L511-L513
train
206,074
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_set_description
def groups_set_description(self, room_id, description, **kwargs): """Sets the description for the private group.""" return self.__call_api_post('groups.setDescription', roomId=room_id, description=description, kwargs=kwargs)
python
def groups_set_description(self, room_id, description, **kwargs): """Sets the description for the private group.""" return self.__call_api_post('groups.setDescription', roomId=room_id, description=description, kwargs=kwargs)
[ "def", "groups_set_description", "(", "self", ",", "room_id", ",", "description", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.setDescription'", ",", "roomId", "=", "room_id", ",", "description", "=", "description", ...
Sets the description for the private group.
[ "Sets", "the", "description", "for", "the", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L515-L517
train
206,075
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_set_read_only
def groups_set_read_only(self, room_id, read_only, **kwargs): """Sets whether the group is read only or not.""" return self.__call_api_post('groups.setReadOnly', roomId=room_id, readOnly=bool(read_only), kwargs=kwargs)
python
def groups_set_read_only(self, room_id, read_only, **kwargs): """Sets whether the group is read only or not.""" return self.__call_api_post('groups.setReadOnly', roomId=room_id, readOnly=bool(read_only), kwargs=kwargs)
[ "def", "groups_set_read_only", "(", "self", ",", "room_id", ",", "read_only", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.setReadOnly'", ",", "roomId", "=", "room_id", ",", "readOnly", "=", "bool", "(", "read_on...
Sets whether the group is read only or not.
[ "Sets", "whether", "the", "group", "is", "read", "only", "or", "not", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L519-L521
train
206,076
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_set_topic
def groups_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the private group.""" return self.__call_api_post('groups.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
python
def groups_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the private group.""" return self.__call_api_post('groups.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
[ "def", "groups_set_topic", "(", "self", ",", "room_id", ",", "topic", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.setTopic'", ",", "roomId", "=", "room_id", ",", "topic", "=", "topic", ",", "kwargs", "=", "k...
Sets the topic for the private group.
[ "Sets", "the", "topic", "for", "the", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L523-L525
train
206,077
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_set_type
def groups_set_type(self, room_id, a_type, **kwargs): """Sets the type of room this group should be. The type of room this channel should be, either c or p.""" return self.__call_api_post('groups.setType', roomId=room_id, type=a_type, kwargs=kwargs)
python
def groups_set_type(self, room_id, a_type, **kwargs): """Sets the type of room this group should be. The type of room this channel should be, either c or p.""" return self.__call_api_post('groups.setType', roomId=room_id, type=a_type, kwargs=kwargs)
[ "def", "groups_set_type", "(", "self", ",", "room_id", ",", "a_type", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'groups.setType'", ",", "roomId", "=", "room_id", ",", "type", "=", "a_type", ",", "kwargs", "=", "kw...
Sets the type of room this group should be. The type of room this channel should be, either c or p.
[ "Sets", "the", "type", "of", "room", "this", "group", "should", "be", ".", "The", "type", "of", "room", "this", "channel", "should", "be", "either", "c", "or", "p", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L527-L529
train
206,078
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.groups_delete
def groups_delete(self, room_id=None, group=None, **kwargs): """Delete a private group.""" if room_id: return self.__call_api_post('groups.delete', roomId=room_id, kwargs=kwargs) elif group: return self.__call_api_post('groups.delete', roomName=group, kwargs=kwargs) else: raise RocketMissingParamException('roomId or group required')
python
def groups_delete(self, room_id=None, group=None, **kwargs): """Delete a private group.""" if room_id: return self.__call_api_post('groups.delete', roomId=room_id, kwargs=kwargs) elif group: return self.__call_api_post('groups.delete', roomName=group, kwargs=kwargs) else: raise RocketMissingParamException('roomId or group required')
[ "def", "groups_delete", "(", "self", ",", "room_id", "=", "None", ",", "group", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "room_id", ":", "return", "self", ".", "__call_api_post", "(", "'groups.delete'", ",", "roomId", "=", "room_id", ",", ...
Delete a private group.
[ "Delete", "a", "private", "group", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L531-L538
train
206,079
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.im_history
def im_history(self, room_id, **kwargs): """Retrieves the history for a private im chat""" return self.__call_api_get('im.history', roomId=room_id, kwargs=kwargs)
python
def im_history(self, room_id, **kwargs): """Retrieves the history for a private im chat""" return self.__call_api_get('im.history', roomId=room_id, kwargs=kwargs)
[ "def", "im_history", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'im.history'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Retrieves the history for a private im chat
[ "Retrieves", "the", "history", "for", "a", "private", "im", "chat" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L576-L578
train
206,080
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.im_create
def im_create(self, username, **kwargs): """Create a direct message session with another user.""" return self.__call_api_post('im.create', username=username, kwargs=kwargs)
python
def im_create(self, username, **kwargs): """Create a direct message session with another user.""" return self.__call_api_post('im.create', username=username, kwargs=kwargs)
[ "def", "im_create", "(", "self", ",", "username", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'im.create'", ",", "username", "=", "username", ",", "kwargs", "=", "kwargs", ")" ]
Create a direct message session with another user.
[ "Create", "a", "direct", "message", "session", "with", "another", "user", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L580-L582
train
206,081
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.im_messages_others
def im_messages_others(self, room_id, **kwargs): """Retrieves the messages from any direct message in the server""" return self.__call_api_get('im.messages.others', roomId=room_id, kwargs=kwargs)
python
def im_messages_others(self, room_id, **kwargs): """Retrieves the messages from any direct message in the server""" return self.__call_api_get('im.messages.others', roomId=room_id, kwargs=kwargs)
[ "def", "im_messages_others", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'im.messages.others'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Retrieves the messages from any direct message in the server
[ "Retrieves", "the", "messages", "from", "any", "direct", "message", "in", "the", "server" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L592-L594
train
206,082
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.im_set_topic
def im_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the direct message""" return self.__call_api_post('im.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
python
def im_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the direct message""" return self.__call_api_post('im.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
[ "def", "im_set_topic", "(", "self", ",", "room_id", ",", "topic", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'im.setTopic'", ",", "roomId", "=", "room_id", ",", "topic", "=", "topic", ",", "kwargs", "=", "kwargs", ...
Sets the topic for the direct message
[ "Sets", "the", "topic", "for", "the", "direct", "message" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L596-L598
train
206,083
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.im_files
def im_files(self, room_id=None, user_name=None, **kwargs): """Retrieves the files from a direct message.""" if room_id: return self.__call_api_get('im.files', roomId=room_id, kwargs=kwargs) elif user_name: return self.__call_api_get('im.files', username=user_name, kwargs=kwargs) else: raise RocketMissingParamException('roomId or username required')
python
def im_files(self, room_id=None, user_name=None, **kwargs): """Retrieves the files from a direct message.""" if room_id: return self.__call_api_get('im.files', roomId=room_id, kwargs=kwargs) elif user_name: return self.__call_api_get('im.files', username=user_name, kwargs=kwargs) else: raise RocketMissingParamException('roomId or username required')
[ "def", "im_files", "(", "self", ",", "room_id", "=", "None", ",", "user_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "room_id", ":", "return", "self", ".", "__call_api_get", "(", "'im.files'", ",", "roomId", "=", "room_id", ",", "kwargs...
Retrieves the files from a direct message.
[ "Retrieves", "the", "files", "from", "a", "direct", "message", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L600-L607
train
206,084
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.rooms_upload
def rooms_upload(self, rid, file, **kwargs): """Post a message with attached file to a dedicated room.""" files = { 'file': (os.path.basename(file), open(file, 'rb'), mimetypes.guess_type(file)[0]), } return self.__call_api_post('rooms.upload/' + rid, kwargs=kwargs, use_json=False, files=files)
python
def rooms_upload(self, rid, file, **kwargs): """Post a message with attached file to a dedicated room.""" files = { 'file': (os.path.basename(file), open(file, 'rb'), mimetypes.guess_type(file)[0]), } return self.__call_api_post('rooms.upload/' + rid, kwargs=kwargs, use_json=False, files=files)
[ "def", "rooms_upload", "(", "self", ",", "rid", ",", "file", ",", "*", "*", "kwargs", ")", ":", "files", "=", "{", "'file'", ":", "(", "os", ".", "path", ".", "basename", "(", "file", ")", ",", "open", "(", "file", ",", "'rb'", ")", ",", "mimet...
Post a message with attached file to a dedicated room.
[ "Post", "a", "message", "with", "attached", "file", "to", "a", "dedicated", "room", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L644-L649
train
206,085
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.rooms_clean_history
def rooms_clean_history(self, room_id, latest, oldest, **kwargs): """Cleans up a room, removing messages from the provided time range.""" return self.__call_api_post('rooms.cleanHistory', roomId=room_id, latest=latest, oldest=oldest, kwargs=kwargs)
python
def rooms_clean_history(self, room_id, latest, oldest, **kwargs): """Cleans up a room, removing messages from the provided time range.""" return self.__call_api_post('rooms.cleanHistory', roomId=room_id, latest=latest, oldest=oldest, kwargs=kwargs)
[ "def", "rooms_clean_history", "(", "self", ",", "room_id", ",", "latest", ",", "oldest", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'rooms.cleanHistory'", ",", "roomId", "=", "room_id", ",", "latest", "=", "latest", ...
Cleans up a room, removing messages from the provided time range.
[ "Cleans", "up", "a", "room", "removing", "messages", "from", "the", "provided", "time", "range", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L655-L657
train
206,086
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.rooms_favorite
def rooms_favorite(self, room_id=None, room_name=None, favorite=True): """Favorite or unfavorite room.""" if room_id is not None: return self.__call_api_post('rooms.favorite', roomId=room_id, favorite=favorite) elif room_name is not None: return self.__call_api_post('rooms.favorite', roomName=room_name, favorite=favorite) else: raise RocketMissingParamException('roomId or roomName required')
python
def rooms_favorite(self, room_id=None, room_name=None, favorite=True): """Favorite or unfavorite room.""" if room_id is not None: return self.__call_api_post('rooms.favorite', roomId=room_id, favorite=favorite) elif room_name is not None: return self.__call_api_post('rooms.favorite', roomName=room_name, favorite=favorite) else: raise RocketMissingParamException('roomId or roomName required')
[ "def", "rooms_favorite", "(", "self", ",", "room_id", "=", "None", ",", "room_name", "=", "None", ",", "favorite", "=", "True", ")", ":", "if", "room_id", "is", "not", "None", ":", "return", "self", ".", "__call_api_post", "(", "'rooms.favorite'", ",", "...
Favorite or unfavorite room.
[ "Favorite", "or", "unfavorite", "room", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L659-L666
train
206,087
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.rooms_info
def rooms_info(self, room_id=None, room_name=None): """Retrieves the information about the room.""" if room_id is not None: return self.__call_api_get('rooms.info', roomId=room_id) elif room_name is not None: return self.__call_api_get('rooms.info', roomName=room_name) else: raise RocketMissingParamException('roomId or roomName required')
python
def rooms_info(self, room_id=None, room_name=None): """Retrieves the information about the room.""" if room_id is not None: return self.__call_api_get('rooms.info', roomId=room_id) elif room_name is not None: return self.__call_api_get('rooms.info', roomName=room_name) else: raise RocketMissingParamException('roomId or roomName required')
[ "def", "rooms_info", "(", "self", ",", "room_id", "=", "None", ",", "room_name", "=", "None", ")", ":", "if", "room_id", "is", "not", "None", ":", "return", "self", ".", "__call_api_get", "(", "'rooms.info'", ",", "roomId", "=", "room_id", ")", "elif", ...
Retrieves the information about the room.
[ "Retrieves", "the", "information", "about", "the", "room", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L668-L675
train
206,088
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.subscriptions_get_one
def subscriptions_get_one(self, room_id, **kwargs): """Get the subscription by room id.""" return self.__call_api_get('subscriptions.getOne', roomId=room_id, kwargs=kwargs)
python
def subscriptions_get_one(self, room_id, **kwargs): """Get the subscription by room id.""" return self.__call_api_get('subscriptions.getOne', roomId=room_id, kwargs=kwargs)
[ "def", "subscriptions_get_one", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'subscriptions.getOne'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Get the subscription by room id.
[ "Get", "the", "subscription", "by", "room", "id", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L683-L685
train
206,089
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.subscriptions_unread
def subscriptions_unread(self, room_id, **kwargs): """Mark messages as unread by roomId or from a message""" return self.__call_api_post('subscriptions.unread', roomId=room_id, kwargs=kwargs)
python
def subscriptions_unread(self, room_id, **kwargs): """Mark messages as unread by roomId or from a message""" return self.__call_api_post('subscriptions.unread', roomId=room_id, kwargs=kwargs)
[ "def", "subscriptions_unread", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'subscriptions.unread'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Mark messages as unread by roomId or from a message
[ "Mark", "messages", "as", "unread", "by", "roomId", "or", "from", "a", "message" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L687-L689
train
206,090
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.subscriptions_read
def subscriptions_read(self, rid, **kwargs): """Mark room as read""" return self.__call_api_post('subscriptions.read', rid=rid, kwargs=kwargs)
python
def subscriptions_read(self, rid, **kwargs): """Mark room as read""" return self.__call_api_post('subscriptions.read', rid=rid, kwargs=kwargs)
[ "def", "subscriptions_read", "(", "self", ",", "rid", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'subscriptions.read'", ",", "rid", "=", "rid", ",", "kwargs", "=", "kwargs", ")" ]
Mark room as read
[ "Mark", "room", "as", "read" ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L691-L693
train
206,091
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
RocketChat.assets_set_asset
def assets_set_asset(self, asset_name, file, **kwargs): """Set an asset image by name.""" content_type = mimetypes.MimeTypes().guess_type(file) files = { asset_name: (file, open(file, 'rb'), content_type[0], {'Expires': '0'}), } return self.__call_api_post('assets.setAsset', kwargs=kwargs, use_json=False, files=files)
python
def assets_set_asset(self, asset_name, file, **kwargs): """Set an asset image by name.""" content_type = mimetypes.MimeTypes().guess_type(file) files = { asset_name: (file, open(file, 'rb'), content_type[0], {'Expires': '0'}), } return self.__call_api_post('assets.setAsset', kwargs=kwargs, use_json=False, files=files)
[ "def", "assets_set_asset", "(", "self", ",", "asset_name", ",", "file", ",", "*", "*", "kwargs", ")", ":", "content_type", "=", "mimetypes", ".", "MimeTypes", "(", ")", ".", "guess_type", "(", "file", ")", "files", "=", "{", "asset_name", ":", "(", "fi...
Set an asset image by name.
[ "Set", "an", "asset", "image", "by", "name", "." ]
f220d094434991cb9892418245f054ea06f28aad
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L697-L703
train
206,092
invisibleroads/socketIO-client
socketIO_client/namespaces.py
find_callback
def find_callback(args, kw=None): 'Return callback whether passed as a last argument or as a keyword' if args and callable(args[-1]): return args[-1], args[:-1] try: return kw['callback'], args except (KeyError, TypeError): return None, args
python
def find_callback(args, kw=None): 'Return callback whether passed as a last argument or as a keyword' if args and callable(args[-1]): return args[-1], args[:-1] try: return kw['callback'], args except (KeyError, TypeError): return None, args
[ "def", "find_callback", "(", "args", ",", "kw", "=", "None", ")", ":", "if", "args", "and", "callable", "(", "args", "[", "-", "1", "]", ")", ":", "return", "args", "[", "-", "1", "]", ",", "args", "[", ":", "-", "1", "]", "try", ":", "return...
Return callback whether passed as a last argument or as a keyword
[ "Return", "callback", "whether", "passed", "as", "a", "last", "argument", "or", "as", "a", "keyword" ]
1e58adda9397500d89b4521c90aa06e6a511cef6
https://github.com/invisibleroads/socketIO-client/blob/1e58adda9397500d89b4521c90aa06e6a511cef6/socketIO_client/namespaces.py#L236-L243
train
206,093
invisibleroads/socketIO-client
socketIO_client/namespaces.py
EngineIONamespace.once
def once(self, event, callback): 'Define a callback to handle the first event emitted by the server' self._once_events.add(event) self.on(event, callback)
python
def once(self, event, callback): 'Define a callback to handle the first event emitted by the server' self._once_events.add(event) self.on(event, callback)
[ "def", "once", "(", "self", ",", "event", ",", "callback", ")", ":", "self", ".", "_once_events", ".", "add", "(", "event", ")", "self", ".", "on", "(", "event", ",", "callback", ")" ]
Define a callback to handle the first event emitted by the server
[ "Define", "a", "callback", "to", "handle", "the", "first", "event", "emitted", "by", "the", "server" ]
1e58adda9397500d89b4521c90aa06e6a511cef6
https://github.com/invisibleroads/socketIO-client/blob/1e58adda9397500d89b4521c90aa06e6a511cef6/socketIO_client/namespaces.py#L22-L25
train
206,094
invisibleroads/socketIO-client
socketIO_client/namespaces.py
EngineIONamespace.off
def off(self, event): 'Remove an event handler' try: self._once_events.remove(event) except KeyError: pass self._callback_by_event.pop(event, None)
python
def off(self, event): 'Remove an event handler' try: self._once_events.remove(event) except KeyError: pass self._callback_by_event.pop(event, None)
[ "def", "off", "(", "self", ",", "event", ")", ":", "try", ":", "self", ".", "_once_events", ".", "remove", "(", "event", ")", "except", "KeyError", ":", "pass", "self", ".", "_callback_by_event", ".", "pop", "(", "event", ",", "None", ")" ]
Remove an event handler
[ "Remove", "an", "event", "handler" ]
1e58adda9397500d89b4521c90aa06e6a511cef6
https://github.com/invisibleroads/socketIO-client/blob/1e58adda9397500d89b4521c90aa06e6a511cef6/socketIO_client/namespaces.py#L27-L33
train
206,095
invisibleroads/socketIO-client
socketIO_client/__init__.py
EngineIO.wait
def wait(self, seconds=None, **kw): 'Wait in a loop and react to events as defined in the namespaces' # Use ping/pong to unblock recv for polling transport self._heartbeat_thread.hurry() # Use timeout to unblock recv for websocket transport self._transport.set_timeout(seconds=1) # Listen warning_screen = self._yield_warning_screen(seconds) for elapsed_time in warning_screen: if self._should_stop_waiting(**kw): break try: try: self._process_packets() except TimeoutError: pass except KeyboardInterrupt: self._close() raise except ConnectionError as e: self._opened = False try: warning = Exception('[connection error] %s' % e) warning_screen.throw(warning) except StopIteration: self._warn(warning) try: namespace = self.get_namespace() namespace._find_packet_callback('disconnect')() except PacketError: pass self._heartbeat_thread.relax() self._transport.set_timeout()
python
def wait(self, seconds=None, **kw): 'Wait in a loop and react to events as defined in the namespaces' # Use ping/pong to unblock recv for polling transport self._heartbeat_thread.hurry() # Use timeout to unblock recv for websocket transport self._transport.set_timeout(seconds=1) # Listen warning_screen = self._yield_warning_screen(seconds) for elapsed_time in warning_screen: if self._should_stop_waiting(**kw): break try: try: self._process_packets() except TimeoutError: pass except KeyboardInterrupt: self._close() raise except ConnectionError as e: self._opened = False try: warning = Exception('[connection error] %s' % e) warning_screen.throw(warning) except StopIteration: self._warn(warning) try: namespace = self.get_namespace() namespace._find_packet_callback('disconnect')() except PacketError: pass self._heartbeat_thread.relax() self._transport.set_timeout()
[ "def", "wait", "(", "self", ",", "seconds", "=", "None", ",", "*", "*", "kw", ")", ":", "# Use ping/pong to unblock recv for polling transport", "self", ".", "_heartbeat_thread", ".", "hurry", "(", ")", "# Use timeout to unblock recv for websocket transport", "self", ...
Wait in a loop and react to events as defined in the namespaces
[ "Wait", "in", "a", "loop", "and", "react", "to", "events", "as", "defined", "in", "the", "namespaces" ]
1e58adda9397500d89b4521c90aa06e6a511cef6
https://github.com/invisibleroads/socketIO-client/blob/1e58adda9397500d89b4521c90aa06e6a511cef6/socketIO_client/__init__.py#L238-L270
train
206,096
invisibleroads/socketIO-client
socketIO_client/__init__.py
SocketIO._prepare_to_send_ack
def _prepare_to_send_ack(self, path, ack_id): 'Return function that acknowledges the server' return lambda *args: self._ack(path, ack_id, *args)
python
def _prepare_to_send_ack(self, path, ack_id): 'Return function that acknowledges the server' return lambda *args: self._ack(path, ack_id, *args)
[ "def", "_prepare_to_send_ack", "(", "self", ",", "path", ",", "ack_id", ")", ":", "return", "lambda", "*", "args", ":", "self", ".", "_ack", "(", "path", ",", "ack_id", ",", "*", "args", ")" ]
Return function that acknowledges the server
[ "Return", "function", "that", "acknowledges", "the", "server" ]
1e58adda9397500d89b4521c90aa06e6a511cef6
https://github.com/invisibleroads/socketIO-client/blob/1e58adda9397500d89b4521c90aa06e6a511cef6/socketIO_client/__init__.py#L531-L533
train
206,097
asciimoo/drawille
examples/rotating_cube.py
Point3D.rotateX
def rotateX(self, angle): """ Rotates the point around the X axis by the given angle in degrees. """ rad = angle * math.pi / 180 cosa = math.cos(rad) sina = math.sin(rad) y = self.y * cosa - self.z * sina z = self.y * sina + self.z * cosa return Point3D(self.x, y, z)
python
def rotateX(self, angle): """ Rotates the point around the X axis by the given angle in degrees. """ rad = angle * math.pi / 180 cosa = math.cos(rad) sina = math.sin(rad) y = self.y * cosa - self.z * sina z = self.y * sina + self.z * cosa return Point3D(self.x, y, z)
[ "def", "rotateX", "(", "self", ",", "angle", ")", ":", "rad", "=", "angle", "*", "math", ".", "pi", "/", "180", "cosa", "=", "math", ".", "cos", "(", "rad", ")", "sina", "=", "math", ".", "sin", "(", "rad", ")", "y", "=", "self", ".", "y", ...
Rotates the point around the X axis by the given angle in degrees.
[ "Rotates", "the", "point", "around", "the", "X", "axis", "by", "the", "given", "angle", "in", "degrees", "." ]
ab58bba76cad68674ce50df7382c235ed21ab5ae
https://github.com/asciimoo/drawille/blob/ab58bba76cad68674ce50df7382c235ed21ab5ae/examples/rotating_cube.py#L19-L26
train
206,098
asciimoo/drawille
drawille.py
animate
def animate(canvas, fn, delay=1./24, *args, **kwargs): """Animation automation function :param canvas: :class:`Canvas` object :param fn: Callable. Frame coord generator :param delay: Float. Delay between frames. :param *args, **kwargs: optional fn parameters """ # python2 unicode curses fix if not IS_PY3: import locale locale.setlocale(locale.LC_ALL, "") def animation(stdscr): for frame in fn(*args, **kwargs): for x,y in frame: canvas.set(x,y) f = canvas.frame() stdscr.addstr(0, 0, '{0}\n'.format(f)) stdscr.refresh() if delay: sleep(delay) canvas.clear() curses.wrapper(animation)
python
def animate(canvas, fn, delay=1./24, *args, **kwargs): """Animation automation function :param canvas: :class:`Canvas` object :param fn: Callable. Frame coord generator :param delay: Float. Delay between frames. :param *args, **kwargs: optional fn parameters """ # python2 unicode curses fix if not IS_PY3: import locale locale.setlocale(locale.LC_ALL, "") def animation(stdscr): for frame in fn(*args, **kwargs): for x,y in frame: canvas.set(x,y) f = canvas.frame() stdscr.addstr(0, 0, '{0}\n'.format(f)) stdscr.refresh() if delay: sleep(delay) canvas.clear() curses.wrapper(animation)
[ "def", "animate", "(", "canvas", ",", "fn", ",", "delay", "=", "1.", "/", "24", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# python2 unicode curses fix", "if", "not", "IS_PY3", ":", "import", "locale", "locale", ".", "setlocale", "(", "local...
Animation automation function :param canvas: :class:`Canvas` object :param fn: Callable. Frame coord generator :param delay: Float. Delay between frames. :param *args, **kwargs: optional fn parameters
[ "Animation", "automation", "function" ]
ab58bba76cad68674ce50df7382c235ed21ab5ae
https://github.com/asciimoo/drawille/blob/ab58bba76cad68674ce50df7382c235ed21ab5ae/drawille.py#L390-L417
train
206,099