Search is not available for this dataset
text
stringlengths
75
104k
def _string_width(self, s): """Get width of a string in the current font""" s = str(s) w = 0 for i in s: w += self.character_widths[i] return w * self.font_size / 1000.0
def getCellVertexes(self, i, j): """ Edge coordinates of an hexagon centered in (x,y) having a side of d: [x-d/2, y+sqrt(3)*d/2] [x+d/2, y+sqrt(3)*d/2] [x-d, y] [x+d, y] [x-d/2,...
def rotatePoint(self, pointX, pointY): """ Rotates a point relative to the mesh origin by the angle specified in the angle property. Uses the angle formed between the segment linking the point of interest to the origin and the parallel intersecting the origin. This angle is called beta i...
def set_information(self, title=None, subject=None, author=None, keywords=None, creator=None): """ Convenience function to add property info, can set any attribute and leave the others blank, it won't over-write previously set items. """ info_dict = {"title": title, "subject": subject, ...
def set_display_mode(self, zoom='fullpage', layout='continuous'): """ Set the default viewing options. """ self.zoom_options = ["fullpage", "fullwidth", "real", "default"] self.layout_options = ["single", "continuous", "two", "default"] if zoom in self.zoom_options or (isinstance(z...
def close(self): """ Prompt the objects to output pdf code, and save to file. """ self.document._set_page_numbers() # Places header, pages, page content first. self._put_header() self._put_pages() self._put_resources() # Information object self._pu...
def _put_header(self): """ Standard first line in a PDF. """ self.session._out('%%PDF-%s' % self.pdf_version) if self.session.compression: self.session.buffer += '%' + chr(235) + chr(236) + chr(237) + chr(238) + "\n"
def _put_pages(self): """ First, the Document object does the heavy-lifting for the individual page objects and content. Then, the overall "Pages" object is generated. """ self.document._get_orientation_changes() self.document._output_pages() ...
def _put_resource_dict(self): """ Creates PDF reference to resource objects. """ self.session._add_object(2) self.session._out('<<') self.session._out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]') self.session._out('/Font <<') for font in self.document...
def _put_information(self): """PDF Information object.""" self.session._add_object() self.session._out('<<') self.session._out('/Producer ' + self._text_to_string( 'PDFLite, https://github.com/katerina7479')) if self.title: self.session._out('/Title...
def _put_catalog(self): """Catalog object.""" self.session._add_object() self.session._out('<<') self.session._out('/Type /Catalog') self.session._out('/Pages 1 0 R') if self.zoom_mode == 'fullpage': self.session._out('/OpenAction [3 0 R /Fit]') ...
def _put_cross_reference(self): """ Cross Reference Object, calculates the position in bytes to the start (first number) of each object in order by number (zero is special) from the beginning of the file. """ self.session._out('xref') ...
def _put_trailer(self): """ Final Trailer calculations, and end-of-file reference. """ startxref = len(self.session.buffer) self._put_cross_reference() md5 = hashlib.md5() md5.update(datetime.now().strftime('%Y%m%d%H%M%S')) ...
def _output_to_file(self): """ Save to filepath specified on init. (Will throw an error if the document is already open). """ f = open(self.filepath, 'wb') if not f: raise Exception('Unable to create output file: ', self.filepath) f.w...
def _text_to_string(self, text): """ Provides for escape characters and converting to pdf text object (pdf strings are in parantheses). Mainly for use in the information block here, this functionality is also present in the text object. """ if text: ...
def floyd(seqs, f=None, start=None, key=lambda x: x): """Floyd's Cycle Detector. See help(cycle_detector) for more context. Args: *args: Two iterators issueing the exact same sequence: -or- f, start: Function and starting state for finite state machine Yields: Values yielde...
def naive(seqs, f=None, start=None, key=lambda x: x): """Naive cycle detector See help(cycle_detector) for more context. Args: sequence: A sequence to detect cyles in. f, start: Function and starting state for finite state machine Yields: Values yielded by sequence_a if it termi...
def gosper(seqs, f=None, start=None, key=lambda x: x): """Gosper's cycle detector See help(cycle_detector) for more context. Args: sequence: A sequence to detect cyles in. f, start: Function and starting state for finite state machine Yields: Values yielded by sequence_a if it t...
def brent(seqs, f=None, start=None, key=lambda x: x): """Brent's Cycle Detector. See help(cycle_detector) for more context. Args: *args: Two iterators issueing the exact same sequence: -or- f, start: Function and starting state for finite state machine Yields: Values yielde...
def x_fit(self, test_length): """ Test to see if the line can has enough space for the given length. """ if (self.x + test_length) >= self.xmax: return False else: return True
def y_fit(self, test_length): """ Test to see if the page has enough space for the given text height. """ if (self.y + test_length) >= self.ymax: return False else: return True
def x_is_greater_than(self, test_ordinate): """ Comparison for x coordinate""" self._is_coordinate(test_ordinate) if self.x > test_ordinate.x: return True else: return False
def y_is_greater_than(self, test_ordinate): """Comparison for y coordinate""" self._is_coordinate(test_ordinate) if self.y > test_ordinate.y: return True else: return False
def copy(self): """ Create a copy, and return it.""" new_cursor = self.__class__(self.x, self.y) new_cursor.set_bounds(self.xmin, self.ymin, self.xmax, self.ymax, self.ymaxmax) new_cursor.set_deltas(self.dx, self.dy) return new_cursor
def x_plus(self, dx=None): """ Mutable x addition. Defaults to set delta value. """ if dx is None: self.x += self.dx else: self.x = self.x + dx
def y_plus(self, dy=None): """ Mutable y addition. Defaults to set delta value. """ if dy is None: self.y += self.dy else: self.y = self.y + dy
def set_page_size(self, layout): """ Valid choices: 'a3, 'a4', 'a5', 'letter', 'legal', '11x17'. """ self.layout = layout.lower() if self.layout in self.layout_dict: self.page_size = self.layout_dict[self.layout] else: dimensions = self.layout.spl...
def _draw(self): """ Don't use this, use document.draw_table """ self._compile() self.rows[0]._advance_first_row() self._set_borders() self._draw_fill() self._draw_borders() self._draw_text() self._set_final_cursor()
def create(self, name, description=None, color=None): """ Creates a new label and returns the response :param name: The label name :type name: str :param description: An optional description for the label. The name is used if no description is provided. :typ...
def list(self): """ Get all current labels :return: The Logentries API response :rtype: list of dict :raises: This will raise a :class:`ServerException<logentries_api.exceptions.ServerException>` if there is an error from Logentries """ r...
def get(self, name): """ Get labels by name :param name: The label name, it must be an exact match. :type name: str :return: A list of matching labels. An empty list is returned if there are not any matches :rtype: list of dict :raises: This will ra...
def update(self, label): """ Update a Label :param label: The data to update. Must include keys: * id (str) * appearance (dict) * description (str) * name (str) * title (str) :type label: dict Example: .. cod...
def delete(self, id): """ Delete the specified label :param id: the label's ID :type id: str :raises: This will raise a :class:`ServerException<logentries_api.exceptions.ServerException>` if there is an error from Logentries """ return se...
def create(self, label_id): """ Create a new tag :param label_id: The Label ID (the 'sn' key of the create label response) :type label_id: str :returns: The response of your post :rtype: dict :raises: This will raise a :class:`ServerException<logent...
def list(self): """ Get all current tags :return: All tags :rtype: list of dict :raises: This will raise a :class:`ServerException<logentries_api.exceptions.ServerException>` if there is an error from Logentries """ return list( ...
def get(self, label_sn): """ Get tags by a label's sn key :param label_sn: A corresponding label's ``sn`` key. :type label_sn: str or int :return: A list of matching tags. An empty list is returned if there are not any matches :rtype: list of dict :...
def create(self, name, regexes, tag_ids, logs=None): """ Create a hook :param name: The hook's name (should be the same as the tag) :type name: str :param regexes: The list of regular expressions that Logentries expects. Ex: `['user_agent = /curl\/[\d.]*/']` Would m...
def list(self): """ Get all current hooks :return: All hooks :rtype: list of dict :raises: This will raise a :class:`ServerException<logentries_api.exceptions.ServerException>` if there is an error from Logentries """ return self._post( ...
def get(self, name_or_tag_id): """ Get hooks by name or tag_id. :param name_or_tag_id: The hook's name or associated tag['id'] :type name_or_tag_id: str :return: A list of matching tags. An empty list is returned if there are not any matches :rtype: list of d...
def update(self, hook): """ Update a hook :param hook: The data to update. Must include keys: * id (str) * name (str) * triggers (list of str) * sources (list of str) * groups (list of str) * actions (list of str) ...
def create(self, alert_config, occurrence_frequency_count=None, occurrence_frequency_unit=None, alert_frequency_count=None, alert_frequency_unit=None): """ Create a new alert :param alert_config: A list of AlertConfig cl...
def get(self, alert_type, alert_args=None): """ Get alerts that match the alert type and args. :param alert_type: The type of the alert. Must be one of 'pagerduty', 'mailto', 'webhook', 'slack', or 'hipchat' :type alert_type: str :param alert_args: The args for the ...
def update(self, alert): """ Update an alert :param alert: The data to update. Must include keys: * id (str) * rate_count (int) * rate_range (str): 'day' or 'hour' * limit_count (int) * limit_range (str): 'day' or 'hour' *...
def setup(app): """ Initialize this Sphinx extension """ app.setup_extension('sphinx.ext.todo') app.setup_extension('sphinx.ext.mathjax') app.setup_extension("sphinx.ext.intersphinx") app.config.intersphinx_mapping.update({ 'https://docs.python.org/': None }) app.config....
def themes_path(): """ Retrieve the location of the themes directory from the location of this package This is taken from Sphinx's theme documentation """ package_dir = os.path.abspath(os.path.dirname(__file__)) return os.path.join(package_dir, 'themes')
def _post(self, request, uri, params=None): """ A wrapper for posting things. :param request: The request type. Must be one of the :class:`ApiActions<logentries_api.base.ApiActions>` :type request: str :param uri: The API endpoint to hit. Must be one of ...
def list(self): """ Get all log sets :return: Returns a dictionary where the key is the hostname or log set, and the value is a list of the log keys :rtype: dict :raises: This will raise a :class:`ServerException<logentries_api.exceptions.ServerException...
def get(self, log_set): """ Get a specific log or log set :param log_set: The log set or log to get. Ex: `.get(log_set='app')` or `.get(log_set='app/log')` :type log_set: str :returns: The response of your log set or log :rtype: dict :raises: This w...
def find_attacker_slider(dest_list, occ_bb, piece_bb, target_bb, pos, domain): """ Find a slider attacker Parameters ---------- dest_list : list To store the results. occ_bb : int, bitboard Occupancy bitboard. piece_bb : int, bitboard Bitboar...
def duration(self): ''' The approximate transit duration for the general case of an eccentric orbit ''' ecc = self.ecc if not np.isnan(self.ecc) else np.sqrt(self.ecw**2 + self.esw**2) esw = self.esw if not np.isnan(self.esw) else ecc * np.sin(self.w) aRs = ((G *...
def update(self, **kwargs): ''' Update the transit keyword arguments ''' if kwargs.get('verify_kwargs', True): valid = [y[0] for x in [TRANSIT, LIMBDARK, SETTINGS] for y in x._fields_] # List of valid kwargs valid += ['b', 'times'] ...
def Compute(self): ''' Computes the light curve model ''' err = _Compute(self.transit, self.limbdark, self.settings, self.arrays) if err != _ERR_NONE: RaiseError(err)
def Bin(self): ''' Bins the light curve model to the provided time array ''' err = _Bin(self.transit, self.limbdark, self.settings, self.arrays) if err != _ERR_NONE: RaiseError(err)
def Free(self): ''' Frees the memory used by all of the dynamically allocated C arrays. ''' if self.arrays._calloc: _dbl_free(self.arrays._time) _dbl_free(self.arrays._flux) _dbl_free(self.arrays._bflx) _dbl_free(self.arrays._M) _dbl_free(self.arrays._E) _dbl_fr...
def __recv(self, size=4096): """Reads data from the socket. Raises: NNTPError: When connection times out or read from socket fails. """ data = self.socket.recv(size) if not data: raise NNTPError("Failed to read from socket") self.__buffer.write(da...
def __line_gen(self): """Generator that reads a line of data from the server. It first attempts to read from the internal buffer. If there is not enough data to read a line it then requests more data from the server and adds it to the buffer. This process repeats until a line of data ...
def __buf_gen(self, length=0): """Generator that reads a block of data from the server. It first attempts to read from the internal buffer. If there is not enough data in the internal buffer it then requests more data from the server and adds it to the buffer. Args: ...
def status(self): """Reads a command response status. If there is no response message then the returned status message will be an empty string. Raises: NNTPError: If data is required to be read from the socket and fails. NNTPProtocolError: If the status line can...
def __info_plain_gen(self): """Generator for the lines of an info (textual) response. When a terminating line (line containing single period) is received the generator exits. If there is a line begining with an 'escaped' period then the extra period is trimmed. Yields:...
def __info_gzip_gen(self): """Generator for the lines of a compressed info (textual) response. Compressed responses are an extension to the NNTP protocol supported by some usenet servers to reduce the bandwidth of heavily used range style commands that can return large amounts of textua...
def __info_yenczlib_gen(self): """Generator for the lines of a compressed info (textual) response. Compressed responses are an extension to the NNTP protocol supported by some usenet servers to reduce the bandwidth of heavily used range style commands that can return large amounts of te...
def info_gen(self, code, message, compressed=False): """Dispatcher for the info generators. Determines which __info_*_gen() should be used based on the supplied parameters. Args: code: The status code for the command response. message: The status message for the...
def info(self, code, message, compressed=False): """The complete content of an info response. This should only used for commands that return small or known amounts of data. Returns: A the complete content of a textual response. """ return "".join([x for x in...
def command(self, verb, args=None): """Call a command on the server. If the user has not authenticated then authentication will be done as part of calling the command on the server. For commands that don't return a status message the status message will default to an empty stri...
def capabilities(self, keyword=None): """CAPABILITIES command. Determines the capabilities of the server. Although RFC3977 states that this is a required command for servers to implement not all servers do, so expect that NNTPPermanentError may be raised when this command is is...
def mode_reader(self): """MODE READER command. Instructs a mode-switching server to switch modes. See <http://tools.ietf.org/html/rfc3977#section-5.3> Returns: Boolean value indicating whether posting is allowed or not. """ code, message = self.command("MOD...
def quit(self): """QUIT command. Tells the server to close the connection. After the server acknowledges the request to quit the connection is closed both at the server and client. Only useful for graceful shutdown. If you are in a generator use close() instead. Once th...
def date(self): """DATE command. Coordinated Universal time from the perspective of the usenet server. It can be used to provide information that might be useful when using the NEWNEWS command. See <http://tools.ietf.org/html/rfc3977#section-7.1> Returns: T...
def help(self): """HELP command. Provides a short summary of commands that are understood by the usenet server. See <http://tools.ietf.org/html/rfc3977#section-7.2> Returns: The help text from the server. """ code, message = self.command("HELP") ...
def newgroups_gen(self, timestamp): """Generator for the NEWGROUPS command. Generates a list of newsgroups created on the server since the specified timestamp. See <http://tools.ietf.org/html/rfc3977#section-7.3> Args: timestamp: Datetime object giving 'created sin...
def newnews_gen(self, pattern, timestamp): """Generator for the NEWNEWS command. Generates a list of message-ids for articles created since the specified timestamp for newsgroups with names that match the given pattern. See <http://tools.ietf.org/html/rfc3977#section-7.4> Args...
def newnews(self, pattern, timestamp): """NEWNEWS command. Retrieves a list of message-ids for articles created since the specified timestamp for newsgroups with names that match the given pattern. See newnews_gen() for more details. See <http://tools.ietf.org/html/rfc3977#sect...
def list_active_gen(self, pattern=None): """Generator for the LIST ACTIVE command. Generates a list of active newsgroups that match the specified pattern. If no pattern is specfied then all active groups are generated. See <http://tools.ietf.org/html/rfc3977#section-7.6.3> Arg...
def list_active_times_gen(self): """Generator for the LIST ACTIVE.TIMES command. Generates a list of newsgroups including the creation time and who created them. See <http://tools.ietf.org/html/rfc3977#section-7.6.4> Yields: A tuple containing the name, creation da...
def list_newsgroups_gen(self, pattern=None): """Generator for the LIST NEWSGROUPS command. Generates a list of newsgroups including the name and a short description. See <http://tools.ietf.org/html/rfc3977#section-7.6.6> Args: pattern: Glob matching newsgroups of i...
def list_overview_fmt_gen(self): """Generator for the LIST OVERVIEW.FMT See list_overview_fmt() for more information. Yields: An element in the list returned by list_overview_fmt(). """ code, message = self.command("LIST OVERVIEW.FMT") if code != 215: ...
def list_extensions_gen(self): """Generator for the LIST EXTENSIONS command. """ code, message = self.command("LIST EXTENSIONS") if code != 202: raise NNTPReplyError(code, message) for line in self.info_gen(code, message): yield line.strip()
def list_gen(self, keyword=None, arg=None): """Generator for LIST command. See list() for more information. Yields: An element in the list returned by list(). """ if keyword: keyword = keyword.upper() if keyword is None or keyword == "ACTIVE": ...
def list(self, keyword=None, arg=None): """LIST command. A wrapper for all of the other list commands. The output of this command depends on the keyword specified. The output format for each keyword can be found in the list function that corresponds to the keyword. Args: ...
def group(self, name): """GROUP command. """ args = name code, message = self.command("GROUP", args) if code != 211: raise NNTPReplyError(code, message) parts = message.split(None, 4) try: total = int(parts[0]) first = int(par...
def next(self): """NEXT command. """ code, message = self.command("NEXT") if code != 223: raise NNTPReplyError(code, message) parts = message.split(None, 3) try: article = int(parts[0]) ident = parts[1] except (IndexError, Valu...
def article(self, msgid_article=None, decode=None): """ARTICLE command. """ args = None if msgid_article is not None: args = utils.unparse_msgid_article(msgid_article) code, message = self.command("ARTICLE", args) if code != 220: raise NNTPReplyEr...
def head(self, msgid_article=None): """HEAD command. """ args = None if msgid_article is not None: args = utils.unparse_msgid_article(msgid_article) code, message = self.command("HEAD", args) if code != 221: raise NNTPReplyError(code, message) ...
def body(self, msgid_article=None, decode=False): """BODY command. """ args = None if msgid_article is not None: args = utils.unparse_msgid_article(msgid_article) code, message = self.command("BODY", args) if code != 222: raise NNTPReplyError(code...
def xgtitle(self, pattern=None): """XGTITLE command. """ args = pattern code, message = self.command("XGTITLE", args) if code != 282: raise NNTPReplyError(code, message) return self.info(code, message)
def xhdr(self, header, msgid_range=None): """XHDR command. """ args = header if range is not None: args += " " + utils.unparse_msgid_range(msgid_range) code, message = self.command("XHDR", args) if code != 221: raise NNTPReplyError(code, message) ...
def xzhdr(self, header, msgid_range=None): """XZHDR command. Args: msgid_range: A message-id as a string, or an article number as an integer, or a tuple of specifying a range of article numbers in the form (first, [last]) - if last is omitted then all article...
def xover_gen(self, range=None): """Generator for the XOVER command. The XOVER command returns information from the overview database for the article(s) specified. <http://tools.ietf.org/html/rfc2980#section-2.8> Args: range: An article number as an integer, or a t...
def xpat_gen(self, header, msgid_range, *pattern): """Generator for the XPAT command. """ args = " ".join( [header, utils.unparse_msgid_range(msgid_range)] + list(pattern) ) code, message = self.command("XPAT", args) if code != 221: raise NNTPRepl...
def xpat(self, header, id_range, *pattern): """XPAT command. """ return [x for x in self.xpat_gen(header, id_range, *pattern)]
def xfeature_compress_gzip(self, terminator=False): """XFEATURE COMPRESS GZIP command. """ args = "TERMINATOR" if terminator else None code, message = self.command("XFEATURE COMPRESS GZIP", args) if code != 290: raise NNTPReplyError(code, message) return Tru...
def post(self, headers={}, body=""): """POST command. Args: headers: A dictionary of headers. body: A string or file like object containing the post content. Raises: NNTPDataError: If binary characters are detected in the message body. ...
def _lower(v): """assumes that classes that inherit list, tuple or dict have a constructor that is compatible with those base classes. If you are using classes that don't satisfy this requirement you can subclass them and add a lower() method for the class""" if hasattr(v, "lower"): return v...
def I(r, limbdark): ''' The standard quadratic limb darkening law. :param ndarray r: The radius vector :param limbdark: A :py:class:`pysyzygy.transit.LIMBDARK` instance containing the limb darkening law information :returns: The stellar intensity as a function of `r` ''' if...
def PlotTransit(compact = False, ldplot = True, plottitle = "", xlim = None, binned = True, **kwargs): ''' Plots a light curve described by `kwargs` :param bool compact: Display the compact version of the plot? Default `False` :param bool ldplot: Displat the limb darkening inset? Default `Tr...
def _offset(value): """Parse timezone to offset in seconds. Args: value: A timezone in the '+0000' format. An integer would also work. Returns: The timezone offset from GMT in seconds as an integer. """ o = int(value) if o == 0: return 0 a = abs(o) s = a*36+(a%1...
def timestamp_d_b_Y_H_M_S(value): """Convert timestamp string to time in seconds since epoch. Timestamps strings like '18 Jun 2013 12:00:00 GMT' are able to be converted by this function. Args: value: A timestamp string in the format '%d %b %Y %H:%M:%S GMT'. Returns: The time in s...
def datetimeobj_d_b_Y_H_M_S(value): """Convert timestamp string to a datetime object. Timestamps strings like '18 Jun 2013 12:00:00 GMT' are able to be converted by this function. Args: value: A timestamp string in the format '%d %b %Y %H:%M:%S GMT'. Returns: A datetime object. ...
def timestamp_a__d_b_Y_H_M_S_z(value): """Convert timestamp string to time in seconds since epoch. Timestamps strings like 'Tue, 18 Jun 2013 22:00:00 +1000' are able to be converted by this function. Args: value: A timestamp string in the format '%a, %d %b %Y %H:%M:%S %z'. Returns: ...
def datetimeobj_a__d_b_Y_H_M_S_z(value): """Convert timestamp string to a datetime object. Timestamps strings like 'Tue, 18 Jun 2013 22:00:00 +1000' are able to be converted by this function. Args: value: A timestamp string in the format '%a, %d %b %Y %H:%M:%S %z'. Returns: A date...