repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Accelize/pycosio
pycosio/_core/io_base_buffered.py
ObjectBufferedIOBase.seek
def seek(self, offset, whence=SEEK_SET): """ Change the stream position to the given byte offset. Args: offset: Offset is interpreted relative to the position indicated by whence. whence: The default value for whence is SEEK_SET. Values fo...
python
def seek(self, offset, whence=SEEK_SET): """ Change the stream position to the given byte offset. Args: offset: Offset is interpreted relative to the position indicated by whence. whence: The default value for whence is SEEK_SET. Values fo...
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "SEEK_SET", ")", ":", "if", "not", "self", ".", "_seekable", ":", "raise", "UnsupportedOperation", "(", "'seek'", ")", "# Only read mode is seekable", "with", "self", ".", "_seek_lock", ":", "# S...
Change the stream position to the given byte offset. Args: offset: Offset is interpreted relative to the position indicated by whence. whence: The default value for whence is SEEK_SET. Values for whence are: SEEK_SET or 0 – start of the st...
[ "Change", "the", "stream", "position", "to", "the", "given", "byte", "offset", "." ]
train
https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L439-L471
Accelize/pycosio
pycosio/_core/io_base_buffered.py
ObjectBufferedIOBase.write
def write(self, b): """ Write the given bytes-like object, b, to the underlying raw stream, and return the number of bytes written. Args: b (bytes-like object): Bytes to write. Returns: int: The number of bytes written. """ if not self._w...
python
def write(self, b): """ Write the given bytes-like object, b, to the underlying raw stream, and return the number of bytes written. Args: b (bytes-like object): Bytes to write. Returns: int: The number of bytes written. """ if not self._w...
[ "def", "write", "(", "self", ",", "b", ")", ":", "if", "not", "self", ".", "_writable", ":", "raise", "UnsupportedOperation", "(", "'write'", ")", "size", "=", "len", "(", "b", ")", "b_view", "=", "memoryview", "(", "b", ")", "size_left", "=", "size"...
Write the given bytes-like object, b, to the underlying raw stream, and return the number of bytes written. Args: b (bytes-like object): Bytes to write. Returns: int: The number of bytes written.
[ "Write", "the", "given", "bytes", "-", "like", "object", "b", "to", "the", "underlying", "raw", "stream", "and", "return", "the", "number", "of", "bytes", "written", "." ]
train
https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L473-L548
mnooner256/pyqrcode
pyqrcode/__init__.py
create
def create(content, error='H', version=None, mode=None, encoding=None): """When creating a QR code only the content to be encoded is required, all the other properties of the code will be guessed based on the contents given. This function will return a :class:`QRCode` object. Unless you are familiar wi...
python
def create(content, error='H', version=None, mode=None, encoding=None): """When creating a QR code only the content to be encoded is required, all the other properties of the code will be guessed based on the contents given. This function will return a :class:`QRCode` object. Unless you are familiar wi...
[ "def", "create", "(", "content", ",", "error", "=", "'H'", ",", "version", "=", "None", ",", "mode", "=", "None", ",", "encoding", "=", "None", ")", ":", "return", "QRCode", "(", "content", ",", "error", ",", "version", ",", "mode", ",", "encoding", ...
When creating a QR code only the content to be encoded is required, all the other properties of the code will be guessed based on the contents given. This function will return a :class:`QRCode` object. Unless you are familiar with QR code's inner workings it is recommended that you just specify the *co...
[ "When", "creating", "a", "QR", "code", "only", "the", "content", "to", "be", "encoded", "is", "required", "all", "the", "other", "properties", "of", "the", "code", "will", "be", "guessed", "based", "on", "the", "contents", "given", ".", "This", "function",...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L54-L111
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode._detect_content_type
def _detect_content_type(self, content, encoding): """This method tries to auto-detect the type of the data. It first tries to see if the data is a valid integer, in which case it returns numeric. Next, it tests the data to see if it is 'alphanumeric.' QR Codes use a special table with v...
python
def _detect_content_type(self, content, encoding): """This method tries to auto-detect the type of the data. It first tries to see if the data is a valid integer, in which case it returns numeric. Next, it tests the data to see if it is 'alphanumeric.' QR Codes use a special table with v...
[ "def", "_detect_content_type", "(", "self", ",", "content", ",", "encoding", ")", ":", "def", "two_bytes", "(", "c", ")", ":", "\"\"\"Output two byte character code as a single integer.\"\"\"", "def", "next_byte", "(", "b", ")", ":", "\"\"\"Make sure that character code...
This method tries to auto-detect the type of the data. It first tries to see if the data is a valid integer, in which case it returns numeric. Next, it tests the data to see if it is 'alphanumeric.' QR Codes use a special table with very limited range of ASCII characters. The code's data...
[ "This", "method", "tries", "to", "auto", "-", "detect", "the", "type", "of", "the", "data", ".", "It", "first", "tries", "to", "see", "if", "the", "data", "is", "a", "valid", "integer", "in", "which", "case", "it", "returns", "numeric", ".", "Next", ...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L240-L330
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode._pick_best_fit
def _pick_best_fit(self, content): """This method return the smallest possible QR code version number that will fit the specified data with the given error level. """ import math for version in range(1, 41): #Get the maximum possible capacity capa...
python
def _pick_best_fit(self, content): """This method return the smallest possible QR code version number that will fit the specified data with the given error level. """ import math for version in range(1, 41): #Get the maximum possible capacity capa...
[ "def", "_pick_best_fit", "(", "self", ",", "content", ")", ":", "import", "math", "for", "version", "in", "range", "(", "1", ",", "41", ")", ":", "#Get the maximum possible capacity", "capacity", "=", "tables", ".", "data_capacity", "[", "version", "]", "[",...
This method return the smallest possible QR code version number that will fit the specified data with the given error level.
[ "This", "method", "return", "the", "smallest", "possible", "QR", "code", "version", "number", "that", "will", "fit", "the", "specified", "data", "with", "the", "given", "error", "level", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L332-L351
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.show
def show(self, wait=1.2, scale=10, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4): """Displays this QR code. This method is mainly intended for debugging purposes. This method saves the output of the :py:meth:`png` method (with a default scaling...
python
def show(self, wait=1.2, scale=10, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4): """Displays this QR code. This method is mainly intended for debugging purposes. This method saves the output of the :py:meth:`png` method (with a default scaling...
[ "def", "show", "(", "self", ",", "wait", "=", "1.2", ",", "scale", "=", "10", ",", "module_color", "=", "(", "0", ",", "0", ",", "0", ",", "255", ")", ",", "background", "=", "(", "255", ",", "255", ",", "255", ",", "255", ")", ",", "quiet_zo...
Displays this QR code. This method is mainly intended for debugging purposes. This method saves the output of the :py:meth:`png` method (with a default scaling factor of 10) to a temporary file and opens it with the standard PNG viewer application or within the standard webbrowser. The...
[ "Displays", "this", "QR", "code", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L353-L389
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.get_png_size
def get_png_size(self, scale=1, quiet_zone=4): """This is method helps users determine what *scale* to use when creating a PNG of this QR code. It is meant mostly to be used in the console to help the user determine the pixel size of the code using various scales. This method wi...
python
def get_png_size(self, scale=1, quiet_zone=4): """This is method helps users determine what *scale* to use when creating a PNG of this QR code. It is meant mostly to be used in the console to help the user determine the pixel size of the code using various scales. This method wi...
[ "def", "get_png_size", "(", "self", ",", "scale", "=", "1", ",", "quiet_zone", "=", "4", ")", ":", "return", "builder", ".", "_get_png_size", "(", "self", ".", "version", ",", "scale", ",", "quiet_zone", ")" ]
This is method helps users determine what *scale* to use when creating a PNG of this QR code. It is meant mostly to be used in the console to help the user determine the pixel size of the code using various scales. This method will return an integer representing the width and height of ...
[ "This", "is", "method", "helps", "users", "determine", "what", "*", "scale", "*", "to", "use", "when", "creating", "a", "PNG", "of", "this", "QR", "code", ".", "It", "is", "meant", "mostly", "to", "be", "used", "in", "the", "console", "to", "help", "...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L391-L414
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.png
def png(self, file, scale=1, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4): """This method writes the QR code out as an PNG image. The resulting PNG has a bit depth of 1. The file parameter is used to specify where to write the image to. It can either be...
python
def png(self, file, scale=1, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4): """This method writes the QR code out as an PNG image. The resulting PNG has a bit depth of 1. The file parameter is used to specify where to write the image to. It can either be...
[ "def", "png", "(", "self", ",", "file", ",", "scale", "=", "1", ",", "module_color", "=", "(", "0", ",", "0", ",", "0", ",", "255", ")", ",", "background", "=", "(", "255", ",", "255", ",", "255", ",", "255", ")", ",", "quiet_zone", "=", "4",...
This method writes the QR code out as an PNG image. The resulting PNG has a bit depth of 1. The file parameter is used to specify where to write the image to. It can either be an writable stream or a file path. .. note:: This method depends on the pypng module to actually cr...
[ "This", "method", "writes", "the", "QR", "code", "out", "as", "an", "PNG", "image", ".", "The", "resulting", "PNG", "has", "a", "bit", "depth", "of", "1", ".", "The", "file", "parameter", "is", "used", "to", "specify", "where", "to", "write", "the", ...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L416-L463
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.png_as_base64_str
def png_as_base64_str(self, scale=1, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4): """This method uses the png render and returns the PNG image encoded as base64 string. This can be useful for creating dynamic PNG images for web developmen...
python
def png_as_base64_str(self, scale=1, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4): """This method uses the png render and returns the PNG image encoded as base64 string. This can be useful for creating dynamic PNG images for web developmen...
[ "def", "png_as_base64_str", "(", "self", ",", "scale", "=", "1", ",", "module_color", "=", "(", "0", ",", "0", ",", "0", ",", "255", ")", ",", "background", "=", "(", "255", ",", "255", ",", "255", ",", "255", ")", ",", "quiet_zone", "=", "4", ...
This method uses the png render and returns the PNG image encoded as base64 string. This can be useful for creating dynamic PNG images for web development, since no file needs to be created. Example: >>> code = pyqrcode.create('Are you suggesting coconuts migrate?') ...
[ "This", "method", "uses", "the", "png", "render", "and", "returns", "the", "PNG", "image", "encoded", "as", "base64", "string", ".", "This", "can", "be", "useful", "for", "creating", "dynamic", "PNG", "images", "for", "web", "development", "since", "no", "...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L465-L491
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.xbm
def xbm(self, scale=1, quiet_zone=4): """Returns a string representing an XBM image of the QR code. The XBM format is a black and white image format that looks like a C header file. Because displaying QR codes in Tkinter is the primary use case for this renderer, this m...
python
def xbm(self, scale=1, quiet_zone=4): """Returns a string representing an XBM image of the QR code. The XBM format is a black and white image format that looks like a C header file. Because displaying QR codes in Tkinter is the primary use case for this renderer, this m...
[ "def", "xbm", "(", "self", ",", "scale", "=", "1", ",", "quiet_zone", "=", "4", ")", ":", "return", "builder", ".", "_xbm", "(", "self", ".", "code", ",", "scale", ",", "quiet_zone", ")" ]
Returns a string representing an XBM image of the QR code. The XBM format is a black and white image format that looks like a C header file. Because displaying QR codes in Tkinter is the primary use case for this renderer, this method does not take a file parameter. Ins...
[ "Returns", "a", "string", "representing", "an", "XBM", "image", "of", "the", "QR", "code", ".", "The", "XBM", "format", "is", "a", "black", "and", "white", "image", "format", "that", "looks", "like", "a", "C", "header", "file", ".", "Because", "displayin...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L493-L529
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.svg
def svg(self, file, scale=1, module_color='#000', background=None, quiet_zone=4, xmldecl=True, svgns=True, title=None, svgclass='pyqrcode', lineclass='pyqrline', omithw=False, debug=False): """This method writes the QR code out as an SVG document. The code is drawn by...
python
def svg(self, file, scale=1, module_color='#000', background=None, quiet_zone=4, xmldecl=True, svgns=True, title=None, svgclass='pyqrcode', lineclass='pyqrline', omithw=False, debug=False): """This method writes the QR code out as an SVG document. The code is drawn by...
[ "def", "svg", "(", "self", ",", "file", ",", "scale", "=", "1", ",", "module_color", "=", "'#000'", ",", "background", "=", "None", ",", "quiet_zone", "=", "4", ",", "xmldecl", "=", "True", ",", "svgns", "=", "True", ",", "title", "=", "None", ",",...
This method writes the QR code out as an SVG document. The code is drawn by drawing only the modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row are drawn with a single line. The *file* parameter is used to specify where to write the document...
[ "This", "method", "writes", "the", "QR", "code", "out", "as", "an", "SVG", "document", ".", "The", "code", "is", "drawn", "by", "drawing", "only", "the", "modules", "corresponding", "to", "a", "1", ".", "They", "are", "drawn", "using", "a", "line", "su...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L531-L589
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.eps
def eps(self, file, scale=1, module_color=(0, 0, 0), background=None, quiet_zone=4): """This method writes the QR code out as an EPS document. The code is drawn by only writing the data modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row ...
python
def eps(self, file, scale=1, module_color=(0, 0, 0), background=None, quiet_zone=4): """This method writes the QR code out as an EPS document. The code is drawn by only writing the data modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row ...
[ "def", "eps", "(", "self", ",", "file", ",", "scale", "=", "1", ",", "module_color", "=", "(", "0", ",", "0", ",", "0", ")", ",", "background", "=", "None", ",", "quiet_zone", "=", "4", ")", ":", "builder", ".", "_eps", "(", "self", ".", "code"...
This method writes the QR code out as an EPS document. The code is drawn by only writing the data modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row are drawn with a single line. The *file* parameter is used to specify where to write the doc...
[ "This", "method", "writes", "the", "QR", "code", "out", "as", "an", "EPS", "document", ".", "The", "code", "is", "drawn", "by", "only", "writing", "the", "data", "modules", "corresponding", "to", "a", "1", ".", "They", "are", "drawn", "using", "a", "li...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L591-L624
mnooner256/pyqrcode
pyqrcode/__init__.py
QRCode.terminal
def terminal(self, module_color='default', background='reverse', quiet_zone=4): """This method returns a string containing ASCII escape codes, such that if printed to a compatible terminal, it will display a vaild QR code. The code is printed using ASCII escape codes tha...
python
def terminal(self, module_color='default', background='reverse', quiet_zone=4): """This method returns a string containing ASCII escape codes, such that if printed to a compatible terminal, it will display a vaild QR code. The code is printed using ASCII escape codes tha...
[ "def", "terminal", "(", "self", ",", "module_color", "=", "'default'", ",", "background", "=", "'reverse'", ",", "quiet_zone", "=", "4", ")", ":", "return", "builder", ".", "_terminal", "(", "self", ".", "code", ",", "module_color", ",", "background", ",",...
This method returns a string containing ASCII escape codes, such that if printed to a compatible terminal, it will display a vaild QR code. The code is printed using ASCII escape codes that alter the coloring of the background. The *module_color* parameter sets what color to use...
[ "This", "method", "returns", "a", "string", "containing", "ASCII", "escape", "codes", "such", "that", "if", "printed", "to", "a", "compatible", "terminal", "it", "will", "display", "a", "vaild", "QR", "code", ".", "The", "code", "is", "printed", "using", "...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/__init__.py#L626-L672
mnooner256/pyqrcode
pyqrcode/builder.py
_get_writable
def _get_writable(stream_or_path, mode): """This method returns a tuple containing the stream and a flag to indicate if the stream should be automatically closed. The `stream_or_path` parameter is returned if it is an open writable stream. Otherwise, it treats the `stream_or_path` parameter as a file p...
python
def _get_writable(stream_or_path, mode): """This method returns a tuple containing the stream and a flag to indicate if the stream should be automatically closed. The `stream_or_path` parameter is returned if it is an open writable stream. Otherwise, it treats the `stream_or_path` parameter as a file p...
[ "def", "_get_writable", "(", "stream_or_path", ",", "mode", ")", ":", "is_stream", "=", "hasattr", "(", "stream_or_path", ",", "'write'", ")", "if", "not", "is_stream", ":", "# No stream provided, treat \"stream_or_path\" as path", "stream_or_path", "=", "open", "(", ...
This method returns a tuple containing the stream and a flag to indicate if the stream should be automatically closed. The `stream_or_path` parameter is returned if it is an open writable stream. Otherwise, it treats the `stream_or_path` parameter as a file path and opens it with the given mode. I...
[ "This", "method", "returns", "a", "tuple", "containing", "the", "stream", "and", "a", "flag", "to", "indicate", "if", "the", "stream", "should", "be", "automatically", "closed", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L907-L925
mnooner256/pyqrcode
pyqrcode/builder.py
_get_png_size
def _get_png_size(version, scale, quiet_zone=4): """See: QRCode.get_png_size This function was abstracted away from QRCode to allow for the output of QR codes during the build process, i.e. for debugging. It works just the same except you must specify the code's version. This is needed to calculate...
python
def _get_png_size(version, scale, quiet_zone=4): """See: QRCode.get_png_size This function was abstracted away from QRCode to allow for the output of QR codes during the build process, i.e. for debugging. It works just the same except you must specify the code's version. This is needed to calculate...
[ "def", "_get_png_size", "(", "version", ",", "scale", ",", "quiet_zone", "=", "4", ")", ":", "#Formula: scale times number of modules plus the border on each side", "return", "(", "int", "(", "scale", ")", "*", "tables", ".", "version_size", "[", "version", "]", "...
See: QRCode.get_png_size This function was abstracted away from QRCode to allow for the output of QR codes during the build process, i.e. for debugging. It works just the same except you must specify the code's version. This is needed to calculate the PNG's size.
[ "See", ":", "QRCode", ".", "get_png_size" ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L928-L937
mnooner256/pyqrcode
pyqrcode/builder.py
_terminal
def _terminal(code, module_color='default', background='reverse', quiet_zone=4): """This method returns a string containing ASCII escape codes, such that if printed to a terminal, it will display a vaild QR code. The module_color and the background color should be keys in the tables.term_colors table fo...
python
def _terminal(code, module_color='default', background='reverse', quiet_zone=4): """This method returns a string containing ASCII escape codes, such that if printed to a terminal, it will display a vaild QR code. The module_color and the background color should be keys in the tables.term_colors table fo...
[ "def", "_terminal", "(", "code", ",", "module_color", "=", "'default'", ",", "background", "=", "'reverse'", ",", "quiet_zone", "=", "4", ")", ":", "buf", "=", "io", ".", "StringIO", "(", ")", "def", "draw_border", "(", ")", ":", "for", "i", "in", "r...
This method returns a string containing ASCII escape codes, such that if printed to a terminal, it will display a vaild QR code. The module_color and the background color should be keys in the tables.term_colors table for printing using the 8/16 color scheme. Alternatively, they can be a number between ...
[ "This", "method", "returns", "a", "string", "containing", "ASCII", "escape", "codes", "such", "that", "if", "printed", "to", "a", "terminal", "it", "will", "display", "a", "vaild", "QR", "code", ".", "The", "module_color", "and", "the", "background", "color"...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L940-L1014
mnooner256/pyqrcode
pyqrcode/builder.py
_text
def _text(code, quiet_zone=4): """This method returns a text based representation of the QR code. This is useful for debugging purposes. """ buf = io.StringIO() border_row = '0' * (len(code[0]) + (quiet_zone*2)) #Every QR code start with a quiet zone at the top for b in range(quiet_zone): ...
python
def _text(code, quiet_zone=4): """This method returns a text based representation of the QR code. This is useful for debugging purposes. """ buf = io.StringIO() border_row = '0' * (len(code[0]) + (quiet_zone*2)) #Every QR code start with a quiet zone at the top for b in range(quiet_zone): ...
[ "def", "_text", "(", "code", ",", "quiet_zone", "=", "4", ")", ":", "buf", "=", "io", ".", "StringIO", "(", ")", "border_row", "=", "'0'", "*", "(", "len", "(", "code", "[", "0", "]", ")", "+", "(", "quiet_zone", "*", "2", ")", ")", "#Every QR ...
This method returns a text based representation of the QR code. This is useful for debugging purposes.
[ "This", "method", "returns", "a", "text", "based", "representation", "of", "the", "QR", "code", ".", "This", "is", "useful", "for", "debugging", "purposes", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L1016-L1055
mnooner256/pyqrcode
pyqrcode/builder.py
_xbm
def _xbm(code, scale=1, quiet_zone=4): """This function will format the QR code as a X BitMap. This can be used to display the QR code with Tkinter. """ try: str = unicode # Python 2 except NameError: str = __builtins__['str'] buf = io.StringIO() # Calculate th...
python
def _xbm(code, scale=1, quiet_zone=4): """This function will format the QR code as a X BitMap. This can be used to display the QR code with Tkinter. """ try: str = unicode # Python 2 except NameError: str = __builtins__['str'] buf = io.StringIO() # Calculate th...
[ "def", "_xbm", "(", "code", ",", "scale", "=", "1", ",", "quiet_zone", "=", "4", ")", ":", "try", ":", "str", "=", "unicode", "# Python 2", "except", "NameError", ":", "str", "=", "__builtins__", "[", "'str'", "]", "buf", "=", "io", ".", "StringIO", ...
This function will format the QR code as a X BitMap. This can be used to display the QR code with Tkinter.
[ "This", "function", "will", "format", "the", "QR", "code", "as", "a", "X", "BitMap", ".", "This", "can", "be", "used", "to", "display", "the", "QR", "code", "with", "Tkinter", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L1057-L1105
mnooner256/pyqrcode
pyqrcode/builder.py
_svg
def _svg(code, version, file, scale=1, module_color='#000', background=None, quiet_zone=4, xmldecl=True, svgns=True, title=None, svgclass='pyqrcode', lineclass='pyqrline', omithw=False, debug=False): """This function writes the QR code out as an SVG document. The code is drawn by drawing only ...
python
def _svg(code, version, file, scale=1, module_color='#000', background=None, quiet_zone=4, xmldecl=True, svgns=True, title=None, svgclass='pyqrcode', lineclass='pyqrline', omithw=False, debug=False): """This function writes the QR code out as an SVG document. The code is drawn by drawing only ...
[ "def", "_svg", "(", "code", ",", "version", ",", "file", ",", "scale", "=", "1", ",", "module_color", "=", "'#000'", ",", "background", "=", "None", ",", "quiet_zone", "=", "4", ",", "xmldecl", "=", "True", ",", "svgns", "=", "True", ",", "title", ...
This function writes the QR code out as an SVG document. The code is drawn by drawing only the modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row are drawn with a single line. The file parameter is used to specify where to write the document to. It can eithe...
[ "This", "function", "writes", "the", "QR", "code", "out", "as", "an", "SVG", "document", ".", "The", "code", "is", "drawn", "by", "drawing", "only", "the", "modules", "corresponding", "to", "a", "1", ".", "They", "are", "drawn", "using", "a", "line", "...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L1107-L1241
mnooner256/pyqrcode
pyqrcode/builder.py
_png
def _png(code, version, file, scale=1, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4, debug=False): """See: pyqrcode.QRCode.png() This function was abstracted away from QRCode to allow for the output of QR codes during the build process, i.e. for debugging. It works ...
python
def _png(code, version, file, scale=1, module_color=(0, 0, 0, 255), background=(255, 255, 255, 255), quiet_zone=4, debug=False): """See: pyqrcode.QRCode.png() This function was abstracted away from QRCode to allow for the output of QR codes during the build process, i.e. for debugging. It works ...
[ "def", "_png", "(", "code", ",", "version", ",", "file", ",", "scale", "=", "1", ",", "module_color", "=", "(", "0", ",", "0", ",", "0", ",", "255", ")", ",", "background", "=", "(", "255", ",", "255", ",", "255", ",", "255", ")", ",", "quiet...
See: pyqrcode.QRCode.png() This function was abstracted away from QRCode to allow for the output of QR codes during the build process, i.e. for debugging. It works just the same except you must specify the code's version. This is needed to calculate the PNG's size. This method will write the given...
[ "See", ":", "pyqrcode", ".", "QRCode", ".", "png", "()" ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L1244-L1391
mnooner256/pyqrcode
pyqrcode/builder.py
_eps
def _eps(code, version, file_or_path, scale=1, module_color=(0, 0, 0), background=None, quiet_zone=4): """This function writes the QR code out as an EPS document. The code is drawn by drawing only the modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row ...
python
def _eps(code, version, file_or_path, scale=1, module_color=(0, 0, 0), background=None, quiet_zone=4): """This function writes the QR code out as an EPS document. The code is drawn by drawing only the modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row ...
[ "def", "_eps", "(", "code", ",", "version", ",", "file_or_path", ",", "scale", "=", "1", ",", "module_color", "=", "(", "0", ",", "0", ",", "0", ")", ",", "background", "=", "None", ",", "quiet_zone", "=", "4", ")", ":", "from", "functools", "impor...
This function writes the QR code out as an EPS document. The code is drawn by drawing only the modules corresponding to a 1. They are drawn using a line, such that contiguous modules in a row are drawn with a single line. The file parameter is used to specify where to write the document to. It can eithe...
[ "This", "function", "writes", "the", "QR", "code", "out", "as", "an", "EPS", "document", ".", "The", "code", "is", "drawn", "by", "drawing", "only", "the", "modules", "corresponding", "to", "a", "1", ".", "They", "are", "drawn", "using", "a", "line", "...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L1394-L1514
mnooner256/pyqrcode
pyqrcode/builder.py
_hex_to_rgb
def _hex_to_rgb(color): """\ Helper function to convert a color provided in hexadecimal format as RGB triple. """ if color[0] == '#': color = color[1:] if len(color) == 3: color = color[0] * 2 + color[1] * 2 + color[2] * 2 if len(color) != 6: raise ValueError('Input #...
python
def _hex_to_rgb(color): """\ Helper function to convert a color provided in hexadecimal format as RGB triple. """ if color[0] == '#': color = color[1:] if len(color) == 3: color = color[0] * 2 + color[1] * 2 + color[2] * 2 if len(color) != 6: raise ValueError('Input #...
[ "def", "_hex_to_rgb", "(", "color", ")", ":", "if", "color", "[", "0", "]", "==", "'#'", ":", "color", "=", "color", "[", "1", ":", "]", "if", "len", "(", "color", ")", "==", "3", ":", "color", "=", "color", "[", "0", "]", "*", "2", "+", "c...
\ Helper function to convert a color provided in hexadecimal format as RGB triple.
[ "\\", "Helper", "function", "to", "convert", "a", "color", "provided", "in", "hexadecimal", "format", "as", "RGB", "triple", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L1517-L1528
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.grouper
def grouper(self, n, iterable, fillvalue=None): """This generator yields a set of tuples, where the iterable is broken into n sized chunks. If the iterable is not evenly sized then fillvalue will be appended to the last tuple to make up the difference. This function is copied fr...
python
def grouper(self, n, iterable, fillvalue=None): """This generator yields a set of tuples, where the iterable is broken into n sized chunks. If the iterable is not evenly sized then fillvalue will be appended to the last tuple to make up the difference. This function is copied fr...
[ "def", "grouper", "(", "self", ",", "n", ",", "iterable", ",", "fillvalue", "=", "None", ")", ":", "args", "=", "[", "iter", "(", "iterable", ")", "]", "*", "n", "if", "hasattr", "(", "itertools", ",", "'zip_longest'", ")", ":", "return", "itertools"...
This generator yields a set of tuples, where the iterable is broken into n sized chunks. If the iterable is not evenly sized then fillvalue will be appended to the last tuple to make up the difference. This function is copied from the standard docs on itertools.
[ "This", "generator", "yields", "a", "set", "of", "tuples", "where", "the", "iterable", "is", "broken", "into", "n", "sized", "chunks", ".", "If", "the", "iterable", "is", "not", "evenly", "sized", "then", "fillvalue", "will", "be", "appended", "to", "the",...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L98-L110
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.get_data_length
def get_data_length(self): """QR codes contain a "data length" field. This method creates this field. A binary string representing the appropriate length is returned. """ #The "data length" field varies by the type of code and its mode. #discover how long the "data lengt...
python
def get_data_length(self): """QR codes contain a "data length" field. This method creates this field. A binary string representing the appropriate length is returned. """ #The "data length" field varies by the type of code and its mode. #discover how long the "data lengt...
[ "def", "get_data_length", "(", "self", ")", ":", "#The \"data length\" field varies by the type of code and its mode.", "#discover how long the \"data length\" field should be.", "if", "1", "<=", "self", ".", "version", "<=", "9", ":", "max_version", "=", "9", "elif", "10",...
QR codes contain a "data length" field. This method creates this field. A binary string representing the appropriate length is returned.
[ "QR", "codes", "contain", "a", "data", "length", "field", ".", "This", "method", "creates", "this", "field", ".", "A", "binary", "string", "representing", "the", "appropriate", "length", "is", "returned", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L119-L144
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.encode
def encode(self): """This method encodes the data into a binary string using the appropriate algorithm specified by the mode. """ if self.mode == tables.modes['alphanumeric']: encoded = self.encode_alphanumeric() elif self.mode == tables.modes['numeric']: ...
python
def encode(self): """This method encodes the data into a binary string using the appropriate algorithm specified by the mode. """ if self.mode == tables.modes['alphanumeric']: encoded = self.encode_alphanumeric() elif self.mode == tables.modes['numeric']: ...
[ "def", "encode", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "tables", ".", "modes", "[", "'alphanumeric'", "]", ":", "encoded", "=", "self", ".", "encode_alphanumeric", "(", ")", "elif", "self", ".", "mode", "==", "tables", ".", "modes", ...
This method encodes the data into a binary string using the appropriate algorithm specified by the mode.
[ "This", "method", "encodes", "the", "data", "into", "a", "binary", "string", "using", "the", "appropriate", "algorithm", "specified", "by", "the", "mode", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L146-L158
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.encode_alphanumeric
def encode_alphanumeric(self): """This method encodes the QR code's data if its mode is alphanumeric. It returns the data encoded as a binary string. """ #Convert the string to upper case self.data = self.data.upper() #Change the data such that it uses a QR code ascii ta...
python
def encode_alphanumeric(self): """This method encodes the QR code's data if its mode is alphanumeric. It returns the data encoded as a binary string. """ #Convert the string to upper case self.data = self.data.upper() #Change the data such that it uses a QR code ascii ta...
[ "def", "encode_alphanumeric", "(", "self", ")", ":", "#Convert the string to upper case", "self", ".", "data", "=", "self", ".", "data", ".", "upper", "(", ")", "#Change the data such that it uses a QR code ascii table", "ascii", "=", "[", "]", "for", "char", "in", ...
This method encodes the QR code's data if its mode is alphanumeric. It returns the data encoded as a binary string.
[ "This", "method", "encodes", "the", "QR", "code", "s", "data", "if", "its", "mode", "is", "alphanumeric", ".", "It", "returns", "the", "data", "encoded", "as", "a", "binary", "string", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L160-L186
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.encode_numeric
def encode_numeric(self): """This method encodes the QR code's data if its mode is numeric. It returns the data encoded as a binary string. """ with io.StringIO() as buf: #Break the number into groups of three digits for triplet in self.grouper(3, self.data): ...
python
def encode_numeric(self): """This method encodes the QR code's data if its mode is numeric. It returns the data encoded as a binary string. """ with io.StringIO() as buf: #Break the number into groups of three digits for triplet in self.grouper(3, self.data): ...
[ "def", "encode_numeric", "(", "self", ")", ":", "with", "io", ".", "StringIO", "(", ")", "as", "buf", ":", "#Break the number into groups of three digits", "for", "triplet", "in", "self", ".", "grouper", "(", "3", ",", "self", ".", "data", ")", ":", "numbe...
This method encodes the QR code's data if its mode is numeric. It returns the data encoded as a binary string.
[ "This", "method", "encodes", "the", "QR", "code", "s", "data", "if", "its", "mode", "is", "numeric", ".", "It", "returns", "the", "data", "encoded", "as", "a", "binary", "string", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L188-L219
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.encode_bytes
def encode_bytes(self): """This method encodes the QR code's data if its mode is 8 bit mode. It returns the data encoded as a binary string. """ with io.StringIO() as buf: for char in self.data: if not isinstance(char, int): buf.write('{{0:...
python
def encode_bytes(self): """This method encodes the QR code's data if its mode is 8 bit mode. It returns the data encoded as a binary string. """ with io.StringIO() as buf: for char in self.data: if not isinstance(char, int): buf.write('{{0:...
[ "def", "encode_bytes", "(", "self", ")", ":", "with", "io", ".", "StringIO", "(", ")", "as", "buf", ":", "for", "char", "in", "self", ".", "data", ":", "if", "not", "isinstance", "(", "char", ",", "int", ")", ":", "buf", ".", "write", "(", "'{{0:...
This method encodes the QR code's data if its mode is 8 bit mode. It returns the data encoded as a binary string.
[ "This", "method", "encodes", "the", "QR", "code", "s", "data", "if", "its", "mode", "is", "8", "bit", "mode", ".", "It", "returns", "the", "data", "encoded", "as", "a", "binary", "string", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L221-L231
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.encode_kanji
def encode_kanji(self): """This method encodes the QR code's data if its mode is kanji. It returns the data encoded as a binary string. """ def two_bytes(data): """Output two byte character code as a single integer.""" def next_byte(b): """Make sur...
python
def encode_kanji(self): """This method encodes the QR code's data if its mode is kanji. It returns the data encoded as a binary string. """ def two_bytes(data): """Output two byte character code as a single integer.""" def next_byte(b): """Make sur...
[ "def", "encode_kanji", "(", "self", ")", ":", "def", "two_bytes", "(", "data", ")", ":", "\"\"\"Output two byte character code as a single integer.\"\"\"", "def", "next_byte", "(", "b", ")", ":", "\"\"\"Make sure that character code is an int. Python 2 and\n 3 co...
This method encodes the QR code's data if its mode is kanji. It returns the data encoded as a binary string.
[ "This", "method", "encodes", "the", "QR", "code", "s", "data", "if", "its", "mode", "is", "kanji", ".", "It", "returns", "the", "data", "encoded", "as", "a", "binary", "string", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L233-L274
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.add_data
def add_data(self): """This function properly constructs a QR code's data string. It takes into account the interleaving pattern required by the standard. """ #Encode the data into a QR code self.buffer.write(self.binary_string(self.mode, 4)) self.buffer.write(self.get_da...
python
def add_data(self): """This function properly constructs a QR code's data string. It takes into account the interleaving pattern required by the standard. """ #Encode the data into a QR code self.buffer.write(self.binary_string(self.mode, 4)) self.buffer.write(self.get_da...
[ "def", "add_data", "(", "self", ")", ":", "#Encode the data into a QR code", "self", ".", "buffer", ".", "write", "(", "self", ".", "binary_string", "(", "self", ".", "mode", ",", "4", ")", ")", "self", ".", "buffer", ".", "write", "(", "self", ".", "g...
This function properly constructs a QR code's data string. It takes into account the interleaving pattern required by the standard.
[ "This", "function", "properly", "constructs", "a", "QR", "code", "s", "data", "string", ".", "It", "takes", "into", "account", "the", "interleaving", "pattern", "required", "by", "the", "standard", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L277-L377
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.terminate_bits
def terminate_bits(self, payload): """This method adds zeros to the end of the encoded data so that the encoded data is of the correct length. It returns a binary string containing the bits to be added. """ data_capacity = tables.data_capacity[self.version][self.error][0] ...
python
def terminate_bits(self, payload): """This method adds zeros to the end of the encoded data so that the encoded data is of the correct length. It returns a binary string containing the bits to be added. """ data_capacity = tables.data_capacity[self.version][self.error][0] ...
[ "def", "terminate_bits", "(", "self", ",", "payload", ")", ":", "data_capacity", "=", "tables", ".", "data_capacity", "[", "self", ".", "version", "]", "[", "self", ".", "error", "]", "[", "0", "]", "if", "len", "(", "payload", ")", ">", "data_capacity...
This method adds zeros to the end of the encoded data so that the encoded data is of the correct length. It returns a binary string containing the bits to be added.
[ "This", "method", "adds", "zeros", "to", "the", "end", "of", "the", "encoded", "data", "so", "that", "the", "encoded", "data", "is", "of", "the", "correct", "length", ".", "It", "returns", "a", "binary", "string", "containing", "the", "bits", "to", "be",...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L379-L400
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.delimit_words
def delimit_words(self): """This method takes the existing encoded binary string and returns a binary string that will pad it such that the encoded string contains only full bytes. """ bits_short = 8 - (len(self.buffer.getvalue()) % 8) #The string already falls o...
python
def delimit_words(self): """This method takes the existing encoded binary string and returns a binary string that will pad it such that the encoded string contains only full bytes. """ bits_short = 8 - (len(self.buffer.getvalue()) % 8) #The string already falls o...
[ "def", "delimit_words", "(", "self", ")", ":", "bits_short", "=", "8", "-", "(", "len", "(", "self", ".", "buffer", ".", "getvalue", "(", ")", ")", "%", "8", ")", "#The string already falls on an byte boundary do nothing", "if", "bits_short", "==", "0", "or"...
This method takes the existing encoded binary string and returns a binary string that will pad it such that the encoded string contains only full bytes.
[ "This", "method", "takes", "the", "existing", "encoded", "binary", "string", "and", "returns", "a", "binary", "string", "that", "will", "pad", "it", "such", "that", "the", "encoded", "string", "contains", "only", "full", "bytes", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L402-L413
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.add_words
def add_words(self): """The data block must fill the entire data capacity of the QR code. If we fall short, then we must add bytes to the end of the encoded data field. The value of these bytes are specified in the standard. """ data_blocks = len(self.buffer.getvalue()) // 8 ...
python
def add_words(self): """The data block must fill the entire data capacity of the QR code. If we fall short, then we must add bytes to the end of the encoded data field. The value of these bytes are specified in the standard. """ data_blocks = len(self.buffer.getvalue()) // 8 ...
[ "def", "add_words", "(", "self", ")", ":", "data_blocks", "=", "len", "(", "self", ".", "buffer", ".", "getvalue", "(", ")", ")", "//", "8", "total_blocks", "=", "tables", ".", "data_capacity", "[", "self", ".", "version", "]", "[", "self", ".", "err...
The data block must fill the entire data capacity of the QR code. If we fall short, then we must add bytes to the end of the encoded data field. The value of these bytes are specified in the standard.
[ "The", "data", "block", "must", "fill", "the", "entire", "data", "capacity", "of", "the", "QR", "code", ".", "If", "we", "fall", "short", "then", "we", "must", "add", "bytes", "to", "the", "end", "of", "the", "encoded", "data", "field", ".", "The", "...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L415-L432
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.make_error_block
def make_error_block(self, block, block_number): """This function constructs the error correction block of the given data block. This is *very complicated* process. To understand the code you need to read: * http://www.thonky.com/qr-code-tutorial/part-2-error-correction/ * http:...
python
def make_error_block(self, block, block_number): """This function constructs the error correction block of the given data block. This is *very complicated* process. To understand the code you need to read: * http://www.thonky.com/qr-code-tutorial/part-2-error-correction/ * http:...
[ "def", "make_error_block", "(", "self", ",", "block", ",", "block_number", ")", ":", "#Get the error information from the standards table", "error_info", "=", "tables", ".", "eccwbi", "[", "self", ".", "version", "]", "[", "self", ".", "error", "]", "#This is the ...
This function constructs the error correction block of the given data block. This is *very complicated* process. To understand the code you need to read: * http://www.thonky.com/qr-code-tutorial/part-2-error-correction/ * http://www.matchadesign.com/blog/qr-code-demystified-part-4/
[ "This", "function", "constructs", "the", "error", "correction", "block", "of", "the", "given", "data", "block", ".", "This", "is", "*", "very", "complicated", "*", "process", ".", "To", "understand", "the", "code", "you", "need", "to", "read", ":" ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L434-L495
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.make_code
def make_code(self): """This method returns the best possible QR code.""" from copy import deepcopy #Get the size of the underlying matrix matrix_size = tables.version_size[self.version] #Create a template matrix we will build the codes with row = [' ' for x in range(ma...
python
def make_code(self): """This method returns the best possible QR code.""" from copy import deepcopy #Get the size of the underlying matrix matrix_size = tables.version_size[self.version] #Create a template matrix we will build the codes with row = [' ' for x in range(ma...
[ "def", "make_code", "(", "self", ")", ":", "from", "copy", "import", "deepcopy", "#Get the size of the underlying matrix", "matrix_size", "=", "tables", ".", "version_size", "[", "self", ".", "version", "]", "#Create a template matrix we will build the codes with", "row",...
This method returns the best possible QR code.
[ "This", "method", "returns", "the", "best", "possible", "QR", "code", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L497-L517
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.add_detection_pattern
def add_detection_pattern(self, m): """This method add the detection patterns to the QR code. This lets the scanner orient the pattern. It is required for all QR codes. The detection pattern consists of three boxes located at the upper left, upper right, and lower left corners of the mat...
python
def add_detection_pattern(self, m): """This method add the detection patterns to the QR code. This lets the scanner orient the pattern. It is required for all QR codes. The detection pattern consists of three boxes located at the upper left, upper right, and lower left corners of the mat...
[ "def", "add_detection_pattern", "(", "self", ",", "m", ")", ":", "#Draw outer black box", "for", "i", "in", "range", "(", "7", ")", ":", "inv", "=", "-", "(", "i", "+", "1", ")", "for", "j", "in", "[", "0", ",", "6", ",", "-", "1", ",", "-", ...
This method add the detection patterns to the QR code. This lets the scanner orient the pattern. It is required for all QR codes. The detection pattern consists of three boxes located at the upper left, upper right, and lower left corners of the matrix. Also, two special lines called the...
[ "This", "method", "add", "the", "detection", "patterns", "to", "the", "QR", "code", ".", "This", "lets", "the", "scanner", "orient", "the", "pattern", ".", "It", "is", "required", "for", "all", "QR", "codes", ".", "The", "detection", "pattern", "consists",...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L519-L577
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.add_position_pattern
def add_position_pattern(self, m): """This method draws the position adjustment patterns onto the QR Code. All QR code versions larger than one require these special boxes called position adjustment patterns. """ #Version 1 does not have a position adjustment pattern if s...
python
def add_position_pattern(self, m): """This method draws the position adjustment patterns onto the QR Code. All QR code versions larger than one require these special boxes called position adjustment patterns. """ #Version 1 does not have a position adjustment pattern if s...
[ "def", "add_position_pattern", "(", "self", ",", "m", ")", ":", "#Version 1 does not have a position adjustment pattern", "if", "self", ".", "version", "==", "1", ":", "return", "#Get the coordinates for where to place the boxes", "coordinates", "=", "tables", ".", "posit...
This method draws the position adjustment patterns onto the QR Code. All QR code versions larger than one require these special boxes called position adjustment patterns.
[ "This", "method", "draws", "the", "position", "adjustment", "patterns", "onto", "the", "QR", "Code", ".", "All", "QR", "code", "versions", "larger", "than", "one", "require", "these", "special", "boxes", "called", "position", "adjustment", "patterns", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L579-L623
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.add_version_pattern
def add_version_pattern(self, m): """For QR codes with a version 7 or higher, a special pattern specifying the code's version is required. For further information see: http://www.thonky.com/qr-code-tutorial/format-version-information/#example-of-version-7-information-string """ ...
python
def add_version_pattern(self, m): """For QR codes with a version 7 or higher, a special pattern specifying the code's version is required. For further information see: http://www.thonky.com/qr-code-tutorial/format-version-information/#example-of-version-7-information-string """ ...
[ "def", "add_version_pattern", "(", "self", ",", "m", ")", ":", "if", "self", ".", "version", "<", "7", ":", "return", "#Get the bit fields for this code's version", "#We will iterate across the string, the bit string", "#needs the least significant digit in the zero-th position",...
For QR codes with a version 7 or higher, a special pattern specifying the code's version is required. For further information see: http://www.thonky.com/qr-code-tutorial/format-version-information/#example-of-version-7-information-string
[ "For", "QR", "codes", "with", "a", "version", "7", "or", "higher", "a", "special", "pattern", "specifying", "the", "code", "s", "version", "is", "required", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L625-L653
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.make_masks
def make_masks(self, template): """This method generates all seven masks so that the best mask can be determined. The template parameter is a code matrix that will server as the base for all the generated masks. """ from copy import deepcopy nmasks = len(tables.mask_patt...
python
def make_masks(self, template): """This method generates all seven masks so that the best mask can be determined. The template parameter is a code matrix that will server as the base for all the generated masks. """ from copy import deepcopy nmasks = len(tables.mask_patt...
[ "def", "make_masks", "(", "self", ",", "template", ")", ":", "from", "copy", "import", "deepcopy", "nmasks", "=", "len", "(", "tables", ".", "mask_patterns", ")", "masks", "=", "[", "''", "]", "*", "nmasks", "count", "=", "0", "for", "n", "in", "rang...
This method generates all seven masks so that the best mask can be determined. The template parameter is a code matrix that will server as the base for all the generated masks.
[ "This", "method", "generates", "all", "seven", "masks", "so", "that", "the", "best", "mask", "can", "be", "determined", ".", "The", "template", "parameter", "is", "a", "code", "matrix", "that", "will", "server", "as", "the", "base", "for", "all", "the", ...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L655-L729
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.choose_best_mask
def choose_best_mask(self): """This method returns the index of the "best" mask as defined by having the lowest total penalty score. The penalty rules are defined by the standard. The mask with the lowest total score should be the easiest to read by optical scanners. """ ...
python
def choose_best_mask(self): """This method returns the index of the "best" mask as defined by having the lowest total penalty score. The penalty rules are defined by the standard. The mask with the lowest total score should be the easiest to read by optical scanners. """ ...
[ "def", "choose_best_mask", "(", "self", ")", ":", "self", ".", "scores", "=", "[", "]", "for", "n", "in", "range", "(", "len", "(", "self", ".", "masks", ")", ")", ":", "self", ".", "scores", ".", "append", "(", "[", "0", ",", "0", ",", "0", ...
This method returns the index of the "best" mask as defined by having the lowest total penalty score. The penalty rules are defined by the standard. The mask with the lowest total score should be the easiest to read by optical scanners.
[ "This", "method", "returns", "the", "index", "of", "the", "best", "mask", "as", "defined", "by", "having", "the", "lowest", "total", "penalty", "score", ".", "The", "penalty", "rules", "are", "defined", "by", "the", "standard", ".", "The", "mask", "with", ...
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L731-L868
mnooner256/pyqrcode
pyqrcode/builder.py
QRCodeBuilder.add_type_pattern
def add_type_pattern(self, m, type_bits): """This will add the pattern to the QR code that represents the error level and the type of mask used to make the code. """ field = iter(type_bits) for i in range(7): bit = int(next(field)) #Skip the timing bits ...
python
def add_type_pattern(self, m, type_bits): """This will add the pattern to the QR code that represents the error level and the type of mask used to make the code. """ field = iter(type_bits) for i in range(7): bit = int(next(field)) #Skip the timing bits ...
[ "def", "add_type_pattern", "(", "self", ",", "m", ",", "type_bits", ")", ":", "field", "=", "iter", "(", "type_bits", ")", "for", "i", "in", "range", "(", "7", ")", ":", "bit", "=", "int", "(", "next", "(", "field", ")", ")", "#Skip the timing bits",...
This will add the pattern to the QR code that represents the error level and the type of mask used to make the code.
[ "This", "will", "add", "the", "pattern", "to", "the", "QR", "code", "that", "represents", "the", "error", "level", "and", "the", "type", "of", "mask", "used", "to", "make", "the", "code", "." ]
train
https://github.com/mnooner256/pyqrcode/blob/674a77b5eaf850d063f518bd90c243ee34ad6b5d/pyqrcode/builder.py#L870-L897
arokem/python-matlab-bridge
tools/github_stats.py
split_pulls
def split_pulls(all_issues, project="arokem/python-matlab-bridge"): """split a list of closed issues into non-PR Issues and Pull Requests""" pulls = [] issues = [] for i in all_issues: if is_pull_request(i): pull = get_pull_request(project, i['number'], auth=True) pulls.a...
python
def split_pulls(all_issues, project="arokem/python-matlab-bridge"): """split a list of closed issues into non-PR Issues and Pull Requests""" pulls = [] issues = [] for i in all_issues: if is_pull_request(i): pull = get_pull_request(project, i['number'], auth=True) pulls.a...
[ "def", "split_pulls", "(", "all_issues", ",", "project", "=", "\"arokem/python-matlab-bridge\"", ")", ":", "pulls", "=", "[", "]", "issues", "=", "[", "]", "for", "i", "in", "all_issues", ":", "if", "is_pull_request", "(", "i", ")", ":", "pull", "=", "ge...
split a list of closed issues into non-PR Issues and Pull Requests
[ "split", "a", "list", "of", "closed", "issues", "into", "non", "-", "PR", "Issues", "and", "Pull", "Requests" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/github_stats.py#L53-L63
arokem/python-matlab-bridge
tools/github_stats.py
issues_closed_since
def issues_closed_since(period=timedelta(days=365), project="arokem/python-matlab-bridge", pulls=False): """Get all issues closed since a particular point in time. period can either be a datetime object, or a timedelta object. In the latter case, it is used as a time before the present. """ which =...
python
def issues_closed_since(period=timedelta(days=365), project="arokem/python-matlab-bridge", pulls=False): """Get all issues closed since a particular point in time. period can either be a datetime object, or a timedelta object. In the latter case, it is used as a time before the present. """ which =...
[ "def", "issues_closed_since", "(", "period", "=", "timedelta", "(", "days", "=", "365", ")", ",", "project", "=", "\"arokem/python-matlab-bridge\"", ",", "pulls", "=", "False", ")", ":", "which", "=", "'pulls'", "if", "pulls", "else", "'issues'", "if", "isin...
Get all issues closed since a particular point in time. period can either be a datetime object, or a timedelta object. In the latter case, it is used as a time before the present.
[ "Get", "all", "issues", "closed", "since", "a", "particular", "point", "in", "time", ".", "period", "can", "either", "be", "a", "datetime", "object", "or", "a", "timedelta", "object", ".", "In", "the", "latter", "case", "it", "is", "used", "as", "a", "...
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/github_stats.py#L66-L89
arokem/python-matlab-bridge
tools/github_stats.py
sorted_by_field
def sorted_by_field(issues, field='closed_at', reverse=False): """Return a list of issues sorted by closing date date.""" return sorted(issues, key = lambda i:i[field], reverse=reverse)
python
def sorted_by_field(issues, field='closed_at', reverse=False): """Return a list of issues sorted by closing date date.""" return sorted(issues, key = lambda i:i[field], reverse=reverse)
[ "def", "sorted_by_field", "(", "issues", ",", "field", "=", "'closed_at'", ",", "reverse", "=", "False", ")", ":", "return", "sorted", "(", "issues", ",", "key", "=", "lambda", "i", ":", "i", "[", "field", "]", ",", "reverse", "=", "reverse", ")" ]
Return a list of issues sorted by closing date date.
[ "Return", "a", "list", "of", "issues", "sorted", "by", "closing", "date", "date", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/github_stats.py#L92-L94
arokem/python-matlab-bridge
tools/github_stats.py
report
def report(issues, show_urls=False): """Summary report about a list of issues, printing number and title. """ # titles may have unicode in them, so we must encode everything below if show_urls: for i in issues: print(u'#%d: %s' % (i['number'], i[...
python
def report(issues, show_urls=False): """Summary report about a list of issues, printing number and title. """ # titles may have unicode in them, so we must encode everything below if show_urls: for i in issues: print(u'#%d: %s' % (i['number'], i[...
[ "def", "report", "(", "issues", ",", "show_urls", "=", "False", ")", ":", "# titles may have unicode in them, so we must encode everything below", "if", "show_urls", ":", "for", "i", "in", "issues", ":", "print", "(", "u'#%d: %s'", "%", "(", "i", "[", "'number'", ...
Summary report about a list of issues, printing number and title.
[ "Summary", "report", "about", "a", "list", "of", "issues", "printing", "number", "and", "title", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/github_stats.py#L97-L107
arokem/python-matlab-bridge
pymatbridge/pymatbridge.py
encode_ndarray
def encode_ndarray(obj): """Write a numpy array and its shape to base64 buffers""" shape = obj.shape if len(shape) == 1: shape = (1, obj.shape[0]) if obj.flags.c_contiguous: obj = obj.T elif not obj.flags.f_contiguous: obj = asfortranarray(obj.T) else: obj = obj.T...
python
def encode_ndarray(obj): """Write a numpy array and its shape to base64 buffers""" shape = obj.shape if len(shape) == 1: shape = (1, obj.shape[0]) if obj.flags.c_contiguous: obj = obj.T elif not obj.flags.f_contiguous: obj = asfortranarray(obj.T) else: obj = obj.T...
[ "def", "encode_ndarray", "(", "obj", ")", ":", "shape", "=", "obj", ".", "shape", "if", "len", "(", "shape", ")", "==", "1", ":", "shape", "=", "(", "1", ",", "obj", ".", "shape", "[", "0", "]", ")", "if", "obj", ".", "flags", ".", "c_contiguou...
Write a numpy array and its shape to base64 buffers
[ "Write", "a", "numpy", "array", "and", "its", "shape", "to", "base64", "buffers" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/pymatbridge.py#L46-L63
arokem/python-matlab-bridge
pymatbridge/pymatbridge.py
decode_arr
def decode_arr(data): """Extract a numpy array from a base64 buffer""" data = data.encode('utf-8') return frombuffer(base64.b64decode(data), float64)
python
def decode_arr(data): """Extract a numpy array from a base64 buffer""" data = data.encode('utf-8') return frombuffer(base64.b64decode(data), float64)
[ "def", "decode_arr", "(", "data", ")", ":", "data", "=", "data", ".", "encode", "(", "'utf-8'", ")", "return", "frombuffer", "(", "base64", ".", "b64decode", "(", "data", ")", ",", "float64", ")" ]
Extract a numpy array from a base64 buffer
[ "Extract", "a", "numpy", "array", "from", "a", "base64", "buffer" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/pymatbridge.py#L88-L91
arokem/python-matlab-bridge
pymatbridge/pymatbridge.py
_Session.run_func
def run_func(self, func_path, *func_args, **kwargs): """Run a function in Matlab and return the result. Parameters ---------- func_path: str Name of function to run or a path to an m-file. func_args: object, optional Function args to send to the function....
python
def run_func(self, func_path, *func_args, **kwargs): """Run a function in Matlab and return the result. Parameters ---------- func_path: str Name of function to run or a path to an m-file. func_args: object, optional Function args to send to the function....
[ "def", "run_func", "(", "self", ",", "func_path", ",", "*", "func_args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "started", ":", "raise", "ValueError", "(", "'Session not started, use start()'", ")", "nargout", "=", "kwargs", ".", "pop...
Run a function in Matlab and return the result. Parameters ---------- func_path: str Name of function to run or a path to an m-file. func_args: object, optional Function args to send to the function. nargout: int, optional Desired number of re...
[ "Run", "a", "function", "in", "Matlab", "and", "return", "the", "result", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/pymatbridge.py#L276-L311
arokem/python-matlab-bridge
pymatbridge/pymatbridge.py
_Session._bind_method
def _bind_method(self, name, unconditionally=False): """Generate a Matlab function and bind it to the instance This is where the magic happens. When an unknown attribute of the Matlab class is requested, it is assumed to be a call to a Matlab function, and is generated and bound to the ...
python
def _bind_method(self, name, unconditionally=False): """Generate a Matlab function and bind it to the instance This is where the magic happens. When an unknown attribute of the Matlab class is requested, it is assumed to be a call to a Matlab function, and is generated and bound to the ...
[ "def", "_bind_method", "(", "self", ",", "name", ",", "unconditionally", "=", "False", ")", ":", "# TODO: This does not work if the function is a mex function inside a folder of the same name", "exists", "=", "self", ".", "run_func", "(", "'exist'", ",", "name", ")", "[...
Generate a Matlab function and bind it to the instance This is where the magic happens. When an unknown attribute of the Matlab class is requested, it is assumed to be a call to a Matlab function, and is generated and bound to the instance. This works because getattr() falls back to __...
[ "Generate", "a", "Matlab", "function", "and", "bind", "it", "to", "the", "instance" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/pymatbridge.py#L359-L411
arokem/python-matlab-bridge
pymatbridge/publish.py
format_line
def format_line(line): """ Format a line of Matlab into either a markdown line or a code line. Parameters ---------- line : str The line of code to be formatted. Formatting occurs according to the following rules: - If the line starts with (at least) two %% signs, a new cel...
python
def format_line(line): """ Format a line of Matlab into either a markdown line or a code line. Parameters ---------- line : str The line of code to be formatted. Formatting occurs according to the following rules: - If the line starts with (at least) two %% signs, a new cel...
[ "def", "format_line", "(", "line", ")", ":", "if", "line", ".", "startswith", "(", "'%%'", ")", ":", "md", "=", "True", "new_cell", "=", "True", "source", "=", "line", ".", "split", "(", "'%%'", ")", "[", "1", "]", "+", "'\\n'", "# line-breaks in md ...
Format a line of Matlab into either a markdown line or a code line. Parameters ---------- line : str The line of code to be formatted. Formatting occurs according to the following rules: - If the line starts with (at least) two %% signs, a new cell will be started. ...
[ "Format", "a", "line", "of", "Matlab", "into", "either", "a", "markdown", "line", "or", "a", "code", "line", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/publish.py#L11-L45
arokem/python-matlab-bridge
pymatbridge/publish.py
lines_to_notebook
def lines_to_notebook(lines, name=None): """ Convert the lines of an m file into an IPython notebook Parameters ---------- lines : list A list of strings. Each element is a line in the m file Returns ------- notebook : an IPython NotebookNode class instance, containing the ...
python
def lines_to_notebook(lines, name=None): """ Convert the lines of an m file into an IPython notebook Parameters ---------- lines : list A list of strings. Each element is a line in the m file Returns ------- notebook : an IPython NotebookNode class instance, containing the ...
[ "def", "lines_to_notebook", "(", "lines", ",", "name", "=", "None", ")", ":", "source", "=", "[", "]", "md", "=", "np", ".", "empty", "(", "len", "(", "lines", ")", ",", "dtype", "=", "object", ")", "new_cell", "=", "np", ".", "empty", "(", "len"...
Convert the lines of an m file into an IPython notebook Parameters ---------- lines : list A list of strings. Each element is a line in the m file Returns ------- notebook : an IPython NotebookNode class instance, containing the information required to create a file
[ "Convert", "the", "lines", "of", "an", "m", "file", "into", "an", "IPython", "notebook" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/publish.py#L62-L114
arokem/python-matlab-bridge
pymatbridge/publish.py
convert_mfile
def convert_mfile(mfile, outfile=None): """ Convert a Matlab m-file into a Matlab notebook in ipynb format Parameters ---------- mfile : string Full path to a matlab m file to convert outfile : string (optional) Full path to the output ipynb file """ lines = mfile_to_l...
python
def convert_mfile(mfile, outfile=None): """ Convert a Matlab m-file into a Matlab notebook in ipynb format Parameters ---------- mfile : string Full path to a matlab m file to convert outfile : string (optional) Full path to the output ipynb file """ lines = mfile_to_l...
[ "def", "convert_mfile", "(", "mfile", ",", "outfile", "=", "None", ")", ":", "lines", "=", "mfile_to_lines", "(", "mfile", ")", "nb", "=", "lines_to_notebook", "(", "lines", ")", "if", "outfile", "is", "None", ":", "outfile", "=", "mfile", ".", "split", ...
Convert a Matlab m-file into a Matlab notebook in ipynb format Parameters ---------- mfile : string Full path to a matlab m file to convert outfile : string (optional) Full path to the output ipynb file
[ "Convert", "a", "Matlab", "m", "-", "file", "into", "a", "Matlab", "notebook", "in", "ipynb", "format" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/publish.py#L117-L135
arokem/python-matlab-bridge
pymatbridge/matlab_magic.py
load_ipython_extension
def load_ipython_extension(ip, **kwargs): """Load the extension in IPython.""" global _loaded if not _loaded: ip.register_magics(MatlabMagics(ip, **kwargs)) _loaded = True
python
def load_ipython_extension(ip, **kwargs): """Load the extension in IPython.""" global _loaded if not _loaded: ip.register_magics(MatlabMagics(ip, **kwargs)) _loaded = True
[ "def", "load_ipython_extension", "(", "ip", ",", "*", "*", "kwargs", ")", ":", "global", "_loaded", "if", "not", "_loaded", ":", "ip", ".", "register_magics", "(", "MatlabMagics", "(", "ip", ",", "*", "*", "kwargs", ")", ")", "_loaded", "=", "True" ]
Load the extension in IPython.
[ "Load", "the", "extension", "in", "IPython", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/matlab_magic.py#L205-L210
arokem/python-matlab-bridge
tools/gh_api.py
post_gist
def post_gist(content, description='', filename='file', auth=False): """Post some text to a Gist, and return the URL.""" post_data = json.dumps({ "description": description, "public": True, "files": { filename: { "content": content } } }).encode('utf-8') ...
python
def post_gist(content, description='', filename='file', auth=False): """Post some text to a Gist, and return the URL.""" post_data = json.dumps({ "description": description, "public": True, "files": { filename: { "content": content } } }).encode('utf-8') ...
[ "def", "post_gist", "(", "content", ",", "description", "=", "''", ",", "filename", "=", "'file'", ",", "auth", "=", "False", ")", ":", "post_data", "=", "json", ".", "dumps", "(", "{", "\"description\"", ":", "description", ",", "\"public\"", ":", "True...
Post some text to a Gist, and return the URL.
[ "Post", "some", "text", "to", "a", "Gist", "and", "return", "the", "URL", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L80-L96
arokem/python-matlab-bridge
tools/gh_api.py
get_pull_request
def get_pull_request(project, num, auth=False): """get pull request info by number """ url = "https://api.github.com/repos/{project}/pulls/{num}".format(project=project, num=num) if auth: header = make_auth_header() else: header = None response = requests.get(url, headers=header...
python
def get_pull_request(project, num, auth=False): """get pull request info by number """ url = "https://api.github.com/repos/{project}/pulls/{num}".format(project=project, num=num) if auth: header = make_auth_header() else: header = None response = requests.get(url, headers=header...
[ "def", "get_pull_request", "(", "project", ",", "num", ",", "auth", "=", "False", ")", ":", "url", "=", "\"https://api.github.com/repos/{project}/pulls/{num}\"", ".", "format", "(", "project", "=", "project", ",", "num", "=", "num", ")", "if", "auth", ":", "...
get pull request info by number
[ "get", "pull", "request", "info", "by", "number" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L98-L108
arokem/python-matlab-bridge
tools/gh_api.py
get_pull_request_files
def get_pull_request_files(project, num, auth=False): """get list of files in a pull request""" url = "https://api.github.com/repos/{project}/pulls/{num}/files".format(project=project, num=num) if auth: header = make_auth_header() else: header = None return get_paged_request(url, hea...
python
def get_pull_request_files(project, num, auth=False): """get list of files in a pull request""" url = "https://api.github.com/repos/{project}/pulls/{num}/files".format(project=project, num=num) if auth: header = make_auth_header() else: header = None return get_paged_request(url, hea...
[ "def", "get_pull_request_files", "(", "project", ",", "num", ",", "auth", "=", "False", ")", ":", "url", "=", "\"https://api.github.com/repos/{project}/pulls/{num}/files\"", ".", "format", "(", "project", "=", "project", ",", "num", "=", "num", ")", "if", "auth"...
get list of files in a pull request
[ "get", "list", "of", "files", "in", "a", "pull", "request" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L110-L117
arokem/python-matlab-bridge
tools/gh_api.py
get_paged_request
def get_paged_request(url, headers=None, **params): """get a full list, handling APIv3's paging""" results = [] params.setdefault("per_page", 100) while True: if '?' in url: params = None print("fetching %s" % url, file=sys.stderr) else: print("fetchin...
python
def get_paged_request(url, headers=None, **params): """get a full list, handling APIv3's paging""" results = [] params.setdefault("per_page", 100) while True: if '?' in url: params = None print("fetching %s" % url, file=sys.stderr) else: print("fetchin...
[ "def", "get_paged_request", "(", "url", ",", "headers", "=", "None", ",", "*", "*", "params", ")", ":", "results", "=", "[", "]", "params", ".", "setdefault", "(", "\"per_page\"", ",", "100", ")", "while", "True", ":", "if", "'?'", "in", "url", ":", ...
get a full list, handling APIv3's paging
[ "get", "a", "full", "list", "handling", "APIv3", "s", "paging" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L122-L139
arokem/python-matlab-bridge
tools/gh_api.py
get_pulls_list
def get_pulls_list(project, auth=False, **params): """get pull request list""" params.setdefault("state", "closed") url = "https://api.github.com/repos/{project}/pulls".format(project=project) if auth: headers = make_auth_header() else: headers = None pages = get_paged_request(ur...
python
def get_pulls_list(project, auth=False, **params): """get pull request list""" params.setdefault("state", "closed") url = "https://api.github.com/repos/{project}/pulls".format(project=project) if auth: headers = make_auth_header() else: headers = None pages = get_paged_request(ur...
[ "def", "get_pulls_list", "(", "project", ",", "auth", "=", "False", ",", "*", "*", "params", ")", ":", "params", ".", "setdefault", "(", "\"state\"", ",", "\"closed\"", ")", "url", "=", "\"https://api.github.com/repos/{project}/pulls\"", ".", "format", "(", "p...
get pull request list
[ "get", "pull", "request", "list" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L141-L150
arokem/python-matlab-bridge
tools/gh_api.py
encode_multipart_formdata
def encode_multipart_formdata(fields, boundary=None): """ Encode a dictionary of ``fields`` using the multipart/form-data mime format. :param fields: Dictionary of fields or list of (key, value) field tuples. The key is treated as the field name, and the value as the body of the form-data ...
python
def encode_multipart_formdata(fields, boundary=None): """ Encode a dictionary of ``fields`` using the multipart/form-data mime format. :param fields: Dictionary of fields or list of (key, value) field tuples. The key is treated as the field name, and the value as the body of the form-data ...
[ "def", "encode_multipart_formdata", "(", "fields", ",", "boundary", "=", "None", ")", ":", "# copy requests imports in here:", "from", "io", "import", "BytesIO", "from", "requests", ".", "packages", ".", "urllib3", ".", "filepost", "import", "(", "choose_boundary", ...
Encode a dictionary of ``fields`` using the multipart/form-data mime format. :param fields: Dictionary of fields or list of (key, value) field tuples. The key is treated as the field name, and the value as the body of the form-data bytes. If the value is a tuple of two elements, then the f...
[ "Encode", "a", "dictionary", "of", "fields", "using", "the", "multipart", "/", "form", "-", "data", "mime", "format", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L207-L260
arokem/python-matlab-bridge
tools/gh_api.py
post_download
def post_download(project, filename, name=None, description=""): """Upload a file to the GitHub downloads area""" if name is None: name = os.path.basename(filename) with open(filename, 'rb') as f: filedata = f.read() url = "https://api.github.com/repos/{project}/downloads".format(projec...
python
def post_download(project, filename, name=None, description=""): """Upload a file to the GitHub downloads area""" if name is None: name = os.path.basename(filename) with open(filename, 'rb') as f: filedata = f.read() url = "https://api.github.com/repos/{project}/downloads".format(projec...
[ "def", "post_download", "(", "project", ",", "filename", ",", "name", "=", "None", ",", "description", "=", "\"\"", ")", ":", "if", "name", "is", "None", ":", "name", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "with", "open", "(",...
Upload a file to the GitHub downloads area
[ "Upload", "a", "file", "to", "the", "GitHub", "downloads", "area" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/tools/gh_api.py#L263-L292
arokem/python-matlab-bridge
pymatbridge/messenger/make.py
is_executable_file
def is_executable_file(path): """Checks that path is an executable regular file (or a symlink to a file). This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``, but on some platforms :func:`os.access` gives us the wrong answer, so this checks permission bits directly. Note ----...
python
def is_executable_file(path): """Checks that path is an executable regular file (or a symlink to a file). This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``, but on some platforms :func:`os.access` gives us the wrong answer, so this checks permission bits directly. Note ----...
[ "def", "is_executable_file", "(", "path", ")", ":", "# follow symlinks,", "fpath", "=", "os", ".", "path", ".", "realpath", "(", "path", ")", "# return False for non-files (directories, fifo, etc.)", "if", "not", "os", ".", "path", ".", "isfile", "(", "fpath", "...
Checks that path is an executable regular file (or a symlink to a file). This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``, but on some platforms :func:`os.access` gives us the wrong answer, so this checks permission bits directly. Note ---- This function is taken from the ...
[ "Checks", "that", "path", "is", "an", "executable", "regular", "file", "(", "or", "a", "symlink", "to", "a", "file", ")", "." ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/messenger/make.py#L40-L85
arokem/python-matlab-bridge
pymatbridge/messenger/make.py
which
def which(filename): '''This takes a given filename; tries to find it in the environment path; then checks if it is executable. This returns the full path to the filename if found and executable. Otherwise this returns None. Note ---- This function is taken from the pexpect module, see module d...
python
def which(filename): '''This takes a given filename; tries to find it in the environment path; then checks if it is executable. This returns the full path to the filename if found and executable. Otherwise this returns None. Note ---- This function is taken from the pexpect module, see module d...
[ "def", "which", "(", "filename", ")", ":", "# Special case where filename contains an explicit path.", "if", "os", ".", "path", ".", "dirname", "(", "filename", ")", "!=", "''", "and", "is_executable_file", "(", "filename", ")", ":", "return", "filename", "if", ...
This takes a given filename; tries to find it in the environment path; then checks if it is executable. This returns the full path to the filename if found and executable. Otherwise this returns None. Note ---- This function is taken from the pexpect module, see module doc-string for license.
[ "This", "takes", "a", "given", "filename", ";", "tries", "to", "find", "it", "in", "the", "environment", "path", ";", "then", "checks", "if", "it", "is", "executable", ".", "This", "returns", "the", "full", "path", "to", "the", "filename", "if", "found",...
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/messenger/make.py#L88-L118
arokem/python-matlab-bridge
pymatbridge/messenger/make.py
build_matlab
def build_matlab(static=False): """build the messenger mex for MATLAB static : bool Determines if the zmq library has been statically linked. If so, it will append the command line option -DZMQ_STATIC when compiling the mex so it matches libzmq. """ cfg = get_config() # To d...
python
def build_matlab(static=False): """build the messenger mex for MATLAB static : bool Determines if the zmq library has been statically linked. If so, it will append the command line option -DZMQ_STATIC when compiling the mex so it matches libzmq. """ cfg = get_config() # To d...
[ "def", "build_matlab", "(", "static", "=", "False", ")", ":", "cfg", "=", "get_config", "(", ")", "# To deal with spaces, remove quotes now, and add", "# to the full commands themselves.", "if", "'matlab_bin'", "in", "cfg", "and", "cfg", "[", "'matlab_bin'", "]", "!="...
build the messenger mex for MATLAB static : bool Determines if the zmq library has been statically linked. If so, it will append the command line option -DZMQ_STATIC when compiling the mex so it matches libzmq.
[ "build", "the", "messenger", "mex", "for", "MATLAB" ]
train
https://github.com/arokem/python-matlab-bridge/blob/9822c7b55435662f4f033c5479cc03fea2255755/pymatbridge/messenger/make.py#L242-L270
sixty-north/asq
asq/extension.py
add_method
def add_method(function, klass, name=None): '''Add an existing function to a class as a method. Note: Consider using the extend decorator as a more readable alternative to using this function directly. Args: function: The function to be added to the class klass. klass: Th...
python
def add_method(function, klass, name=None): '''Add an existing function to a class as a method. Note: Consider using the extend decorator as a more readable alternative to using this function directly. Args: function: The function to be added to the class klass. klass: Th...
[ "def", "add_method", "(", "function", ",", "klass", ",", "name", "=", "None", ")", ":", "# Should we be using functools.update_wrapper in here?\r", "if", "name", "is", "None", ":", "name", "=", "function_name", "(", "function", ")", "if", "hasattr", "(", "klass"...
Add an existing function to a class as a method. Note: Consider using the extend decorator as a more readable alternative to using this function directly. Args: function: The function to be added to the class klass. klass: The class to which the new method will be added. ...
[ "Add", "an", "existing", "function", "to", "a", "class", "as", "a", "method", ".", "Note", ":", "Consider", "using", "the", "extend", "decorator", "as", "a", "more", "readable", "alternative", "to", "using", "this", "function", "directly", ".", "Args", ":"...
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/extension.py#L8-L36
sixty-north/asq
asq/extension.py
extend
def extend(klass, name=None): '''A function decorator for extending an existing class. Use as a decorator for functions to add to an existing class. Args: klass: The class to be decorated. name: The name the new method is to be given in the klass class. Returns: A ...
python
def extend(klass, name=None): '''A function decorator for extending an existing class. Use as a decorator for functions to add to an existing class. Args: klass: The class to be decorated. name: The name the new method is to be given in the klass class. Returns: A ...
[ "def", "extend", "(", "klass", ",", "name", "=", "None", ")", ":", "def", "decorator", "(", "f", ")", ":", "return", "add_method", "(", "f", ",", "klass", ",", "name", ")", "return", "decorator" ]
A function decorator for extending an existing class. Use as a decorator for functions to add to an existing class. Args: klass: The class to be decorated. name: The name the new method is to be given in the klass class. Returns: A decorator function which accepts a sin...
[ "A", "function", "decorator", "for", "extending", "an", "existing", "class", ".", "Use", "as", "a", "decorator", "for", "functions", "to", "add", "to", "an", "existing", "class", ".", "Args", ":", "klass", ":", "The", "class", "to", "be", "decorated", "....
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/extension.py#L39-L60
sixty-north/asq
asq/queryables.py
Queryable.select
def select( self, selector): '''Transforms each element of a sequence into a new form. Each element of the source is transformed through a selector function to produce a corresponding element in teh result sequence. If the selector is identity the method will re...
python
def select( self, selector): '''Transforms each element of a sequence into a new form. Each element of the source is transformed through a selector function to produce a corresponding element in teh result sequence. If the selector is identity the method will re...
[ "def", "select", "(", "self", ",", "selector", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call select() on a closed Queryable.\"", ")", "try", ":", "selector", "=", "make_selector", "(", "selector", ")", "ex...
Transforms each element of a sequence into a new form. Each element of the source is transformed through a selector function to produce a corresponding element in teh result sequence. If the selector is identity the method will return self. Note: This method uses deferred execution. ...
[ "Transforms", "each", "element", "of", "a", "sequence", "into", "a", "new", "form", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L151-L192
sixty-north/asq
asq/queryables.py
Queryable.select_with_index
def select_with_index( self, selector=IndexedElement, transform=identity): '''Transforms each element of a sequence into a new form, incorporating the index of the element. Each element is transformed through a selector function which accepts the elem...
python
def select_with_index( self, selector=IndexedElement, transform=identity): '''Transforms each element of a sequence into a new form, incorporating the index of the element. Each element is transformed through a selector function which accepts the elem...
[ "def", "select_with_index", "(", "self", ",", "selector", "=", "IndexedElement", ",", "transform", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call select_with_index() on a \"", "\"closed Queryable...
Transforms each element of a sequence into a new form, incorporating the index of the element. Each element is transformed through a selector function which accepts the element value and its zero-based index in the source sequence. The generated sequence is lazily evaluated. No...
[ "Transforms", "each", "element", "of", "a", "sequence", "into", "a", "new", "form", "incorporating", "the", "index", "of", "the", "element", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L194-L238
sixty-north/asq
asq/queryables.py
Queryable.select_with_correspondence
def select_with_correspondence( self, selector, result_selector=KeyedElement): '''Apply a callable to each element in an input sequence, generating a new sequence of 2-tuples where the first element is the input value and the second is the transformed input va...
python
def select_with_correspondence( self, selector, result_selector=KeyedElement): '''Apply a callable to each element in an input sequence, generating a new sequence of 2-tuples where the first element is the input value and the second is the transformed input va...
[ "def", "select_with_correspondence", "(", "self", ",", "selector", ",", "result_selector", "=", "KeyedElement", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call select_with_correspondence() on a \"", "\"closed Queryabl...
Apply a callable to each element in an input sequence, generating a new sequence of 2-tuples where the first element is the input value and the second is the transformed input value. The generated sequence is lazily evaluated. Note: This method uses deferred execution. Args: ...
[ "Apply", "a", "callable", "to", "each", "element", "in", "an", "input", "sequence", "generating", "a", "new", "sequence", "of", "2", "-", "tuples", "where", "the", "first", "element", "is", "the", "input", "value", "and", "the", "second", "is", "the", "t...
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L240-L289
sixty-north/asq
asq/queryables.py
Queryable.select_many
def select_many( self, collection_selector=identity, result_selector=identity): '''Projects each element of a sequence to an intermediate new sequence, flattens the resulting sequences into one sequence and optionally transforms the flattened sequence using a ...
python
def select_many( self, collection_selector=identity, result_selector=identity): '''Projects each element of a sequence to an intermediate new sequence, flattens the resulting sequences into one sequence and optionally transforms the flattened sequence using a ...
[ "def", "select_many", "(", "self", ",", "collection_selector", "=", "identity", ",", "result_selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call select_many() on a closed \"", "\"Queryable....
Projects each element of a sequence to an intermediate new sequence, flattens the resulting sequences into one sequence and optionally transforms the flattened sequence using a selector function. Note: This method uses deferred execution. Args: collection_selector: A unary ...
[ "Projects", "each", "element", "of", "a", "sequence", "to", "an", "intermediate", "new", "sequence", "flattens", "the", "resulting", "sequences", "into", "one", "sequence", "and", "optionally", "transforms", "the", "flattened", "sequence", "using", "a", "selector"...
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L291-L344
sixty-north/asq
asq/queryables.py
Queryable.select_many_with_index
def select_many_with_index( self, collection_selector=IndexedElement, result_selector=lambda source_element, collection_element: collection_element): '''Projects each element of a sequence to an intermediate new sequence, incorporati...
python
def select_many_with_index( self, collection_selector=IndexedElement, result_selector=lambda source_element, collection_element: collection_element): '''Projects each element of a sequence to an intermediate new sequence, incorporati...
[ "def", "select_many_with_index", "(", "self", ",", "collection_selector", "=", "IndexedElement", ",", "result_selector", "=", "lambda", "source_element", ",", "collection_element", ":", "collection_element", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "r...
Projects each element of a sequence to an intermediate new sequence, incorporating the index of the element, flattens the resulting sequence into one sequence and optionally transforms the flattened sequence using a selector function. Note: This method uses deferred execution. ...
[ "Projects", "each", "element", "of", "a", "sequence", "to", "an", "intermediate", "new", "sequence", "incorporating", "the", "index", "of", "the", "element", "flattens", "the", "resulting", "sequence", "into", "one", "sequence", "and", "optionally", "transforms", ...
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L346-L407
sixty-north/asq
asq/queryables.py
Queryable.select_many_with_correspondence
def select_many_with_correspondence( self, collection_selector=identity, result_selector=KeyedElement): '''Projects each element of a sequence to an intermediate new sequence, and flattens the resulting sequence, into one sequence and uses a selector function ...
python
def select_many_with_correspondence( self, collection_selector=identity, result_selector=KeyedElement): '''Projects each element of a sequence to an intermediate new sequence, and flattens the resulting sequence, into one sequence and uses a selector function ...
[ "def", "select_many_with_correspondence", "(", "self", ",", "collection_selector", "=", "identity", ",", "result_selector", "=", "KeyedElement", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call \"", "\"select_many_...
Projects each element of a sequence to an intermediate new sequence, and flattens the resulting sequence, into one sequence and uses a selector function to incorporate the corresponding source for each item in the result sequence. Note: This method uses deferred execution. Args...
[ "Projects", "each", "element", "of", "a", "sequence", "to", "an", "intermediate", "new", "sequence", "and", "flattens", "the", "resulting", "sequence", "into", "one", "sequence", "and", "uses", "a", "selector", "function", "to", "incorporate", "the", "correspond...
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L417-L476
sixty-north/asq
asq/queryables.py
Queryable.group_by
def group_by(self, key_selector=identity, element_selector=identity, result_selector=lambda key, grouping: grouping): '''Groups the elements according to the value of a key extracted by a selector function. Note: This method has different behaviour to itertools...
python
def group_by(self, key_selector=identity, element_selector=identity, result_selector=lambda key, grouping: grouping): '''Groups the elements according to the value of a key extracted by a selector function. Note: This method has different behaviour to itertools...
[ "def", "group_by", "(", "self", ",", "key_selector", "=", "identity", ",", "element_selector", "=", "identity", ",", "result_selector", "=", "lambda", "key", ",", "grouping", ":", "grouping", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", ...
Groups the elements according to the value of a key extracted by a selector function. Note: This method has different behaviour to itertools.groupby in the Python standard library because it aggregates all items with the same key, rather than returning groups of consecutive item...
[ "Groups", "the", "elements", "according", "to", "the", "value", "of", "a", "key", "extracted", "by", "a", "selector", "function", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L486-L543
sixty-north/asq
asq/queryables.py
Queryable.where
def where(self, predicate): '''Filters elements according to whether they match a predicate. Note: This method uses deferred execution. Args: predicate: A unary function which is applied to each element in the source sequence. Source elements for which the predicate...
python
def where(self, predicate): '''Filters elements according to whether they match a predicate. Note: This method uses deferred execution. Args: predicate: A unary function which is applied to each element in the source sequence. Source elements for which the predicate...
[ "def", "where", "(", "self", ",", "predicate", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call where() on a closed Queryable.\"", ")", "if", "not", "is_callable", "(", "predicate", ")", ":", "raise", "TypeEr...
Filters elements according to whether they match a predicate. Note: This method uses deferred execution. Args: predicate: A unary function which is applied to each element in the source sequence. Source elements for which the predicate returns True will be p...
[ "Filters", "elements", "according", "to", "whether", "they", "match", "a", "predicate", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L551-L576
sixty-north/asq
asq/queryables.py
Queryable.of_type
def of_type(self, classinfo): '''Filters elements according to whether they are of a certain type. Note: This method uses deferred execution. Args: classinfo: If classinfo is neither a class object nor a type object it may be a tuple of class or type objects, or may...
python
def of_type(self, classinfo): '''Filters elements according to whether they are of a certain type. Note: This method uses deferred execution. Args: classinfo: If classinfo is neither a class object nor a type object it may be a tuple of class or type objects, or may...
[ "def", "of_type", "(", "self", ",", "classinfo", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call of_type() on a closed \"", "\"Queryable.\"", ")", "if", "not", "is_type", "(", "classinfo", ")", ":", "raise",...
Filters elements according to whether they are of a certain type. Note: This method uses deferred execution. Args: classinfo: If classinfo is neither a class object nor a type object it may be a tuple of class or type objects, or may recursively contain othe...
[ "Filters", "elements", "according", "to", "whether", "they", "are", "of", "a", "certain", "type", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L578-L607
sixty-north/asq
asq/queryables.py
Queryable.order_by
def order_by(self, key_selector=identity): '''Sorts by a key in ascending order. Introduces a primary sorting order to the sequence. Additional sort criteria should be specified by subsequent calls to then_by() and then_by_descending(). Calling order_by() or order_by_descending() on ...
python
def order_by(self, key_selector=identity): '''Sorts by a key in ascending order. Introduces a primary sorting order to the sequence. Additional sort criteria should be specified by subsequent calls to then_by() and then_by_descending(). Calling order_by() or order_by_descending() on ...
[ "def", "order_by", "(", "self", ",", "key_selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call order_by() on a \"", "\"closed Queryable.\"", ")", "if", "not", "is_callable", "(", "key_se...
Sorts by a key in ascending order. Introduces a primary sorting order to the sequence. Additional sort criteria should be specified by subsequent calls to then_by() and then_by_descending(). Calling order_by() or order_by_descending() on the results of a call to order_by() will introdu...
[ "Sorts", "by", "a", "key", "in", "ascending", "order", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L609-L642
sixty-north/asq
asq/queryables.py
Queryable.take
def take(self, count=1): '''Returns a specified number of elements from the start of a sequence. If the source sequence contains fewer elements than requested only the available elements will be returned and no exception will be raised. Note: This method uses deferred execution. ...
python
def take(self, count=1): '''Returns a specified number of elements from the start of a sequence. If the source sequence contains fewer elements than requested only the available elements will be returned and no exception will be raised. Note: This method uses deferred execution. ...
[ "def", "take", "(", "self", ",", "count", "=", "1", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call take() on a closed Queryable.\"", ")", "count", "=", "max", "(", "0", ",", "count", ")", "return", "s...
Returns a specified number of elements from the start of a sequence. If the source sequence contains fewer elements than requested only the available elements will be returned and no exception will be raised. Note: This method uses deferred execution. Args: count: An optio...
[ "Returns", "a", "specified", "number", "of", "elements", "from", "the", "start", "of", "a", "sequence", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L679-L702
sixty-north/asq
asq/queryables.py
Queryable.take_while
def take_while(self, predicate): '''Returns elements from the start while the predicate is True. Note: This method uses deferred execution. Args: predicate: A function returning True or False with which elements will be tested. Returns: A Querya...
python
def take_while(self, predicate): '''Returns elements from the start while the predicate is True. Note: This method uses deferred execution. Args: predicate: A function returning True or False with which elements will be tested. Returns: A Querya...
[ "def", "take_while", "(", "self", ",", "predicate", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call take_while() on a closed \"", "\"Queryable.\"", ")", "if", "not", "is_callable", "(", "predicate", ")", ":", ...
Returns elements from the start while the predicate is True. Note: This method uses deferred execution. Args: predicate: A function returning True or False with which elements will be tested. Returns: A Queryable over the elements from the beginning of ...
[ "Returns", "elements", "from", "the", "start", "while", "the", "predicate", "is", "True", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L704-L730
sixty-north/asq
asq/queryables.py
Queryable.skip
def skip(self, count=1): '''Skip the first count contiguous elements of the source sequence. If the source sequence contains fewer than count elements returns an empty sequence and does not raise an exception. Note: This method uses deferred execution. Args: count:...
python
def skip(self, count=1): '''Skip the first count contiguous elements of the source sequence. If the source sequence contains fewer than count elements returns an empty sequence and does not raise an exception. Note: This method uses deferred execution. Args: count:...
[ "def", "skip", "(", "self", ",", "count", "=", "1", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call skip() on a closed Queryable.\"", ")", "count", "=", "max", "(", "0", ",", "count", ")", "if", "count...
Skip the first count contiguous elements of the source sequence. If the source sequence contains fewer than count elements returns an empty sequence and does not raise an exception. Note: This method uses deferred execution. Args: count: The number of elements to skip from...
[ "Skip", "the", "first", "count", "contiguous", "elements", "of", "the", "source", "sequence", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L739-L777
sixty-north/asq
asq/queryables.py
Queryable.skip_while
def skip_while(self, predicate): '''Omit elements from the start for which a predicate is True. Note: This method uses deferred execution. Args: predicate: A single argument predicate function. Returns: A Queryable over the sequence of elements beginning with t...
python
def skip_while(self, predicate): '''Omit elements from the start for which a predicate is True. Note: This method uses deferred execution. Args: predicate: A single argument predicate function. Returns: A Queryable over the sequence of elements beginning with t...
[ "def", "skip_while", "(", "self", ",", "predicate", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call take_while() on a \"", "\"closed Queryable.\"", ")", "if", "not", "is_callable", "(", "predicate", ")", ":", ...
Omit elements from the start for which a predicate is True. Note: This method uses deferred execution. Args: predicate: A single argument predicate function. Returns: A Queryable over the sequence of elements beginning with the first element for which the p...
[ "Omit", "elements", "from", "the", "start", "for", "which", "a", "predicate", "is", "True", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L789-L813
sixty-north/asq
asq/queryables.py
Queryable.concat
def concat(self, second_iterable): '''Concatenates two sequences. Note: This method uses deferred execution. Args: second_iterable: The sequence to concatenate on to the sequence. Returns: A Queryable over the concatenated sequences. Raises: ...
python
def concat(self, second_iterable): '''Concatenates two sequences. Note: This method uses deferred execution. Args: second_iterable: The sequence to concatenate on to the sequence. Returns: A Queryable over the concatenated sequences. Raises: ...
[ "def", "concat", "(", "self", ",", "second_iterable", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call concat() on a closed Queryable.\"", ")", "if", "not", "is_iterable", "(", "second_iterable", ")", ":", "rai...
Concatenates two sequences. Note: This method uses deferred execution. Args: second_iterable: The sequence to concatenate on to the sequence. Returns: A Queryable over the concatenated sequences. Raises: ValueError: If the Queryable is closed(). ...
[ "Concatenates", "two", "sequences", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L815-L837
sixty-north/asq
asq/queryables.py
Queryable.reverse
def reverse(self): '''Returns the sequence reversed. Note: This method uses deferred execution, but the whole source sequence is consumed once execution commences. Returns: The source sequence in reverse order. Raises: ValueError: If the Queryable i...
python
def reverse(self): '''Returns the sequence reversed. Note: This method uses deferred execution, but the whole source sequence is consumed once execution commences. Returns: The source sequence in reverse order. Raises: ValueError: If the Queryable i...
[ "def", "reverse", "(", "self", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call reverse() on a \"", "\"closed Queryable.\"", ")", "# Attempt an optimised version", "try", ":", "r", "=", "reversed", "(", "self", ...
Returns the sequence reversed. Note: This method uses deferred execution, but the whole source sequence is consumed once execution commences. Returns: The source sequence in reverse order. Raises: ValueError: If the Queryable is closed().
[ "Returns", "the", "sequence", "reversed", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L839-L863
sixty-north/asq
asq/queryables.py
Queryable.element_at
def element_at(self, index): '''Return the element at ordinal index. Note: This method uses immediate execution. Args: index: The index of the element to be returned. Returns: The element at ordinal index in the source sequence. Raises: Val...
python
def element_at(self, index): '''Return the element at ordinal index. Note: This method uses immediate execution. Args: index: The index of the element to be returned. Returns: The element at ordinal index in the source sequence. Raises: Val...
[ "def", "element_at", "(", "self", ",", "index", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call element_at() on a \"", "\"closed Queryable.\"", ")", "if", "index", "<", "0", ":", "raise", "OutOfRangeError", ...
Return the element at ordinal index. Note: This method uses immediate execution. Args: index: The index of the element to be returned. Returns: The element at ordinal index in the source sequence. Raises: ValueError: If the Queryable is closed(). ...
[ "Return", "the", "element", "at", "ordinal", "index", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L871-L905
sixty-north/asq
asq/queryables.py
Queryable.count
def count(self, predicate=None): '''Return the number of elements (which match an optional predicate). Note: This method uses immediate execution. Args: predicate: An optional unary predicate function used to identify elements which will be counted. The single posit...
python
def count(self, predicate=None): '''Return the number of elements (which match an optional predicate). Note: This method uses immediate execution. Args: predicate: An optional unary predicate function used to identify elements which will be counted. The single posit...
[ "def", "count", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call element_at() on a \"", "\"closed Queryable.\"", ")", "return", "self", ".", "_count", "(", ")", "...
Return the number of elements (which match an optional predicate). Note: This method uses immediate execution. Args: predicate: An optional unary predicate function used to identify elements which will be counted. The single positional argument of the functi...
[ "Return", "the", "number", "of", "elements", "(", "which", "match", "an", "optional", "predicate", ")", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L907-L932
sixty-north/asq
asq/queryables.py
Queryable.any
def any(self, predicate=None): '''Determine if the source sequence contains any elements which satisfy the predicate. Only enough of the sequence to satisfy the predicate once is consumed. Note: This method uses immediate execution. Args: predicate: An optional sin...
python
def any(self, predicate=None): '''Determine if the source sequence contains any elements which satisfy the predicate. Only enough of the sequence to satisfy the predicate once is consumed. Note: This method uses immediate execution. Args: predicate: An optional sin...
[ "def", "any", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call any() on a closed Queryable.\"", ")", "if", "predicate", "is", "None", ":", "predicate", "=", "lamb...
Determine if the source sequence contains any elements which satisfy the predicate. Only enough of the sequence to satisfy the predicate once is consumed. Note: This method uses immediate execution. Args: predicate: An optional single argument function used to test each ...
[ "Determine", "if", "the", "source", "sequence", "contains", "any", "elements", "which", "satisfy", "the", "predicate", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L956-L988
sixty-north/asq
asq/queryables.py
Queryable.all
def all(self, predicate=bool): '''Determine if all elements in the source sequence satisfy a condition. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: predicate (callable): An optional single argument function used to ...
python
def all(self, predicate=bool): '''Determine if all elements in the source sequence satisfy a condition. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: predicate (callable): An optional single argument function used to ...
[ "def", "all", "(", "self", ",", "predicate", "=", "bool", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call all() on a closed Queryable.\"", ")", "if", "not", "is_callable", "(", "predicate", ")", ":", "rais...
Determine if all elements in the source sequence satisfy a condition. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: predicate (callable): An optional single argument function used to test each elements. If omitted, t...
[ "Determine", "if", "all", "elements", "in", "the", "source", "sequence", "satisfy", "a", "condition", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L990-L1017
sixty-north/asq
asq/queryables.py
Queryable.sum
def sum(self, selector=identity): '''Return the arithmetic sum of the values in the sequence.. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: selector: An optional single argument function which will be used t...
python
def sum(self, selector=identity): '''Return the arithmetic sum of the values in the sequence.. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: selector: An optional single argument function which will be used t...
[ "def", "sum", "(", "self", ",", "selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call sum() on a closed Queryable.\"", ")", "if", "not", "is_callable", "(", "selector", ")", ":", "ra...
Return the arithmetic sum of the values in the sequence.. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: selector: An optional single argument function which will be used to project the elements of the sequence. If om...
[ "Return", "the", "arithmetic", "sum", "of", "the", "values", "in", "the", "sequence", ".." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1076-L1103
sixty-north/asq
asq/queryables.py
Queryable.average
def average(self, selector=identity): '''Return the arithmetic mean of the values in the sequence.. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: selector: An optional single argument function which will be used ...
python
def average(self, selector=identity): '''Return the arithmetic mean of the values in the sequence.. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: selector: An optional single argument function which will be used ...
[ "def", "average", "(", "self", ",", "selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call average() on a \"", "\"closed Queryable.\"", ")", "if", "not", "is_callable", "(", "selector", ...
Return the arithmetic mean of the values in the sequence.. All of the source sequence will be consumed. Note: This method uses immediate execution. Args: selector: An optional single argument function which will be used to project the elements of the sequence. If o...
[ "Return", "the", "arithmetic", "mean", "of", "the", "values", "in", "the", "sequence", ".." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1105-L1139
sixty-north/asq
asq/queryables.py
Queryable.contains
def contains(self, value, equality_comparer=operator.eq): '''Determines whether the sequence contains a particular value. Execution is immediate. Depending on the type of the sequence, all or none of the sequence may be consumed by this operation. Note: This method uses immediate execu...
python
def contains(self, value, equality_comparer=operator.eq): '''Determines whether the sequence contains a particular value. Execution is immediate. Depending on the type of the sequence, all or none of the sequence may be consumed by this operation. Note: This method uses immediate execu...
[ "def", "contains", "(", "self", ",", "value", ",", "equality_comparer", "=", "operator", ".", "eq", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call contains() on a \"", "\"closed Queryable.\"", ")", "if", "n...
Determines whether the sequence contains a particular value. Execution is immediate. Depending on the type of the sequence, all or none of the sequence may be consumed by this operation. Note: This method uses immediate execution. Args: value: The value to test for members...
[ "Determines", "whether", "the", "sequence", "contains", "a", "particular", "value", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1141-L1173
sixty-north/asq
asq/queryables.py
Queryable.default_if_empty
def default_if_empty(self, default): '''If the source sequence is empty return a single element sequence containing the supplied default value, otherwise return the source sequence unchanged. Note: This method uses deferred execution. Args: default: The element to b...
python
def default_if_empty(self, default): '''If the source sequence is empty return a single element sequence containing the supplied default value, otherwise return the source sequence unchanged. Note: This method uses deferred execution. Args: default: The element to b...
[ "def", "default_if_empty", "(", "self", ",", "default", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call default_if_empty() on a \"", "\"closed Queryable.\"", ")", "return", "self", ".", "_create", "(", "self", ...
If the source sequence is empty return a single element sequence containing the supplied default value, otherwise return the source sequence unchanged. Note: This method uses deferred execution. Args: default: The element to be returned if the source sequence is empty. ...
[ "If", "the", "source", "sequence", "is", "empty", "return", "a", "single", "element", "sequence", "containing", "the", "supplied", "default", "value", "otherwise", "return", "the", "source", "sequence", "unchanged", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1175-L1197
sixty-north/asq
asq/queryables.py
Queryable.distinct
def distinct(self, selector=identity): '''Eliminate duplicate elements from a sequence. Note: This method uses deferred execution. Args: selector: An optional single argument function the result of which is the value compared for uniqueness against elements already ...
python
def distinct(self, selector=identity): '''Eliminate duplicate elements from a sequence. Note: This method uses deferred execution. Args: selector: An optional single argument function the result of which is the value compared for uniqueness against elements already ...
[ "def", "distinct", "(", "self", ",", "selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call distinct() on a \"", "\"closed Queryable.\"", ")", "if", "not", "is_callable", "(", "selector",...
Eliminate duplicate elements from a sequence. Note: This method uses deferred execution. Args: selector: An optional single argument function the result of which is the value compared for uniqueness against elements already consumed. If omitted, the element ...
[ "Eliminate", "duplicate", "elements", "from", "a", "sequence", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1216-L1244
sixty-north/asq
asq/queryables.py
Queryable.difference
def difference(self, second_iterable, selector=identity): '''Returns those elements which are in the source sequence which are not in the second_iterable. This method is equivalent to the Except() LINQ operator, renamed to a valid Python identifier. Note: This method uses defer...
python
def difference(self, second_iterable, selector=identity): '''Returns those elements which are in the source sequence which are not in the second_iterable. This method is equivalent to the Except() LINQ operator, renamed to a valid Python identifier. Note: This method uses defer...
[ "def", "difference", "(", "self", ",", "second_iterable", ",", "selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call difference() on a \"", "\"closed Queryable.\"", ")", "if", "not", "is...
Returns those elements which are in the source sequence which are not in the second_iterable. This method is equivalent to the Except() LINQ operator, renamed to a valid Python identifier. Note: This method uses deferred execution, but as soon as execution commences the ent...
[ "Returns", "those", "elements", "which", "are", "in", "the", "source", "sequence", "which", "are", "not", "in", "the", "second_iterable", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1255-L1299
sixty-north/asq
asq/queryables.py
Queryable.intersect
def intersect(self, second_iterable, selector=identity): '''Returns those elements which are both in the source sequence and in the second_iterable. Note: This method uses deferred execution. Args: second_iterable: Elements are returned if they are also in the ...
python
def intersect(self, second_iterable, selector=identity): '''Returns those elements which are both in the source sequence and in the second_iterable. Note: This method uses deferred execution. Args: second_iterable: Elements are returned if they are also in the ...
[ "def", "intersect", "(", "self", ",", "second_iterable", ",", "selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call intersect() on a \"", "\"closed Queryable.\"", ")", "if", "not", "is_i...
Returns those elements which are both in the source sequence and in the second_iterable. Note: This method uses deferred execution. Args: second_iterable: Elements are returned if they are also in the sequence. selector: An optional single argument func...
[ "Returns", "those", "elements", "which", "are", "both", "in", "the", "source", "sequence", "and", "in", "the", "second_iterable", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1310-L1347
sixty-north/asq
asq/queryables.py
Queryable.union
def union(self, second_iterable, selector=identity): '''Returns those elements which are either in the source sequence or in the second_iterable, or in both. Note: This method uses deferred execution. Args: second_iterable: Elements from this sequence are returns if they ...
python
def union(self, second_iterable, selector=identity): '''Returns those elements which are either in the source sequence or in the second_iterable, or in both. Note: This method uses deferred execution. Args: second_iterable: Elements from this sequence are returns if they ...
[ "def", "union", "(", "self", ",", "second_iterable", ",", "selector", "=", "identity", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call union() on a closed Queryable.\"", ")", "if", "not", "is_iterable", "(", ...
Returns those elements which are either in the source sequence or in the second_iterable, or in both. Note: This method uses deferred execution. Args: second_iterable: Elements from this sequence are returns if they are not also in the source sequence. ...
[ "Returns", "those", "elements", "which", "are", "either", "in", "the", "source", "sequence", "or", "in", "the", "second_iterable", "or", "in", "both", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1358-L1389
sixty-north/asq
asq/queryables.py
Queryable.join
def join(self, inner_iterable, outer_key_selector=identity, inner_key_selector=identity, result_selector=lambda outer, inner: (outer, inner)): '''Perform an inner join with a second sequence using selected keys. The order of elements from outer is maintained. For each of these...
python
def join(self, inner_iterable, outer_key_selector=identity, inner_key_selector=identity, result_selector=lambda outer, inner: (outer, inner)): '''Perform an inner join with a second sequence using selected keys. The order of elements from outer is maintained. For each of these...
[ "def", "join", "(", "self", ",", "inner_iterable", ",", "outer_key_selector", "=", "identity", ",", "inner_key_selector", "=", "identity", ",", "result_selector", "=", "lambda", "outer", ",", "inner", ":", "(", "outer", ",", "inner", ")", ")", ":", "if", "...
Perform an inner join with a second sequence using selected keys. The order of elements from outer is maintained. For each of these the order of elements from inner is also preserved. Note: This method uses deferred execution. Args: inner_iterable: The sequence to join wit...
[ "Perform", "an", "inner", "join", "with", "a", "second", "sequence", "using", "selected", "keys", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1391-L1452
sixty-north/asq
asq/queryables.py
Queryable.group_join
def group_join(self, inner_iterable, outer_key_selector=identity, inner_key_selector=identity, result_selector=lambda outer, grouping: grouping): '''Match elements of two sequences using keys and group the results. The group_join() query produces a hierarchical result, with all of the ...
python
def group_join(self, inner_iterable, outer_key_selector=identity, inner_key_selector=identity, result_selector=lambda outer, grouping: grouping): '''Match elements of two sequences using keys and group the results. The group_join() query produces a hierarchical result, with all of the ...
[ "def", "group_join", "(", "self", ",", "inner_iterable", ",", "outer_key_selector", "=", "identity", ",", "inner_key_selector", "=", "identity", ",", "result_selector", "=", "lambda", "outer", ",", "grouping", ":", "grouping", ")", ":", "if", "self", ".", "clo...
Match elements of two sequences using keys and group the results. The group_join() query produces a hierarchical result, with all of the inner elements in the result grouped against the matching outer element. The order of elements from outer is maintained. For each of these the ...
[ "Match", "elements", "of", "two", "sequences", "using", "keys", "and", "group", "the", "results", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1461-L1529
sixty-north/asq
asq/queryables.py
Queryable.first
def first(self, predicate=None): '''The first element in a sequence (optionally satisfying a predicate). If the predicate is omitted or is None this query returns the first element in the sequence; otherwise, it returns the first element in the sequence for which the predicate evaluates...
python
def first(self, predicate=None): '''The first element in a sequence (optionally satisfying a predicate). If the predicate is omitted or is None this query returns the first element in the sequence; otherwise, it returns the first element in the sequence for which the predicate evaluates...
[ "def", "first", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call first() on a closed Queryable.\"", ")", "return", "self", ".", "_first", "(", ")", "if", "predica...
The first element in a sequence (optionally satisfying a predicate). If the predicate is omitted or is None this query returns the first element in the sequence; otherwise, it returns the first element in the sequence for which the predicate evaluates to True. Exceptions are raised if t...
[ "The", "first", "element", "in", "a", "sequence", "(", "optionally", "satisfying", "a", "predicate", ")", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1537-L1567
sixty-north/asq
asq/queryables.py
Queryable.first_or_default
def first_or_default(self, default, predicate=None): '''The first element (optionally satisfying a predicate) or a default. If the predicate is omitted or is None this query returns the first element in the sequence; otherwise, it returns the first element in the sequence for which the ...
python
def first_or_default(self, default, predicate=None): '''The first element (optionally satisfying a predicate) or a default. If the predicate is omitted or is None this query returns the first element in the sequence; otherwise, it returns the first element in the sequence for which the ...
[ "def", "first_or_default", "(", "self", ",", "default", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call first_or_default() on a \"", "\"closed Queryable.\"", ")", "return", "self",...
The first element (optionally satisfying a predicate) or a default. If the predicate is omitted or is None this query returns the first element in the sequence; otherwise, it returns the first element in the sequence for which the predicate evaluates to True. If there is no such element...
[ "The", "first", "element", "(", "optionally", "satisfying", "a", "predicate", ")", "or", "a", "default", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1581-L1614
sixty-north/asq
asq/queryables.py
Queryable.single
def single(self, predicate=None): '''The only element (which satisfies a condition). If the predicate is omitted or is None this query returns the only element in the sequence; otherwise, it returns the only element in the sequence for which the predicate evaluates to True. Exceptions a...
python
def single(self, predicate=None): '''The only element (which satisfies a condition). If the predicate is omitted or is None this query returns the only element in the sequence; otherwise, it returns the only element in the sequence for which the predicate evaluates to True. Exceptions a...
[ "def", "single", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call single() on a closed Queryable.\"", ")", "return", "self", ".", "_single", "(", ")", "if", "pred...
The only element (which satisfies a condition). If the predicate is omitted or is None this query returns the only element in the sequence; otherwise, it returns the only element in the sequence for which the predicate evaluates to True. Exceptions are raised if there is either no such ...
[ "The", "only", "element", "(", "which", "satisfies", "a", "condition", ")", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1628-L1661
sixty-north/asq
asq/queryables.py
Queryable.single_or_default
def single_or_default(self, default, predicate=None): '''The only element (which satisfies a condition) or a default. If the predicate is omitted or is None this query returns the only element in the sequence; otherwise, it returns the only element in the sequence for which the predicat...
python
def single_or_default(self, default, predicate=None): '''The only element (which satisfies a condition) or a default. If the predicate is omitted or is None this query returns the only element in the sequence; otherwise, it returns the only element in the sequence for which the predicat...
[ "def", "single_or_default", "(", "self", ",", "default", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call single_or_default() on a closed Queryable.\"", ")", "return", "self", ".", ...
The only element (which satisfies a condition) or a default. If the predicate is omitted or is None this query returns the only element in the sequence; otherwise, it returns the only element in the sequence for which the predicate evaluates to True. A default value is returned if there...
[ "The", "only", "element", "(", "which", "satisfies", "a", "condition", ")", "or", "a", "default", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1690-L1727
sixty-north/asq
asq/queryables.py
Queryable.last
def last(self, predicate=None): '''The last element in a sequence (optionally satisfying a predicate). If the predicate is omitted or is None this query returns the last element in the sequence; otherwise, it returns the last element in the sequence for which the predicate evaluates to ...
python
def last(self, predicate=None): '''The last element in a sequence (optionally satisfying a predicate). If the predicate is omitted or is None this query returns the last element in the sequence; otherwise, it returns the last element in the sequence for which the predicate evaluates to ...
[ "def", "last", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call last() on a closed Queryable.\"", ")", "return", "self", ".", "_last", "(", ")", "if", "predicate"...
The last element in a sequence (optionally satisfying a predicate). If the predicate is omitted or is None this query returns the last element in the sequence; otherwise, it returns the last element in the sequence for which the predicate evaluates to True. Exceptions are raised if ther...
[ "The", "last", "element", "in", "a", "sequence", "(", "optionally", "satisfying", "a", "predicate", ")", "." ]
train
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1755-L1785