Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def has_submenu_items(self, current_page, allow_repeating_parents, original_menu_tag, menu_instance=None, request=None): return menu_instance.page_has_children(self)
[ "\n When rendering pages in a menu template a `has_children_in_menu`\n attribute is added to each page, letting template developers know\n whether or not the item has a submenu that must be rendered.\n\n By default, we return a boolean indicating whether the page has\n suitable ch...
Please provide a description of the function:def get_text_for_repeated_menu_item( self, request=None, current_site=None, original_menu_tag='', **kwargs ): source_field_name = settings.PAGE_FIELD_FOR_MENU_ITEM_TEXT return self.repeated_item_text or getattr( self, source_f...
[ "Return the a string to use as 'text' for this page when it is being\n included as a 'repeated' menu item in a menu. You might want to\n override this method if you're creating a multilingual site and you\n have different translations of 'repeated_item_text' that you wish to\n surface." ...
Please provide a description of the function:def get_repeated_menu_item( self, current_page, current_site, apply_active_classes, original_menu_tag, request=None, use_absolute_page_urls=False, ): menuitem = copy(self) # Set/reset 'text' menuitem.text = self.get_text...
[ "Return something that can be used to display a 'repeated' menu item\n for this specific page." ]
Please provide a description of the function:def menu_text(self, request=None): source_field_name = settings.PAGE_FIELD_FOR_MENU_ITEM_TEXT if( source_field_name != 'menu_text' and hasattr(self, source_field_name) ): return getattr(self, source_field_n...
[ "Return a string to use as link text when this page appears in\n menus." ]
Please provide a description of the function:def link_page_is_suitable_for_display( self, request=None, current_site=None, menu_instance=None, original_menu_tag='' ): if self.link_page: if( not self.link_page.show_in_menus or not self.link...
[ "\n Like menu items, link pages linking to pages should only be included\n in menus when the target page is live and is itself configured to\n appear in menus. Returns a boolean indicating as much\n " ]
Please provide a description of the function:def show_in_menus_custom(self, request=None, current_site=None, menu_instance=None, original_menu_tag=''): if not self.show_in_menus: return False if self.link_page: return self.link_page_is_suitab...
[ "\n Return a boolean indicating whether this page should be included in\n menus being rendered.\n " ]
Please provide a description of the function:def accepts_kwarg(func, kwarg): signature = inspect.signature(func) try: signature.bind_partial(**{kwarg: None}) return True except TypeError: return False
[ "\n Determine whether the callable `func` has a signature that accepts the\n keyword argument `kwarg`\n " ]
Please provide a description of the function:def section_menu( context, show_section_root=True, show_multiple_levels=True, apply_active_classes=True, allow_repeating_parents=True, max_levels=settings.DEFAULT_SECTION_MENU_MAX_LEVELS, template='', sub_menu_template='', sub_menu_templates=None, use_spe...
[ "Render a section menu for the current section." ]
Please provide a description of the function:def sub_menu( context, menuitem_or_page, use_specific=None, allow_repeating_parents=None, apply_active_classes=None, template='', use_absolute_page_urls=None, add_sub_menus_inline=None, **kwargs ): validate_supplied_values('sub_menu', use_specific=use_sp...
[ "\n Retrieve the children pages for the `menuitem_or_page` provided, turn them\n into menu items, and render them to a template.\n " ]
Please provide a description of the function:def get_version(version): "Returns a PEP 386-compliant version number from VERSION." # Now build the two parts of the version number: # main = X.Y[.Z] # sub = .devN - for pre-alpha releases # | {a|b|c}N - for alpha, beta and rc releases main = ge...
[]
Please provide a description of the function:def get_main_version(version): "Returns main version (X.Y[.Z]) from VERSION." parts = 2 if version[2] == 0 else 3 return '.'.join(str(x) for x in version[:parts])
[]
Please provide a description of the function:def get_active_class_for_request(self, request=None): parsed_url = urlparse(self.link_url) if parsed_url.netloc: return '' if request.path == parsed_url.path: return settings.ACTIVE_CLASS if ( reque...
[ "\n Return the most appropriate 'active_class' for this menu item (only\n used when 'link_url' is used instead of 'link_page').\n " ]
Please provide a description of the function:def trace(self, *attributes): def decorator(f): def wrapper(*args, **kwargs): if self._trace_all_requests: return f(*args, **kwargs) self._before_request_fn(list(attributes)) tr...
[ "\n Function decorator that traces functions\n\n NOTE: Must be placed after the @app.route decorator\n\n @param attributes any number of flask.Request attributes\n (strings) to be set as tags on the created span\n " ]
Please provide a description of the function:def get_span(self, request=None): if request is None and stack.top: request = stack.top.request scope = self._current_scopes.get(request, None) return None if scope is None else scope.span
[ "\n Returns the span tracing `request`, or the current request if\n `request==None`.\n\n If there is no such span, get_span returns None.\n\n @param request the request to get the span from\n " ]
Please provide a description of the function:def initial_value(self, field_name: str = None): if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith('_id'): field_name = field_name+'_id' attribute = self._diff_with_initia...
[ "\n Get initial value of field when model was instantiated.\n " ]
Please provide a description of the function:def has_changed(self, field_name: str = None) -> bool: changed = self._diff_with_initial.keys() if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith('_id'): field_name = fiel...
[ "\n Check if a field has changed since the model was instantiated.\n " ]
Please provide a description of the function:def _property_names(self): property_names = [] for name in dir(self): try: attr = getattr(type(self), name) if isinstance(attr, property) or isinstance(attr, cached_property): property...
[ "\n Gather up properties and cached_properties which may be methods\n that were decorated. Need to inspect class versions b/c doing\n getattr on them could cause unwanted side effects.\n " ]
Please provide a description of the function:def _descriptor_names(self): descriptor_names = [] for name in dir(self): try: attr = getattr(type(self), name) if isinstance(attr, DJANGO_RELATED_FIELD_DESCRIPTOR_CLASSES): descripto...
[ "\n Attributes which are Django descriptors. These represent a field\n which is a one-to-many or many-to-many relationship that is\n potentially defined in another model, and doesn't otherwise appear\n as a field on this model.\n " ]
Please provide a description of the function:def _run_hooked_methods(self, hook: str): for method in self._potentially_hooked_methods: for callback_specs in method._hooked: if callback_specs['hook'] != hook: continue when = callback_specs...
[ "\n Iterate through decorated methods to find those that should be\n triggered by the current hook. If conditions exist, check them before\n running otherwise go ahead and run.\n " ]
Please provide a description of the function:def loop(server, test_loop=None): try: loops_without_activity = 0 while test_loop is None or test_loop > 0: start = time.time() loops_without_activity += 1 events = server.slack.rtm_read() for event in...
[ "Run the main loop\n\n server is a limbo Server object\n test_loop, if present, is a number of times to run the loop\n " ]
Please provide a description of the function:def weather(searchterm): unit = "si" if os.environ.get("WEATHER_CELSIUS") else "us" geo = requests.get( "https://api.mapbox.com/geocoding/v5/mapbox.places/{}.json?limit=1&access_token={}".format( quote(searchterm.encode("utf8")), MAPBOX_API_...
[ "Get the weather for a place given by searchterm\n\n Returns a title and a list of forecasts.\n\n The title describes the location for the forecast (i.e. \"Portland, ME USA\")\n The list of forecasts is a list of dictionaries in slack attachment fields\n format (see https://api.slack.com/docs/messag...
Please provide a description of the function:def dig(obj, *keys): for key in keys: if not obj or key not in obj: return None obj = obj[key] return obj
[ "\n Return obj[key_1][key_2][...] for each key in keys, or None if any key\n in the chain is not found\n\n So, given this `obj`:\n\n {\n \"banana\": {\n \"cream\": \"pie\"\n }\n }\n\n dig(obj, \"banana\") -> {\"cream\": \"pie\"}\n dig(obj, \"banana\", \"cream\") -> \"pi...
Please provide a description of the function:def rtm_send_message(self, channel_id, message, thread_ts=None): message = {"type": "message", "channel": channel_id, "text": message} if thread_ts: message["thread_ts"] = thread_ts self.send_to_websocket(message)
[ "\n Send a message using the slack webhook (RTM) API.\n\n RTM messages should be used for simple messages that don't include anything fancy (like\n attachments). Use Slack's basic message formatting:\n https://api.slack.com/docs/message-formatting\n " ]
Please provide a description of the function:def post_message(self, channel_id, message, **kwargs): params = { "post_data": { "text": message, "channel": channel_id, } } params["post_data"].update(kwargs) return self.api_c...
[ "\n Send a message using the slack Event API.\n\n Event messages should be used for more complex messages. See\n https://api.slack.com/methods/chat.postMessage for details on arguments can be included\n with your message.\n\n When using the post_message API, to have your message l...
Please provide a description of the function:def post_reaction(self, channel_id, timestamp, reaction_name, **kwargs): params = { "post_data": { "name": reaction_name, "channel": channel_id, "timestamp": timestamp, } } ...
[ "\n Send a reaction to a message using slack Event API\n " ]
Please provide a description of the function:def get_all(self, api_method, collection_name, **kwargs): objs = [] limit = 250 # if you don't provide a limit, the slack API won't return a cursor to you page = json.loads(self.api_call(api_method, limit=limit, **kwargs)) whi...
[ "\n Return all objects in an api_method, handle pagination, and pass\n kwargs on to the method being called.\n\n For example, \"users.list\" returns an object like:\n\n {\n \"members\": [{<member_obj>}, {<member_obj_2>}],\n \"response_metadata\": {\n ...
Please provide a description of the function:def websocket_safe_read(self): data = [] while True: try: data.append(self.websocket.recv()) except (SSLError, SSLWantReadError) as err: if err.errno == 2: # errno 2 occurs w...
[ " Returns data if available, otherwise ''. Newlines indicate multiple\n messages\n " ]
Please provide a description of the function:def poll(poll, msg, server): poll = remove_smart_quotes(poll.replace(u"\u2014", u"--")) try: args = ARGPARSE.parse_args(shlex.split(poll)).poll except ValueError: return ERROR_INVALID_FORMAT if not 2 < len(args) < len(POLL_EMOJIS) + 1: ...
[ "Given a question and answers, present a poll" ]
Please provide a description of the function:def emoji_list(server, n=1): global EMOJI if EMOJI is None: EMOJI = EmojiCache(server) return EMOJI.get(n)
[ "return a list of `n` random emoji" ]
Please provide a description of the function:def wiki(searchterm): searchterm = quote(searchterm) url = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json" url = url.format(searchterm) result = requests.get(url).json() pages = result["query"]["search"] ...
[ "return the top wiki search result for the term" ]
Please provide a description of the function:def gif(search, unsafe=False): searchb = quote(search.encode("utf8")) safe = "&safe=" if unsafe else "&safe=active" searchurl = "https://www.google.com/search?tbs=itp:animated&tbm=isch&q={0}{1}" \ .format(searchb, safe) # this is an old iphone ...
[ "given a search string, return a gif URL via google search" ]
Please provide a description of the function:def on_message(msg, server): text = msg.get("text", "") match = re.findall(r"!gif (.*)", text) if not match: return res = gif(match[0]) if not res: return attachment = { "fallback": match[0], "title": match[0], ...
[ "handle a message and return an gif" ]
Please provide a description of the function:def fromfile(fname): fig = SVGFigure() with open(fname) as fid: svg_file = etree.parse(fid) fig.root = svg_file.getroot() return fig
[ "Open SVG figure from file.\n\n Parameters\n ----------\n fname : str\n name of the SVG file\n\n Returns\n -------\n SVGFigure\n newly created :py:class:`SVGFigure` initialised with the file content\n " ]
Please provide a description of the function:def fromstring(text): fig = SVGFigure() svg = etree.fromstring(text.encode()) fig.root = svg return fig
[ "Create a SVG figure from a string.\n\n Parameters\n ----------\n text : str\n string representing the SVG content. Must be valid SVG.\n\n Returns\n -------\n SVGFigure\n newly created :py:class:`SVGFigure` initialised with the string\n content.\n " ]
Please provide a description of the function:def from_mpl(fig, savefig_kw=None): fid = StringIO() if savefig_kw is None: savefig_kw = {} try: fig.savefig(fid, format='svg', **savefig_kw) except ValueError: raise(ValueError, "No matplotlib SVG backend") fid.seek(0) ...
[ "Create a SVG figure from a ``matplotlib`` figure.\n\n Parameters\n ----------\n fig : matplotlib.Figure instance\n\n savefig_kw : dict\n keyword arguments to be passed to matplotlib's\n `savefig`\n\n\n\n Returns\n -------\n SVGFigure\n newly created :py:class:`SVGFigure`...
Please provide a description of the function:def moveto(self, x, y, scale=1): self.root.set("transform", "translate(%s, %s) scale(%s) %s" % (x, y, scale, self.root.get("transform") or ''))
[ "Move and scale element.\n\n Parameters\n ----------\n x, y : float\n displacement in x and y coordinates in user units ('px').\n scale : float\n scaling factor. To scale down scale < 1, scale up scale > 1.\n For no scaling scale = 1.\n " ]
Please provide a description of the function:def rotate(self, angle, x=0, y=0): self.root.set("transform", "%s rotate(%f %f %f)" % (self.root.get("transform") or '', angle, x, y))
[ "Rotate element by given angle around given pivot.\n\n Parameters\n ----------\n angle : float\n rotation angle in degrees\n x, y : float\n pivot coordinates in user coordinate system (defaults to top-left\n corner of the figure)\n " ]
Please provide a description of the function:def skew(self, x=0, y=0): if x is not 0: self.skew_x(x) if y is not 0: self.skew_y(y) return self
[ "Skew the element by x and y degrees\n Convenience function which calls skew_x and skew_y\n\n Parameters\n ----------\n x,y : float, float\n skew angle in degrees (default 0)\n\n If an x/y angle is given as zero degrees, that transformation is omitted.\n " ]
Please provide a description of the function:def skew_x(self, x): self.root.set("transform", "%s skewX(%f)" % (self.root.get("transform") or '', x)) return self
[ "Skew element along the x-axis by the given angle.\n\n Parameters\n ----------\n x : float\n x-axis skew angle in degrees\n " ]
Please provide a description of the function:def skew_y(self, y): self.root.set("transform", "%s skewY(%f)" % (self.root.get("transform") or '', y)) return self
[ "Skew element along the y-axis by the given angle.\n\n Parameters\n ----------\n y : float\n y-axis skew angle in degrees\n " ]
Please provide a description of the function:def scale_xy(self, x=0, y=None): self.root.set("transform", "%s scale(%f %f)" % (self.root.get("transform") or '', x, y if y is not None else ''))
[ "Scale element separately across the two axes x and y.\n If y is not provided, it is assumed equal to x (according to the\n W3 specification).\n\n Parameters\n ----------\n x : float\n x-axis scaling factor. To scale down x < 1, scale up x > 1.\n y : (opt...
Please provide a description of the function:def find_id(self, element_id): find = etree.XPath("//*[@id=$id]") return FigureElement(find(self.root, id=element_id)[0])
[ "Find element by its id.\n\n Parameters\n ----------\n element_id : str\n ID of the element to find\n\n Returns\n -------\n FigureElement\n one of the children element with the given ID." ]
Please provide a description of the function:def append(self, element): try: self.root.append(element.root) except AttributeError: self.root.append(GroupElement(element).root)
[ "Append new element to the SVG figure" ]
Please provide a description of the function:def getroot(self): if 'class' in self.root.attrib: attrib = {'class': self.root.attrib['class']} else: attrib = None return GroupElement(self.root.getchildren(), attrib=attrib)
[ "Return the root element of the figure.\n\n The root element is a group of elements after stripping the toplevel\n ``<svg>`` tag.\n\n Returns\n -------\n GroupElement\n All elements of the figure without the ``<svg>`` tag.\n " ]
Please provide a description of the function:def to_str(self): return etree.tostring(self.root, xml_declaration=True, standalone=True, pretty_print=True)
[ "\n Returns a string of the SVG figure.\n " ]
Please provide a description of the function:def save(self, fname): out = etree.tostring(self.root, xml_declaration=True, standalone=True, pretty_print=True) with open(fname, 'wb') as fid: fid.write(out)
[ "Save figure to a file" ]
Please provide a description of the function:def set_size(self, size): w, h = size self.root.set('width', w) self.root.set('height', h)
[ "Set figure size" ]
Please provide a description of the function:def find_id(self, element_id): element = _transform.FigureElement.find_id(self, element_id) return Element(element.root)
[ "Find a single element with the given ID.\n\n Parameters\n ----------\n element_id : str\n ID of the element to find\n\n Returns\n -------\n found element\n " ]
Please provide a description of the function:def find_ids(self, element_ids): elements = [_transform.FigureElement.find_id(self, eid) for eid in element_ids] return Panel(*elements)
[ "Find elements with given IDs.\n\n Parameters\n ----------\n element_ids : list of strings\n list of IDs to find\n\n Returns\n -------\n a new `Panel` object which contains all the found elements.\n " ]
Please provide a description of the function:def save(self, fname): element = _transform.SVGFigure(self.width, self.height) element.append(self) element.save(os.path.join(CONFIG['figure.save_path'], fname))
[ "Save figure to SVG file.\n\n Parameters\n ----------\n fname : str\n Full path to file.\n " ]
Please provide a description of the function:def tostr(self): element = _transform.SVGFigure(self.width, self.height) element.append(self) svgstr = element.to_str() return svgstr
[ "Export SVG as a string" ]
Please provide a description of the function:def tile(self, ncols, nrows): dx = (self.width/ncols).to('px').value dy = (self.height/nrows).to('px').value ix, iy = 0, 0 for el in self: el.move(dx*ix, dy*iy) ix += 1 if ix >= ncols: ...
[ "Automatically tile the panels of the figure.\n\n This will re-arranged all elements of the figure (first in the\n hierarchy) so that they will uniformly cover the figure area.\n\n Parameters\n ----------\n ncols, nrows : type\n The number of columns and rows to arange ...
Please provide a description of the function:def to(self, unit): u = Unit("0cm") u.value = self.value/self.per_inch[self.unit]*self.per_inch[unit] u.unit = unit return u
[ "Convert to a given unit.\n\n Parameters\n ----------\n unit : str\n Name of the unit to convert to.\n\n Returns\n -------\n u : Unit\n new Unit object with the requested unit and computed value.\n " ]
Please provide a description of the function:def set_size(self, width, height): cairo.cairo_xcb_surface_set_size(self._pointer, width, height) self._check_status()
[ "\n Informs cairo of the new size of the X Drawable underlying the surface.\n For a surface created for a Window (rather than a Pixmap), this\n function must be called each time the size of the window changes (for\n a subwindow, you are normally resizing the window yourself, but for a\n ...
Please provide a description of the function:def dlopen(ffi, *names): for name in names: for lib_name in (name, 'lib' + name): try: path = ctypes.util.find_library(lib_name) lib = ffi.dlopen(path or lib_name) if lib: return...
[ "Try various names for the same library, for different platforms." ]
Please provide a description of the function:def _check_status(status): if status != constants.STATUS_SUCCESS: exception = STATUS_TO_EXCEPTION.get(status, CairoError) status_name = ffi.string(ffi.cast("cairo_status_t", status)) message = 'cairo returned %s: %s' % ( status_na...
[ "Take a cairo status code and raise an exception if/as appropriate." ]
Please provide a description of the function:def _encode_path(path_items): points_per_type = PATH_POINTS_PER_TYPE path_items = list(path_items) length = 0 for path_type, coordinates in path_items: num_points = points_per_type[path_type] length += 1 + num_points # 1 header + N point...
[ "Take an iterable of ``(path_operation, coordinates)`` tuples\n in the same format as from :meth:`Context.copy_path`\n and return a ``(path, data)`` tuple of cdata object.\n\n The first cdata object is a ``cairo_path_t *`` pointer\n that can be used as long as both objects live.\n\n " ]
Please provide a description of the function:def _iter_path(pointer): _check_status(pointer.status) data = pointer.data num_data = pointer.num_data points_per_type = PATH_POINTS_PER_TYPE position = 0 while position < num_data: path_data = data[position] path_type = path_data...
[ "Take a cairo_path_t * pointer\n and yield ``(path_operation, coordinates)`` tuples.\n\n See :meth:`Context.copy_path` for the data structure.\n\n " ]
Please provide a description of the function:def _from_pointer(cls, pointer, incref): if pointer == ffi.NULL: raise ValueError('Null pointer') if incref: cairo.cairo_reference(pointer) self = object.__new__(cls) cls._init_pointer(self, pointer) re...
[ "Wrap an existing :c:type:`cairo_t *` cdata pointer.\n\n :type incref: bool\n :param incref:\n Whether increase the :ref:`reference count <refcounting>` now.\n :return:\n A new :class:`Context` instance.\n\n " ]
Please provide a description of the function:def get_target(self): return Surface._from_pointer( cairo.cairo_get_target(self._pointer), incref=True)
[ "Return this context’s target surface.\n\n :returns:\n An instance of :class:`Surface` or one of its sub-classes,\n a new Python object referencing the existing cairo surface.\n\n " ]
Please provide a description of the function:def push_group_with_content(self, content): cairo.cairo_push_group_with_content(self._pointer, content) self._check_status()
[ "Temporarily redirects drawing to an intermediate surface\n known as a group.\n The redirection lasts until the group is completed\n by a call to :meth:`pop_group` or :meth:`pop_group_to_source`.\n These calls provide the result of any drawing\n to the group as a pattern,\n ...
Please provide a description of the function:def pop_group(self): return Pattern._from_pointer( cairo.cairo_pop_group(self._pointer), incref=False)
[ "Terminates the redirection begun by a call to :meth:`push_group`\n or :meth:`push_group_with_content`\n and returns a new pattern containing the results\n of all drawing operations performed to the group.\n\n The :meth:`pop_group` method calls :meth:`restore`,\n (balancing a call...
Please provide a description of the function:def get_group_target(self): return Surface._from_pointer( cairo.cairo_get_group_target(self._pointer), incref=True)
[ "Returns the current destination surface for the context.\n This is either the original target surface\n as passed to :class:`Context`\n or the target surface for the current group as started\n by the most recent call to :meth:`push_group`\n or :meth:`push_group_with_content`.\n\n...
Please provide a description of the function:def set_source_rgba(self, red, green, blue, alpha=1): cairo.cairo_set_source_rgba(self._pointer, red, green, blue, alpha) self._check_status()
[ "Sets the source pattern within this context to a solid color.\n This color will then be used for any subsequent drawing operation\n until a new source pattern is set.\n\n The color and alpha components are\n floating point numbers in the range 0 to 1.\n If the values passed in a...
Please provide a description of the function:def set_source_rgb(self, red, green, blue): cairo.cairo_set_source_rgb(self._pointer, red, green, blue) self._check_status()
[ "Same as :meth:`set_source_rgba` with alpha always 1.\n Exists for compatibility with pycairo.\n\n " ]
Please provide a description of the function:def set_source_surface(self, surface, x=0, y=0): cairo.cairo_set_source_surface(self._pointer, surface._pointer, x, y) self._check_status()
[ "This is a convenience method for creating a pattern from surface\n and setting it as the source in this context with :meth:`set_source`.\n\n The :obj:`x` and :obj:`y` parameters give the user-space coordinate\n at which the surface origin should appear.\n (The surface origin is its uppe...
Please provide a description of the function:def set_source(self, source): cairo.cairo_set_source(self._pointer, source._pointer) self._check_status()
[ "Sets the source pattern within this context to :obj:`source`.\n This pattern will then be used for any subsequent drawing operation\n until a new source pattern is set.\n\n .. note::\n\n The pattern's transformation matrix will be locked\n to the user space in effect at t...
Please provide a description of the function:def get_source(self): return Pattern._from_pointer( cairo.cairo_get_source(self._pointer), incref=True)
[ "Return this context’s source.\n\n :returns:\n An instance of :class:`Pattern` or one of its sub-classes,\n a new Python object referencing the existing cairo pattern.\n\n " ]
Please provide a description of the function:def set_antialias(self, antialias): cairo.cairo_set_antialias(self._pointer, antialias) self._check_status()
[ "Set the :ref:`ANTIALIAS` of the rasterizer used for drawing shapes.\n This value is a hint,\n and a particular backend may or may not support a particular value.\n At the current time,\n no backend supports :obj:`SUBPIXEL <ANTIALIAS_SUBPIXEL>`\n when drawing shapes.\n\n No...
Please provide a description of the function:def set_dash(self, dashes, offset=0): cairo.cairo_set_dash( self._pointer, ffi.new('double[]', dashes), len(dashes), offset) self._check_status()
[ "Sets the dash pattern to be used by :meth:`stroke`.\n A dash pattern is specified by dashes, a list of positive values.\n Each value provides the length of alternate \"on\" and \"off\"\n portions of the stroke.\n :obj:`offset` specifies an offset into the pattern\n at which the s...
Please provide a description of the function:def get_dash(self): dashes = ffi.new('double[]', cairo.cairo_get_dash_count(self._pointer)) offset = ffi.new('double *') cairo.cairo_get_dash(self._pointer, dashes, offset) self._check_status() return list(dashes), offset[0]
[ "Return the current dash pattern.\n\n :returns:\n A ``(dashes, offset)`` tuple of a list and a float.\n :obj:`dashes` is a list of floats,\n empty if no dashing is in effect.\n\n " ]
Please provide a description of the function:def set_fill_rule(self, fill_rule): cairo.cairo_set_fill_rule(self._pointer, fill_rule) self._check_status()
[ "Set the current :ref:`FILL_RULE` within the cairo context.\n The fill rule is used to determine which regions are inside\n or outside a complex (potentially self-intersecting) path.\n The current fill rule affects both :meth:`fill` and :meth:`clip`.\n\n The default fill rule is :obj:`WI...
Please provide a description of the function:def set_line_cap(self, line_cap): cairo.cairo_set_line_cap(self._pointer, line_cap) self._check_status()
[ "Set the current :ref:`LINE_CAP` within the cairo context.\n As with the other stroke parameters,\n the current line cap style is examined by\n :meth:`stroke`, :meth:`stroke_extents`, and :meth:`stroke_to_path`,\n but does not have any effect during path construction.\n\n The defa...
Please provide a description of the function:def set_line_join(self, line_join): cairo.cairo_set_line_join(self._pointer, line_join) self._check_status()
[ "Set the current :ref:`LINE_JOIN` within the cairo context.\n As with the other stroke parameters,\n the current line cap style is examined by\n :meth:`stroke`, :meth:`stroke_extents`, and :meth:`stroke_to_path`,\n but does not have any effect during path construction.\n\n The def...
Please provide a description of the function:def set_line_width(self, width): cairo.cairo_set_line_width(self._pointer, width) self._check_status()
[ "Sets the current line width within the cairo context.\n The line width value specifies the diameter of a pen\n that is circular in user space,\n (though device-space pen may be an ellipse in general\n due to scaling / shear / rotation of the CTM).\n\n .. note::\n When ...
Please provide a description of the function:def set_miter_limit(self, limit): cairo.cairo_set_miter_limit(self._pointer, limit) self._check_status()
[ "Sets the current miter limit within the cairo context.\n\n If the current line join style is set to :obj:`MITER <LINE_JOIN_MITER>`\n (see :meth:`set_line_join`),\n the miter limit is used to determine\n whether the lines should be joined with a bevel instead of a miter.\n Cairo d...
Please provide a description of the function:def set_operator(self, operator): cairo.cairo_set_operator(self._pointer, operator) self._check_status()
[ "Set the current :ref:`OPERATOR`\n to be used for all drawing operations.\n\n The default operator is :obj:`OVER <OPERATOR_OVER>`.\n\n :param operator: A :ref:`OPERATOR` string.\n\n " ]
Please provide a description of the function:def set_tolerance(self, tolerance): cairo.cairo_set_tolerance(self._pointer, tolerance) self._check_status()
[ "Sets the tolerance used when converting paths into trapezoids.\n Curved segments of the path will be subdivided\n until the maximum deviation between the original path\n and the polygonal approximation is less than tolerance.\n The default value is 0.1.\n A larger value will give...
Please provide a description of the function:def translate(self, tx, ty): cairo.cairo_translate(self._pointer, tx, ty) self._check_status()
[ "Modifies the current transformation matrix (CTM)\n by translating the user-space origin by ``(tx, ty)``.\n This offset is interpreted as a user-space coordinate\n according to the CTM in place before the new call to :meth:`translate`.\n In other words, the translation of the user-space ...
Please provide a description of the function:def scale(self, sx, sy=None): if sy is None: sy = sx cairo.cairo_scale(self._pointer, sx, sy) self._check_status()
[ "Modifies the current transformation matrix (CTM)\n by scaling the X and Y user-space axes\n by :obj:`sx` and :obj:`sy` respectively.\n The scaling of the axes takes place after\n any existing transformation of user space.\n\n If :obj:`sy` is omitted, it is the same as :obj:`sx`\n...
Please provide a description of the function:def rotate(self, radians): cairo.cairo_rotate(self._pointer, radians) self._check_status()
[ "Modifies the current transformation matrix (CTM)\n by rotating the user-space axes by angle :obj:`radians`.\n The rotation of the axes takes places\n after any existing transformation of user space.\n\n :type radians: float\n :param radians:\n Angle of rotation, in rad...
Please provide a description of the function:def transform(self, matrix): cairo.cairo_transform(self._pointer, matrix._pointer) self._check_status()
[ "Modifies the current transformation matrix (CTM)\n by applying :obj:`matrix` as an additional transformation.\n The new transformation of user space takes place\n after any existing transformation.\n\n :param matrix:\n A transformation :class:`Matrix`\n to be appli...
Please provide a description of the function:def set_matrix(self, matrix): cairo.cairo_set_matrix(self._pointer, matrix._pointer) self._check_status()
[ "Modifies the current transformation matrix (CTM)\n by setting it equal to :obj:`matrix`.\n\n :param matrix:\n A transformation :class:`Matrix` from user space to device space.\n\n " ]
Please provide a description of the function:def get_matrix(self): matrix = Matrix() cairo.cairo_get_matrix(self._pointer, matrix._pointer) self._check_status() return matrix
[ "Return a copy of the current transformation matrix (CTM)." ]
Please provide a description of the function:def user_to_device(self, x, y): xy = ffi.new('double[2]', [x, y]) cairo.cairo_user_to_device(self._pointer, xy + 0, xy + 1) self._check_status() return tuple(xy)
[ "Transform a coordinate from user space to device space\n by multiplying the given point\n by the current transformation matrix (CTM).\n\n :param x: X position.\n :param y: Y position.\n :type x: float\n :type y: float\n :returns: A ``(device_x, device_y)`` tuple of ...
Please provide a description of the function:def user_to_device_distance(self, dx, dy): xy = ffi.new('double[2]', [dx, dy]) cairo.cairo_user_to_device_distance(self._pointer, xy + 0, xy + 1) self._check_status() return tuple(xy)
[ "Transform a distance vector from user space to device space.\n This method is similar to :meth:`Context.user_to_device`\n except that the translation components of the CTM\n will be ignored when transforming ``(dx, dy)``.\n\n :param dx: X component of a distance vector.\n :param ...
Please provide a description of the function:def device_to_user(self, x, y): xy = ffi.new('double[2]', [x, y]) cairo.cairo_device_to_user(self._pointer, xy + 0, xy + 1) self._check_status() return tuple(xy)
[ "Transform a coordinate from device space to user space\n by multiplying the given point\n by the inverse of the current transformation matrix (CTM).\n\n :param x: X position.\n :param y: Y position.\n :type x: float\n :type y: float\n :returns: A ``(user_x, user_y)`...
Please provide a description of the function:def device_to_user_distance(self, dx, dy): xy = ffi.new('double[2]', [dx, dy]) cairo.cairo_device_to_user_distance(self._pointer, xy + 0, xy + 1) self._check_status() return tuple(xy)
[ "Transform a distance vector from device space to user space.\n This method is similar to :meth:`Context.device_to_user`\n except that the translation components of the inverse CTM\n will be ignored when transforming ``(dx, dy)``.\n\n :param dx: X component of a distance vector.\n ...
Please provide a description of the function:def get_current_point(self): # I’d prefer returning None if self.has_current_point() is False # But keep (0, 0) for compat with pycairo. xy = ffi.new('double[2]') cairo.cairo_get_current_point(self._pointer, xy + 0, xy + 1) se...
[ "Return the current point of the current path,\n which is conceptually the final point reached by the path so far.\n\n The current point is returned in the user-space coordinate system.\n If there is no defined current point\n or if the context is in an error status,\n ``(0, 0)`` ...
Please provide a description of the function:def move_to(self, x, y): cairo.cairo_move_to(self._pointer, x, y) self._check_status()
[ "Begin a new sub-path.\n After this call the current point will be ``(x, y)``.\n\n :param x: X position of the new point.\n :param y: Y position of the new point.\n :type float: x\n :type float: y\n\n " ]
Please provide a description of the function:def rel_move_to(self, dx, dy): cairo.cairo_rel_move_to(self._pointer, dx, dy) self._check_status()
[ "Begin a new sub-path.\n After this call the current point will be offset by ``(dx, dy)``.\n\n Given a current point of ``(x, y)``,\n ``context.rel_move_to(dx, dy)`` is logically equivalent to\n ``context.move_to(x + dx, y + dy)``.\n\n :param dx: The X offset.\n :param dy: ...
Please provide a description of the function:def line_to(self, x, y): cairo.cairo_line_to(self._pointer, x, y) self._check_status()
[ "Adds a line to the path from the current point\n to position ``(x, y)`` in user-space coordinates.\n After this call the current point will be ``(x, y)``.\n\n If there is no current point before the call to :meth:`line_to`\n this method will behave as ``context.move_to(x, y)``.\n\n ...
Please provide a description of the function:def rel_line_to(self, dx, dy): cairo.cairo_rel_line_to(self._pointer, dx, dy) self._check_status()
[ " Relative-coordinate version of :meth:`line_to`.\n Adds a line to the path from the current point\n to a point that is offset from the current point\n by ``(dx, dy)`` in user space.\n After this call the current point will be offset by ``(dx, dy)``.\n\n Given a current point of `...
Please provide a description of the function:def rectangle(self, x, y, width, height): cairo.cairo_rectangle(self._pointer, x, y, width, height) self._check_status()
[ "Adds a closed sub-path rectangle\n of the given size to the current path\n at position ``(x, y)`` in user-space coordinates.\n\n This method is logically equivalent to::\n\n context.move_to(x, y)\n context.rel_line_to(width, 0)\n context.rel_line_to(0, height)\...
Please provide a description of the function:def arc(self, xc, yc, radius, angle1, angle2): cairo.cairo_arc(self._pointer, xc, yc, radius, angle1, angle2) self._check_status()
[ "Adds a circular arc of the given radius to the current path.\n The arc is centered at ``(xc, yc)``,\n begins at :obj:`angle1`\n and proceeds in the direction of increasing angles\n to end at :obj:`angle2`.\n If :obj:`angle2` is less than :obj:`angle1`\n it will be progress...
Please provide a description of the function:def arc_negative(self, xc, yc, radius, angle1, angle2): cairo.cairo_arc_negative(self._pointer, xc, yc, radius, angle1, angle2) self._check_status()
[ "Adds a circular arc of the given radius to the current path.\n The arc is centered at ``(xc, yc)``,\n begins at :obj:`angle1`\n and proceeds in the direction of decreasing angles\n to end at :obj:`angle2`.\n If :obj:`angle2` is greater than :obj:`angle1`\n it will be progr...
Please provide a description of the function:def curve_to(self, x1, y1, x2, y2, x3, y3): cairo.cairo_curve_to(self._pointer, x1, y1, x2, y2, x3, y3) self._check_status()
[ "Adds a cubic Bézier spline to the path\n from the current point\n to position ``(x3, y3)`` in user-space coordinates,\n using ``(x1, y1)`` and ``(x2, y2)`` as the control points.\n After this call the current point will be ``(x3, y3)``.\n\n If there is no current point before the...
Please provide a description of the function:def rel_curve_to(self, dx1, dy1, dx2, dy2, dx3, dy3): cairo.cairo_rel_curve_to(self._pointer, dx1, dy1, dx2, dy2, dx3, dy3) self._check_status()
[ " Relative-coordinate version of :meth:`curve_to`.\n All offsets are relative to the current point.\n Adds a cubic Bézier spline to the path from the current point\n to a point offset from the current point by ``(dx3, dy3)``,\n using points offset by ``(dx1, dy1)`` and ``(dx2, dy2)``\n ...
Please provide a description of the function:def text_path(self, text): cairo.cairo_text_path(self._pointer, _encode_string(text)) self._check_status()
[ "Adds closed paths for text to the current path.\n The generated path if filled,\n achieves an effect similar to that of :meth:`show_text`.\n\n Text conversion and positioning is done similar to :meth:`show_text`.\n\n Like :meth:`show_text`,\n after this call the current point is ...
Please provide a description of the function:def glyph_path(self, glyphs): glyphs = ffi.new('cairo_glyph_t[]', glyphs) cairo.cairo_glyph_path(self._pointer, glyphs, len(glyphs)) self._check_status()
[ "Adds closed paths for the glyphs to the current path.\n The generated path if filled,\n achieves an effect similar to that of :meth:`show_glyphs`.\n\n :param glyphs:\n The glyphs to show.\n See :meth:`show_text_glyphs` for the data structure.\n\n " ]