repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.printPi
def printPi(self): """ Prints all states state and their steady state probabilities. Not recommended for large state spaces. """ assert self.pi is not None, "Calculate pi before calling printPi()" assert len(self.mapping)>0, "printPi() can only be used in combination with...
python
def printPi(self): """ Prints all states state and their steady state probabilities. Not recommended for large state spaces. """ assert self.pi is not None, "Calculate pi before calling printPi()" assert len(self.mapping)>0, "printPi() can only be used in combination with...
[ "def", "printPi", "(", "self", ")", ":", "assert", "self", ".", "pi", "is", "not", "None", ",", "\"Calculate pi before calling printPi()\"", "assert", "len", "(", "self", ".", "mapping", ")", ">", "0", ",", "\"printPi() can only be used in combination with the direc...
Prints all states state and their steady state probabilities. Not recommended for large state spaces.
[ "Prints", "all", "states", "state", "and", "their", "steady", "state", "probabilities", ".", "Not", "recommended", "for", "large", "state", "spaces", "." ]
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L596-L604
train
insilichem/pychimera
pychimera/platforms/win.py
launch_ipython
def launch_ipython(argv=None): """ Force usage of QtConsole under Windows """ from .linux import launch_ipython as _launch_ipython_linux os.environ = {str(k): str(v) for k,v in os.environ.items()} try: from qtconsole.qtconsoleapp import JupyterQtConsoleApp except ImportError: ...
python
def launch_ipython(argv=None): """ Force usage of QtConsole under Windows """ from .linux import launch_ipython as _launch_ipython_linux os.environ = {str(k): str(v) for k,v in os.environ.items()} try: from qtconsole.qtconsoleapp import JupyterQtConsoleApp except ImportError: ...
[ "def", "launch_ipython", "(", "argv", "=", "None", ")", ":", "from", ".", "linux", "import", "launch_ipython", "as", "_launch_ipython_linux", "os", ".", "environ", "=", "{", "str", "(", "k", ")", ":", "str", "(", "v", ")", "for", "k", ",", "v", "in",...
Force usage of QtConsole under Windows
[ "Force", "usage", "of", "QtConsole", "under", "Windows" ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/platforms/win.py#L44-L56
train
insilichem/pychimera
pychimera/platforms/linux.py
launch_ipython
def launch_ipython(argv=None, ipython_app=None): """ Launch IPython from this interpreter with custom args if needed. Chimera magic commands are also enabled automatically. """ try: if ipython_app is None: from IPython.terminal.ipapp import TerminalIPythonApp as ipython_app ...
python
def launch_ipython(argv=None, ipython_app=None): """ Launch IPython from this interpreter with custom args if needed. Chimera magic commands are also enabled automatically. """ try: if ipython_app is None: from IPython.terminal.ipapp import TerminalIPythonApp as ipython_app ...
[ "def", "launch_ipython", "(", "argv", "=", "None", ",", "ipython_app", "=", "None", ")", ":", "try", ":", "if", "ipython_app", "is", "None", ":", "from", "IPython", ".", "terminal", ".", "ipapp", "import", "TerminalIPythonApp", "as", "ipython_app", "from", ...
Launch IPython from this interpreter with custom args if needed. Chimera magic commands are also enabled automatically.
[ "Launch", "IPython", "from", "this", "interpreter", "with", "custom", "args", "if", "needed", ".", "Chimera", "magic", "commands", "are", "also", "enabled", "automatically", "." ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/platforms/linux.py#L46-L67
train
insilichem/pychimera
pychimera/jupyter_utils.py
launch_notebook
def launch_notebook(argv=None): """ Launch a Jupyter Notebook, with custom Untitled filenames and a prepopulated first cell with necessary boilerplate code. Notes ----- To populate the first cell, the function `new_notebook` imported in notebook.services.contents needs to be monkey patched....
python
def launch_notebook(argv=None): """ Launch a Jupyter Notebook, with custom Untitled filenames and a prepopulated first cell with necessary boilerplate code. Notes ----- To populate the first cell, the function `new_notebook` imported in notebook.services.contents needs to be monkey patched....
[ "def", "launch_notebook", "(", "argv", "=", "None", ")", ":", "try", ":", "import", "nbformat", ".", "v4", "as", "nbf", "from", "notebook", ".", "notebookapp", "import", "NotebookApp", "from", "notebook", ".", "services", ".", "contents", "import", "manager"...
Launch a Jupyter Notebook, with custom Untitled filenames and a prepopulated first cell with necessary boilerplate code. Notes ----- To populate the first cell, the function `new_notebook` imported in notebook.services.contents needs to be monkey patched. Dirty but functional. Same thing could ...
[ "Launch", "a", "Jupyter", "Notebook", "with", "custom", "Untitled", "filenames", "and", "a", "prepopulated", "first", "cell", "with", "necessary", "boilerplate", "code", "." ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/jupyter_utils.py#L28-L63
train
insilichem/pychimera
pychimera/jupyter_utils.py
enable_chimera_inline
def enable_chimera_inline(): """ Enable IPython magic commands to run some Chimera actions Currently supported: - %chimera_export_3D [<model>]: Depicts the Chimera 3D canvas in a WebGL iframe. Requires a headless Chimera build and a Notebook instance. SLOW. - %chimera_run <command>:...
python
def enable_chimera_inline(): """ Enable IPython magic commands to run some Chimera actions Currently supported: - %chimera_export_3D [<model>]: Depicts the Chimera 3D canvas in a WebGL iframe. Requires a headless Chimera build and a Notebook instance. SLOW. - %chimera_run <command>:...
[ "def", "enable_chimera_inline", "(", ")", ":", "from", "IPython", ".", "display", "import", "IFrame", "from", "IPython", ".", "core", ".", "magic", "import", "register_line_magic", "import", "chimera", "import", "Midas", "@", "register_line_magic", "def", "chimera...
Enable IPython magic commands to run some Chimera actions Currently supported: - %chimera_export_3D [<model>]: Depicts the Chimera 3D canvas in a WebGL iframe. Requires a headless Chimera build and a Notebook instance. SLOW. - %chimera_run <command>: Runs Chimera commands meant to b...
[ "Enable", "IPython", "magic", "commands", "to", "run", "some", "Chimera", "actions" ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/jupyter_utils.py#L77-L125
train
insilichem/pychimera
pychimera/jupyter_utils.py
chimera_view
def chimera_view(*molecules): """ Depicts the requested molecules with NGLViewer in a Python notebook. This method does not require a headless Chimera build, however. Parameters ---------- molecules : tuple of chimera.Molecule Molecules to display. If none is given, all present molecule...
python
def chimera_view(*molecules): """ Depicts the requested molecules with NGLViewer in a Python notebook. This method does not require a headless Chimera build, however. Parameters ---------- molecules : tuple of chimera.Molecule Molecules to display. If none is given, all present molecule...
[ "def", "chimera_view", "(", "*", "molecules", ")", ":", "try", ":", "import", "nglview", "as", "nv", "except", "ImportError", ":", "raise", "ImportError", "(", "'You must install nglview!'", ")", "import", "chimera", "class", "_ChimeraStructure", "(", "nv", ".",...
Depicts the requested molecules with NGLViewer in a Python notebook. This method does not require a headless Chimera build, however. Parameters ---------- molecules : tuple of chimera.Molecule Molecules to display. If none is given, all present molecules in Chimera canvas will be displa...
[ "Depicts", "the", "requested", "molecules", "with", "NGLViewer", "in", "a", "Python", "notebook", ".", "This", "method", "does", "not", "require", "a", "headless", "Chimera", "build", "however", "." ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/jupyter_utils.py#L128-L163
train
insilichem/pychimera
pychimera/core.py
enable_chimera
def enable_chimera(verbose=False, nogui=True): """ Bypass script loading and initialize Chimera correctly, once the env has been properly patched. Parameters ---------- verbose : bool, optional, default=False If True, let Chimera speak freely. It can be _very_ verbose. nogui : bool,...
python
def enable_chimera(verbose=False, nogui=True): """ Bypass script loading and initialize Chimera correctly, once the env has been properly patched. Parameters ---------- verbose : bool, optional, default=False If True, let Chimera speak freely. It can be _very_ verbose. nogui : bool,...
[ "def", "enable_chimera", "(", "verbose", "=", "False", ",", "nogui", "=", "True", ")", ":", "if", "os", ".", "getenv", "(", "'CHIMERA_ENABLED'", ")", ":", "return", "import", "chimera", "_pre_gui_patches", "(", ")", "if", "not", "nogui", ":", "chimera", ...
Bypass script loading and initialize Chimera correctly, once the env has been properly patched. Parameters ---------- verbose : bool, optional, default=False If True, let Chimera speak freely. It can be _very_ verbose. nogui : bool, optional, default=True Don't start the GUI.
[ "Bypass", "script", "loading", "and", "initialize", "Chimera", "correctly", "once", "the", "env", "has", "been", "properly", "patched", "." ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/core.py#L37-L65
train
insilichem/pychimera
pychimera/core.py
patch_sys_version
def patch_sys_version(): """ Remove Continuum copyright statement to avoid parsing errors in IDLE """ if '|' in sys.version: sys_version = sys.version.split('|') sys.version = ' '.join([sys_version[0].strip(), sys_version[-1].strip()])
python
def patch_sys_version(): """ Remove Continuum copyright statement to avoid parsing errors in IDLE """ if '|' in sys.version: sys_version = sys.version.split('|') sys.version = ' '.join([sys_version[0].strip(), sys_version[-1].strip()])
[ "def", "patch_sys_version", "(", ")", ":", "if", "'|'", "in", "sys", ".", "version", ":", "sys_version", "=", "sys", ".", "version", ".", "split", "(", "'|'", ")", "sys", ".", "version", "=", "' '", ".", "join", "(", "[", "sys_version", "[", "0", "...
Remove Continuum copyright statement to avoid parsing errors in IDLE
[ "Remove", "Continuum", "copyright", "statement", "to", "avoid", "parsing", "errors", "in", "IDLE" ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/core.py#L100-L104
train
insilichem/pychimera
pychimera/core.py
patch_environ
def patch_environ(nogui=True): """ Patch current environment variables so Chimera can start up and we can import its modules. Be warned that calling this function WILL restart your interpreter. Otherwise, Python won't catch the new LD_LIBRARY_PATH (or platform equivalent) and Chimera won't find its ...
python
def patch_environ(nogui=True): """ Patch current environment variables so Chimera can start up and we can import its modules. Be warned that calling this function WILL restart your interpreter. Otherwise, Python won't catch the new LD_LIBRARY_PATH (or platform equivalent) and Chimera won't find its ...
[ "def", "patch_environ", "(", "nogui", "=", "True", ")", ":", "if", "'CHIMERA'", "in", "os", ".", "environ", ":", "return", "paths", "=", "guess_chimera_path", "(", "search_all", "=", "nogui", ")", "CHIMERA_BASE", "=", "paths", "[", "0", "]", "if", "nogui...
Patch current environment variables so Chimera can start up and we can import its modules. Be warned that calling this function WILL restart your interpreter. Otherwise, Python won't catch the new LD_LIBRARY_PATH (or platform equivalent) and Chimera won't find its libraries during import. Parameters ...
[ "Patch", "current", "environment", "variables", "so", "Chimera", "can", "start", "up", "and", "we", "can", "import", "its", "modules", "." ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/core.py#L107-L164
train
insilichem/pychimera
pychimera/core.py
guess_chimera_path
def guess_chimera_path(search_all=False): """ Try to guess Chimera installation path. Parameters ---------- search_all : bool, optional, default=False If no CHIMERADIR env var is set, collect all posible locations of Chimera installations. Returns ------- paths: list of...
python
def guess_chimera_path(search_all=False): """ Try to guess Chimera installation path. Parameters ---------- search_all : bool, optional, default=False If no CHIMERADIR env var is set, collect all posible locations of Chimera installations. Returns ------- paths: list of...
[ "def", "guess_chimera_path", "(", "search_all", "=", "False", ")", ":", "paths", "=", "_search_chimera", "(", "CHIMERA_BINARY", ",", "CHIMERA_LOCATIONS", ",", "CHIMERA_PREFIX", ",", "search_all", "=", "search_all", ")", "if", "not", "paths", "and", "search_all", ...
Try to guess Chimera installation path. Parameters ---------- search_all : bool, optional, default=False If no CHIMERADIR env var is set, collect all posible locations of Chimera installations. Returns ------- paths: list of str Alphabetically sorted list of possible Ch...
[ "Try", "to", "guess", "Chimera", "installation", "path", "." ]
5227d1c0e9e1ce165fc68157eda788cd0843842b
https://github.com/insilichem/pychimera/blob/5227d1c0e9e1ce165fc68157eda788cd0843842b/pychimera/core.py#L167-L190
train
heuer/segno
segno/__init__.py
make_micro
def make_micro(content, error=None, version=None, mode=None, mask=None, encoding=None, boost_error=True): """\ Creates a Micro QR Code. See :py:func:`make` for a description of the parameters. Note: Error correction level "H" isn't available for Micro QR Codes. If used, this functio...
python
def make_micro(content, error=None, version=None, mode=None, mask=None, encoding=None, boost_error=True): """\ Creates a Micro QR Code. See :py:func:`make` for a description of the parameters. Note: Error correction level "H" isn't available for Micro QR Codes. If used, this functio...
[ "def", "make_micro", "(", "content", ",", "error", "=", "None", ",", "version", "=", "None", ",", "mode", "=", "None", ",", "mask", "=", "None", ",", "encoding", "=", "None", ",", "boost_error", "=", "True", ")", ":", "return", "make", "(", "content"...
\ Creates a Micro QR Code. See :py:func:`make` for a description of the parameters. Note: Error correction level "H" isn't available for Micro QR Codes. If used, this function raises a :py:class:`segno.ErrorLevelError`. :rtype: QRCode
[ "\\", "Creates", "a", "Micro", "QR", "Code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L164-L177
train
heuer/segno
segno/__init__.py
make_sequence
def make_sequence(content, error=None, version=None, mode=None, mask=None, encoding=None, boost_error=True, symbol_count=None): """\ Creates a sequence of QR Codes. If the content fits into one QR Code and neither ``version`` nor ``symbol_count`` is provided, this function may return ...
python
def make_sequence(content, error=None, version=None, mode=None, mask=None, encoding=None, boost_error=True, symbol_count=None): """\ Creates a sequence of QR Codes. If the content fits into one QR Code and neither ``version`` nor ``symbol_count`` is provided, this function may return ...
[ "def", "make_sequence", "(", "content", ",", "error", "=", "None", ",", "version", "=", "None", ",", "mode", "=", "None", ",", "mask", "=", "None", ",", "encoding", "=", "None", ",", "boost_error", "=", "True", ",", "symbol_count", "=", "None", ")", ...
\ Creates a sequence of QR Codes. If the content fits into one QR Code and neither ``version`` nor ``symbol_count`` is provided, this function may return a sequence with one QR Code which does not use the Structured Append mode. Otherwise a sequence of 2 .. n (max. n = 16) QR Codes is returned whi...
[ "\\", "Creates", "a", "sequence", "of", "QR", "Codes", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L180-L218
train
heuer/segno
segno/__init__.py
QRCode.designator
def designator(self): """\ Returns the version and error correction level as string `V-E` where `V` represents the version number and `E` the error level. """ version = str(self.version) return '-'.join((version, self.error) if self.error else (version,))
python
def designator(self): """\ Returns the version and error correction level as string `V-E` where `V` represents the version number and `E` the error level. """ version = str(self.version) return '-'.join((version, self.error) if self.error else (version,))
[ "def", "designator", "(", "self", ")", ":", "version", "=", "str", "(", "self", ".", "version", ")", "return", "'-'", ".", "join", "(", "(", "version", ",", "self", ".", "error", ")", "if", "self", ".", "error", "else", "(", "version", ",", ")", ...
\ Returns the version and error correction level as string `V-E` where `V` represents the version number and `E` the error level.
[ "\\", "Returns", "the", "version", "and", "error", "correction", "level", "as", "string", "V", "-", "E", "where", "V", "represents", "the", "version", "number", "and", "E", "the", "error", "level", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L269-L275
train
heuer/segno
segno/__init__.py
QRCode.matrix_iter
def matrix_iter(self, scale=1, border=None): """\ Returns an iterator over the matrix which includes the border. The border is returned as sequence of light modules. Dark modules are reported as ``0x1``, light modules have the value ``0x0``. The following example conver...
python
def matrix_iter(self, scale=1, border=None): """\ Returns an iterator over the matrix which includes the border. The border is returned as sequence of light modules. Dark modules are reported as ``0x1``, light modules have the value ``0x0``. The following example conver...
[ "def", "matrix_iter", "(", "self", ",", "scale", "=", "1", ",", "border", "=", "None", ")", ":", "return", "utils", ".", "matrix_iter", "(", "self", ".", "matrix", ",", "self", ".", "_version", ",", "scale", ",", "border", ")" ]
\ Returns an iterator over the matrix which includes the border. The border is returned as sequence of light modules. Dark modules are reported as ``0x1``, light modules have the value ``0x0``. The following example converts the QR Code matrix into a list of lists which...
[ "\\", "Returns", "an", "iterator", "over", "the", "matrix", "which", "includes", "the", "border", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L311-L339
train
heuer/segno
segno/__init__.py
QRCode.show
def show(self, delete_after=20, scale=10, border=None, color='#000', background='#fff'): # pragma: no cover """\ Displays this QR code. This method is mainly intended for debugging purposes. This method saves the output of the :py:meth:`png` method (by default wit...
python
def show(self, delete_after=20, scale=10, border=None, color='#000', background='#fff'): # pragma: no cover """\ Displays this QR code. This method is mainly intended for debugging purposes. This method saves the output of the :py:meth:`png` method (by default wit...
[ "def", "show", "(", "self", ",", "delete_after", "=", "20", ",", "scale", "=", "10", ",", "border", "=", "None", ",", "color", "=", "'#000'", ",", "background", "=", "'#fff'", ")", ":", "import", "os", "import", "time", "import", "tempfile", "import", ...
\ Displays this QR code. This method is mainly intended for debugging purposes. This method saves the output of the :py:meth:`png` method (by default with a scaling factor of 10) to a temporary file and opens it with the standard PNG viewer application or within the standard we...
[ "\\", "Displays", "this", "QR", "code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L341-L391
train
heuer/segno
segno/__init__.py
QRCode.svg_data_uri
def svg_data_uri(self, xmldecl=False, encode_minimal=False, omit_charset=False, nl=False, **kw): """\ Converts the QR Code into a SVG data URI. The XML declaration is omitted by default (set ``xmldecl`` to ``True`` to enable it), further the newline is omitted by de...
python
def svg_data_uri(self, xmldecl=False, encode_minimal=False, omit_charset=False, nl=False, **kw): """\ Converts the QR Code into a SVG data URI. The XML declaration is omitted by default (set ``xmldecl`` to ``True`` to enable it), further the newline is omitted by de...
[ "def", "svg_data_uri", "(", "self", ",", "xmldecl", "=", "False", ",", "encode_minimal", "=", "False", ",", "omit_charset", "=", "False", ",", "nl", "=", "False", ",", "**", "kw", ")", ":", "return", "writers", ".", "as_svg_data_uri", "(", "self", ".", ...
\ Converts the QR Code into a SVG data URI. The XML declaration is omitted by default (set ``xmldecl`` to ``True`` to enable it), further the newline is omitted by default (set ``nl`` to ``True`` to enable it). Aside from the missing ``out`` parameter and the different ``xmldec...
[ "\\", "Converts", "the", "QR", "Code", "into", "a", "SVG", "data", "URI", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L393-L418
train
heuer/segno
segno/__init__.py
QRCode.png_data_uri
def png_data_uri(self, **kw): """\ Converts the QR Code into a PNG data URI. Uses the same keyword parameters as the usual PNG serializer. :rtype: str """ return writers.as_png_data_uri(self.matrix, self._version, **kw)
python
def png_data_uri(self, **kw): """\ Converts the QR Code into a PNG data URI. Uses the same keyword parameters as the usual PNG serializer. :rtype: str """ return writers.as_png_data_uri(self.matrix, self._version, **kw)
[ "def", "png_data_uri", "(", "self", ",", "**", "kw", ")", ":", "return", "writers", ".", "as_png_data_uri", "(", "self", ".", "matrix", ",", "self", ".", "_version", ",", "**", "kw", ")" ]
\ Converts the QR Code into a PNG data URI. Uses the same keyword parameters as the usual PNG serializer. :rtype: str
[ "\\", "Converts", "the", "QR", "Code", "into", "a", "PNG", "data", "URI", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L420-L428
train
heuer/segno
segno/__init__.py
QRCode.terminal
def terminal(self, out=None, border=None): """\ Serializes the matrix as ANSI escape code. :param out: Filename or a file-like object supporting to write text. If ``None`` (default), the matrix is written to ``sys.stdout``. :param int border: Integer indicating the size ...
python
def terminal(self, out=None, border=None): """\ Serializes the matrix as ANSI escape code. :param out: Filename or a file-like object supporting to write text. If ``None`` (default), the matrix is written to ``sys.stdout``. :param int border: Integer indicating the size ...
[ "def", "terminal", "(", "self", ",", "out", "=", "None", ",", "border", "=", "None", ")", ":", "if", "out", "is", "None", "and", "sys", ".", "platform", "==", "'win32'", ":", "try", ":", "writers", ".", "write_terminal_win", "(", "self", ".", "matrix...
\ Serializes the matrix as ANSI escape code. :param out: Filename or a file-like object supporting to write text. If ``None`` (default), the matrix is written to ``sys.stdout``. :param int border: Integer indicating the size of the quiet zone. If set to ``None`` ...
[ "\\", "Serializes", "the", "matrix", "as", "ANSI", "escape", "code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L430-L452
train
heuer/segno
segno/__init__.py
QRCode.save
def save(self, out, kind=None, **kw): """\ Serializes the QR Code in one of the supported formats. The serialization format depends on the filename extension. **Common keywords** ========== ============================================================== Name ...
python
def save(self, out, kind=None, **kw): """\ Serializes the QR Code in one of the supported formats. The serialization format depends on the filename extension. **Common keywords** ========== ============================================================== Name ...
[ "def", "save", "(", "self", ",", "out", ",", "kind", "=", "None", ",", "**", "kw", ")", ":", "writers", ".", "save", "(", "self", ".", "matrix", ",", "self", ".", "_version", ",", "out", ",", "kind", ",", "**", "kw", ")" ]
\ Serializes the QR Code in one of the supported formats. The serialization format depends on the filename extension. **Common keywords** ========== ============================================================== Name Description ========== ==============...
[ "\\", "Serializes", "the", "QR", "Code", "in", "one", "of", "the", "supported", "formats", ".", "The", "serialization", "format", "depends", "on", "the", "filename", "extension", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L454-L728
train
heuer/segno
segno/__init__.py
QRCodeSequence.terminal
def terminal(self, out=None, border=None): """\ Serializes the sequence of QR Codes as ANSI escape code. See :py:meth:`QRCode.terminal()` for details. """ for qrcode in self: qrcode.terminal(out=out, border=border)
python
def terminal(self, out=None, border=None): """\ Serializes the sequence of QR Codes as ANSI escape code. See :py:meth:`QRCode.terminal()` for details. """ for qrcode in self: qrcode.terminal(out=out, border=border)
[ "def", "terminal", "(", "self", ",", "out", "=", "None", ",", "border", "=", "None", ")", ":", "for", "qrcode", "in", "self", ":", "qrcode", ".", "terminal", "(", "out", "=", "out", ",", "border", "=", "border", ")" ]
\ Serializes the sequence of QR Codes as ANSI escape code. See :py:meth:`QRCode.terminal()` for details.
[ "\\", "Serializes", "the", "sequence", "of", "QR", "Codes", "as", "ANSI", "escape", "code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L760-L767
train
heuer/segno
segno/__init__.py
QRCodeSequence.save
def save(self, out, kind=None, **kw): """\ Saves the sequence of QR Code to `out`. If `out` is a filename, this method modifies the filename and adds ``<Number of QR Codes>-<Current QR Code>`` to it. ``structured-append.svg`` becomes (if the sequence contains two QR Codes): ...
python
def save(self, out, kind=None, **kw): """\ Saves the sequence of QR Code to `out`. If `out` is a filename, this method modifies the filename and adds ``<Number of QR Codes>-<Current QR Code>`` to it. ``structured-append.svg`` becomes (if the sequence contains two QR Codes): ...
[ "def", "save", "(", "self", ",", "out", ",", "kind", "=", "None", ",", "**", "kw", ")", ":", "m", "=", "len", "(", "self", ")", "def", "prepare_fn_noop", "(", "o", ",", "n", ")", ":", "return", "o", "def", "prepare_filename", "(", "o", ",", "n"...
\ Saves the sequence of QR Code to `out`. If `out` is a filename, this method modifies the filename and adds ``<Number of QR Codes>-<Current QR Code>`` to it. ``structured-append.svg`` becomes (if the sequence contains two QR Codes): ``structured-append-02-01.svg`` and ``structu...
[ "\\", "Saves", "the", "sequence", "of", "QR", "Code", "to", "out", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L769-L805
train
heuer/segno
segno/writers.py
writable
def writable(file_or_path, mode, encoding=None): """\ Returns a writable file-like object. Usage:: with writable(file_name_or_path, 'wb') as f: ... :param file_or_path: Either a file-like object or a filename. :param str mode: String indicating the writing mode (i.e. ``'wb'``...
python
def writable(file_or_path, mode, encoding=None): """\ Returns a writable file-like object. Usage:: with writable(file_name_or_path, 'wb') as f: ... :param file_or_path: Either a file-like object or a filename. :param str mode: String indicating the writing mode (i.e. ``'wb'``...
[ "def", "writable", "(", "file_or_path", ",", "mode", ",", "encoding", "=", "None", ")", ":", "f", "=", "file_or_path", "must_close", "=", "False", "try", ":", "file_or_path", ".", "write", "if", "encoding", "is", "not", "None", ":", "f", "=", "codecs", ...
\ Returns a writable file-like object. Usage:: with writable(file_name_or_path, 'wb') as f: ... :param file_or_path: Either a file-like object or a filename. :param str mode: String indicating the writing mode (i.e. ``'wb'``)
[ "\\", "Returns", "a", "writable", "file", "-", "like", "object", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L49-L75
train
heuer/segno
segno/writers.py
as_svg_data_uri
def as_svg_data_uri(matrix, version, scale=1, border=None, color='#000', background=None, xmldecl=False, svgns=True, title=None, desc=None, svgid=None, svgclass='segno', lineclass='qrline', omitsize=False, unit='', encoding='utf-8', svgvers...
python
def as_svg_data_uri(matrix, version, scale=1, border=None, color='#000', background=None, xmldecl=False, svgns=True, title=None, desc=None, svgid=None, svgclass='segno', lineclass='qrline', omitsize=False, unit='', encoding='utf-8', svgvers...
[ "def", "as_svg_data_uri", "(", "matrix", ",", "version", ",", "scale", "=", "1", ",", "border", "=", "None", ",", "color", "=", "'#000'", ",", "background", "=", "None", ",", "xmldecl", "=", "False", ",", "svgns", "=", "True", ",", "title", "=", "Non...
\ Converts the matrix to a SVG data URI. The XML declaration is omitted by default (set ``xmldecl`` to ``True`` to enable it), further the newline is omitted by default (set ``nl`` to ``True`` to enable it). Aside from the missing ``out`` parameter and the different ``xmldecl`` and ``nl`` defa...
[ "\\", "Converts", "the", "matrix", "to", "a", "SVG", "data", "URI", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L197-L232
train
heuer/segno
segno/writers.py
write_svg_debug
def write_svg_debug(matrix, version, out, scale=15, border=None, fallback_color='fuchsia', color_mapping=None, add_legend=True): """\ Internal SVG serializer which is useful to debugging purposes. This function is not exposed to the QRCode class by intention and the ...
python
def write_svg_debug(matrix, version, out, scale=15, border=None, fallback_color='fuchsia', color_mapping=None, add_legend=True): """\ Internal SVG serializer which is useful to debugging purposes. This function is not exposed to the QRCode class by intention and the ...
[ "def", "write_svg_debug", "(", "matrix", ",", "version", ",", "out", ",", "scale", "=", "15", ",", "border", "=", "None", ",", "fallback_color", "=", "'fuchsia'", ",", "color_mapping", "=", "None", ",", "add_legend", "=", "True", ")", ":", "clr_mapping", ...
\ Internal SVG serializer which is useful to debugging purposes. This function is not exposed to the QRCode class by intention and the resulting SVG document is very inefficient (lots of <rect/>s). Dark modules are black and light modules are white by default. Provide a custom `color_mapping` to ov...
[ "\\", "Internal", "SVG", "serializer", "which", "is", "useful", "to", "debugging", "purposes", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L235-L290
train
heuer/segno
segno/writers.py
write_eps
def write_eps(matrix, version, out, scale=1, border=None, color='#000', background=None): """\ Serializes the QR Code as EPS document. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like object supporting to write...
python
def write_eps(matrix, version, out, scale=1, border=None, color='#000', background=None): """\ Serializes the QR Code as EPS document. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like object supporting to write...
[ "def", "write_eps", "(", "matrix", ",", "version", ",", "out", ",", "scale", "=", "1", ",", "border", "=", "None", ",", "color", "=", "'#000'", ",", "background", "=", "None", ")", ":", "import", "textwrap", "def", "write_line", "(", "writemeth", ",", ...
\ Serializes the QR Code as EPS document. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like object supporting to write strings. :param scale: Indicates the size of a single module (default: 1 which corresponds to ...
[ "\\", "Serializes", "the", "QR", "Code", "as", "EPS", "document", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L293-L384
train
heuer/segno
segno/writers.py
as_png_data_uri
def as_png_data_uri(matrix, version, scale=1, border=None, color='#000', background='#fff', compresslevel=9, addad=True): """\ Converts the provided matrix into a PNG data URI. :rtype: str """ buff = io.BytesIO() write_png(matrix, version, buff, scale=scale, border=border, c...
python
def as_png_data_uri(matrix, version, scale=1, border=None, color='#000', background='#fff', compresslevel=9, addad=True): """\ Converts the provided matrix into a PNG data URI. :rtype: str """ buff = io.BytesIO() write_png(matrix, version, buff, scale=scale, border=border, c...
[ "def", "as_png_data_uri", "(", "matrix", ",", "version", ",", "scale", "=", "1", ",", "border", "=", "None", ",", "color", "=", "'#000'", ",", "background", "=", "'#fff'", ",", "compresslevel", "=", "9", ",", "addad", "=", "True", ")", ":", "buff", "...
\ Converts the provided matrix into a PNG data URI. :rtype: str
[ "\\", "Converts", "the", "provided", "matrix", "into", "a", "PNG", "data", "URI", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L568-L579
train
heuer/segno
segno/writers.py
write_txt
def write_txt(matrix, version, out, border=None, color='1', background='0'): """\ Serializes QR code in a text format. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like object supporting to write text. :param int border: ...
python
def write_txt(matrix, version, out, border=None, color='1', background='0'): """\ Serializes QR code in a text format. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like object supporting to write text. :param int border: ...
[ "def", "write_txt", "(", "matrix", ",", "version", ",", "out", ",", "border", "=", "None", ",", "color", "=", "'1'", ",", "background", "=", "'0'", ")", ":", "row_iter", "=", "matrix_iter", "(", "matrix", ",", "version", ",", "scale", "=", "1", ",", ...
\ Serializes QR code in a text format. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like object supporting to write text. :param int border: Integer indicating the size of the quiet zone. If set to ``None`` (defau...
[ "\\", "Serializes", "QR", "code", "in", "a", "text", "format", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L677-L696
train
heuer/segno
segno/writers.py
write_tex
def write_tex(matrix, version, out, scale=1, border=None, color='black', unit='pt', url=None): """\ Serializes the matrix as LaTeX PGF picture. Requires the `PGF/TikZ <https://en.wikipedia.org/wiki/PGF/TikZ>`_ package (i.e. ``\\usepackage{pgf}``) in the LaTeX source. :param matrix: The matrix to s...
python
def write_tex(matrix, version, out, scale=1, border=None, color='black', unit='pt', url=None): """\ Serializes the matrix as LaTeX PGF picture. Requires the `PGF/TikZ <https://en.wikipedia.org/wiki/PGF/TikZ>`_ package (i.e. ``\\usepackage{pgf}``) in the LaTeX source. :param matrix: The matrix to s...
[ "def", "write_tex", "(", "matrix", ",", "version", ",", "out", ",", "scale", "=", "1", ",", "border", "=", "None", ",", "color", "=", "'black'", ",", "unit", "=", "'pt'", ",", "url", "=", "None", ")", ":", "def", "point", "(", "x", ",", "y", ")...
\ Serializes the matrix as LaTeX PGF picture. Requires the `PGF/TikZ <https://en.wikipedia.org/wiki/PGF/TikZ>`_ package (i.e. ``\\usepackage{pgf}``) in the LaTeX source. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: Filename or a file-like ...
[ "\\", "Serializes", "the", "matrix", "as", "LaTeX", "PGF", "picture", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L878-L921
train
heuer/segno
segno/writers.py
write_terminal
def write_terminal(matrix, version, out, border=None): """\ Function to write to a terminal which supports ANSI escape codes. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version. :param out: Filename or a file-like object supporting to write text. :param int ...
python
def write_terminal(matrix, version, out, border=None): """\ Function to write to a terminal which supports ANSI escape codes. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version. :param out: Filename or a file-like object supporting to write text. :param int ...
[ "def", "write_terminal", "(", "matrix", ",", "version", ",", "out", ",", "border", "=", "None", ")", ":", "with", "writable", "(", "out", ",", "'wt'", ")", "as", "f", ":", "write", "=", "f", ".", "write", "colours", "=", "[", "'\\033[{0}m'", ".", "...
\ Function to write to a terminal which supports ANSI escape codes. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version. :param out: Filename or a file-like object supporting to write text. :param int border: Integer indicating the size of the quiet zone. ...
[ "\\", "Function", "to", "write", "to", "a", "terminal", "which", "supports", "ANSI", "escape", "codes", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L924-L955
train
heuer/segno
segno/writers.py
write_terminal_win
def write_terminal_win(matrix, version, border=None): # pragma: no cover """\ Function to write a QR Code to a MS Windows terminal. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param int border: Integer indicating the size of the quiet zone. ...
python
def write_terminal_win(matrix, version, border=None): # pragma: no cover """\ Function to write a QR Code to a MS Windows terminal. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param int border: Integer indicating the size of the quiet zone. ...
[ "def", "write_terminal_win", "(", "matrix", ",", "version", ",", "border", "=", "None", ")", ":", "import", "sys", "import", "struct", "import", "ctypes", "write", "=", "sys", ".", "stdout", ".", "write", "std_out", "=", "ctypes", ".", "windll", ".", "ke...
\ Function to write a QR Code to a MS Windows terminal. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param int border: Integer indicating the size of the quiet zone. If set to ``None`` (default), the recommended border size will be use...
[ "\\", "Function", "to", "write", "a", "QR", "Code", "to", "a", "MS", "Windows", "terminal", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L958-L997
train
heuer/segno
segno/writers.py
_pack_bits_into_byte
def _pack_bits_into_byte(iterable): """\ Packs eight bits into one byte. If the length of the iterable is not a multiple of eight, ``0x0`` is used to fill-up the missing values. """ return (reduce(lambda x, y: (x << 1) + y, e) for e in zip_longest(*[iter(iterable)] * 8, fillvalue=0x...
python
def _pack_bits_into_byte(iterable): """\ Packs eight bits into one byte. If the length of the iterable is not a multiple of eight, ``0x0`` is used to fill-up the missing values. """ return (reduce(lambda x, y: (x << 1) + y, e) for e in zip_longest(*[iter(iterable)] * 8, fillvalue=0x...
[ "def", "_pack_bits_into_byte", "(", "iterable", ")", ":", "return", "(", "reduce", "(", "lambda", "x", ",", "y", ":", "(", "x", "<<", "1", ")", "+", "y", ",", "e", ")", "for", "e", "in", "zip_longest", "(", "*", "[", "iter", "(", "iterable", ")",...
\ Packs eight bits into one byte. If the length of the iterable is not a multiple of eight, ``0x0`` is used to fill-up the missing values.
[ "\\", "Packs", "eight", "bits", "into", "one", "byte", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L1000-L1008
train
heuer/segno
segno/writers.py
save
def save(matrix, version, out, kind=None, **kw): """\ Serializes the matrix in any of the supported formats. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: A filename or a writable file-like object with a ``name`` attribute. If a stre...
python
def save(matrix, version, out, kind=None, **kw): """\ Serializes the matrix in any of the supported formats. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: A filename or a writable file-like object with a ``name`` attribute. If a stre...
[ "def", "save", "(", "matrix", ",", "version", ",", "out", ",", "kind", "=", "None", ",", "**", "kw", ")", ":", "is_stream", "=", "False", "if", "kind", "is", "None", ":", "try", ":", "fname", "=", "out", ".", "name", "is_stream", "=", "True", "ex...
\ Serializes the matrix in any of the supported formats. :param matrix: The matrix to serialize. :param int version: The (Micro) QR code version :param out: A filename or a writable file-like object with a ``name`` attribute. If a stream like :py:class:`io.ByteIO` or :py:class:`...
[ "\\", "Serializes", "the", "matrix", "in", "any", "of", "the", "supported", "formats", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/writers.py#L1026-L1065
train
heuer/segno
segno/cli.py
parse
def parse(args): """\ Parses the arguments and returns the result. """ parser = make_parser() if not len(args): parser.print_help() sys.exit(1) parsed_args = parser.parse_args(args) if parsed_args.error == '-': parsed_args.error = None # 'micro' is False by defaul...
python
def parse(args): """\ Parses the arguments and returns the result. """ parser = make_parser() if not len(args): parser.print_help() sys.exit(1) parsed_args = parser.parse_args(args) if parsed_args.error == '-': parsed_args.error = None # 'micro' is False by defaul...
[ "def", "parse", "(", "args", ")", ":", "parser", "=", "make_parser", "(", ")", "if", "not", "len", "(", "args", ")", ":", "parser", ".", "print_help", "(", ")", "sys", ".", "exit", "(", "1", ")", "parsed_args", "=", "parser", ".", "parse_args", "("...
\ Parses the arguments and returns the result.
[ "\\", "Parses", "the", "arguments", "and", "returns", "the", "result", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/cli.py#L124-L143
train
heuer/segno
segno/cli.py
build_config
def build_config(config, filename=None): """\ Builds a configuration and returns it. The config contains only keywords, which are supported by the serializer. Unsupported values are ignored. """ # Done here since it seems not to be possible to detect if an argument # was supplied by the user or ...
python
def build_config(config, filename=None): """\ Builds a configuration and returns it. The config contains only keywords, which are supported by the serializer. Unsupported values are ignored. """ # Done here since it seems not to be possible to detect if an argument # was supplied by the user or ...
[ "def", "build_config", "(", "config", ",", "filename", "=", "None", ")", ":", "for", "clr", "in", "(", "'color'", ",", "'background'", ")", ":", "val", "=", "config", ".", "pop", "(", "clr", ",", "None", ")", "if", "val", "in", "(", "'transparent'", ...
\ Builds a configuration and returns it. The config contains only keywords, which are supported by the serializer. Unsupported values are ignored.
[ "\\", "Builds", "a", "configuration", "and", "returns", "it", ".", "The", "config", "contains", "only", "keywords", "which", "are", "supported", "by", "the", "serializer", ".", "Unsupported", "values", "are", "ignored", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/cli.py#L146-L178
train
heuer/segno
segno/helpers.py
make_wifi_data
def make_wifi_data(ssid, password, security, hidden=False): """\ Creates WIFI configuration string. :param str ssid: The SSID of the network. :param str|None password: The password. :param str|None security: Authentication type; the value should be "WEP" or "WPA". Set to ``None`` to omi...
python
def make_wifi_data(ssid, password, security, hidden=False): """\ Creates WIFI configuration string. :param str ssid: The SSID of the network. :param str|None password: The password. :param str|None security: Authentication type; the value should be "WEP" or "WPA". Set to ``None`` to omi...
[ "def", "make_wifi_data", "(", "ssid", ",", "password", ",", "security", ",", "hidden", "=", "False", ")", ":", "def", "quotation_mark", "(", "x", ")", ":", "try", ":", "int", "(", "x", ",", "16", ")", "except", "ValueError", ":", "return", "''", "ret...
\ Creates WIFI configuration string. :param str ssid: The SSID of the network. :param str|None password: The password. :param str|None security: Authentication type; the value should be "WEP" or "WPA". Set to ``None`` to omit the value. "nopass" is equivalent to setting the valu...
[ "\\", "Creates", "WIFI", "configuration", "string", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/helpers.py#L63-L99
train
heuer/segno
segno/helpers.py
make_wifi
def make_wifi(ssid, password, security, hidden=False): """\ Creates a WIFI configuration QR Code. :param str ssid: The SSID of the network. :param str|None password: The password. :param str|None security: Authentication type; the value should be "WEP" or "WPA". Set to ``None`` to omit ...
python
def make_wifi(ssid, password, security, hidden=False): """\ Creates a WIFI configuration QR Code. :param str ssid: The SSID of the network. :param str|None password: The password. :param str|None security: Authentication type; the value should be "WEP" or "WPA". Set to ``None`` to omit ...
[ "def", "make_wifi", "(", "ssid", ",", "password", ",", "security", ",", "hidden", "=", "False", ")", ":", "return", "segno", ".", "make_qr", "(", "make_wifi_data", "(", "ssid", ",", "password", ",", "security", ",", "hidden", ")", ")" ]
\ Creates a WIFI configuration QR Code. :param str ssid: The SSID of the network. :param str|None password: The password. :param str|None security: Authentication type; the value should be "WEP" or "WPA". Set to ``None`` to omit the value. "nopass" is equivalent to setting the v...
[ "\\", "Creates", "a", "WIFI", "configuration", "QR", "Code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/helpers.py#L102-L115
train
heuer/segno
segno/helpers.py
make_mecard_data
def make_mecard_data(name, reading=None, email=None, phone=None, videophone=None, memo=None, nickname=None, birthday=None, url=None, pobox=None, roomno=None, houseno=None, city=None, prefecture=None, zipcode=None, country=None): """\ Creates a strin...
python
def make_mecard_data(name, reading=None, email=None, phone=None, videophone=None, memo=None, nickname=None, birthday=None, url=None, pobox=None, roomno=None, houseno=None, city=None, prefecture=None, zipcode=None, country=None): """\ Creates a strin...
[ "def", "make_mecard_data", "(", "name", ",", "reading", "=", "None", ",", "email", "=", "None", ",", "phone", "=", "None", ",", "videophone", "=", "None", ",", "memo", "=", "None", ",", "nickname", "=", "None", ",", "birthday", "=", "None", ",", "url...
\ Creates a string encoding the contact information as MeCard. :param str name: Name. If it contains a comma, the first part is treated as lastname and the second part is treated as forename. :param str|None reading: Designates a text string to be set as the kana name in the phonebo...
[ "\\", "Creates", "a", "string", "encoding", "the", "contact", "information", "as", "MeCard", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/helpers.py#L118-L179
train
heuer/segno
segno/helpers.py
make_geo_data
def make_geo_data(lat, lng): """\ Creates a geo location URI. :param float lat: Latitude :param float lng: Longitude :rtype: str """ def float_to_str(f): return '{0:.8f}'.format(f).rstrip('0') return 'geo:{0},{1}'.format(float_to_str(lat), float_to_str(lng))
python
def make_geo_data(lat, lng): """\ Creates a geo location URI. :param float lat: Latitude :param float lng: Longitude :rtype: str """ def float_to_str(f): return '{0:.8f}'.format(f).rstrip('0') return 'geo:{0},{1}'.format(float_to_str(lat), float_to_str(lng))
[ "def", "make_geo_data", "(", "lat", ",", "lng", ")", ":", "def", "float_to_str", "(", "f", ")", ":", "return", "'{0:.8f}'", ".", "format", "(", "f", ")", ".", "rstrip", "(", "'0'", ")", "return", "'geo:{0},{1}'", ".", "format", "(", "float_to_str", "("...
\ Creates a geo location URI. :param float lat: Latitude :param float lng: Longitude :rtype: str
[ "\\", "Creates", "a", "geo", "location", "URI", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/helpers.py#L364-L375
train
heuer/segno
segno/encoder.py
boost_error_level
def boost_error_level(version, error, segments, eci, is_sa=False): """\ Increases the error level if possible. :param int version: Version constant. :param int|None error: Error level constant or ``None`` :param Segments segments: Instance of :py:class:`Segments` :param bool eci: Indicates if E...
python
def boost_error_level(version, error, segments, eci, is_sa=False): """\ Increases the error level if possible. :param int version: Version constant. :param int|None error: Error level constant or ``None`` :param Segments segments: Instance of :py:class:`Segments` :param bool eci: Indicates if E...
[ "def", "boost_error_level", "(", "version", ",", "error", ",", "segments", ",", "eci", ",", "is_sa", "=", "False", ")", ":", "if", "error", "not", "in", "(", "consts", ".", "ERROR_LEVEL_H", ",", "None", ")", "and", "len", "(", "segments", ")", "==", ...
\ Increases the error level if possible. :param int version: Version constant. :param int|None error: Error level constant or ``None`` :param Segments segments: Instance of :py:class:`Segments` :param bool eci: Indicates if ECI designator should be written. :param bool is_sa: Indicates if Struc...
[ "\\", "Increases", "the", "error", "level", "if", "possible", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L302-L327
train
heuer/segno
segno/encoder.py
write_segment
def write_segment(buff, segment, ver, ver_range, eci=False): """\ Writes a segment. :param buff: The byte buffer. :param _Segment segment: The segment to serialize. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param ver_rang...
python
def write_segment(buff, segment, ver, ver_range, eci=False): """\ Writes a segment. :param buff: The byte buffer. :param _Segment segment: The segment to serialize. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param ver_rang...
[ "def", "write_segment", "(", "buff", ",", "segment", ",", "ver", ",", "ver_range", ",", "eci", "=", "False", ")", ":", "mode", "=", "segment", ".", "mode", "append_bits", "=", "buff", ".", "append_bits", "if", "eci", "and", "mode", "==", "consts", ".",...
\ Writes a segment. :param buff: The byte buffer. :param _Segment segment: The segment to serialize. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param ver_range: "M1", "M2", "M3", or "M4" if a Micro QR Code is written, ...
[ "\\", "Writes", "a", "segment", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L330-L355
train
heuer/segno
segno/encoder.py
write_terminator
def write_terminator(buff, capacity, ver, length): """\ Writes the terminator. :param buff: The byte buffer. :param capacity: Symbol capacity. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param length: Length of the data bit...
python
def write_terminator(buff, capacity, ver, length): """\ Writes the terminator. :param buff: The byte buffer. :param capacity: Symbol capacity. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param length: Length of the data bit...
[ "def", "write_terminator", "(", "buff", ",", "capacity", ",", "ver", ",", "length", ")", ":", "buff", ".", "extend", "(", "[", "0", "]", "*", "min", "(", "capacity", "-", "length", ",", "consts", ".", "TERMINATOR_LENGTH", "[", "ver", "]", ")", ")" ]
\ Writes the terminator. :param buff: The byte buffer. :param capacity: Symbol capacity. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param length: Length of the data bit stream.
[ "\\", "Writes", "the", "terminator", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L358-L369
train
heuer/segno
segno/encoder.py
write_padding_bits
def write_padding_bits(buff, version, length): """\ Writes padding bits if the data stream does not meet the codeword boundary. :param buff: The byte buffer. :param int length: Data stream length. """ # ISO/IEC 18004:2015(E) - 7.4.10 Bit stream to codeword conversion -- page 32 # [...] ...
python
def write_padding_bits(buff, version, length): """\ Writes padding bits if the data stream does not meet the codeword boundary. :param buff: The byte buffer. :param int length: Data stream length. """ # ISO/IEC 18004:2015(E) - 7.4.10 Bit stream to codeword conversion -- page 32 # [...] ...
[ "def", "write_padding_bits", "(", "buff", ",", "version", ",", "length", ")", ":", "if", "version", "not", "in", "(", "consts", ".", "VERSION_M1", ",", "consts", ".", "VERSION_M3", ")", ":", "buff", ".", "extend", "(", "[", "0", "]", "*", "(", "8", ...
\ Writes padding bits if the data stream does not meet the codeword boundary. :param buff: The byte buffer. :param int length: Data stream length.
[ "\\", "Writes", "padding", "bits", "if", "the", "data", "stream", "does", "not", "meet", "the", "codeword", "boundary", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L372-L388
train
heuer/segno
segno/encoder.py
write_pad_codewords
def write_pad_codewords(buff, version, capacity, length): """\ Writes the pad codewords iff the data does not fill the capacity of the symbol. :param buff: The byte buffer. :param int version: The (Micro) QR Code version. :param int capacity: The total capacity of the symbol (incl. error correc...
python
def write_pad_codewords(buff, version, capacity, length): """\ Writes the pad codewords iff the data does not fill the capacity of the symbol. :param buff: The byte buffer. :param int version: The (Micro) QR Code version. :param int capacity: The total capacity of the symbol (incl. error correc...
[ "def", "write_pad_codewords", "(", "buff", ",", "version", ",", "capacity", ",", "length", ")", ":", "write", "=", "buff", ".", "extend", "if", "version", "in", "(", "consts", ".", "VERSION_M1", ",", "consts", ".", "VERSION_M3", ")", ":", "write", "(", ...
\ Writes the pad codewords iff the data does not fill the capacity of the symbol. :param buff: The byte buffer. :param int version: The (Micro) QR Code version. :param int capacity: The total capacity of the symbol (incl. error correction) :param int length: Length of the data bit stream.
[ "\\", "Writes", "the", "pad", "codewords", "iff", "the", "data", "does", "not", "fill", "the", "capacity", "of", "the", "symbol", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L391-L415
train
heuer/segno
segno/encoder.py
add_alignment_patterns
def add_alignment_patterns(matrix, version): """\ Adds the adjustment patterns to the matrix. For versions < 2 this is a no-op. ISO/IEC 18004:2015(E) -- 6.3.6 Alignment patterns (page 17) ISO/IEC 18004:2015(E) -- Annex E Position of alignment patterns (page 83) """ if version < 2: r...
python
def add_alignment_patterns(matrix, version): """\ Adds the adjustment patterns to the matrix. For versions < 2 this is a no-op. ISO/IEC 18004:2015(E) -- 6.3.6 Alignment patterns (page 17) ISO/IEC 18004:2015(E) -- Annex E Position of alignment patterns (page 83) """ if version < 2: r...
[ "def", "add_alignment_patterns", "(", "matrix", ",", "version", ")", ":", "if", "version", "<", "2", ":", "return", "matrix_size", "=", "len", "(", "matrix", ")", "positions", "=", "consts", ".", "ALIGNMENT_POS", "[", "version", "-", "2", "]", "for", "po...
\ Adds the adjustment patterns to the matrix. For versions < 2 this is a no-op. ISO/IEC 18004:2015(E) -- 6.3.6 Alignment patterns (page 17) ISO/IEC 18004:2015(E) -- Annex E Position of alignment patterns (page 83)
[ "\\", "Adds", "the", "adjustment", "patterns", "to", "the", "matrix", ".", "For", "versions", "<", "2", "this", "is", "a", "no", "-", "op", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L493-L513
train
heuer/segno
segno/encoder.py
make_blocks
def make_blocks(ec_infos, codewords): """\ Returns the data and error blocks. :param ec_infos: Iterable of ECC information :param codewords: Iterable of (integer) code words. """ data_blocks, error_blocks = [], [] offset = 0 for ec_info in ec_infos: for i in range(ec_info.num_bl...
python
def make_blocks(ec_infos, codewords): """\ Returns the data and error blocks. :param ec_infos: Iterable of ECC information :param codewords: Iterable of (integer) code words. """ data_blocks, error_blocks = [], [] offset = 0 for ec_info in ec_infos: for i in range(ec_info.num_bl...
[ "def", "make_blocks", "(", "ec_infos", ",", "codewords", ")", ":", "data_blocks", ",", "error_blocks", "=", "[", "]", ",", "[", "]", "offset", "=", "0", "for", "ec_info", "in", "ec_infos", ":", "for", "i", "in", "range", "(", "ec_info", ".", "num_block...
\ Returns the data and error blocks. :param ec_infos: Iterable of ECC information :param codewords: Iterable of (integer) code words.
[ "\\", "Returns", "the", "data", "and", "error", "blocks", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L609-L624
train
heuer/segno
segno/encoder.py
make_error_block
def make_error_block(ec_info, data_block): """\ Creates the error code words for the provided data block. :param ec_info: ECC information (number of blocks, number of code words etc.) :param data_block: Iterable of (integer) code words. """ num_error_words = ec_info.num_total - ec_info.num_data...
python
def make_error_block(ec_info, data_block): """\ Creates the error code words for the provided data block. :param ec_info: ECC information (number of blocks, number of code words etc.) :param data_block: Iterable of (integer) code words. """ num_error_words = ec_info.num_total - ec_info.num_data...
[ "def", "make_error_block", "(", "ec_info", ",", "data_block", ")", ":", "num_error_words", "=", "ec_info", ".", "num_total", "-", "ec_info", ".", "num_data", "error_block", "=", "bytearray", "(", "data_block", ")", "error_block", ".", "extend", "(", "[", "0", ...
\ Creates the error code words for the provided data block. :param ec_info: ECC information (number of blocks, number of code words etc.) :param data_block: Iterable of (integer) code words.
[ "\\", "Creates", "the", "error", "code", "words", "for", "the", "provided", "data", "block", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L627-L651
train
heuer/segno
segno/encoder.py
find_and_apply_best_mask
def find_and_apply_best_mask(matrix, version, is_micro, proposed_mask=None): """\ Applies all mask patterns against the provided QR Code matrix and returns the best matrix and best pattern. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data...
python
def find_and_apply_best_mask(matrix, version, is_micro, proposed_mask=None): """\ Applies all mask patterns against the provided QR Code matrix and returns the best matrix and best pattern. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data...
[ "def", "find_and_apply_best_mask", "(", "matrix", ",", "version", ",", "is_micro", ",", "proposed_mask", "=", "None", ")", ":", "matrix_size", "=", "len", "(", "matrix", ")", "is_better", "=", "lt", "best_score", "=", "_MAX_PENALTY_SCORE", "eval_mask", "=", "e...
\ Applies all mask patterns against the provided QR Code matrix and returns the best matrix and best pattern. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results (page 53) ISO/IEC 18004:2015(E) -- 7.8.3.1 Evaluation of QR Cod...
[ "\\", "Applies", "all", "mask", "patterns", "against", "the", "provided", "QR", "Code", "matrix", "and", "returns", "the", "best", "matrix", "and", "best", "pattern", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L654-L715
train
heuer/segno
segno/encoder.py
apply_mask
def apply_mask(matrix, mask_pattern, matrix_size, is_encoding_region): """\ Applies the provided mask pattern on the `matrix`. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) :param tuple matrix: A tuple of bytearrays :param mask_pattern: A mask pattern (a function) :param int matr...
python
def apply_mask(matrix, mask_pattern, matrix_size, is_encoding_region): """\ Applies the provided mask pattern on the `matrix`. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) :param tuple matrix: A tuple of bytearrays :param mask_pattern: A mask pattern (a function) :param int matr...
[ "def", "apply_mask", "(", "matrix", ",", "mask_pattern", ",", "matrix_size", ",", "is_encoding_region", ")", ":", "for", "i", "in", "range", "(", "matrix_size", ")", ":", "for", "j", "in", "range", "(", "matrix_size", ")", ":", "if", "is_encoding_region", ...
\ Applies the provided mask pattern on the `matrix`. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) :param tuple matrix: A tuple of bytearrays :param mask_pattern: A mask pattern (a function) :param int matrix_size: width or height of the matrix :param is_encoding_region: A functi...
[ "\\", "Applies", "the", "provided", "mask", "pattern", "on", "the", "matrix", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L718-L733
train
heuer/segno
segno/encoder.py
evaluate_mask
def evaluate_mask(matrix, matrix_size): """\ Evaluates the provided `matrix` of a QR code. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results (page 53) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The penalty score o...
python
def evaluate_mask(matrix, matrix_size): """\ Evaluates the provided `matrix` of a QR code. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results (page 53) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The penalty score o...
[ "def", "evaluate_mask", "(", "matrix", ",", "matrix_size", ")", ":", "return", "score_n1", "(", "matrix", ",", "matrix_size", ")", "+", "score_n2", "(", "matrix", ",", "matrix_size", ")", "+", "score_n3", "(", "matrix", ",", "matrix_size", ")", "+", "score...
\ Evaluates the provided `matrix` of a QR code. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results (page 53) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The penalty score of the matrix.
[ "\\", "Evaluates", "the", "provided", "matrix", "of", "a", "QR", "code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L736-L747
train
heuer/segno
segno/encoder.py
score_n1
def score_n1(matrix, matrix_size): """\ Implements the penalty score feature 1. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================================ ======================== ====== Feature Ev...
python
def score_n1(matrix, matrix_size): """\ Implements the penalty score feature 1. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================================ ======================== ====== Feature Ev...
[ "def", "score_n1", "(", "matrix", ",", "matrix_size", ")", ":", "score", "=", "0", "for", "i", "in", "range", "(", "matrix_size", ")", ":", "prev_bit_row", ",", "prev_bit_col", "=", "-", "1", ",", "-", "1", "row_counter", ",", "col_counter", "=", "0", ...
\ Implements the penalty score feature 1. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================================ ======================== ====== Feature Evaluation condition Points =====...
[ "\\", "Implements", "the", "penalty", "score", "feature", "1", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L750-L795
train
heuer/segno
segno/encoder.py
score_n2
def score_n2(matrix, matrix_size): """\ Implements the penalty score feature 2. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================== ==================== =============== Feature Evaluation condition Poi...
python
def score_n2(matrix, matrix_size): """\ Implements the penalty score feature 2. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================== ==================== =============== Feature Evaluation condition Poi...
[ "def", "score_n2", "(", "matrix", ",", "matrix_size", ")", ":", "score", "=", "0", "for", "i", "in", "range", "(", "matrix_size", "-", "1", ")", ":", "for", "j", "in", "range", "(", "matrix_size", "-", "1", ")", ":", "bit", "=", "matrix", "[", "i...
\ Implements the penalty score feature 2. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ============================== ==================== =============== Feature Evaluation condition Points ============================== =...
[ "\\", "Implements", "the", "penalty", "score", "feature", "2", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L798-L823
train
heuer/segno
segno/encoder.py
score_n3
def score_n3(matrix, matrix_size): """\ Implements the penalty score feature 3. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ========================================= ======================== ====== Feature Evaluatio...
python
def score_n3(matrix, matrix_size): """\ Implements the penalty score feature 3. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ========================================= ======================== ====== Feature Evaluatio...
[ "def", "score_n3", "(", "matrix", ",", "matrix_size", ")", ":", "def", "is_match", "(", "seq", ",", "start", ",", "end", ")", ":", "start", "=", "max", "(", "start", ",", "0", ")", "end", "=", "min", "(", "end", ",", "matrix_size", ")", "for", "i...
\ Implements the penalty score feature 3. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) ========================================= ======================== ====== Feature Evaluation condition Points =============...
[ "\\", "Implements", "the", "penalty", "score", "feature", "3", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L827-L877
train
heuer/segno
segno/encoder.py
score_n4
def score_n4(matrix, matrix_size): """\ Implements the penalty score feature 4. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) =========================================== ==================================== ====== Feature ...
python
def score_n4(matrix, matrix_size): """\ Implements the penalty score feature 4. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) =========================================== ==================================== ====== Feature ...
[ "def", "score_n4", "(", "matrix", ",", "matrix_size", ")", ":", "dark_modules", "=", "sum", "(", "map", "(", "sum", ",", "matrix", ")", ")", "total_modules", "=", "matrix_size", "**", "2", "k", "=", "int", "(", "abs", "(", "dark_modules", "*", "2", "...
\ Implements the penalty score feature 4. ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54) =========================================== ==================================== ====== Feature Evaluation condition ...
[ "\\", "Implements", "the", "penalty", "score", "feature", "4", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L880-L901
train
heuer/segno
segno/encoder.py
evaluate_micro_mask
def evaluate_micro_mask(matrix, matrix_size): """\ Evaluates the provided `matrix` of a Micro QR code. ISO/IEC 18004:2015(E) -- 7.8.3.2 Evaluation of Micro QR Code symbols (page 54) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The ...
python
def evaluate_micro_mask(matrix, matrix_size): """\ Evaluates the provided `matrix` of a Micro QR code. ISO/IEC 18004:2015(E) -- 7.8.3.2 Evaluation of Micro QR Code symbols (page 54) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The ...
[ "def", "evaluate_micro_mask", "(", "matrix", ",", "matrix_size", ")", ":", "sum1", "=", "sum", "(", "matrix", "[", "i", "]", "[", "-", "1", "]", "==", "0x1", "for", "i", "in", "range", "(", "1", ",", "matrix_size", ")", ")", "sum2", "=", "sum", "...
\ Evaluates the provided `matrix` of a Micro QR code. ISO/IEC 18004:2015(E) -- 7.8.3.2 Evaluation of Micro QR Code symbols (page 54) :param matrix: The matrix to evaluate :param matrix_size: The width (or height) of the matrix. :return int: The penalty score of the matrix.
[ "\\", "Evaluates", "the", "provided", "matrix", "of", "a", "Micro", "QR", "code", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L904-L916
train
heuer/segno
segno/encoder.py
calc_format_info
def calc_format_info(version, error, mask_pattern): """\ Returns the format information for the provided error level and mask patttern. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- Table C.1 — Valid format information bit sequences (page 80) :param int version...
python
def calc_format_info(version, error, mask_pattern): """\ Returns the format information for the provided error level and mask patttern. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- Table C.1 — Valid format information bit sequences (page 80) :param int version...
[ "def", "calc_format_info", "(", "version", ",", "error", ",", "mask_pattern", ")", ":", "fmt", "=", "mask_pattern", "if", "version", ">", "0", ":", "if", "error", "==", "consts", ".", "ERROR_LEVEL_L", ":", "fmt", "+=", "0x08", "elif", "error", "==", "con...
\ Returns the format information for the provided error level and mask patttern. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- Table C.1 — Valid format information bit sequences (page 80) :param int version: Version constant :param int error: Error level consta...
[ "\\", "Returns", "the", "format", "information", "for", "the", "provided", "error", "level", "and", "mask", "patttern", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L919-L942
train
heuer/segno
segno/encoder.py
add_format_info
def add_format_info(matrix, version, error, mask_pattern): """\ Adds the format information into the provided matrix. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- 7.9.1 QR Code symbols ISO/IEC 18004:2015(E) -- 7.9.2 Micro QR Code symbols :param matrix: The...
python
def add_format_info(matrix, version, error, mask_pattern): """\ Adds the format information into the provided matrix. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- 7.9.1 QR Code symbols ISO/IEC 18004:2015(E) -- 7.9.2 Micro QR Code symbols :param matrix: The...
[ "def", "add_format_info", "(", "matrix", ",", "version", ",", "error", ",", "mask_pattern", ")", ":", "is_micro", "=", "version", "<", "1", "format_info", "=", "calc_format_info", "(", "version", ",", "error", ",", "mask_pattern", ")", "offset", "=", "int", ...
\ Adds the format information into the provided matrix. ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55) ISO/IEC 18004:2015(E) -- 7.9.1 QR Code symbols ISO/IEC 18004:2015(E) -- 7.9.2 Micro QR Code symbols :param matrix: The matrix. :param int version: Version constant :param int e...
[ "\\", "Adds", "the", "format", "information", "into", "the", "provided", "matrix", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L945-L1006
train
heuer/segno
segno/encoder.py
add_version_info
def add_version_info(matrix, version): """\ Adds the version information to the matrix, for versions < 7 this is a no-op. ISO/IEC 18004:2015(E) -- 7.10 Version information (page 58) """ # # module 0 = least significant bit # module 17 = most significant bit # # Figure 27 — Version ...
python
def add_version_info(matrix, version): """\ Adds the version information to the matrix, for versions < 7 this is a no-op. ISO/IEC 18004:2015(E) -- 7.10 Version information (page 58) """ # # module 0 = least significant bit # module 17 = most significant bit # # Figure 27 — Version ...
[ "def", "add_version_info", "(", "matrix", ",", "version", ")", ":", "if", "version", "<", "7", ":", "return", "version_info", "=", "consts", ".", "VERSION_INFO", "[", "version", "-", "7", "]", "for", "i", "in", "range", "(", "6", ")", ":", "bit1", "=...
\ Adds the version information to the matrix, for versions < 7 this is a no-op. ISO/IEC 18004:2015(E) -- 7.10 Version information (page 58)
[ "\\", "Adds", "the", "version", "information", "to", "the", "matrix", "for", "versions", "<", "7", "this", "is", "a", "no", "-", "op", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1009-L1044
train
heuer/segno
segno/encoder.py
prepare_data
def prepare_data(content, mode, encoding, version=None): """\ Returns an iterable of `Segment` instances. If `content` is a string, an integer, or bytes, the returned tuple will have a single item. If `content` is a list or a tuple, a tuple of `Segment` instances of the same length is returned. ...
python
def prepare_data(content, mode, encoding, version=None): """\ Returns an iterable of `Segment` instances. If `content` is a string, an integer, or bytes, the returned tuple will have a single item. If `content` is a list or a tuple, a tuple of `Segment` instances of the same length is returned. ...
[ "def", "prepare_data", "(", "content", ",", "mode", ",", "encoding", ",", "version", "=", "None", ")", ":", "segments", "=", "Segments", "(", ")", "add_segment", "=", "segments", ".", "add_segment", "if", "isinstance", "(", "content", ",", "(", "str_type",...
\ Returns an iterable of `Segment` instances. If `content` is a string, an integer, or bytes, the returned tuple will have a single item. If `content` is a list or a tuple, a tuple of `Segment` instances of the same length is returned. :param content: Either a string, bytes, an integer or an itera...
[ "\\", "Returns", "an", "iterable", "of", "Segment", "instances", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1047-L1079
train
heuer/segno
segno/encoder.py
data_to_bytes
def data_to_bytes(data, encoding): """\ Converts the provided data into bytes. If the data is already a byte sequence, it will be left unchanged. This function tries to use the provided `encoding` (if not ``None``) or the default encoding (ISO/IEC 8859-1). It uses UTF-8 as fallback. Returns th...
python
def data_to_bytes(data, encoding): """\ Converts the provided data into bytes. If the data is already a byte sequence, it will be left unchanged. This function tries to use the provided `encoding` (if not ``None``) or the default encoding (ISO/IEC 8859-1). It uses UTF-8 as fallback. Returns th...
[ "def", "data_to_bytes", "(", "data", ",", "encoding", ")", ":", "if", "isinstance", "(", "data", ",", "bytes", ")", ":", "return", "data", ",", "len", "(", "data", ")", ",", "encoding", "or", "consts", ".", "DEFAULT_BYTE_ENCODING", "data", "=", "str", ...
\ Converts the provided data into bytes. If the data is already a byte sequence, it will be left unchanged. This function tries to use the provided `encoding` (if not ``None``) or the default encoding (ISO/IEC 8859-1). It uses UTF-8 as fallback. Returns the (byte) data, the data length and the enc...
[ "\\", "Converts", "the", "provided", "data", "into", "bytes", ".", "If", "the", "data", "is", "already", "a", "byte", "sequence", "it", "will", "be", "left", "unchanged", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1082-L1117
train
heuer/segno
segno/encoder.py
normalize_version
def normalize_version(version): """\ Canonicalizes the provided `version`. If the `version` is ``None``, this function returns ``None``. Otherwise this function checks if `version` is an integer or a Micro QR Code version. In case the string represents a Micro QR Code version, an uppercased str...
python
def normalize_version(version): """\ Canonicalizes the provided `version`. If the `version` is ``None``, this function returns ``None``. Otherwise this function checks if `version` is an integer or a Micro QR Code version. In case the string represents a Micro QR Code version, an uppercased str...
[ "def", "normalize_version", "(", "version", ")", ":", "if", "version", "is", "None", ":", "return", "None", "error", "=", "False", "try", ":", "version", "=", "int", "(", "version", ")", "error", "=", "version", "<", "1", "except", "(", "ValueError", "...
\ Canonicalizes the provided `version`. If the `version` is ``None``, this function returns ``None``. Otherwise this function checks if `version` is an integer or a Micro QR Code version. In case the string represents a Micro QR Code version, an uppercased string identifier is returned. If the...
[ "\\", "Canonicalizes", "the", "provided", "version", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1245-L1278
train
heuer/segno
segno/encoder.py
normalize_errorlevel
def normalize_errorlevel(error, accept_none=False): """\ Returns a constant for the provided error level. This function returns ``None`` if the provided parameter is ``None`` and `accept_none` is set to ``True`` (default: ``False``). If `error` is ``None`` and `accept_none` is ``False`` or if the p...
python
def normalize_errorlevel(error, accept_none=False): """\ Returns a constant for the provided error level. This function returns ``None`` if the provided parameter is ``None`` and `accept_none` is set to ``True`` (default: ``False``). If `error` is ``None`` and `accept_none` is ``False`` or if the p...
[ "def", "normalize_errorlevel", "(", "error", ",", "accept_none", "=", "False", ")", ":", "if", "error", "is", "None", ":", "if", "not", "accept_none", ":", "raise", "ErrorLevelError", "(", "'The error level must be provided'", ")", "return", "error", "try", ":",...
\ Returns a constant for the provided error level. This function returns ``None`` if the provided parameter is ``None`` and `accept_none` is set to ``True`` (default: ``False``). If `error` is ``None`` and `accept_none` is ``False`` or if the provided parameter cannot be mapped to a valid QR Code e...
[ "\\", "Returns", "a", "constant", "for", "the", "provided", "error", "level", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1329-L1353
train
heuer/segno
segno/encoder.py
get_mode_name
def get_mode_name(mode_const): """\ Returns the mode name for the provided mode constant. :param int mode_const: The mode constant (see :py:module:`segno.consts`) """ for name, val in consts.MODE_MAPPING.items(): if val == mode_const: return name raise ModeError('Unknown mod...
python
def get_mode_name(mode_const): """\ Returns the mode name for the provided mode constant. :param int mode_const: The mode constant (see :py:module:`segno.consts`) """ for name, val in consts.MODE_MAPPING.items(): if val == mode_const: return name raise ModeError('Unknown mod...
[ "def", "get_mode_name", "(", "mode_const", ")", ":", "for", "name", ",", "val", "in", "consts", ".", "MODE_MAPPING", ".", "items", "(", ")", ":", "if", "val", "==", "mode_const", ":", "return", "name", "raise", "ModeError", "(", "'Unknown mode \"{0}\"'", "...
\ Returns the mode name for the provided mode constant. :param int mode_const: The mode constant (see :py:module:`segno.consts`)
[ "\\", "Returns", "the", "mode", "name", "for", "the", "provided", "mode", "constant", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1356-L1365
train
heuer/segno
segno/encoder.py
get_error_name
def get_error_name(error_const): """\ Returns the error name for the provided error constant. :param int error_const: The error constant (see :py:module:`segno.consts`) """ for name, val in consts.ERROR_MAPPING.items(): if val == error_const: return name raise ErrorLevelErro...
python
def get_error_name(error_const): """\ Returns the error name for the provided error constant. :param int error_const: The error constant (see :py:module:`segno.consts`) """ for name, val in consts.ERROR_MAPPING.items(): if val == error_const: return name raise ErrorLevelErro...
[ "def", "get_error_name", "(", "error_const", ")", ":", "for", "name", ",", "val", "in", "consts", ".", "ERROR_MAPPING", ".", "items", "(", ")", ":", "if", "val", "==", "error_const", ":", "return", "name", "raise", "ErrorLevelError", "(", "'Unknown error lev...
\ Returns the error name for the provided error constant. :param int error_const: The error constant (see :py:module:`segno.consts`)
[ "\\", "Returns", "the", "error", "name", "for", "the", "provided", "error", "constant", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1368-L1377
train
heuer/segno
segno/encoder.py
get_version_name
def get_version_name(version_const): """\ Returns the version name. For version 1 .. 40 it returns the version as integer, for Micro QR Codes it returns a string like ``M1`` etc. :raises: VersionError: In case the `version_constant` is unknown. """ if 0 < version_const < 41: return...
python
def get_version_name(version_const): """\ Returns the version name. For version 1 .. 40 it returns the version as integer, for Micro QR Codes it returns a string like ``M1`` etc. :raises: VersionError: In case the `version_constant` is unknown. """ if 0 < version_const < 41: return...
[ "def", "get_version_name", "(", "version_const", ")", ":", "if", "0", "<", "version_const", "<", "41", ":", "return", "version_const", "for", "name", ",", "v", "in", "consts", ".", "MICRO_VERSION_MAPPING", ".", "items", "(", ")", ":", "if", "v", "==", "v...
\ Returns the version name. For version 1 .. 40 it returns the version as integer, for Micro QR Codes it returns a string like ``M1`` etc. :raises: VersionError: In case the `version_constant` is unknown.
[ "\\", "Returns", "the", "version", "name", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1380-L1394
train
heuer/segno
segno/encoder.py
is_kanji
def is_kanji(data): """\ Returns if the `data` can be encoded in "kanji" mode. :param bytes data: The data to check. :rtype: bool """ data_len = len(data) if not data_len or data_len % 2: return False if _PY2: data = (ord(c) for c in data) data_iter = iter(data) ...
python
def is_kanji(data): """\ Returns if the `data` can be encoded in "kanji" mode. :param bytes data: The data to check. :rtype: bool """ data_len = len(data) if not data_len or data_len % 2: return False if _PY2: data = (ord(c) for c in data) data_iter = iter(data) ...
[ "def", "is_kanji", "(", "data", ")", ":", "data_len", "=", "len", "(", "data", ")", "if", "not", "data_len", "or", "data_len", "%", "2", ":", "return", "False", "if", "_PY2", ":", "data", "=", "(", "ord", "(", "c", ")", "for", "c", "in", "data", ...
\ Returns if the `data` can be encoded in "kanji" mode. :param bytes data: The data to check. :rtype: bool
[ "\\", "Returns", "if", "the", "data", "can", "be", "encoded", "in", "kanji", "mode", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1409-L1426
train
heuer/segno
segno/encoder.py
calc_structured_append_parity
def calc_structured_append_parity(content): """\ Calculates the parity data for the Structured Append mode. :param str content: The content. :rtype: int """ if not isinstance(content, str_type): content = str(content) try: data = content.encode('iso-8859-1') except Unico...
python
def calc_structured_append_parity(content): """\ Calculates the parity data for the Structured Append mode. :param str content: The content. :rtype: int """ if not isinstance(content, str_type): content = str(content) try: data = content.encode('iso-8859-1') except Unico...
[ "def", "calc_structured_append_parity", "(", "content", ")", ":", "if", "not", "isinstance", "(", "content", ",", "str_type", ")", ":", "content", "=", "str", "(", "content", ")", "try", ":", "data", "=", "content", ".", "encode", "(", "'iso-8859-1'", ")",...
\ Calculates the parity data for the Structured Append mode. :param str content: The content. :rtype: int
[ "\\", "Calculates", "the", "parity", "data", "for", "the", "Structured", "Append", "mode", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1490-L1508
train
heuer/segno
segno/encoder.py
is_mode_supported
def is_mode_supported(mode, ver): """\ Returns if `mode` is supported by `version`. Note: This function does not check if `version` is actually a valid (Micro) QR Code version. Invalid versions like ``41`` may return an illegal value. :param int mode: Canonicalized mode. :param int or None...
python
def is_mode_supported(mode, ver): """\ Returns if `mode` is supported by `version`. Note: This function does not check if `version` is actually a valid (Micro) QR Code version. Invalid versions like ``41`` may return an illegal value. :param int mode: Canonicalized mode. :param int or None...
[ "def", "is_mode_supported", "(", "mode", ",", "ver", ")", ":", "ver", "=", "None", "if", "ver", ">", "0", "else", "ver", "try", ":", "return", "ver", "in", "consts", ".", "SUPPORTED_MODES", "[", "mode", "]", "except", "KeyError", ":", "raise", "ModeErr...
\ Returns if `mode` is supported by `version`. Note: This function does not check if `version` is actually a valid (Micro) QR Code version. Invalid versions like ``41`` may return an illegal value. :param int mode: Canonicalized mode. :param int or None ver: (Micro) QR Code version constant. ...
[ "\\", "Returns", "if", "mode", "is", "supported", "by", "version", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1511-L1527
train
heuer/segno
segno/encoder.py
version_range
def version_range(version): """\ Returns the version range for the provided version. This applies to QR Code versions, only. :param int version: The QR Code version (1 .. 40) :rtype: int """ # ISO/IEC 18004:2015(E) # Table 3 — Number of bits in character count indicator for QR Code (pag...
python
def version_range(version): """\ Returns the version range for the provided version. This applies to QR Code versions, only. :param int version: The QR Code version (1 .. 40) :rtype: int """ # ISO/IEC 18004:2015(E) # Table 3 — Number of bits in character count indicator for QR Code (pag...
[ "def", "version_range", "(", "version", ")", ":", "if", "0", "<", "version", "<", "10", ":", "return", "consts", ".", "VERSION_RANGE_01_09", "elif", "9", "<", "version", "<", "27", ":", "return", "consts", ".", "VERSION_RANGE_10_26", "elif", "26", "<", "...
\ Returns the version range for the provided version. This applies to QR Code versions, only. :param int version: The QR Code version (1 .. 40) :rtype: int
[ "\\", "Returns", "the", "version", "range", "for", "the", "provided", "version", ".", "This", "applies", "to", "QR", "Code", "versions", "only", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1543-L1559
train
heuer/segno
segno/encoder.py
get_eci_assignment_number
def get_eci_assignment_number(encoding): """\ Returns the ECI number for the provided encoding. :param str encoding: A encoding name :return str: The ECI number. """ try: return consts.ECI_ASSIGNMENT_NUM[codecs.lookup(encoding).name] except KeyError: raise QRCodeError('Unkno...
python
def get_eci_assignment_number(encoding): """\ Returns the ECI number for the provided encoding. :param str encoding: A encoding name :return str: The ECI number. """ try: return consts.ECI_ASSIGNMENT_NUM[codecs.lookup(encoding).name] except KeyError: raise QRCodeError('Unkno...
[ "def", "get_eci_assignment_number", "(", "encoding", ")", ":", "try", ":", "return", "consts", ".", "ECI_ASSIGNMENT_NUM", "[", "codecs", ".", "lookup", "(", "encoding", ")", ".", "name", "]", "except", "KeyError", ":", "raise", "QRCodeError", "(", "'Unknown EC...
\ Returns the ECI number for the provided encoding. :param str encoding: A encoding name :return str: The ECI number.
[ "\\", "Returns", "the", "ECI", "number", "for", "the", "provided", "encoding", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1562-L1573
train
heuer/segno
segno/encoder.py
get_data_mask_functions
def get_data_mask_functions(is_micro): """ Returns the data mask functions. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) Table 10 — Data mask pattern generation conditions (page 50) =============== ===================== ===================================== QR Code Pattern...
python
def get_data_mask_functions(is_micro): """ Returns the data mask functions. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) Table 10 — Data mask pattern generation conditions (page 50) =============== ===================== ===================================== QR Code Pattern...
[ "def", "get_data_mask_functions", "(", "is_micro", ")", ":", "def", "fn0", "(", "i", ",", "j", ")", ":", "return", "(", "i", "+", "j", ")", "&", "0x1", "==", "0", "def", "fn1", "(", "i", ",", "j", ")", ":", "return", "i", "&", "0x1", "==", "0...
Returns the data mask functions. ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50) Table 10 — Data mask pattern generation conditions (page 50) =============== ===================== ===================================== QR Code Pattern Micro QR Code Pattern Condition ========...
[ "Returns", "the", "data", "mask", "functions", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1576-L1629
train
heuer/segno
segno/encoder.py
Buffer.toints
def toints(self): """\ Returns an iterable of integers interpreting the content of `seq` as sequence of binary numbers of length 8. """ def grouper(iterable, n, fillvalue=None): "Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x')...
python
def toints(self): """\ Returns an iterable of integers interpreting the content of `seq` as sequence of binary numbers of length 8. """ def grouper(iterable, n, fillvalue=None): "Collect data into fixed-length chunks or blocks" # grouper('ABCDEFG', 3, 'x')...
[ "def", "toints", "(", "self", ")", ":", "def", "grouper", "(", "iterable", ",", "n", ",", "fillvalue", "=", "None", ")", ":", "\"Collect data into fixed-length chunks or blocks\"", "return", "zip_longest", "(", "*", "[", "iter", "(", "iterable", ")", "]", "*...
\ Returns an iterable of integers interpreting the content of `seq` as sequence of binary numbers of length 8.
[ "\\", "Returns", "an", "iterable", "of", "integers", "interpreting", "the", "content", "of", "seq", "as", "sequence", "of", "binary", "numbers", "of", "length", "8", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L1735-L1744
train
heuer/segno
segno/colors.py
color_to_webcolor
def color_to_webcolor(color, allow_css3_colors=True, optimize=True): """\ Returns either a hexadecimal code or a color name. :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or ``(R, G, B, A)``)...
python
def color_to_webcolor(color, allow_css3_colors=True, optimize=True): """\ Returns either a hexadecimal code or a color name. :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or ``(R, G, B, A)``)...
[ "def", "color_to_webcolor", "(", "color", ",", "allow_css3_colors", "=", "True", ",", "optimize", "=", "True", ")", ":", "if", "color_is_black", "(", "color", ")", ":", "return", "'#000'", "elif", "color_is_white", "(", "color", ")", ":", "return", "'#fff'",...
\ Returns either a hexadecimal code or a color name. :param color: A web color name (i.e. ``darkblue``) or a hexadecimal value (``#RGB`` or ``#RRGGBB``) or a RGB(A) tuple (i.e. ``(R, G, B)`` or ``(R, G, B, A)``) :param bool allow_css3_colors: Indicates if a CSS3 color value like ...
[ "\\", "Returns", "either", "a", "hexadecimal", "code", "or", "a", "color", "name", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/colors.py#L35-L69
train
heuer/segno
segno/utils.py
check_valid_border
def check_valid_border(border): """\ Raises a ValueError iff `border` is negative. :param int border: Indicating the size of the quiet zone. """ if border is not None and (int(border) != border or border < 0): raise ValueError('The border must not a non-negative integer value. ' ...
python
def check_valid_border(border): """\ Raises a ValueError iff `border` is negative. :param int border: Indicating the size of the quiet zone. """ if border is not None and (int(border) != border or border < 0): raise ValueError('The border must not a non-negative integer value. ' ...
[ "def", "check_valid_border", "(", "border", ")", ":", "if", "border", "is", "not", "None", "and", "(", "int", "(", "border", ")", "!=", "border", "or", "border", "<", "0", ")", ":", "raise", "ValueError", "(", "'The border must not a non-negative integer value...
\ Raises a ValueError iff `border` is negative. :param int border: Indicating the size of the quiet zone.
[ "\\", "Raises", "a", "ValueError", "iff", "border", "is", "negative", "." ]
64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/utils.py#L79-L87
train
CyberReboot/vent
vent/menu.py
VentApp.onStart
def onStart(self): """ Override onStart method for npyscreen """ curses.mousemask(0) self.paths.host_config() version = Version() # setup initial runtime stuff if self.first_time[0] and self.first_time[1] != 'exists': system = System() thr = Threa...
python
def onStart(self): """ Override onStart method for npyscreen """ curses.mousemask(0) self.paths.host_config() version = Version() # setup initial runtime stuff if self.first_time[0] and self.first_time[1] != 'exists': system = System() thr = Threa...
[ "def", "onStart", "(", "self", ")", ":", "curses", ".", "mousemask", "(", "0", ")", "self", ".", "paths", ".", "host_config", "(", ")", "version", "=", "Version", "(", ")", "if", "self", ".", "first_time", "[", "0", "]", "and", "self", ".", "first_...
Override onStart method for npyscreen
[ "Override", "onStart", "method", "for", "npyscreen" ]
9956a09146b11a89a0eabab3bc7ce8906d124885
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menu.py#L35-L97
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.setGroups
def setGroups(self, groups, kerningGroupConversionRenameMaps=None): """ Copy the groups into our font. """ skipping = [] for name, members in groups.items(): checked = [] for m in members: if m in self.font: checked.append(m) ...
python
def setGroups(self, groups, kerningGroupConversionRenameMaps=None): """ Copy the groups into our font. """ skipping = [] for name, members in groups.items(): checked = [] for m in members: if m in self.font: checked.append(m) ...
[ "def", "setGroups", "(", "self", ",", "groups", ",", "kerningGroupConversionRenameMaps", "=", "None", ")", ":", "skipping", "=", "[", "]", "for", "name", ",", "members", "in", "groups", ".", "items", "(", ")", ":", "checked", "=", "[", "]", "for", "m",...
Copy the groups into our font.
[ "Copy", "the", "groups", "into", "our", "font", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L80-L100
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.setLib
def setLib(self, lib): """ Copy the lib items into our font. """ for name, item in lib.items(): self.font.lib[name] = item
python
def setLib(self, lib): """ Copy the lib items into our font. """ for name, item in lib.items(): self.font.lib[name] = item
[ "def", "setLib", "(", "self", ",", "lib", ")", ":", "for", "name", ",", "item", "in", "lib", ".", "items", "(", ")", ":", "self", ".", "font", ".", "lib", "[", "name", "]", "=", "item" ]
Copy the lib items into our font.
[ "Copy", "the", "lib", "items", "into", "our", "font", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L110-L113
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.copyFeatures
def copyFeatures(self, featureSource): """ Copy the features from this source """ if featureSource in self.sources: src, loc = self.sources[featureSource] if isinstance(src.features.text, str): self.font.features.text = u""+src.features.text elif isins...
python
def copyFeatures(self, featureSource): """ Copy the features from this source """ if featureSource in self.sources: src, loc = self.sources[featureSource] if isinstance(src.features.text, str): self.font.features.text = u""+src.features.text elif isins...
[ "def", "copyFeatures", "(", "self", ",", "featureSource", ")", ":", "if", "featureSource", "in", "self", ".", "sources", ":", "src", ",", "loc", "=", "self", ".", "sources", "[", "featureSource", "]", "if", "isinstance", "(", "src", ".", "features", ".",...
Copy the features from this source
[ "Copy", "the", "features", "from", "this", "source" ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L135-L142
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.makeUnicodeMapFromSources
def makeUnicodeMapFromSources(self): """ Create a dict with glyphName -> unicode value pairs using the data in the sources. If all master glyphs have the same unicode value this value will be used in the map. If master glyphs have conflicting value, a warning wil...
python
def makeUnicodeMapFromSources(self): """ Create a dict with glyphName -> unicode value pairs using the data in the sources. If all master glyphs have the same unicode value this value will be used in the map. If master glyphs have conflicting value, a warning wil...
[ "def", "makeUnicodeMapFromSources", "(", "self", ")", ":", "values", "=", "{", "}", "for", "locationName", ",", "(", "source", ",", "loc", ")", "in", "self", ".", "sources", ".", "items", "(", ")", ":", "for", "glyph", "in", "source", ":", "if", "gly...
Create a dict with glyphName -> unicode value pairs using the data in the sources. If all master glyphs have the same unicode value this value will be used in the map. If master glyphs have conflicting value, a warning will be printed, no value will be used. ...
[ "Create", "a", "dict", "with", "glyphName", "-", ">", "unicode", "value", "pairs", "using", "the", "data", "in", "the", "sources", ".", "If", "all", "master", "glyphs", "have", "the", "same", "unicode", "value", "this", "value", "will", "be", "used", "in...
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L144-L169
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.getAvailableGlyphnames
def getAvailableGlyphnames(self): """ Return a list of all glyphnames we have masters for.""" glyphNames = {} for locationName, (source, loc) in self.sources.items(): for glyph in source: glyphNames[glyph.name] = 1 names = sorted(glyphNames.keys()) ret...
python
def getAvailableGlyphnames(self): """ Return a list of all glyphnames we have masters for.""" glyphNames = {} for locationName, (source, loc) in self.sources.items(): for glyph in source: glyphNames[glyph.name] = 1 names = sorted(glyphNames.keys()) ret...
[ "def", "getAvailableGlyphnames", "(", "self", ")", ":", "glyphNames", "=", "{", "}", "for", "locationName", ",", "(", "source", ",", "loc", ")", "in", "self", ".", "sources", ".", "items", "(", ")", ":", "for", "glyph", "in", "source", ":", "glyphNames...
Return a list of all glyphnames we have masters for.
[ "Return", "a", "list", "of", "all", "glyphnames", "we", "have", "masters", "for", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L171-L178
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.addInfo
def addInfo(self, instanceLocation=None, sources=None, copySourceName=None): """ Add font info data. """ if instanceLocation is None: instanceLocation = self.locationObject infoObject = self.font.info infoMasters = [] if sources is None: sources = self.sou...
python
def addInfo(self, instanceLocation=None, sources=None, copySourceName=None): """ Add font info data. """ if instanceLocation is None: instanceLocation = self.locationObject infoObject = self.font.info infoMasters = [] if sources is None: sources = self.sou...
[ "def", "addInfo", "(", "self", ",", "instanceLocation", "=", "None", ",", "sources", "=", "None", ",", "copySourceName", "=", "None", ")", ":", "if", "instanceLocation", "is", "None", ":", "instanceLocation", "=", "self", ".", "locationObject", "infoObject", ...
Add font info data.
[ "Add", "font", "info", "data", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L184-L219
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter._copyFontInfo
def _copyFontInfo(self, targetInfo, sourceInfo): """ Copy the non-calculating fields from the source info. """ infoAttributes = [ "versionMajor", "versionMinor", "copyright", "trademark", "note", "openTypeGaspRangeRecords", ...
python
def _copyFontInfo(self, targetInfo, sourceInfo): """ Copy the non-calculating fields from the source info. """ infoAttributes = [ "versionMajor", "versionMinor", "copyright", "trademark", "note", "openTypeGaspRangeRecords", ...
[ "def", "_copyFontInfo", "(", "self", ",", "targetInfo", ",", "sourceInfo", ")", ":", "infoAttributes", "=", "[", "\"versionMajor\"", ",", "\"versionMinor\"", ",", "\"copyright\"", ",", "\"trademark\"", ",", "\"note\"", ",", "\"openTypeGaspRangeRecords\"", ",", "\"op...
Copy the non-calculating fields from the source info.
[ "Copy", "the", "non", "-", "calculating", "fields", "from", "the", "source", "info", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L221-L271
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter._calculateGlyph
def _calculateGlyph(self, targetGlyphObject, instanceLocationObject, glyphMasters): """ Build a Mutator object for this glyph. * name: glyphName * location: Location object * glyphMasters: dict with font objects. """ sources = None items = []...
python
def _calculateGlyph(self, targetGlyphObject, instanceLocationObject, glyphMasters): """ Build a Mutator object for this glyph. * name: glyphName * location: Location object * glyphMasters: dict with font objects. """ sources = None items = []...
[ "def", "_calculateGlyph", "(", "self", ",", "targetGlyphObject", ",", "instanceLocationObject", ",", "glyphMasters", ")", ":", "sources", "=", "None", "items", "=", "[", "]", "for", "item", "in", "glyphMasters", ":", "locationObject", "=", "item", "[", "'locat...
Build a Mutator object for this glyph. * name: glyphName * location: Location object * glyphMasters: dict with font objects.
[ "Build", "a", "Mutator", "object", "for", "this", "glyph", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L351-L388
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
InstanceWriter.save
def save(self): """ Save the UFO.""" # handle glyphs that were muted for name in self.mutedGlyphsNames: if name not in self.font: continue if self.logger: self.logger.info("removing muted glyph %s", name) del self.font[name] # XXX ...
python
def save(self): """ Save the UFO.""" # handle glyphs that were muted for name in self.mutedGlyphsNames: if name not in self.font: continue if self.logger: self.logger.info("removing muted glyph %s", name) del self.font[name] # XXX ...
[ "def", "save", "(", "self", ")", ":", "for", "name", "in", "self", ".", "mutedGlyphsNames", ":", "if", "name", "not", "in", "self", ".", "font", ":", "continue", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "info", "(", "\"removing m...
Save the UFO.
[ "Save", "the", "UFO", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L390-L418
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentWriter.save
def save(self, pretty=True): """ Save the xml. Make pretty if necessary. """ self.endInstance() if pretty: _indent(self.root, whitespace=self._whiteSpace) tree = ET.ElementTree(self.root) tree.write(self.path, encoding="utf-8", method='xml', xml_declaration=True) ...
python
def save(self, pretty=True): """ Save the xml. Make pretty if necessary. """ self.endInstance() if pretty: _indent(self.root, whitespace=self._whiteSpace) tree = ET.ElementTree(self.root) tree.write(self.path, encoding="utf-8", method='xml', xml_declaration=True) ...
[ "def", "save", "(", "self", ",", "pretty", "=", "True", ")", ":", "self", ".", "endInstance", "(", ")", "if", "pretty", ":", "_indent", "(", "self", ".", "root", ",", "whitespace", "=", "self", ".", "_whiteSpace", ")", "tree", "=", "ET", ".", "Elem...
Save the xml. Make pretty if necessary.
[ "Save", "the", "xml", ".", "Make", "pretty", "if", "necessary", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L73-L81
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentWriter._makeLocationElement
def _makeLocationElement(self, locationObject, name=None): """ Convert Location object to an locationElement.""" locElement = ET.Element("location") if name is not None: locElement.attrib['name'] = name for dimensionName, dimensionValue in locationObject.items(): d...
python
def _makeLocationElement(self, locationObject, name=None): """ Convert Location object to an locationElement.""" locElement = ET.Element("location") if name is not None: locElement.attrib['name'] = name for dimensionName, dimensionValue in locationObject.items(): d...
[ "def", "_makeLocationElement", "(", "self", ",", "locationObject", ",", "name", "=", "None", ")", ":", "locElement", "=", "ET", ".", "Element", "(", "\"location\"", ")", "if", "name", "is", "not", "None", ":", "locElement", ".", "attrib", "[", "'name'", ...
Convert Location object to an locationElement.
[ "Convert", "Location", "object", "to", "an", "locationElement", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L83-L98
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.reportProgress
def reportProgress(self, state, action, text=None, tick=None): """ If we want to keep other code updated about our progress. state: 'prep' reading sources 'generate' making instances 'done' wrapping up 'error' ...
python
def reportProgress(self, state, action, text=None, tick=None): """ If we want to keep other code updated about our progress. state: 'prep' reading sources 'generate' making instances 'done' wrapping up 'error' ...
[ "def", "reportProgress", "(", "self", ",", "state", ",", "action", ",", "text", "=", "None", ",", "tick", "=", "None", ")", ":", "if", "self", ".", "progressFunc", "is", "not", "None", ":", "self", ".", "progressFunc", "(", "state", "=", "state", ","...
If we want to keep other code updated about our progress. state: 'prep' reading sources 'generate' making instances 'done' wrapping up 'error' reporting a problem action: 'start' begin generatin...
[ "If", "we", "want", "to", "keep", "other", "code", "updated", "about", "our", "progress", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L411-L428
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.getSourcePaths
def getSourcePaths(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Return a list of paths referenced in the document.""" paths = [] for name in self.sources.keys(): paths.append(self.sources[name][0].path) return paths
python
def getSourcePaths(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Return a list of paths referenced in the document.""" paths = [] for name in self.sources.keys(): paths.append(self.sources[name][0].path) return paths
[ "def", "getSourcePaths", "(", "self", ",", "makeGlyphs", "=", "True", ",", "makeKerning", "=", "True", ",", "makeInfo", "=", "True", ")", ":", "paths", "=", "[", "]", "for", "name", "in", "self", ".", "sources", ".", "keys", "(", ")", ":", "paths", ...
Return a list of paths referenced in the document.
[ "Return", "a", "list", "of", "paths", "referenced", "in", "the", "document", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L430-L435
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.process
def process(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Process the input file and generate the instances. """ if self.logger: self.logger.info("Reading %s", self.path) self.readInstances(makeGlyphs=makeGlyphs, makeKerning=makeKerning, makeInfo=makeInfo) self...
python
def process(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Process the input file and generate the instances. """ if self.logger: self.logger.info("Reading %s", self.path) self.readInstances(makeGlyphs=makeGlyphs, makeKerning=makeKerning, makeInfo=makeInfo) self...
[ "def", "process", "(", "self", ",", "makeGlyphs", "=", "True", ",", "makeKerning", "=", "True", ",", "makeInfo", "=", "True", ")", ":", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "info", "(", "\"Reading %s\"", ",", "self", ".", "pa...
Process the input file and generate the instances.
[ "Process", "the", "input", "file", "and", "generate", "the", "instances", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L437-L442
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readWarp
def readWarp(self): """ Read the warp element :: <warp> <axis name="weight"> <map input="0" output="0" /> <map input="500" output="200" /> <map input="1000" output="1000" /> </axis> </war...
python
def readWarp(self): """ Read the warp element :: <warp> <axis name="weight"> <map input="0" output="0" /> <map input="500" output="200" /> <map input="1000" output="1000" /> </axis> </war...
[ "def", "readWarp", "(", "self", ")", ":", "warpDict", "=", "{", "}", "for", "warpAxisElement", "in", "self", ".", "root", ".", "findall", "(", "\".warp/axis\"", ")", ":", "axisName", "=", "warpAxisElement", ".", "attrib", ".", "get", "(", "\"name\"", ")"...
Read the warp element :: <warp> <axis name="weight"> <map input="0" output="0" /> <map input="500" output="200" /> <map input="1000" output="1000" /> </axis> </warp>
[ "Read", "the", "warp", "element" ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L457-L478
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readAxes
def readAxes(self): """ Read the axes element. """ for axisElement in self.root.findall(".axes/axis"): axis = {} axis['name'] = name = axisElement.attrib.get("name") axis['tag'] = axisElement.attrib.get("tag") axis['minimum'] = float(axisElement.at...
python
def readAxes(self): """ Read the axes element. """ for axisElement in self.root.findall(".axes/axis"): axis = {} axis['name'] = name = axisElement.attrib.get("name") axis['tag'] = axisElement.attrib.get("tag") axis['minimum'] = float(axisElement.at...
[ "def", "readAxes", "(", "self", ")", ":", "for", "axisElement", "in", "self", ".", "root", ".", "findall", "(", "\".axes/axis\"", ")", ":", "axis", "=", "{", "}", "axis", "[", "'name'", "]", "=", "name", "=", "axisElement", ".", "attrib", ".", "get",...
Read the axes element.
[ "Read", "the", "axes", "element", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L480-L499
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readSources
def readSources(self): """ Read the source elements. :: <source filename="LightCondensed.ufo" location="location-token-aaa" name="master-token-aaa1"> <info mute="1" copy="1"/> <kerning mute="1"/> <glyph mute="1" name="thirdGlyph"/> ...
python
def readSources(self): """ Read the source elements. :: <source filename="LightCondensed.ufo" location="location-token-aaa" name="master-token-aaa1"> <info mute="1" copy="1"/> <kerning mute="1"/> <glyph mute="1" name="thirdGlyph"/> ...
[ "def", "readSources", "(", "self", ")", ":", "for", "sourceCount", ",", "sourceElement", "in", "enumerate", "(", "self", ".", "root", ".", "findall", "(", "\".sources/source\"", ")", ")", ":", "filename", "=", "sourceElement", ".", "attrib", ".", "get", "(...
Read the source elements. :: <source filename="LightCondensed.ufo" location="location-token-aaa" name="master-token-aaa1"> <info mute="1" copy="1"/> <kerning mute="1"/> <glyph mute="1" name="thirdGlyph"/> </source>
[ "Read", "the", "source", "elements", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L501-L576
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.locationFromElement
def locationFromElement(self, element): """ Find the MutatorMath location of this element, either by name or from a child element. """ elementLocation = None for locationElement in element.findall('.location'): elementLocation = self.readLocationElement(locationEl...
python
def locationFromElement(self, element): """ Find the MutatorMath location of this element, either by name or from a child element. """ elementLocation = None for locationElement in element.findall('.location'): elementLocation = self.readLocationElement(locationEl...
[ "def", "locationFromElement", "(", "self", ",", "element", ")", ":", "elementLocation", "=", "None", "for", "locationElement", "in", "element", ".", "findall", "(", "'.location'", ")", ":", "elementLocation", "=", "self", ".", "readLocationElement", "(", "locati...
Find the MutatorMath location of this element, either by name or from a child element.
[ "Find", "the", "MutatorMath", "location", "of", "this", "element", "either", "by", "name", "or", "from", "a", "child", "element", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L578-L586
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readInstance
def readInstance(self, key, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Read a single instance element. key: an (attribute, value) tuple used to find the requested instance. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-...
python
def readInstance(self, key, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Read a single instance element. key: an (attribute, value) tuple used to find the requested instance. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-...
[ "def", "readInstance", "(", "self", ",", "key", ",", "makeGlyphs", "=", "True", ",", "makeKerning", "=", "True", ",", "makeInfo", "=", "True", ")", ":", "attrib", ",", "value", "=", "key", "for", "instanceElement", "in", "self", ".", "root", ".", "find...
Read a single instance element. key: an (attribute, value) tuple used to find the requested instance. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular">
[ "Read", "a", "single", "instance", "element", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L612-L627
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readInstances
def readInstances(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Read all instance elements. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular"> """ for instanceElement in self.root.finda...
python
def readInstances(self, makeGlyphs=True, makeKerning=True, makeInfo=True): """ Read all instance elements. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular"> """ for instanceElement in self.root.finda...
[ "def", "readInstances", "(", "self", ",", "makeGlyphs", "=", "True", ",", "makeKerning", "=", "True", ",", "makeInfo", "=", "True", ")", ":", "for", "instanceElement", "in", "self", ".", "root", ".", "findall", "(", "'.instances/instance'", ")", ":", "self...
Read all instance elements. :: <instance familyname="SuperFamily" filename="OutputNameInstance1.ufo" location="location-token-aaa" stylename="Regular">
[ "Read", "all", "instance", "elements", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L629-L638
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readInfoElement
def readInfoElement(self, infoElement, instanceObject): """ Read the info element. :: <info/> <info"> <location/> </info> """ infoLocation = self.locationFromElement(infoElement) instanceObject.addInfo(in...
python
def readInfoElement(self, infoElement, instanceObject): """ Read the info element. :: <info/> <info"> <location/> </info> """ infoLocation = self.locationFromElement(infoElement) instanceObject.addInfo(in...
[ "def", "readInfoElement", "(", "self", ",", "infoElement", ",", "instanceObject", ")", ":", "infoLocation", "=", "self", ".", "locationFromElement", "(", "infoElement", ")", "instanceObject", ".", "addInfo", "(", "infoLocation", ",", "copySourceName", "=", "self",...
Read the info element. :: <info/> <info"> <location/> </info>
[ "Read", "the", "info", "element", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L765-L778
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readKerningElement
def readKerningElement(self, kerningElement, instanceObject): """ Read the kerning element. :: Make kerning at the location and with the masters specified at the instance level. <kerning/> """ kerningLocation = self.locationFromElement(kerningElement) ...
python
def readKerningElement(self, kerningElement, instanceObject): """ Read the kerning element. :: Make kerning at the location and with the masters specified at the instance level. <kerning/> """ kerningLocation = self.locationFromElement(kerningElement) ...
[ "def", "readKerningElement", "(", "self", ",", "kerningElement", ",", "instanceObject", ")", ":", "kerningLocation", "=", "self", ".", "locationFromElement", "(", "kerningElement", ")", "instanceObject", ".", "addKerning", "(", "kerningLocation", ")" ]
Read the kerning element. :: Make kerning at the location and with the masters specified at the instance level. <kerning/>
[ "Read", "the", "kerning", "element", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L780-L790
train
LettError/MutatorMath
Lib/mutatorMath/ufo/document.py
DesignSpaceDocumentReader.readGlyphElement
def readGlyphElement(self, glyphElement, instanceObject): """ Read the glyph element. :: <glyph name="b" unicode="0x62"/> <glyph name="b"/> <glyph name="b"> <master location="location-token-bbb" source="master-token-aaa2"/> ...
python
def readGlyphElement(self, glyphElement, instanceObject): """ Read the glyph element. :: <glyph name="b" unicode="0x62"/> <glyph name="b"/> <glyph name="b"> <master location="location-token-bbb" source="master-token-aaa2"/> ...
[ "def", "readGlyphElement", "(", "self", ",", "glyphElement", ",", "instanceObject", ")", ":", "glyphName", "=", "glyphElement", ".", "attrib", ".", "get", "(", "'name'", ")", "if", "glyphName", "is", "None", ":", "raise", "MutatorError", "(", "\"Glyph object w...
Read the glyph element. :: <glyph name="b" unicode="0x62"/> <glyph name="b"/> <glyph name="b"> <master location="location-token-bbb" source="master-token-aaa2"/> <master glyphname="b.alt1" location="location-token-ccc" source="master-token-...
[ "Read", "the", "glyph", "element", "." ]
10318fc4e7c9cee9df6130826829baea3054a42b
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/document.py#L792-L865
train
viralogic/py-enumerable
py_linq/py_linq.py
Enumerable.group_by
def group_by(self, key_names=[], key=lambda x: x, result_func=lambda x: x): """ Groups an enumerable on given key selector. Index of key name corresponds to index of key lambda function. Usage: Enumerable([1,2,3]).group_by(key_names=['id'], key=lambda x: x) _ ...
python
def group_by(self, key_names=[], key=lambda x: x, result_func=lambda x: x): """ Groups an enumerable on given key selector. Index of key name corresponds to index of key lambda function. Usage: Enumerable([1,2,3]).group_by(key_names=['id'], key=lambda x: x) _ ...
[ "def", "group_by", "(", "self", ",", "key_names", "=", "[", "]", ",", "key", "=", "lambda", "x", ":", "x", ",", "result_func", "=", "lambda", "x", ":", "x", ")", ":", "result", "=", "[", "]", "ordered", "=", "sorted", "(", "self", ",", "key", "...
Groups an enumerable on given key selector. Index of key name corresponds to index of key lambda function. Usage: Enumerable([1,2,3]).group_by(key_names=['id'], key=lambda x: x) _ .to_list() --> Enumerable object [ Grouping object { ...
[ "Groups", "an", "enumerable", "on", "given", "key", "selector", ".", "Index", "of", "key", "name", "corresponds", "to", "index", "of", "key", "lambda", "function", "." ]
63363649bccef223379e1e87056747240c83aa9d
https://github.com/viralogic/py-enumerable/blob/63363649bccef223379e1e87056747240c83aa9d/py_linq/py_linq.py#L287-L331
train
CyberReboot/vent
vent/api/tools.py
Tools.inventory
def inventory(self, choices=None): """ Return a dictionary of the inventory items and status """ status = (True, None) if not choices: return (False, 'No choices made') try: # choices: repos, tools, images, built, running, enabled items = {'repos': [],...
python
def inventory(self, choices=None): """ Return a dictionary of the inventory items and status """ status = (True, None) if not choices: return (False, 'No choices made') try: # choices: repos, tools, images, built, running, enabled items = {'repos': [],...
[ "def", "inventory", "(", "self", ",", "choices", "=", "None", ")", ":", "status", "=", "(", "True", ",", "None", ")", "if", "not", "choices", ":", "return", "(", "False", ",", "'No choices made'", ")", "try", ":", "items", "=", "{", "'repos'", ":", ...
Return a dictionary of the inventory items and status
[ "Return", "a", "dictionary", "of", "the", "inventory", "items", "and", "status" ]
9956a09146b11a89a0eabab3bc7ce8906d124885
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/api/tools.py#L90-L145
train
CyberReboot/vent
vent/api/tools.py
Tools._start_priority_containers
def _start_priority_containers(self, groups, group_orders, tool_d): """ Select containers based on priorities to start """ vent_cfg = Template(self.path_dirs.cfg_file) cfg_groups = vent_cfg.option('groups', 'start_order') if cfg_groups[0]: cfg_groups = cfg_groups[1].split(','...
python
def _start_priority_containers(self, groups, group_orders, tool_d): """ Select containers based on priorities to start """ vent_cfg = Template(self.path_dirs.cfg_file) cfg_groups = vent_cfg.option('groups', 'start_order') if cfg_groups[0]: cfg_groups = cfg_groups[1].split(','...
[ "def", "_start_priority_containers", "(", "self", ",", "groups", ",", "group_orders", ",", "tool_d", ")", ":", "vent_cfg", "=", "Template", "(", "self", ".", "path_dirs", ".", "cfg_file", ")", "cfg_groups", "=", "vent_cfg", ".", "option", "(", "'groups'", ",...
Select containers based on priorities to start
[ "Select", "containers", "based", "on", "priorities", "to", "start" ]
9956a09146b11a89a0eabab3bc7ce8906d124885
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/api/tools.py#L651-L683
train