repository_name
stringlengths 7
55
| func_path_in_repository
stringlengths 4
223
| func_name
stringlengths 1
134
| whole_func_string
stringlengths 75
104k
| language
stringclasses 1
value | func_code_string
stringlengths 75
104k
| func_code_tokens
sequencelengths 19
28.4k
| func_documentation_string
stringlengths 1
46.9k
| func_documentation_tokens
sequencelengths 1
1.97k
| split_name
stringclasses 1
value | func_code_url
stringlengths 87
315
|
---|---|---|---|---|---|---|---|---|---|---|
sci-bots/svg-model | svg_model/__init__.py | remove_layer | def remove_layer(svg_source, layer_name):
'''
Remove layer(s) from SVG document.
Arguments
---------
svg_source : str or file-like
A file path, URI, or file-like object.
layer_name : str or list
Layer name or list of layer names to remove from SVG document.
Returns
-------
StringIO.StringIO
File-like object containing XML document with layer(s) removed.
'''
# Parse input file.
xml_root = lxml.etree.parse(svg_source)
svg_root = xml_root.xpath('/svg:svg', namespaces=INKSCAPE_NSMAP)[0]
if isinstance(layer_name, str):
layer_name = [layer_name]
for layer_name_i in layer_name:
# Remove existing layer from source, in-memory XML (source file remains
# unmodified).
layer_xpath = '//svg:g[@inkscape:label="%s"]' % layer_name_i
layer_groups = svg_root.xpath(layer_xpath, namespaces=INKSCAPE_NSMAP)
if layer_groups:
for g in layer_groups:
g.getparent().remove(g)
# Write result to `StringIO`.
output = StringIO.StringIO()
xml_root.write(output)
output.seek(0)
return output | python | def remove_layer(svg_source, layer_name):
'''
Remove layer(s) from SVG document.
Arguments
---------
svg_source : str or file-like
A file path, URI, or file-like object.
layer_name : str or list
Layer name or list of layer names to remove from SVG document.
Returns
-------
StringIO.StringIO
File-like object containing XML document with layer(s) removed.
'''
# Parse input file.
xml_root = lxml.etree.parse(svg_source)
svg_root = xml_root.xpath('/svg:svg', namespaces=INKSCAPE_NSMAP)[0]
if isinstance(layer_name, str):
layer_name = [layer_name]
for layer_name_i in layer_name:
# Remove existing layer from source, in-memory XML (source file remains
# unmodified).
layer_xpath = '//svg:g[@inkscape:label="%s"]' % layer_name_i
layer_groups = svg_root.xpath(layer_xpath, namespaces=INKSCAPE_NSMAP)
if layer_groups:
for g in layer_groups:
g.getparent().remove(g)
# Write result to `StringIO`.
output = StringIO.StringIO()
xml_root.write(output)
output.seek(0)
return output | [
"def",
"remove_layer",
"(",
"svg_source",
",",
"layer_name",
")",
":",
"# Parse input file.",
"xml_root",
"=",
"lxml",
".",
"etree",
".",
"parse",
"(",
"svg_source",
")",
"svg_root",
"=",
"xml_root",
".",
"xpath",
"(",
"'/svg:svg'",
",",
"namespaces",
"=",
"INKSCAPE_NSMAP",
")",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"layer_name",
",",
"str",
")",
":",
"layer_name",
"=",
"[",
"layer_name",
"]",
"for",
"layer_name_i",
"in",
"layer_name",
":",
"# Remove existing layer from source, in-memory XML (source file remains",
"# unmodified).",
"layer_xpath",
"=",
"'//svg:g[@inkscape:label=\"%s\"]'",
"%",
"layer_name_i",
"layer_groups",
"=",
"svg_root",
".",
"xpath",
"(",
"layer_xpath",
",",
"namespaces",
"=",
"INKSCAPE_NSMAP",
")",
"if",
"layer_groups",
":",
"for",
"g",
"in",
"layer_groups",
":",
"g",
".",
"getparent",
"(",
")",
".",
"remove",
"(",
"g",
")",
"# Write result to `StringIO`.",
"output",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"xml_root",
".",
"write",
"(",
"output",
")",
"output",
".",
"seek",
"(",
"0",
")",
"return",
"output"
] | Remove layer(s) from SVG document.
Arguments
---------
svg_source : str or file-like
A file path, URI, or file-like object.
layer_name : str or list
Layer name or list of layer names to remove from SVG document.
Returns
-------
StringIO.StringIO
File-like object containing XML document with layer(s) removed. | [
"Remove",
"layer",
"(",
"s",
")",
"from",
"SVG",
"document",
"."
] | train | https://github.com/sci-bots/svg-model/blob/2d119650f995e62b29ce0b3151a23f3b957cb072/svg_model/__init__.py#L408-L445 |
BlueBrain/hpcbench | hpcbench/toolbox/loader.py | load_eggs | def load_eggs(entry_point_name):
"""Loader that loads any eggs in `sys.path`."""
def _load_eggs():
distributions, errors = working_set.find_plugins(Environment())
for dist in distributions:
# pylint: disable=unsupported-membership-test
if dist not in working_set:
LOGGER.debug('Adding plugin %s from %s', dist, dist.location)
working_set.add(dist)
def _log_error(item, err):
if isinstance(err, DistributionNotFound):
LOGGER.debug('Skipping "%s": ("%s" not found)', item, err)
elif isinstance(err, VersionConflict):
LOGGER.error('Skipping "%s": (version conflict "%s")', item, err)
elif isinstance(err, UnknownExtra):
LOGGER.error('Skipping "%s": (unknown extra "%s")', item, err)
else:
LOGGER.error('Skipping "%s": %s', item, err)
for dist, err in errors.items():
_log_error(dist, err)
for entry in sorted(
working_set.iter_entry_points(entry_point_name),
key=lambda entry: entry.name,
):
try:
entry.load(require=True)
except Exception as exc: # pylint: disable=broad-except
_log_error(entry, exc)
return _load_eggs | python | def load_eggs(entry_point_name):
"""Loader that loads any eggs in `sys.path`."""
def _load_eggs():
distributions, errors = working_set.find_plugins(Environment())
for dist in distributions:
# pylint: disable=unsupported-membership-test
if dist not in working_set:
LOGGER.debug('Adding plugin %s from %s', dist, dist.location)
working_set.add(dist)
def _log_error(item, err):
if isinstance(err, DistributionNotFound):
LOGGER.debug('Skipping "%s": ("%s" not found)', item, err)
elif isinstance(err, VersionConflict):
LOGGER.error('Skipping "%s": (version conflict "%s")', item, err)
elif isinstance(err, UnknownExtra):
LOGGER.error('Skipping "%s": (unknown extra "%s")', item, err)
else:
LOGGER.error('Skipping "%s": %s', item, err)
for dist, err in errors.items():
_log_error(dist, err)
for entry in sorted(
working_set.iter_entry_points(entry_point_name),
key=lambda entry: entry.name,
):
try:
entry.load(require=True)
except Exception as exc: # pylint: disable=broad-except
_log_error(entry, exc)
return _load_eggs | [
"def",
"load_eggs",
"(",
"entry_point_name",
")",
":",
"def",
"_load_eggs",
"(",
")",
":",
"distributions",
",",
"errors",
"=",
"working_set",
".",
"find_plugins",
"(",
"Environment",
"(",
")",
")",
"for",
"dist",
"in",
"distributions",
":",
"# pylint: disable=unsupported-membership-test",
"if",
"dist",
"not",
"in",
"working_set",
":",
"LOGGER",
".",
"debug",
"(",
"'Adding plugin %s from %s'",
",",
"dist",
",",
"dist",
".",
"location",
")",
"working_set",
".",
"add",
"(",
"dist",
")",
"def",
"_log_error",
"(",
"item",
",",
"err",
")",
":",
"if",
"isinstance",
"(",
"err",
",",
"DistributionNotFound",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Skipping \"%s\": (\"%s\" not found)'",
",",
"item",
",",
"err",
")",
"elif",
"isinstance",
"(",
"err",
",",
"VersionConflict",
")",
":",
"LOGGER",
".",
"error",
"(",
"'Skipping \"%s\": (version conflict \"%s\")'",
",",
"item",
",",
"err",
")",
"elif",
"isinstance",
"(",
"err",
",",
"UnknownExtra",
")",
":",
"LOGGER",
".",
"error",
"(",
"'Skipping \"%s\": (unknown extra \"%s\")'",
",",
"item",
",",
"err",
")",
"else",
":",
"LOGGER",
".",
"error",
"(",
"'Skipping \"%s\": %s'",
",",
"item",
",",
"err",
")",
"for",
"dist",
",",
"err",
"in",
"errors",
".",
"items",
"(",
")",
":",
"_log_error",
"(",
"dist",
",",
"err",
")",
"for",
"entry",
"in",
"sorted",
"(",
"working_set",
".",
"iter_entry_points",
"(",
"entry_point_name",
")",
",",
"key",
"=",
"lambda",
"entry",
":",
"entry",
".",
"name",
",",
")",
":",
"try",
":",
"entry",
".",
"load",
"(",
"require",
"=",
"True",
")",
"except",
"Exception",
"as",
"exc",
":",
"# pylint: disable=broad-except",
"_log_error",
"(",
"entry",
",",
"exc",
")",
"return",
"_load_eggs"
] | Loader that loads any eggs in `sys.path`. | [
"Loader",
"that",
"loads",
"any",
"eggs",
"in",
"sys",
".",
"path",
"."
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/toolbox/loader.py#L18-L51 |
Capitains/Nautilus | capitains_nautilus/cts/collections.py | SparqlXmlCitation.refsDecl | def refsDecl(self):
""" ResfDecl expression of the citation scheme
:rtype: str
:Example: /tei:TEI/tei:text/tei:body/tei:div//tei:l[@n='$1']
"""
for refsDecl in self.graph.objects(self.asNode(), RDF_NAMESPACES.TEI.replacementPattern):
return str(refsDecl) | python | def refsDecl(self):
""" ResfDecl expression of the citation scheme
:rtype: str
:Example: /tei:TEI/tei:text/tei:body/tei:div//tei:l[@n='$1']
"""
for refsDecl in self.graph.objects(self.asNode(), RDF_NAMESPACES.TEI.replacementPattern):
return str(refsDecl) | [
"def",
"refsDecl",
"(",
"self",
")",
":",
"for",
"refsDecl",
"in",
"self",
".",
"graph",
".",
"objects",
"(",
"self",
".",
"asNode",
"(",
")",
",",
"RDF_NAMESPACES",
".",
"TEI",
".",
"replacementPattern",
")",
":",
"return",
"str",
"(",
"refsDecl",
")"
] | ResfDecl expression of the citation scheme
:rtype: str
:Example: /tei:TEI/tei:text/tei:body/tei:div//tei:l[@n='$1'] | [
"ResfDecl",
"expression",
"of",
"the",
"citation",
"scheme"
] | train | https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/cts/collections.py#L108-L115 |
KelSolaar/Manager | manager/components_manager.py | Profile.file | def file(self, value):
"""
Setter for **self.__file** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format("file", value)
self.__file = value | python | def file(self, value):
"""
Setter for **self.__file** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format("file", value)
self.__file = value | [
"def",
"file",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"file\"",
",",
"value",
")",
"self",
".",
"__file",
"=",
"value"
] | Setter for **self.__file** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__file",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L154-L164 |
KelSolaar/Manager | manager/components_manager.py | Profile.directory | def directory(self, value):
"""
Setter for **self.__directory** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"directory", value)
assert os.path.exists(value), "'{0}' attribute: '{1}' directory doesn't exists!".format("directory", value)
self.__directory = value | python | def directory(self, value):
"""
Setter for **self.__directory** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"directory", value)
assert os.path.exists(value), "'{0}' attribute: '{1}' directory doesn't exists!".format("directory", value)
self.__directory = value | [
"def",
"directory",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"directory\"",
",",
"value",
")",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"value",
")",
",",
"\"'{0}' attribute: '{1}' directory doesn't exists!\"",
".",
"format",
"(",
"\"directory\"",
",",
"value",
")",
"self",
".",
"__directory",
"=",
"value"
] | Setter for **self.__directory** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__directory",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L189-L201 |
KelSolaar/Manager | manager/components_manager.py | Profile.attribute | def attribute(self, value):
"""
Setter for **self.__attribute** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"attribute", value)
self.__attribute = value | python | def attribute(self, value):
"""
Setter for **self.__attribute** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"attribute", value)
self.__attribute = value | [
"def",
"attribute",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"attribute\"",
",",
"value",
")",
"self",
".",
"__attribute",
"=",
"value"
] | Setter for **self.__attribute** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__attribute",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L226-L237 |
KelSolaar/Manager | manager/components_manager.py | Profile.require | def require(self, value):
"""
Setter for **self.__require** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format(
"require", value)
self.__require = value | python | def require(self, value):
"""
Setter for **self.__require** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format(
"require", value)
self.__require = value | [
"def",
"require",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"tuple",
",",
"list",
")",
",",
"\"'{0}' attribute: '{1}' type is not 'tuple' or 'list'!\"",
".",
"format",
"(",
"\"require\"",
",",
"value",
")",
"self",
".",
"__require",
"=",
"value"
] | Setter for **self.__require** attribute.
:param value: Attribute value.
:type value: tuple or list | [
"Setter",
"for",
"**",
"self",
".",
"__require",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L262-L273 |
KelSolaar/Manager | manager/components_manager.py | Profile.module | def module(self, value):
"""
Setter for **self.__module** attribute.
:param value: Attribute value.
:type value: ModuleType
"""
if value is not None:
assert type(value) is type(sys), "'{0}' attribute: '{1}' type is not 'module'!".format("module", value)
self.__module = value | python | def module(self, value):
"""
Setter for **self.__module** attribute.
:param value: Attribute value.
:type value: ModuleType
"""
if value is not None:
assert type(value) is type(sys), "'{0}' attribute: '{1}' type is not 'module'!".format("module", value)
self.__module = value | [
"def",
"module",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"type",
"(",
"sys",
")",
",",
"\"'{0}' attribute: '{1}' type is not 'module'!\"",
".",
"format",
"(",
"\"module\"",
",",
"value",
")",
"self",
".",
"__module",
"=",
"value"
] | Setter for **self.__module** attribute.
:param value: Attribute value.
:type value: ModuleType | [
"Setter",
"for",
"**",
"self",
".",
"__module",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L298-L308 |
KelSolaar/Manager | manager/components_manager.py | Profile.category | def category(self, value):
"""
Setter for **self.__category** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"category", value)
self.__category = value | python | def category(self, value):
"""
Setter for **self.__category** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"category", value)
self.__category = value | [
"def",
"category",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"category\"",
",",
"value",
")",
"self",
".",
"__category",
"=",
"value"
] | Setter for **self.__category** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__category",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L365-L376 |
KelSolaar/Manager | manager/components_manager.py | Profile.title | def title(self, value):
"""
Setter for **self.__title** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"title", value)
self.__title = value | python | def title(self, value):
"""
Setter for **self.__title** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"title", value)
self.__title = value | [
"def",
"title",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"title\"",
",",
"value",
")",
"self",
".",
"__title",
"=",
"value"
] | Setter for **self.__title** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__title",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L401-L412 |
KelSolaar/Manager | manager/components_manager.py | Profile.package | def package(self, value):
"""
Setter for **self.__package** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"package", value)
self.__package = value | python | def package(self, value):
"""
Setter for **self.__package** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"package", value)
self.__package = value | [
"def",
"package",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"package\"",
",",
"value",
")",
"self",
".",
"__package",
"=",
"value"
] | Setter for **self.__package** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__package",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L437-L448 |
KelSolaar/Manager | manager/components_manager.py | Profile.version | def version(self, value):
"""
Setter for **self.__version** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"version", value)
self.__version = value | python | def version(self, value):
"""
Setter for **self.__version** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"version", value)
self.__version = value | [
"def",
"version",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"version\"",
",",
"value",
")",
"self",
".",
"__version",
"=",
"value"
] | Setter for **self.__version** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__version",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L473-L484 |
KelSolaar/Manager | manager/components_manager.py | Profile.author | def author(self, value):
"""
Setter for **self.__author** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"author", value)
self.__author = value | python | def author(self, value):
"""
Setter for **self.__author** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"author", value)
self.__author = value | [
"def",
"author",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"author\"",
",",
"value",
")",
"self",
".",
"__author",
"=",
"value"
] | Setter for **self.__author** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__author",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L509-L520 |
KelSolaar/Manager | manager/components_manager.py | Profile.email | def email(self, value):
"""
Setter for **self.__email** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"email", value)
self.__email = value | python | def email(self, value):
"""
Setter for **self.__email** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"email", value)
self.__email = value | [
"def",
"email",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"email\"",
",",
"value",
")",
"self",
".",
"__email",
"=",
"value"
] | Setter for **self.__email** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__email",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L545-L556 |
KelSolaar/Manager | manager/components_manager.py | Profile.url | def url(self, value):
"""
Setter for **self.__url** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"url", value)
self.__url = value | python | def url(self, value):
"""
Setter for **self.__url** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"url", value)
self.__url = value | [
"def",
"url",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"url\"",
",",
"value",
")",
"self",
".",
"__url",
"=",
"value"
] | Setter for **self.__url** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__url",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L581-L592 |
KelSolaar/Manager | manager/components_manager.py | Profile.description | def description(self, value):
"""
Setter for **self.__description** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"description", value)
self.__description = value | python | def description(self, value):
"""
Setter for **self.__description** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"description", value)
self.__description = value | [
"def",
"description",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"description\"",
",",
"value",
")",
"self",
".",
"__description",
"=",
"value"
] | Setter for **self.__description** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__description",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L617-L628 |
KelSolaar/Manager | manager/components_manager.py | Profile.initializeProfile | def initializeProfile(self):
"""
Initializes the Component Profile.
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Building '{0}' profile.".format(self.__file))
sections_file_parser = SectionsFileParser(self.__file)
sections_file_parser.parse()
if sections_file_parser.sections:
fileStructureParsingError = lambda attribute: foundations.exceptions.FileStructureParsingError(
"{0} | No '{1}' attribute found, '{2}' file structure seems invalid!".format(
self.__class__.__name__, attribute, self.__file))
self.__directory = os.path.dirname(self.__file)
self.__name = sections_file_parser.get_value("Name", "Component", default=None)
if self.__name is None:
raise fileStructureParsingError("Name")
self.__title = sections_file_parser.get_value("Title", "Component", default=None)
if self.__title is None:
self.__title = self.__name
self.__package = sections_file_parser.get_value("Module", "Component", default=None)
if self.__package is None:
raise fileStructureParsingError("Module")
self.__attribute = sections_file_parser.get_value("Object", "Component", default=None)
if self.__attribute is None:
raise fileStructureParsingError("Object")
self.__require = sections_file_parser.get_value("Require", "Component", default=None)
self.__require = list() if self.__require is None else self.__require.split("|")
self.__version = sections_file_parser.get_value("Version", "Component", default=None)
if self.__version is None:
raise fileStructureParsingError("Version")
self.__author = sections_file_parser.get_value("Author", "Informations", default=None)
self.__email = sections_file_parser.get_value("Email", "Informations", default=None)
self.__url = sections_file_parser.get_value("Url", "Informations", default=None)
self.__description = sections_file_parser.get_value("Description", "Informations", default=None)
return True
else:
raise foundations.exceptions.FileStructureParsingError(
"{0} | No sections found, '{1}' file structure seems invalid!".format(self.__class__.__name__,
self.__file)) | python | def initializeProfile(self):
"""
Initializes the Component Profile.
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Building '{0}' profile.".format(self.__file))
sections_file_parser = SectionsFileParser(self.__file)
sections_file_parser.parse()
if sections_file_parser.sections:
fileStructureParsingError = lambda attribute: foundations.exceptions.FileStructureParsingError(
"{0} | No '{1}' attribute found, '{2}' file structure seems invalid!".format(
self.__class__.__name__, attribute, self.__file))
self.__directory = os.path.dirname(self.__file)
self.__name = sections_file_parser.get_value("Name", "Component", default=None)
if self.__name is None:
raise fileStructureParsingError("Name")
self.__title = sections_file_parser.get_value("Title", "Component", default=None)
if self.__title is None:
self.__title = self.__name
self.__package = sections_file_parser.get_value("Module", "Component", default=None)
if self.__package is None:
raise fileStructureParsingError("Module")
self.__attribute = sections_file_parser.get_value("Object", "Component", default=None)
if self.__attribute is None:
raise fileStructureParsingError("Object")
self.__require = sections_file_parser.get_value("Require", "Component", default=None)
self.__require = list() if self.__require is None else self.__require.split("|")
self.__version = sections_file_parser.get_value("Version", "Component", default=None)
if self.__version is None:
raise fileStructureParsingError("Version")
self.__author = sections_file_parser.get_value("Author", "Informations", default=None)
self.__email = sections_file_parser.get_value("Email", "Informations", default=None)
self.__url = sections_file_parser.get_value("Url", "Informations", default=None)
self.__description = sections_file_parser.get_value("Description", "Informations", default=None)
return True
else:
raise foundations.exceptions.FileStructureParsingError(
"{0} | No sections found, '{1}' file structure seems invalid!".format(self.__class__.__name__,
self.__file)) | [
"def",
"initializeProfile",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Building '{0}' profile.\"",
".",
"format",
"(",
"self",
".",
"__file",
")",
")",
"sections_file_parser",
"=",
"SectionsFileParser",
"(",
"self",
".",
"__file",
")",
"sections_file_parser",
".",
"parse",
"(",
")",
"if",
"sections_file_parser",
".",
"sections",
":",
"fileStructureParsingError",
"=",
"lambda",
"attribute",
":",
"foundations",
".",
"exceptions",
".",
"FileStructureParsingError",
"(",
"\"{0} | No '{1}' attribute found, '{2}' file structure seems invalid!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"attribute",
",",
"self",
".",
"__file",
")",
")",
"self",
".",
"__directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"__file",
")",
"self",
".",
"__name",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Name\"",
",",
"\"Component\"",
",",
"default",
"=",
"None",
")",
"if",
"self",
".",
"__name",
"is",
"None",
":",
"raise",
"fileStructureParsingError",
"(",
"\"Name\"",
")",
"self",
".",
"__title",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Title\"",
",",
"\"Component\"",
",",
"default",
"=",
"None",
")",
"if",
"self",
".",
"__title",
"is",
"None",
":",
"self",
".",
"__title",
"=",
"self",
".",
"__name",
"self",
".",
"__package",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Module\"",
",",
"\"Component\"",
",",
"default",
"=",
"None",
")",
"if",
"self",
".",
"__package",
"is",
"None",
":",
"raise",
"fileStructureParsingError",
"(",
"\"Module\"",
")",
"self",
".",
"__attribute",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Object\"",
",",
"\"Component\"",
",",
"default",
"=",
"None",
")",
"if",
"self",
".",
"__attribute",
"is",
"None",
":",
"raise",
"fileStructureParsingError",
"(",
"\"Object\"",
")",
"self",
".",
"__require",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Require\"",
",",
"\"Component\"",
",",
"default",
"=",
"None",
")",
"self",
".",
"__require",
"=",
"list",
"(",
")",
"if",
"self",
".",
"__require",
"is",
"None",
"else",
"self",
".",
"__require",
".",
"split",
"(",
"\"|\"",
")",
"self",
".",
"__version",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Version\"",
",",
"\"Component\"",
",",
"default",
"=",
"None",
")",
"if",
"self",
".",
"__version",
"is",
"None",
":",
"raise",
"fileStructureParsingError",
"(",
"\"Version\"",
")",
"self",
".",
"__author",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Author\"",
",",
"\"Informations\"",
",",
"default",
"=",
"None",
")",
"self",
".",
"__email",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Email\"",
",",
"\"Informations\"",
",",
"default",
"=",
"None",
")",
"self",
".",
"__url",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Url\"",
",",
"\"Informations\"",
",",
"default",
"=",
"None",
")",
"self",
".",
"__description",
"=",
"sections_file_parser",
".",
"get_value",
"(",
"\"Description\"",
",",
"\"Informations\"",
",",
"default",
"=",
"None",
")",
"return",
"True",
"else",
":",
"raise",
"foundations",
".",
"exceptions",
".",
"FileStructureParsingError",
"(",
"\"{0} | No sections found, '{1}' file structure seems invalid!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"__file",
")",
")"
] | Initializes the Component Profile.
:return: Method success.
:rtype: bool | [
"Initializes",
"the",
"Component",
"Profile",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L641-L695 |
KelSolaar/Manager | manager/components_manager.py | Manager.paths | def paths(self, value):
"""
Setter for **self.__paths** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format(
"paths", value)
for path in value:
assert type(path) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"paths", path)
assert os.path.exists(path), "'{0}' attribute: '{1}' directory doesn't exists!".format("paths", path)
self.__paths = value | python | def paths(self, value):
"""
Setter for **self.__paths** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format(
"paths", value)
for path in value:
assert type(path) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"paths", path)
assert os.path.exists(path), "'{0}' attribute: '{1}' directory doesn't exists!".format("paths", path)
self.__paths = value | [
"def",
"paths",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"tuple",
",",
"list",
")",
",",
"\"'{0}' attribute: '{1}' type is not 'tuple' or 'list'!\"",
".",
"format",
"(",
"\"paths\"",
",",
"value",
")",
"for",
"path",
"in",
"value",
":",
"assert",
"type",
"(",
"path",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"paths\"",
",",
"path",
")",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
",",
"\"'{0}' attribute: '{1}' directory doesn't exists!\"",
".",
"format",
"(",
"\"paths\"",
",",
"path",
")",
"self",
".",
"__paths",
"=",
"value"
] | Setter for **self.__paths** attribute.
:param value: Attribute value.
:type value: tuple or list | [
"Setter",
"for",
"**",
"self",
".",
"__paths",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L759-L774 |
KelSolaar/Manager | manager/components_manager.py | Manager.extension | def extension(self, value):
"""
Setter for **self.__extension** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"extension", value)
self.__extension = value | python | def extension(self, value):
"""
Setter for **self.__extension** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"extension", value)
self.__extension = value | [
"def",
"extension",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"extension\"",
",",
"value",
")",
"self",
".",
"__extension",
"=",
"value"
] | Setter for **self.__extension** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__extension",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L799-L810 |
KelSolaar/Manager | manager/components_manager.py | Manager.categories | def categories(self, value):
"""
Setter for **self.__categories** attribute.
:param value: Attribute value.
:type value: dict
"""
if value is not None:
assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format("categories", value)
for key in value:
assert type(key) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"categories", key)
self.__categories = value | python | def categories(self, value):
"""
Setter for **self.__categories** attribute.
:param value: Attribute value.
:type value: dict
"""
if value is not None:
assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format("categories", value)
for key in value:
assert type(key) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
"categories", key)
self.__categories = value | [
"def",
"categories",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"dict",
",",
"\"'{0}' attribute: '{1}' type is not 'dict'!\"",
".",
"format",
"(",
"\"categories\"",
",",
"value",
")",
"for",
"key",
"in",
"value",
":",
"assert",
"type",
"(",
"key",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"categories\"",
",",
"key",
")",
"self",
".",
"__categories",
"=",
"value"
] | Setter for **self.__categories** attribute.
:param value: Attribute value.
:type value: dict | [
"Setter",
"for",
"**",
"self",
".",
"__categories",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L835-L848 |
KelSolaar/Manager | manager/components_manager.py | Manager.register_component | def register_component(self, path):
"""
Registers a Component using given path.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.components
{u'core.tests_component_a': <manager.components_manager.Profile object at 0x11c9eb0>}
:param path: Component path.
:type path: unicode
:return: Method success.
:rtype: bool
"""
component = foundations.strings.get_splitext_basename(path)
LOGGER.debug("> Current Component: '{0}'.".format(component))
profile = Profile(file=path)
if profile.initializeProfile():
if os.path.isfile(os.path.join(profile.directory, profile.package) + ".py") or \
os.path.isdir(os.path.join(profile.directory, profile.package)) or \
os.path.basename(profile.directory) == profile.package:
self.__components[profile.name] = profile
return True
else:
raise manager.exceptions.ComponentModuleError(
"{0} | '{1}' has no associated module and has been rejected!".format(self.__class__.__name__,
component))
else:
raise manager.exceptions.ComponentProfileError(
"{0} | '{1}' is not a valid Component and has been rejected!".format(self.__class__.__name__,
component)) | python | def register_component(self, path):
"""
Registers a Component using given path.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.components
{u'core.tests_component_a': <manager.components_manager.Profile object at 0x11c9eb0>}
:param path: Component path.
:type path: unicode
:return: Method success.
:rtype: bool
"""
component = foundations.strings.get_splitext_basename(path)
LOGGER.debug("> Current Component: '{0}'.".format(component))
profile = Profile(file=path)
if profile.initializeProfile():
if os.path.isfile(os.path.join(profile.directory, profile.package) + ".py") or \
os.path.isdir(os.path.join(profile.directory, profile.package)) or \
os.path.basename(profile.directory) == profile.package:
self.__components[profile.name] = profile
return True
else:
raise manager.exceptions.ComponentModuleError(
"{0} | '{1}' has no associated module and has been rejected!".format(self.__class__.__name__,
component))
else:
raise manager.exceptions.ComponentProfileError(
"{0} | '{1}' is not a valid Component and has been rejected!".format(self.__class__.__name__,
component)) | [
"def",
"register_component",
"(",
"self",
",",
"path",
")",
":",
"component",
"=",
"foundations",
".",
"strings",
".",
"get_splitext_basename",
"(",
"path",
")",
"LOGGER",
".",
"debug",
"(",
"\"> Current Component: '{0}'.\"",
".",
"format",
"(",
"component",
")",
")",
"profile",
"=",
"Profile",
"(",
"file",
"=",
"path",
")",
"if",
"profile",
".",
"initializeProfile",
"(",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"profile",
".",
"directory",
",",
"profile",
".",
"package",
")",
"+",
"\".py\"",
")",
"or",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"profile",
".",
"directory",
",",
"profile",
".",
"package",
")",
")",
"or",
"os",
".",
"path",
".",
"basename",
"(",
"profile",
".",
"directory",
")",
"==",
"profile",
".",
"package",
":",
"self",
".",
"__components",
"[",
"profile",
".",
"name",
"]",
"=",
"profile",
"return",
"True",
"else",
":",
"raise",
"manager",
".",
"exceptions",
".",
"ComponentModuleError",
"(",
"\"{0} | '{1}' has no associated module and has been rejected!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"component",
")",
")",
"else",
":",
"raise",
"manager",
".",
"exceptions",
".",
"ComponentProfileError",
"(",
"\"{0} | '{1}' is not a valid Component and has been rejected!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"component",
")",
")"
] | Registers a Component using given path.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.components
{u'core.tests_component_a': <manager.components_manager.Profile object at 0x11c9eb0>}
:param path: Component path.
:type path: unicode
:return: Method success.
:rtype: bool | [
"Registers",
"a",
"Component",
"using",
"given",
"path",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L977-L1011 |
KelSolaar/Manager | manager/components_manager.py | Manager.register_components | def register_components(self):
"""
Registers the Components.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.components.keys()
[u'core.tests_component_a', u'core.tests_component_b']
:return: Method success.
:rtype: bool
"""
unregistered_components = []
for path in self.paths:
for file in foundations.walkers.files_walker(path, ("\.{0}$".format(self.__extension),), ("\._",)):
if not self.register_component(file):
unregistered_components.append(file)
if not unregistered_components:
return True
else:
raise manager.exceptions.ComponentRegistrationError(
"{0} | '{1}' Components failed to register!".format(self.__class__.__name__,
", ".join(unregistered_components))) | python | def register_components(self):
"""
Registers the Components.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.components.keys()
[u'core.tests_component_a', u'core.tests_component_b']
:return: Method success.
:rtype: bool
"""
unregistered_components = []
for path in self.paths:
for file in foundations.walkers.files_walker(path, ("\.{0}$".format(self.__extension),), ("\._",)):
if not self.register_component(file):
unregistered_components.append(file)
if not unregistered_components:
return True
else:
raise manager.exceptions.ComponentRegistrationError(
"{0} | '{1}' Components failed to register!".format(self.__class__.__name__,
", ".join(unregistered_components))) | [
"def",
"register_components",
"(",
"self",
")",
":",
"unregistered_components",
"=",
"[",
"]",
"for",
"path",
"in",
"self",
".",
"paths",
":",
"for",
"file",
"in",
"foundations",
".",
"walkers",
".",
"files_walker",
"(",
"path",
",",
"(",
"\"\\.{0}$\"",
".",
"format",
"(",
"self",
".",
"__extension",
")",
",",
")",
",",
"(",
"\"\\._\"",
",",
")",
")",
":",
"if",
"not",
"self",
".",
"register_component",
"(",
"file",
")",
":",
"unregistered_components",
".",
"append",
"(",
"file",
")",
"if",
"not",
"unregistered_components",
":",
"return",
"True",
"else",
":",
"raise",
"manager",
".",
"exceptions",
".",
"ComponentRegistrationError",
"(",
"\"{0} | '{1}' Components failed to register!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"\", \"",
".",
"join",
"(",
"unregistered_components",
")",
")",
")"
] | Registers the Components.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.components.keys()
[u'core.tests_component_a', u'core.tests_component_b']
:return: Method success.
:rtype: bool | [
"Registers",
"the",
"Components",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1042-L1069 |
KelSolaar/Manager | manager/components_manager.py | Manager.instantiate_component | def instantiate_component(self, component, callback=None):
"""
Instantiates given Component.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.instantiate_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17a5b90>
:param component: Component to instantiate.
:type component: unicode
:param callback: Callback object.
:type callback: object
"""
profile = self.__components[component]
callback and callback(profile)
LOGGER.debug("> Current Component: '{0}'.".format(component))
if os.path.isfile(os.path.join(profile.directory, profile.package) + ".py") or \
os.path.isdir(os.path.join(profile.directory, profile.package)):
path = profile.directory
elif os.path.basename(profile.directory) == profile.package:
path = os.path.join(profile.directory, "..")
not path in sys.path and sys.path.append(path)
profile.module = __import__(profile.package)
object = profile.attribute in profile.module.__dict__ and getattr(profile.module, profile.attribute) or None
if object and inspect.isclass(object):
instance = object(name=profile.name)
for category, type in self.__categories.iteritems():
if type.__name__ in (base.__name__ for base in object.__bases__):
profile.category = category
profile.interface = instance
LOGGER.info("{0} | '{1}' Component has been instantiated!".format(
self.__class__.__name__, profile.name))
return True
else:
del (self.__components[component])
raise manager.exceptions.ComponentInterfaceError(
"{0} | '{1}' Component has no Interface and has been rejected!".format(self.__class__.__name__,
profile.name)) | python | def instantiate_component(self, component, callback=None):
"""
Instantiates given Component.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.instantiate_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17a5b90>
:param component: Component to instantiate.
:type component: unicode
:param callback: Callback object.
:type callback: object
"""
profile = self.__components[component]
callback and callback(profile)
LOGGER.debug("> Current Component: '{0}'.".format(component))
if os.path.isfile(os.path.join(profile.directory, profile.package) + ".py") or \
os.path.isdir(os.path.join(profile.directory, profile.package)):
path = profile.directory
elif os.path.basename(profile.directory) == profile.package:
path = os.path.join(profile.directory, "..")
not path in sys.path and sys.path.append(path)
profile.module = __import__(profile.package)
object = profile.attribute in profile.module.__dict__ and getattr(profile.module, profile.attribute) or None
if object and inspect.isclass(object):
instance = object(name=profile.name)
for category, type in self.__categories.iteritems():
if type.__name__ in (base.__name__ for base in object.__bases__):
profile.category = category
profile.interface = instance
LOGGER.info("{0} | '{1}' Component has been instantiated!".format(
self.__class__.__name__, profile.name))
return True
else:
del (self.__components[component])
raise manager.exceptions.ComponentInterfaceError(
"{0} | '{1}' Component has no Interface and has been rejected!".format(self.__class__.__name__,
profile.name)) | [
"def",
"instantiate_component",
"(",
"self",
",",
"component",
",",
"callback",
"=",
"None",
")",
":",
"profile",
"=",
"self",
".",
"__components",
"[",
"component",
"]",
"callback",
"and",
"callback",
"(",
"profile",
")",
"LOGGER",
".",
"debug",
"(",
"\"> Current Component: '{0}'.\"",
".",
"format",
"(",
"component",
")",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"profile",
".",
"directory",
",",
"profile",
".",
"package",
")",
"+",
"\".py\"",
")",
"or",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"profile",
".",
"directory",
",",
"profile",
".",
"package",
")",
")",
":",
"path",
"=",
"profile",
".",
"directory",
"elif",
"os",
".",
"path",
".",
"basename",
"(",
"profile",
".",
"directory",
")",
"==",
"profile",
".",
"package",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"profile",
".",
"directory",
",",
"\"..\"",
")",
"not",
"path",
"in",
"sys",
".",
"path",
"and",
"sys",
".",
"path",
".",
"append",
"(",
"path",
")",
"profile",
".",
"module",
"=",
"__import__",
"(",
"profile",
".",
"package",
")",
"object",
"=",
"profile",
".",
"attribute",
"in",
"profile",
".",
"module",
".",
"__dict__",
"and",
"getattr",
"(",
"profile",
".",
"module",
",",
"profile",
".",
"attribute",
")",
"or",
"None",
"if",
"object",
"and",
"inspect",
".",
"isclass",
"(",
"object",
")",
":",
"instance",
"=",
"object",
"(",
"name",
"=",
"profile",
".",
"name",
")",
"for",
"category",
",",
"type",
"in",
"self",
".",
"__categories",
".",
"iteritems",
"(",
")",
":",
"if",
"type",
".",
"__name__",
"in",
"(",
"base",
".",
"__name__",
"for",
"base",
"in",
"object",
".",
"__bases__",
")",
":",
"profile",
".",
"category",
"=",
"category",
"profile",
".",
"interface",
"=",
"instance",
"LOGGER",
".",
"info",
"(",
"\"{0} | '{1}' Component has been instantiated!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"profile",
".",
"name",
")",
")",
"return",
"True",
"else",
":",
"del",
"(",
"self",
".",
"__components",
"[",
"component",
"]",
")",
"raise",
"manager",
".",
"exceptions",
".",
"ComponentInterfaceError",
"(",
"\"{0} | '{1}' Component has no Interface and has been rejected!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"profile",
".",
"name",
")",
")"
] | Instantiates given Component.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.instantiate_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17a5b90>
:param component: Component to instantiate.
:type component: unicode
:param callback: Callback object.
:type callback: object | [
"Instantiates",
"given",
"Component",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1098-L1145 |
KelSolaar/Manager | manager/components_manager.py | Manager.instantiate_components | def instantiate_components(self, callback=None):
"""
Instantiates the Components.
Usage::
>>> manager = Manager((tests_manager,))
>>> manager.register_components()
True
>>> manager.instantiate_components()
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17a5bb0>
:param callback: Callback object.
:type callback: object
"""
uninstantiated_components = [component
for component in self.list_components()
if not self.instantiate_component(component, callback)]
if not uninstantiated_components:
return True
else:
raise manager.exceptions.ComponentInstantiationError(
"{0} | '{1}' Components failed to instantiate!".format(self.__class__.__name__,
", ".join(uninstantiated_components))) | python | def instantiate_components(self, callback=None):
"""
Instantiates the Components.
Usage::
>>> manager = Manager((tests_manager,))
>>> manager.register_components()
True
>>> manager.instantiate_components()
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17a5bb0>
:param callback: Callback object.
:type callback: object
"""
uninstantiated_components = [component
for component in self.list_components()
if not self.instantiate_component(component, callback)]
if not uninstantiated_components:
return True
else:
raise manager.exceptions.ComponentInstantiationError(
"{0} | '{1}' Components failed to instantiate!".format(self.__class__.__name__,
", ".join(uninstantiated_components))) | [
"def",
"instantiate_components",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"uninstantiated_components",
"=",
"[",
"component",
"for",
"component",
"in",
"self",
".",
"list_components",
"(",
")",
"if",
"not",
"self",
".",
"instantiate_component",
"(",
"component",
",",
"callback",
")",
"]",
"if",
"not",
"uninstantiated_components",
":",
"return",
"True",
"else",
":",
"raise",
"manager",
".",
"exceptions",
".",
"ComponentInstantiationError",
"(",
"\"{0} | '{1}' Components failed to instantiate!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"\", \"",
".",
"join",
"(",
"uninstantiated_components",
")",
")",
")"
] | Instantiates the Components.
Usage::
>>> manager = Manager((tests_manager,))
>>> manager.register_components()
True
>>> manager.instantiate_components()
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17a5bb0>
:param callback: Callback object.
:type callback: object | [
"Instantiates",
"the",
"Components",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1147-L1173 |
KelSolaar/Manager | manager/components_manager.py | Manager.reload_component | def reload_component(self, component):
"""
Reload given Component module.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.instantiate_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b4890>
>>> manager.reload_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param component: Component name.
:type component: unicode
:return: Reload success.
:rtype: bool
"""
dependents = list(reversed(self.list_dependents(component)))
dependents.append(component)
for dependent in dependents:
profile = self.__components[dependent]
module = __import__(profile.package)
reload(module)
object = profile.attribute in dir(module) and getattr(module, profile.attribute) or None
if object and inspect.isclass(object):
for type in self.__categories.itervalues():
if type.__name__ in (base.__name__ for base in object.__bases__):
instance = object(name=profile.name)
profile.module = module
profile.interface = instance
LOGGER.info("{0} | '{1}' Component has been reloaded!".format(
self.__class__.__name__, profile.name))
return True | python | def reload_component(self, component):
"""
Reload given Component module.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.instantiate_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b4890>
>>> manager.reload_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param component: Component name.
:type component: unicode
:return: Reload success.
:rtype: bool
"""
dependents = list(reversed(self.list_dependents(component)))
dependents.append(component)
for dependent in dependents:
profile = self.__components[dependent]
module = __import__(profile.package)
reload(module)
object = profile.attribute in dir(module) and getattr(module, profile.attribute) or None
if object and inspect.isclass(object):
for type in self.__categories.itervalues():
if type.__name__ in (base.__name__ for base in object.__bases__):
instance = object(name=profile.name)
profile.module = module
profile.interface = instance
LOGGER.info("{0} | '{1}' Component has been reloaded!".format(
self.__class__.__name__, profile.name))
return True | [
"def",
"reload_component",
"(",
"self",
",",
"component",
")",
":",
"dependents",
"=",
"list",
"(",
"reversed",
"(",
"self",
".",
"list_dependents",
"(",
"component",
")",
")",
")",
"dependents",
".",
"append",
"(",
"component",
")",
"for",
"dependent",
"in",
"dependents",
":",
"profile",
"=",
"self",
".",
"__components",
"[",
"dependent",
"]",
"module",
"=",
"__import__",
"(",
"profile",
".",
"package",
")",
"reload",
"(",
"module",
")",
"object",
"=",
"profile",
".",
"attribute",
"in",
"dir",
"(",
"module",
")",
"and",
"getattr",
"(",
"module",
",",
"profile",
".",
"attribute",
")",
"or",
"None",
"if",
"object",
"and",
"inspect",
".",
"isclass",
"(",
"object",
")",
":",
"for",
"type",
"in",
"self",
".",
"__categories",
".",
"itervalues",
"(",
")",
":",
"if",
"type",
".",
"__name__",
"in",
"(",
"base",
".",
"__name__",
"for",
"base",
"in",
"object",
".",
"__bases__",
")",
":",
"instance",
"=",
"object",
"(",
"name",
"=",
"profile",
".",
"name",
")",
"profile",
".",
"module",
"=",
"module",
"profile",
".",
"interface",
"=",
"instance",
"LOGGER",
".",
"info",
"(",
"\"{0} | '{1}' Component has been reloaded!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"profile",
".",
"name",
")",
")",
"return",
"True"
] | Reload given Component module.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.instantiate_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b4890>
>>> manager.reload_component("core.tests_component_a")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param component: Component name.
:type component: unicode
:return: Reload success.
:rtype: bool | [
"Reload",
"given",
"Component",
"module",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1175-L1215 |
KelSolaar/Manager | manager/components_manager.py | Manager.list_components | def list_components(self, dependency_order=True):
"""
Lists the Components by dependency resolving.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.list_components()
[u'core.tests_component_a', u'core.tests_component_b']
:param dependency_order: Components are returned by dependency order.
:type dependency_order: bool
"""
if dependency_order:
return list(itertools.chain.from_iterable([sorted(list(batch)) for batch in
foundations.common.dependency_resolver(
dict((key, value.require) for (key, value) in self))]))
else:
return [key for (key, value) in self] | python | def list_components(self, dependency_order=True):
"""
Lists the Components by dependency resolving.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.list_components()
[u'core.tests_component_a', u'core.tests_component_b']
:param dependency_order: Components are returned by dependency order.
:type dependency_order: bool
"""
if dependency_order:
return list(itertools.chain.from_iterable([sorted(list(batch)) for batch in
foundations.common.dependency_resolver(
dict((key, value.require) for (key, value) in self))]))
else:
return [key for (key, value) in self] | [
"def",
"list_components",
"(",
"self",
",",
"dependency_order",
"=",
"True",
")",
":",
"if",
"dependency_order",
":",
"return",
"list",
"(",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"[",
"sorted",
"(",
"list",
"(",
"batch",
")",
")",
"for",
"batch",
"in",
"foundations",
".",
"common",
".",
"dependency_resolver",
"(",
"dict",
"(",
"(",
"key",
",",
"value",
".",
"require",
")",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
")",
")",
"]",
")",
")",
"else",
":",
"return",
"[",
"key",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
"]"
] | Lists the Components by dependency resolving.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.list_components()
[u'core.tests_component_a', u'core.tests_component_b']
:param dependency_order: Components are returned by dependency order.
:type dependency_order: bool | [
"Lists",
"the",
"Components",
"by",
"dependency",
"resolving",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1217-L1238 |
KelSolaar/Manager | manager/components_manager.py | Manager.list_dependents | def list_dependents(self, component, dependents=None):
"""
Lists given Component dependents Components.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.list_dependents("core.tests_component_a")
[u'core.tests_component_b']
:param component: Component to retrieve the dependents Components.
:type component: unicode
:param dependents: Component dependents Components.
:type dependents: set
:return: Dependent Components.
:rtype: list
"""
dependents = set() if dependents is None else dependents
for name, profile in self:
if not component in profile.require:
continue
dependents.add(name)
self.list_dependents(name, dependents)
return sorted(list(dependents), key=(self.list_components()).index) | python | def list_dependents(self, component, dependents=None):
"""
Lists given Component dependents Components.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.list_dependents("core.tests_component_a")
[u'core.tests_component_b']
:param component: Component to retrieve the dependents Components.
:type component: unicode
:param dependents: Component dependents Components.
:type dependents: set
:return: Dependent Components.
:rtype: list
"""
dependents = set() if dependents is None else dependents
for name, profile in self:
if not component in profile.require:
continue
dependents.add(name)
self.list_dependents(name, dependents)
return sorted(list(dependents), key=(self.list_components()).index) | [
"def",
"list_dependents",
"(",
"self",
",",
"component",
",",
"dependents",
"=",
"None",
")",
":",
"dependents",
"=",
"set",
"(",
")",
"if",
"dependents",
"is",
"None",
"else",
"dependents",
"for",
"name",
",",
"profile",
"in",
"self",
":",
"if",
"not",
"component",
"in",
"profile",
".",
"require",
":",
"continue",
"dependents",
".",
"add",
"(",
"name",
")",
"self",
".",
"list_dependents",
"(",
"name",
",",
"dependents",
")",
"return",
"sorted",
"(",
"list",
"(",
"dependents",
")",
",",
"key",
"=",
"(",
"self",
".",
"list_components",
"(",
")",
")",
".",
"index",
")"
] | Lists given Component dependents Components.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.list_dependents("core.tests_component_a")
[u'core.tests_component_b']
:param component: Component to retrieve the dependents Components.
:type component: unicode
:param dependents: Component dependents Components.
:type dependents: set
:return: Dependent Components.
:rtype: list | [
"Lists",
"given",
"Component",
"dependents",
"Components",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1240-L1268 |
KelSolaar/Manager | manager/components_manager.py | Manager.filter_components | def filter_components(self, pattern, category=None):
"""
Filters the Components using given regex pattern.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.filter_components("\w+A$")
[u'core.tests_component_a']
:param pattern: Regex filtering pattern.
:type pattern: unicode
:param category: Category filter.
:type category: unicode
:return: Matching Components.
:rtype: list
"""
filtered_components = []
for component, profile in self:
if category:
if profile.category != category:
continue
if re.search(pattern, component):
filtered_components.append(component)
return filtered_components | python | def filter_components(self, pattern, category=None):
"""
Filters the Components using given regex pattern.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.filter_components("\w+A$")
[u'core.tests_component_a']
:param pattern: Regex filtering pattern.
:type pattern: unicode
:param category: Category filter.
:type category: unicode
:return: Matching Components.
:rtype: list
"""
filtered_components = []
for component, profile in self:
if category:
if profile.category != category:
continue
if re.search(pattern, component):
filtered_components.append(component)
return filtered_components | [
"def",
"filter_components",
"(",
"self",
",",
"pattern",
",",
"category",
"=",
"None",
")",
":",
"filtered_components",
"=",
"[",
"]",
"for",
"component",
",",
"profile",
"in",
"self",
":",
"if",
"category",
":",
"if",
"profile",
".",
"category",
"!=",
"category",
":",
"continue",
"if",
"re",
".",
"search",
"(",
"pattern",
",",
"component",
")",
":",
"filtered_components",
".",
"append",
"(",
"component",
")",
"return",
"filtered_components"
] | Filters the Components using given regex pattern.
Usage::
>>> manager = Manager(("./manager/tests/tests_manager/resources/components/core",))
>>> manager.register_components()
True
>>> manager.filter_components("\w+A$")
[u'core.tests_component_a']
:param pattern: Regex filtering pattern.
:type pattern: unicode
:param category: Category filter.
:type category: unicode
:return: Matching Components.
:rtype: list | [
"Filters",
"the",
"Components",
"using",
"given",
"regex",
"pattern",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1270-L1298 |
KelSolaar/Manager | manager/components_manager.py | Manager.get_profile | def get_profile(self, component):
"""
Gets given Component profile.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_profile("core.tests_component_a")
<manager.components_manager.Profile object at 0x10258ef10>
:param component: Component to get the profile.
:type component: unicode
:return: Component profile.
:rtype: Profile
"""
components = self.filter_components(r"^{0}$".format(component))
if components != []:
return self.__components[foundations.common.get_first_item(components)] | python | def get_profile(self, component):
"""
Gets given Component profile.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_profile("core.tests_component_a")
<manager.components_manager.Profile object at 0x10258ef10>
:param component: Component to get the profile.
:type component: unicode
:return: Component profile.
:rtype: Profile
"""
components = self.filter_components(r"^{0}$".format(component))
if components != []:
return self.__components[foundations.common.get_first_item(components)] | [
"def",
"get_profile",
"(",
"self",
",",
"component",
")",
":",
"components",
"=",
"self",
".",
"filter_components",
"(",
"r\"^{0}$\"",
".",
"format",
"(",
"component",
")",
")",
"if",
"components",
"!=",
"[",
"]",
":",
"return",
"self",
".",
"__components",
"[",
"foundations",
".",
"common",
".",
"get_first_item",
"(",
"components",
")",
"]"
] | Gets given Component profile.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_profile("core.tests_component_a")
<manager.components_manager.Profile object at 0x10258ef10>
:param component: Component to get the profile.
:type component: unicode
:return: Component profile.
:rtype: Profile | [
"Gets",
"given",
"Component",
"profile",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1300-L1320 |
KelSolaar/Manager | manager/components_manager.py | Manager.get_interface | def get_interface(self, component):
"""
Gets given Component interface.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param component: Component to get the interface.
:type component: unicode
:return: Component interface.
:rtype: object
"""
profile = self.get_profile(component)
if profile:
return profile.interface | python | def get_interface(self, component):
"""
Gets given Component interface.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param component: Component to get the interface.
:type component: unicode
:return: Component interface.
:rtype: object
"""
profile = self.get_profile(component)
if profile:
return profile.interface | [
"def",
"get_interface",
"(",
"self",
",",
"component",
")",
":",
"profile",
"=",
"self",
".",
"get_profile",
"(",
"component",
")",
"if",
"profile",
":",
"return",
"profile",
".",
"interface"
] | Gets given Component interface.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param component: Component to get the interface.
:type component: unicode
:return: Component interface.
:rtype: object | [
"Gets",
"given",
"Component",
"interface",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1322-L1342 |
KelSolaar/Manager | manager/components_manager.py | Manager.get_component_attribute_name | def get_component_attribute_name(component):
"""
Gets given Component attribute name.
Usage::
>>> Manager.get_component_attribute_name("factory.components_manager_ui")
u'factoryComponentsManagerUi'
:param component: Component to get the attribute name.
:type component: unicode
:return: Component attribute name.
:rtype: object
"""
search = re.search(r"(?P<category>\w+)\.(?P<name>\w+)", component)
if search:
name = "{0}{1}{2}".format(
search.group("category"), search.group("name")[0].upper(), search.group("name")[1:])
LOGGER.debug("> Component name: '{0}' to attribute name Active_QLabel: '{1}'.".format(component, name))
else:
name = component
return name | python | def get_component_attribute_name(component):
"""
Gets given Component attribute name.
Usage::
>>> Manager.get_component_attribute_name("factory.components_manager_ui")
u'factoryComponentsManagerUi'
:param component: Component to get the attribute name.
:type component: unicode
:return: Component attribute name.
:rtype: object
"""
search = re.search(r"(?P<category>\w+)\.(?P<name>\w+)", component)
if search:
name = "{0}{1}{2}".format(
search.group("category"), search.group("name")[0].upper(), search.group("name")[1:])
LOGGER.debug("> Component name: '{0}' to attribute name Active_QLabel: '{1}'.".format(component, name))
else:
name = component
return name | [
"def",
"get_component_attribute_name",
"(",
"component",
")",
":",
"search",
"=",
"re",
".",
"search",
"(",
"r\"(?P<category>\\w+)\\.(?P<name>\\w+)\"",
",",
"component",
")",
"if",
"search",
":",
"name",
"=",
"\"{0}{1}{2}\"",
".",
"format",
"(",
"search",
".",
"group",
"(",
"\"category\"",
")",
",",
"search",
".",
"group",
"(",
"\"name\"",
")",
"[",
"0",
"]",
".",
"upper",
"(",
")",
",",
"search",
".",
"group",
"(",
"\"name\"",
")",
"[",
"1",
":",
"]",
")",
"LOGGER",
".",
"debug",
"(",
"\"> Component name: '{0}' to attribute name Active_QLabel: '{1}'.\"",
".",
"format",
"(",
"component",
",",
"name",
")",
")",
"else",
":",
"name",
"=",
"component",
"return",
"name"
] | Gets given Component attribute name.
Usage::
>>> Manager.get_component_attribute_name("factory.components_manager_ui")
u'factoryComponentsManagerUi'
:param component: Component to get the attribute name.
:type component: unicode
:return: Component attribute name.
:rtype: object | [
"Gets",
"given",
"Component",
"attribute",
"name",
"."
] | train | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1345-L1367 |
eng-tools/sfsimodels | sfsimodels/output.py | output_to_table | def output_to_table(obj, olist='inputs', oformat='latex', table_ends=False, prefix=""):
"""
Compile the properties to a table.
:param olist: list, Names of the parameters to be in the output table
:param oformat: str, The type of table to be output
:param table_ends: bool, Add ends to the table
:param prefix: str, A string to be added to the start of each parameter name
:return: para, str, table as a string
"""
para = ""
property_list = []
if olist == 'inputs':
property_list = obj.inputs
elif olist == 'all':
for item in obj.__dict__:
if "_" != item[0]:
property_list.append(item)
for item in property_list:
if hasattr(obj, item):
value = getattr(obj, item)
value_str = format_value(value)
if oformat == "latex":
delimeter = " & "
else:
delimeter = ","
para += "{0}{1}{2}\\\\\n".format(prefix + format_name(item), delimeter, value_str)
if table_ends:
para = add_table_ends(para, oformat)
return para | python | def output_to_table(obj, olist='inputs', oformat='latex', table_ends=False, prefix=""):
"""
Compile the properties to a table.
:param olist: list, Names of the parameters to be in the output table
:param oformat: str, The type of table to be output
:param table_ends: bool, Add ends to the table
:param prefix: str, A string to be added to the start of each parameter name
:return: para, str, table as a string
"""
para = ""
property_list = []
if olist == 'inputs':
property_list = obj.inputs
elif olist == 'all':
for item in obj.__dict__:
if "_" != item[0]:
property_list.append(item)
for item in property_list:
if hasattr(obj, item):
value = getattr(obj, item)
value_str = format_value(value)
if oformat == "latex":
delimeter = " & "
else:
delimeter = ","
para += "{0}{1}{2}\\\\\n".format(prefix + format_name(item), delimeter, value_str)
if table_ends:
para = add_table_ends(para, oformat)
return para | [
"def",
"output_to_table",
"(",
"obj",
",",
"olist",
"=",
"'inputs'",
",",
"oformat",
"=",
"'latex'",
",",
"table_ends",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"para",
"=",
"\"\"",
"property_list",
"=",
"[",
"]",
"if",
"olist",
"==",
"'inputs'",
":",
"property_list",
"=",
"obj",
".",
"inputs",
"elif",
"olist",
"==",
"'all'",
":",
"for",
"item",
"in",
"obj",
".",
"__dict__",
":",
"if",
"\"_\"",
"!=",
"item",
"[",
"0",
"]",
":",
"property_list",
".",
"append",
"(",
"item",
")",
"for",
"item",
"in",
"property_list",
":",
"if",
"hasattr",
"(",
"obj",
",",
"item",
")",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"item",
")",
"value_str",
"=",
"format_value",
"(",
"value",
")",
"if",
"oformat",
"==",
"\"latex\"",
":",
"delimeter",
"=",
"\" & \"",
"else",
":",
"delimeter",
"=",
"\",\"",
"para",
"+=",
"\"{0}{1}{2}\\\\\\\\\\n\"",
".",
"format",
"(",
"prefix",
"+",
"format_name",
"(",
"item",
")",
",",
"delimeter",
",",
"value_str",
")",
"if",
"table_ends",
":",
"para",
"=",
"add_table_ends",
"(",
"para",
",",
"oformat",
")",
"return",
"para"
] | Compile the properties to a table.
:param olist: list, Names of the parameters to be in the output table
:param oformat: str, The type of table to be output
:param table_ends: bool, Add ends to the table
:param prefix: str, A string to be added to the start of each parameter name
:return: para, str, table as a string | [
"Compile",
"the",
"properties",
"to",
"a",
"table",
"."
] | train | https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/output.py#L4-L33 |
eng-tools/sfsimodels | sfsimodels/output.py | format_value | def format_value(value, sf=3):
"""
convert a parameter value into a formatted string with certain significant figures
:param value: the value to be formatted
:param sf: number of significant figures
:return: str
"""
if isinstance(value, str):
return value
elif isinstance(value, list) or isinstance(value, np.ndarray):
value = list(value)
for i in range(len(value)):
vv = format_value(value[i])
value[i] = vv
return "[" + ", ".join(value) + "]"
elif value is None:
return "N/A"
else:
fmt_str = "{0:.%ig}" % sf
return fmt_str.format(value) | python | def format_value(value, sf=3):
"""
convert a parameter value into a formatted string with certain significant figures
:param value: the value to be formatted
:param sf: number of significant figures
:return: str
"""
if isinstance(value, str):
return value
elif isinstance(value, list) or isinstance(value, np.ndarray):
value = list(value)
for i in range(len(value)):
vv = format_value(value[i])
value[i] = vv
return "[" + ", ".join(value) + "]"
elif value is None:
return "N/A"
else:
fmt_str = "{0:.%ig}" % sf
return fmt_str.format(value) | [
"def",
"format_value",
"(",
"value",
",",
"sf",
"=",
"3",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"list",
")",
"or",
"isinstance",
"(",
"value",
",",
"np",
".",
"ndarray",
")",
":",
"value",
"=",
"list",
"(",
"value",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"value",
")",
")",
":",
"vv",
"=",
"format_value",
"(",
"value",
"[",
"i",
"]",
")",
"value",
"[",
"i",
"]",
"=",
"vv",
"return",
"\"[\"",
"+",
"\", \"",
".",
"join",
"(",
"value",
")",
"+",
"\"]\"",
"elif",
"value",
"is",
"None",
":",
"return",
"\"N/A\"",
"else",
":",
"fmt_str",
"=",
"\"{0:.%ig}\"",
"%",
"sf",
"return",
"fmt_str",
".",
"format",
"(",
"value",
")"
] | convert a parameter value into a formatted string with certain significant figures
:param value: the value to be formatted
:param sf: number of significant figures
:return: str | [
"convert",
"a",
"parameter",
"value",
"into",
"a",
"formatted",
"string",
"with",
"certain",
"significant",
"figures"
] | train | https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/output.py#L47-L70 |
eng-tools/sfsimodels | sfsimodels/output.py | add_table_ends | def add_table_ends(para, oformat='latex', caption="caption-text", label="table"):
"""
Adds the latex table ends
:param para:
:param oformat:
:param caption:
:param label:
:return:
"""
fpara = ""
if oformat == 'latex':
fpara += "\\begin{table}[H]\n"
fpara += "\\centering\n"
fpara += "\\begin{tabular}{cc}\n"
fpara += "\\toprule\n"
fpara += "Parameter & Value \\\\\n"
fpara += "\\midrule\n"
fpara += para
fpara += "\\bottomrule\n"
fpara += "\\end{tabular}\n"
fpara += "\\caption{%s \label{tab:%s}}\n" % (caption, label)
fpara += "\\end{table}\n\n"
return fpara | python | def add_table_ends(para, oformat='latex', caption="caption-text", label="table"):
"""
Adds the latex table ends
:param para:
:param oformat:
:param caption:
:param label:
:return:
"""
fpara = ""
if oformat == 'latex':
fpara += "\\begin{table}[H]\n"
fpara += "\\centering\n"
fpara += "\\begin{tabular}{cc}\n"
fpara += "\\toprule\n"
fpara += "Parameter & Value \\\\\n"
fpara += "\\midrule\n"
fpara += para
fpara += "\\bottomrule\n"
fpara += "\\end{tabular}\n"
fpara += "\\caption{%s \label{tab:%s}}\n" % (caption, label)
fpara += "\\end{table}\n\n"
return fpara | [
"def",
"add_table_ends",
"(",
"para",
",",
"oformat",
"=",
"'latex'",
",",
"caption",
"=",
"\"caption-text\"",
",",
"label",
"=",
"\"table\"",
")",
":",
"fpara",
"=",
"\"\"",
"if",
"oformat",
"==",
"'latex'",
":",
"fpara",
"+=",
"\"\\\\begin{table}[H]\\n\"",
"fpara",
"+=",
"\"\\\\centering\\n\"",
"fpara",
"+=",
"\"\\\\begin{tabular}{cc}\\n\"",
"fpara",
"+=",
"\"\\\\toprule\\n\"",
"fpara",
"+=",
"\"Parameter & Value \\\\\\\\\\n\"",
"fpara",
"+=",
"\"\\\\midrule\\n\"",
"fpara",
"+=",
"para",
"fpara",
"+=",
"\"\\\\bottomrule\\n\"",
"fpara",
"+=",
"\"\\\\end{tabular}\\n\"",
"fpara",
"+=",
"\"\\\\caption{%s \\label{tab:%s}}\\n\"",
"%",
"(",
"caption",
",",
"label",
")",
"fpara",
"+=",
"\"\\\\end{table}\\n\\n\"",
"return",
"fpara"
] | Adds the latex table ends
:param para:
:param oformat:
:param caption:
:param label:
:return: | [
"Adds",
"the",
"latex",
"table",
"ends"
] | train | https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/output.py#L73-L96 |
sci-bots/svg-model | svg_model/draw.py | draw_shapes_svg_layer | def draw_shapes_svg_layer(df_shapes, shape_i_columns, layer_name,
layer_number=1, use_svg_path=True):
'''
Draw shapes as a layer in a SVG file.
Args:
df_shapes (pandas.DataFrame): Table of shape vertices (one row per
vertex).
shape_i_columns (str or list) : Either a single column name as a string
or a list of column names in ``df_shapes``. Rows in ``df_shapes``
with the same value in the ``shape_i_columns`` column(s) are
grouped together as a shape.
layer_name (str) : Name of Inkscape layer.
layer_number (int, optional) : Z-order index of Inkscape layer.
use_svg_path (bool, optional) : If ``True``, electrodes are drawn as
``svg:path`` elements. Otherwise, electrodes are drawn as
``svg:polygon`` elements.
Returns
-------
StringIO.StringIO
A file-like object containing SVG XML source.
The XML contains a layer named according to :data:`layer_name`, which
in turn contains ``svg:polygon`` or ``svg:path`` elements corresponding
to the shapes in the input :data:`df_shapes` table.
'''
# Note that `svgwrite.Drawing` requires a filepath to be specified during
# construction, *but* nothing is actually written to the path unless one of
# the `save*` methods is called.
#
# In this function, we do *not* call any of the `save*` methods. Instead,
# we use the `write` method to write to an in-memory file-like object.
minx, miny = df_shapes[['x', 'y']].min().values
maxx, maxy = df_shapes[['x', 'y']].max().values
width = maxx - minx
height = maxy - miny
dwg = svgwrite.Drawing('should_not_exist.svg', size=(width, height),
debug=False)
nsmap = INKSCAPE_NSMAP
dwg.attribs['xmlns:inkscape'] = nsmap['inkscape']
svg_root = dwg.g(id='layer%d' % layer_number,
**{'inkscape:label': layer_name,
'inkscape:groupmode': 'layer'})
minx, miny = df_shapes[['x', 'y']].min().values
for shape_i, df_shape_i in df_shapes.groupby(shape_i_columns):
attr_columns = [c for c in df_shape_i.columns
if c not in ('vertex_i', 'x', 'y')]
attrs = df_shape_i.iloc[0][attr_columns].to_dict()
vertices = df_shape_i[['x', 'y']].values.tolist()
if not use_svg_path:
# Draw electrode shape as an `svg:polygon` element.
p = Polygon(vertices, debug=False, **attrs)
else:
# Draw electrode shape as an `svg:path` element.
commands = ['M %s,%s' % tuple(vertices[0])]
commands += ['L %s,%s' % tuple(v) for v in vertices[1:]]
while vertices[0] == vertices[-1]:
# Start is equal to end of path, but we will use the `'Z'`
# command to close the path, so delete the last point in the
# path.
del vertices[-1]
commands += ['Z']
p = Path_(d=' '.join(commands), debug=False, **attrs)
svg_root.add(p)
dwg.add(svg_root)
# Write result to `StringIO`.
output = StringIO.StringIO()
dwg.write(output)
output.seek(0)
return output | python | def draw_shapes_svg_layer(df_shapes, shape_i_columns, layer_name,
layer_number=1, use_svg_path=True):
'''
Draw shapes as a layer in a SVG file.
Args:
df_shapes (pandas.DataFrame): Table of shape vertices (one row per
vertex).
shape_i_columns (str or list) : Either a single column name as a string
or a list of column names in ``df_shapes``. Rows in ``df_shapes``
with the same value in the ``shape_i_columns`` column(s) are
grouped together as a shape.
layer_name (str) : Name of Inkscape layer.
layer_number (int, optional) : Z-order index of Inkscape layer.
use_svg_path (bool, optional) : If ``True``, electrodes are drawn as
``svg:path`` elements. Otherwise, electrodes are drawn as
``svg:polygon`` elements.
Returns
-------
StringIO.StringIO
A file-like object containing SVG XML source.
The XML contains a layer named according to :data:`layer_name`, which
in turn contains ``svg:polygon`` or ``svg:path`` elements corresponding
to the shapes in the input :data:`df_shapes` table.
'''
# Note that `svgwrite.Drawing` requires a filepath to be specified during
# construction, *but* nothing is actually written to the path unless one of
# the `save*` methods is called.
#
# In this function, we do *not* call any of the `save*` methods. Instead,
# we use the `write` method to write to an in-memory file-like object.
minx, miny = df_shapes[['x', 'y']].min().values
maxx, maxy = df_shapes[['x', 'y']].max().values
width = maxx - minx
height = maxy - miny
dwg = svgwrite.Drawing('should_not_exist.svg', size=(width, height),
debug=False)
nsmap = INKSCAPE_NSMAP
dwg.attribs['xmlns:inkscape'] = nsmap['inkscape']
svg_root = dwg.g(id='layer%d' % layer_number,
**{'inkscape:label': layer_name,
'inkscape:groupmode': 'layer'})
minx, miny = df_shapes[['x', 'y']].min().values
for shape_i, df_shape_i in df_shapes.groupby(shape_i_columns):
attr_columns = [c for c in df_shape_i.columns
if c not in ('vertex_i', 'x', 'y')]
attrs = df_shape_i.iloc[0][attr_columns].to_dict()
vertices = df_shape_i[['x', 'y']].values.tolist()
if not use_svg_path:
# Draw electrode shape as an `svg:polygon` element.
p = Polygon(vertices, debug=False, **attrs)
else:
# Draw electrode shape as an `svg:path` element.
commands = ['M %s,%s' % tuple(vertices[0])]
commands += ['L %s,%s' % tuple(v) for v in vertices[1:]]
while vertices[0] == vertices[-1]:
# Start is equal to end of path, but we will use the `'Z'`
# command to close the path, so delete the last point in the
# path.
del vertices[-1]
commands += ['Z']
p = Path_(d=' '.join(commands), debug=False, **attrs)
svg_root.add(p)
dwg.add(svg_root)
# Write result to `StringIO`.
output = StringIO.StringIO()
dwg.write(output)
output.seek(0)
return output | [
"def",
"draw_shapes_svg_layer",
"(",
"df_shapes",
",",
"shape_i_columns",
",",
"layer_name",
",",
"layer_number",
"=",
"1",
",",
"use_svg_path",
"=",
"True",
")",
":",
"# Note that `svgwrite.Drawing` requires a filepath to be specified during",
"# construction, *but* nothing is actually written to the path unless one of",
"# the `save*` methods is called.",
"#",
"# In this function, we do *not* call any of the `save*` methods. Instead,",
"# we use the `write` method to write to an in-memory file-like object.",
"minx",
",",
"miny",
"=",
"df_shapes",
"[",
"[",
"'x'",
",",
"'y'",
"]",
"]",
".",
"min",
"(",
")",
".",
"values",
"maxx",
",",
"maxy",
"=",
"df_shapes",
"[",
"[",
"'x'",
",",
"'y'",
"]",
"]",
".",
"max",
"(",
")",
".",
"values",
"width",
"=",
"maxx",
"-",
"minx",
"height",
"=",
"maxy",
"-",
"miny",
"dwg",
"=",
"svgwrite",
".",
"Drawing",
"(",
"'should_not_exist.svg'",
",",
"size",
"=",
"(",
"width",
",",
"height",
")",
",",
"debug",
"=",
"False",
")",
"nsmap",
"=",
"INKSCAPE_NSMAP",
"dwg",
".",
"attribs",
"[",
"'xmlns:inkscape'",
"]",
"=",
"nsmap",
"[",
"'inkscape'",
"]",
"svg_root",
"=",
"dwg",
".",
"g",
"(",
"id",
"=",
"'layer%d'",
"%",
"layer_number",
",",
"*",
"*",
"{",
"'inkscape:label'",
":",
"layer_name",
",",
"'inkscape:groupmode'",
":",
"'layer'",
"}",
")",
"minx",
",",
"miny",
"=",
"df_shapes",
"[",
"[",
"'x'",
",",
"'y'",
"]",
"]",
".",
"min",
"(",
")",
".",
"values",
"for",
"shape_i",
",",
"df_shape_i",
"in",
"df_shapes",
".",
"groupby",
"(",
"shape_i_columns",
")",
":",
"attr_columns",
"=",
"[",
"c",
"for",
"c",
"in",
"df_shape_i",
".",
"columns",
"if",
"c",
"not",
"in",
"(",
"'vertex_i'",
",",
"'x'",
",",
"'y'",
")",
"]",
"attrs",
"=",
"df_shape_i",
".",
"iloc",
"[",
"0",
"]",
"[",
"attr_columns",
"]",
".",
"to_dict",
"(",
")",
"vertices",
"=",
"df_shape_i",
"[",
"[",
"'x'",
",",
"'y'",
"]",
"]",
".",
"values",
".",
"tolist",
"(",
")",
"if",
"not",
"use_svg_path",
":",
"# Draw electrode shape as an `svg:polygon` element.",
"p",
"=",
"Polygon",
"(",
"vertices",
",",
"debug",
"=",
"False",
",",
"*",
"*",
"attrs",
")",
"else",
":",
"# Draw electrode shape as an `svg:path` element.",
"commands",
"=",
"[",
"'M %s,%s'",
"%",
"tuple",
"(",
"vertices",
"[",
"0",
"]",
")",
"]",
"commands",
"+=",
"[",
"'L %s,%s'",
"%",
"tuple",
"(",
"v",
")",
"for",
"v",
"in",
"vertices",
"[",
"1",
":",
"]",
"]",
"while",
"vertices",
"[",
"0",
"]",
"==",
"vertices",
"[",
"-",
"1",
"]",
":",
"# Start is equal to end of path, but we will use the `'Z'`",
"# command to close the path, so delete the last point in the",
"# path.",
"del",
"vertices",
"[",
"-",
"1",
"]",
"commands",
"+=",
"[",
"'Z'",
"]",
"p",
"=",
"Path_",
"(",
"d",
"=",
"' '",
".",
"join",
"(",
"commands",
")",
",",
"debug",
"=",
"False",
",",
"*",
"*",
"attrs",
")",
"svg_root",
".",
"add",
"(",
"p",
")",
"dwg",
".",
"add",
"(",
"svg_root",
")",
"# Write result to `StringIO`.",
"output",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"dwg",
".",
"write",
"(",
"output",
")",
"output",
".",
"seek",
"(",
"0",
")",
"return",
"output"
] | Draw shapes as a layer in a SVG file.
Args:
df_shapes (pandas.DataFrame): Table of shape vertices (one row per
vertex).
shape_i_columns (str or list) : Either a single column name as a string
or a list of column names in ``df_shapes``. Rows in ``df_shapes``
with the same value in the ``shape_i_columns`` column(s) are
grouped together as a shape.
layer_name (str) : Name of Inkscape layer.
layer_number (int, optional) : Z-order index of Inkscape layer.
use_svg_path (bool, optional) : If ``True``, electrodes are drawn as
``svg:path`` elements. Otherwise, electrodes are drawn as
``svg:polygon`` elements.
Returns
-------
StringIO.StringIO
A file-like object containing SVG XML source.
The XML contains a layer named according to :data:`layer_name`, which
in turn contains ``svg:polygon`` or ``svg:path`` elements corresponding
to the shapes in the input :data:`df_shapes` table. | [
"Draw",
"shapes",
"as",
"a",
"layer",
"in",
"a",
"SVG",
"file",
"."
] | train | https://github.com/sci-bots/svg-model/blob/2d119650f995e62b29ce0b3151a23f3b957cb072/svg_model/draw.py#L13-L92 |
sci-bots/svg-model | svg_model/draw.py | draw_lines_svg_layer | def draw_lines_svg_layer(df_endpoints, layer_name, layer_number=1):
'''
Draw lines defined by endpoint coordinates as a layer in a SVG file.
Args:
df_endpoints (pandas.DataFrame) : Each row corresponds to the endpoints
of a single line, encoded through the columns: ``x_source``,
``y_source``, ``x_target``, and ``y_target``.
layer_name (str) : Name of Inkscape layer.
layer_number (int, optional) : Z-order index of Inkscape layer.
Returns
-------
StringIO.StringIO
A file-like object containing SVG XML source.
The XML contains a layer named ``"Connections"``, which in turn
contains one line per row in the input :data:`df_endpoints` table.
'''
# Note that `svgwrite.Drawing` requires a filepath to be specified during
# construction, *but* nothing is actually written to the path unless one of
# the `save*` methods is called.
#
# In this function, we do *not* call any of the `save*` methods. Instead,
# we use the `write` method to write to an in-memory file-like object.
dwg = svgwrite.Drawing('should_not_exist.svg', profile='tiny', debug=False)
dwg.attribs['width'] = df_endpoints[['x_source', 'x_target']].values.max()
dwg.attribs['height'] = df_endpoints[['y_source', 'y_target']].values.max()
nsmap = INKSCAPE_NSMAP
dwg.attribs['xmlns:inkscape'] = nsmap['inkscape']
coord_columns = ['x_source', 'y_source', 'x_target', 'y_target']
line_layer = dwg.g(id='layer%d' % layer_number,
**{'inkscape:label': layer_name,
'inkscape:groupmode': 'layer'})
for i, (x1, y1, x2, y2) in df_endpoints[coord_columns].iterrows():
line_i = dwg.line((x1, y1), (x2, y2), id='line%d' % i,
style='stroke:#000000; stroke-width:0.1;')
line_layer.add(line_i)
dwg.add(line_layer)
output = StringIO.StringIO()
dwg.write(output)
# Rewind file.
output.seek(0)
return output | python | def draw_lines_svg_layer(df_endpoints, layer_name, layer_number=1):
'''
Draw lines defined by endpoint coordinates as a layer in a SVG file.
Args:
df_endpoints (pandas.DataFrame) : Each row corresponds to the endpoints
of a single line, encoded through the columns: ``x_source``,
``y_source``, ``x_target``, and ``y_target``.
layer_name (str) : Name of Inkscape layer.
layer_number (int, optional) : Z-order index of Inkscape layer.
Returns
-------
StringIO.StringIO
A file-like object containing SVG XML source.
The XML contains a layer named ``"Connections"``, which in turn
contains one line per row in the input :data:`df_endpoints` table.
'''
# Note that `svgwrite.Drawing` requires a filepath to be specified during
# construction, *but* nothing is actually written to the path unless one of
# the `save*` methods is called.
#
# In this function, we do *not* call any of the `save*` methods. Instead,
# we use the `write` method to write to an in-memory file-like object.
dwg = svgwrite.Drawing('should_not_exist.svg', profile='tiny', debug=False)
dwg.attribs['width'] = df_endpoints[['x_source', 'x_target']].values.max()
dwg.attribs['height'] = df_endpoints[['y_source', 'y_target']].values.max()
nsmap = INKSCAPE_NSMAP
dwg.attribs['xmlns:inkscape'] = nsmap['inkscape']
coord_columns = ['x_source', 'y_source', 'x_target', 'y_target']
line_layer = dwg.g(id='layer%d' % layer_number,
**{'inkscape:label': layer_name,
'inkscape:groupmode': 'layer'})
for i, (x1, y1, x2, y2) in df_endpoints[coord_columns].iterrows():
line_i = dwg.line((x1, y1), (x2, y2), id='line%d' % i,
style='stroke:#000000; stroke-width:0.1;')
line_layer.add(line_i)
dwg.add(line_layer)
output = StringIO.StringIO()
dwg.write(output)
# Rewind file.
output.seek(0)
return output | [
"def",
"draw_lines_svg_layer",
"(",
"df_endpoints",
",",
"layer_name",
",",
"layer_number",
"=",
"1",
")",
":",
"# Note that `svgwrite.Drawing` requires a filepath to be specified during",
"# construction, *but* nothing is actually written to the path unless one of",
"# the `save*` methods is called.",
"#",
"# In this function, we do *not* call any of the `save*` methods. Instead,",
"# we use the `write` method to write to an in-memory file-like object.",
"dwg",
"=",
"svgwrite",
".",
"Drawing",
"(",
"'should_not_exist.svg'",
",",
"profile",
"=",
"'tiny'",
",",
"debug",
"=",
"False",
")",
"dwg",
".",
"attribs",
"[",
"'width'",
"]",
"=",
"df_endpoints",
"[",
"[",
"'x_source'",
",",
"'x_target'",
"]",
"]",
".",
"values",
".",
"max",
"(",
")",
"dwg",
".",
"attribs",
"[",
"'height'",
"]",
"=",
"df_endpoints",
"[",
"[",
"'y_source'",
",",
"'y_target'",
"]",
"]",
".",
"values",
".",
"max",
"(",
")",
"nsmap",
"=",
"INKSCAPE_NSMAP",
"dwg",
".",
"attribs",
"[",
"'xmlns:inkscape'",
"]",
"=",
"nsmap",
"[",
"'inkscape'",
"]",
"coord_columns",
"=",
"[",
"'x_source'",
",",
"'y_source'",
",",
"'x_target'",
",",
"'y_target'",
"]",
"line_layer",
"=",
"dwg",
".",
"g",
"(",
"id",
"=",
"'layer%d'",
"%",
"layer_number",
",",
"*",
"*",
"{",
"'inkscape:label'",
":",
"layer_name",
",",
"'inkscape:groupmode'",
":",
"'layer'",
"}",
")",
"for",
"i",
",",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"in",
"df_endpoints",
"[",
"coord_columns",
"]",
".",
"iterrows",
"(",
")",
":",
"line_i",
"=",
"dwg",
".",
"line",
"(",
"(",
"x1",
",",
"y1",
")",
",",
"(",
"x2",
",",
"y2",
")",
",",
"id",
"=",
"'line%d'",
"%",
"i",
",",
"style",
"=",
"'stroke:#000000; stroke-width:0.1;'",
")",
"line_layer",
".",
"add",
"(",
"line_i",
")",
"dwg",
".",
"add",
"(",
"line_layer",
")",
"output",
"=",
"StringIO",
".",
"StringIO",
"(",
")",
"dwg",
".",
"write",
"(",
"output",
")",
"# Rewind file.",
"output",
".",
"seek",
"(",
"0",
")",
"return",
"output"
] | Draw lines defined by endpoint coordinates as a layer in a SVG file.
Args:
df_endpoints (pandas.DataFrame) : Each row corresponds to the endpoints
of a single line, encoded through the columns: ``x_source``,
``y_source``, ``x_target``, and ``y_target``.
layer_name (str) : Name of Inkscape layer.
layer_number (int, optional) : Z-order index of Inkscape layer.
Returns
-------
StringIO.StringIO
A file-like object containing SVG XML source.
The XML contains a layer named ``"Connections"``, which in turn
contains one line per row in the input :data:`df_endpoints` table. | [
"Draw",
"lines",
"defined",
"by",
"endpoint",
"coordinates",
"as",
"a",
"layer",
"in",
"a",
"SVG",
"file",
"."
] | train | https://github.com/sci-bots/svg-model/blob/2d119650f995e62b29ce0b3151a23f3b957cb072/svg_model/draw.py#L95-L146 |
Capitains/Nautilus | capitains_nautilus/apis/dts.py | DTSApi.dts_error | def dts_error(self, error_name, message=None):
""" Create a DTS Error reply
:param error_name: Name of the error
:param message: Message of the Error
:return: DTS Error Response with information (JSON)
"""
self.nautilus_extension.logger.info("DTS error thrown {} for {} ({})".format(
error_name, request.path, message
))
j = jsonify({
"error": error_name,
"message": message
})
j.status_code = 404
return j | python | def dts_error(self, error_name, message=None):
""" Create a DTS Error reply
:param error_name: Name of the error
:param message: Message of the Error
:return: DTS Error Response with information (JSON)
"""
self.nautilus_extension.logger.info("DTS error thrown {} for {} ({})".format(
error_name, request.path, message
))
j = jsonify({
"error": error_name,
"message": message
})
j.status_code = 404
return j | [
"def",
"dts_error",
"(",
"self",
",",
"error_name",
",",
"message",
"=",
"None",
")",
":",
"self",
".",
"nautilus_extension",
".",
"logger",
".",
"info",
"(",
"\"DTS error thrown {} for {} ({})\"",
".",
"format",
"(",
"error_name",
",",
"request",
".",
"path",
",",
"message",
")",
")",
"j",
"=",
"jsonify",
"(",
"{",
"\"error\"",
":",
"error_name",
",",
"\"message\"",
":",
"message",
"}",
")",
"j",
".",
"status_code",
"=",
"404",
"return",
"j"
] | Create a DTS Error reply
:param error_name: Name of the error
:param message: Message of the Error
:return: DTS Error Response with information (JSON) | [
"Create",
"a",
"DTS",
"Error",
"reply"
] | train | https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/apis/dts.py#L24-L39 |
Capitains/Nautilus | capitains_nautilus/apis/dts.py | DTSApi.r_dts_collection | def r_dts_collection(self, objectId=None):
""" DTS Collection Metadata reply for given objectId
:param objectId: Collection Identifier
:return: JSON Format of DTS Collection
"""
try:
j = self.resolver.getMetadata(objectId=objectId).export(Mimetypes.JSON.DTS.Std)
j = jsonify(j)
j.status_code = 200
except NautilusError as E:
return self.dts_error(error_name=E.__class__.__name__, message=E.__doc__)
return j | python | def r_dts_collection(self, objectId=None):
""" DTS Collection Metadata reply for given objectId
:param objectId: Collection Identifier
:return: JSON Format of DTS Collection
"""
try:
j = self.resolver.getMetadata(objectId=objectId).export(Mimetypes.JSON.DTS.Std)
j = jsonify(j)
j.status_code = 200
except NautilusError as E:
return self.dts_error(error_name=E.__class__.__name__, message=E.__doc__)
return j | [
"def",
"r_dts_collection",
"(",
"self",
",",
"objectId",
"=",
"None",
")",
":",
"try",
":",
"j",
"=",
"self",
".",
"resolver",
".",
"getMetadata",
"(",
"objectId",
"=",
"objectId",
")",
".",
"export",
"(",
"Mimetypes",
".",
"JSON",
".",
"DTS",
".",
"Std",
")",
"j",
"=",
"jsonify",
"(",
"j",
")",
"j",
".",
"status_code",
"=",
"200",
"except",
"NautilusError",
"as",
"E",
":",
"return",
"self",
".",
"dts_error",
"(",
"error_name",
"=",
"E",
".",
"__class__",
".",
"__name__",
",",
"message",
"=",
"E",
".",
"__doc__",
")",
"return",
"j"
] | DTS Collection Metadata reply for given objectId
:param objectId: Collection Identifier
:return: JSON Format of DTS Collection | [
"DTS",
"Collection",
"Metadata",
"reply",
"for",
"given",
"objectId"
] | train | https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/apis/dts.py#L41-L53 |
PolyJIT/benchbuild | benchbuild/utils/db.py | create_run | def create_run(cmd, project, exp, grp):
"""
Create a new 'run' in the database.
This creates a new transaction in the database and creates a new
run in this transaction. Afterwards we return both the transaction as
well as the run itself. The user is responsible for committing it when
the time comes.
Args:
cmd: The command that has been executed.
prj: The project this run belongs to.
exp: The experiment this run belongs to.
grp: The run_group (uuid) we blong to.
Returns:
The inserted tuple representing the run and the session opened with
the new run. Don't forget to commit it at some point.
"""
from benchbuild.utils import schema as s
session = s.Session()
run = s.Run(
command=str(cmd),
project_name=project.name,
project_group=project.group,
experiment_name=exp,
run_group=str(grp),
experiment_group=project.experiment.id)
session.add(run)
session.commit()
return (run, session) | python | def create_run(cmd, project, exp, grp):
"""
Create a new 'run' in the database.
This creates a new transaction in the database and creates a new
run in this transaction. Afterwards we return both the transaction as
well as the run itself. The user is responsible for committing it when
the time comes.
Args:
cmd: The command that has been executed.
prj: The project this run belongs to.
exp: The experiment this run belongs to.
grp: The run_group (uuid) we blong to.
Returns:
The inserted tuple representing the run and the session opened with
the new run. Don't forget to commit it at some point.
"""
from benchbuild.utils import schema as s
session = s.Session()
run = s.Run(
command=str(cmd),
project_name=project.name,
project_group=project.group,
experiment_name=exp,
run_group=str(grp),
experiment_group=project.experiment.id)
session.add(run)
session.commit()
return (run, session) | [
"def",
"create_run",
"(",
"cmd",
",",
"project",
",",
"exp",
",",
"grp",
")",
":",
"from",
"benchbuild",
".",
"utils",
"import",
"schema",
"as",
"s",
"session",
"=",
"s",
".",
"Session",
"(",
")",
"run",
"=",
"s",
".",
"Run",
"(",
"command",
"=",
"str",
"(",
"cmd",
")",
",",
"project_name",
"=",
"project",
".",
"name",
",",
"project_group",
"=",
"project",
".",
"group",
",",
"experiment_name",
"=",
"exp",
",",
"run_group",
"=",
"str",
"(",
"grp",
")",
",",
"experiment_group",
"=",
"project",
".",
"experiment",
".",
"id",
")",
"session",
".",
"add",
"(",
"run",
")",
"session",
".",
"commit",
"(",
")",
"return",
"(",
"run",
",",
"session",
")"
] | Create a new 'run' in the database.
This creates a new transaction in the database and creates a new
run in this transaction. Afterwards we return both the transaction as
well as the run itself. The user is responsible for committing it when
the time comes.
Args:
cmd: The command that has been executed.
prj: The project this run belongs to.
exp: The experiment this run belongs to.
grp: The run_group (uuid) we blong to.
Returns:
The inserted tuple representing the run and the session opened with
the new run. Don't forget to commit it at some point. | [
"Create",
"a",
"new",
"run",
"in",
"the",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L23-L55 |
PolyJIT/benchbuild | benchbuild/utils/db.py | create_run_group | def create_run_group(prj):
"""
Create a new 'run_group' in the database.
This creates a new transaction in the database and creates a new run_group
within this transaction. Afterwards we return both the transaction as well
as the run_group itself. The user is responsible for committing it when the
time comes.
Args:
prj - The project for which we open the run_group.
Returns:
A tuple (group, session) containing both the newly created run_group and
the transaction object.
"""
from benchbuild.utils import schema as s
session = s.Session()
experiment = prj.experiment
group = s.RunGroup(id=prj.run_uuid, experiment=experiment.id)
session.add(group)
session.commit()
return (group, session) | python | def create_run_group(prj):
"""
Create a new 'run_group' in the database.
This creates a new transaction in the database and creates a new run_group
within this transaction. Afterwards we return both the transaction as well
as the run_group itself. The user is responsible for committing it when the
time comes.
Args:
prj - The project for which we open the run_group.
Returns:
A tuple (group, session) containing both the newly created run_group and
the transaction object.
"""
from benchbuild.utils import schema as s
session = s.Session()
experiment = prj.experiment
group = s.RunGroup(id=prj.run_uuid, experiment=experiment.id)
session.add(group)
session.commit()
return (group, session) | [
"def",
"create_run_group",
"(",
"prj",
")",
":",
"from",
"benchbuild",
".",
"utils",
"import",
"schema",
"as",
"s",
"session",
"=",
"s",
".",
"Session",
"(",
")",
"experiment",
"=",
"prj",
".",
"experiment",
"group",
"=",
"s",
".",
"RunGroup",
"(",
"id",
"=",
"prj",
".",
"run_uuid",
",",
"experiment",
"=",
"experiment",
".",
"id",
")",
"session",
".",
"add",
"(",
"group",
")",
"session",
".",
"commit",
"(",
")",
"return",
"(",
"group",
",",
"session",
")"
] | Create a new 'run_group' in the database.
This creates a new transaction in the database and creates a new run_group
within this transaction. Afterwards we return both the transaction as well
as the run_group itself. The user is responsible for committing it when the
time comes.
Args:
prj - The project for which we open the run_group.
Returns:
A tuple (group, session) containing both the newly created run_group and
the transaction object. | [
"Create",
"a",
"new",
"run_group",
"in",
"the",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L58-L82 |
PolyJIT/benchbuild | benchbuild/utils/db.py | persist_project | def persist_project(project):
"""
Persist this project in the benchbuild database.
Args:
project: The project we want to persist.
"""
from benchbuild.utils.schema import Project, Session
session = Session()
projects = session.query(Project) \
.filter(Project.name == project.name) \
.filter(Project.group_name == project.group)
name = project.name
desc = project.__doc__
domain = project.domain
group_name = project.group
version = project.version() \
if callable(project.version) else project.version
try:
src_url = project.src_uri
except AttributeError:
src_url = 'unknown'
if projects.count() == 0:
newp = Project()
newp.name = name
newp.description = desc
newp.src_url = src_url
newp.domain = domain
newp.group_name = group_name
newp.version = version
session.add(newp)
else:
newp_value = {
"name": name,
"description": desc,
"src_url": src_url,
"domain": domain,
"group_name": group_name,
"version": version
}
projects.update(newp_value)
session.commit()
return (projects, session) | python | def persist_project(project):
"""
Persist this project in the benchbuild database.
Args:
project: The project we want to persist.
"""
from benchbuild.utils.schema import Project, Session
session = Session()
projects = session.query(Project) \
.filter(Project.name == project.name) \
.filter(Project.group_name == project.group)
name = project.name
desc = project.__doc__
domain = project.domain
group_name = project.group
version = project.version() \
if callable(project.version) else project.version
try:
src_url = project.src_uri
except AttributeError:
src_url = 'unknown'
if projects.count() == 0:
newp = Project()
newp.name = name
newp.description = desc
newp.src_url = src_url
newp.domain = domain
newp.group_name = group_name
newp.version = version
session.add(newp)
else:
newp_value = {
"name": name,
"description": desc,
"src_url": src_url,
"domain": domain,
"group_name": group_name,
"version": version
}
projects.update(newp_value)
session.commit()
return (projects, session) | [
"def",
"persist_project",
"(",
"project",
")",
":",
"from",
"benchbuild",
".",
"utils",
".",
"schema",
"import",
"Project",
",",
"Session",
"session",
"=",
"Session",
"(",
")",
"projects",
"=",
"session",
".",
"query",
"(",
"Project",
")",
".",
"filter",
"(",
"Project",
".",
"name",
"==",
"project",
".",
"name",
")",
".",
"filter",
"(",
"Project",
".",
"group_name",
"==",
"project",
".",
"group",
")",
"name",
"=",
"project",
".",
"name",
"desc",
"=",
"project",
".",
"__doc__",
"domain",
"=",
"project",
".",
"domain",
"group_name",
"=",
"project",
".",
"group",
"version",
"=",
"project",
".",
"version",
"(",
")",
"if",
"callable",
"(",
"project",
".",
"version",
")",
"else",
"project",
".",
"version",
"try",
":",
"src_url",
"=",
"project",
".",
"src_uri",
"except",
"AttributeError",
":",
"src_url",
"=",
"'unknown'",
"if",
"projects",
".",
"count",
"(",
")",
"==",
"0",
":",
"newp",
"=",
"Project",
"(",
")",
"newp",
".",
"name",
"=",
"name",
"newp",
".",
"description",
"=",
"desc",
"newp",
".",
"src_url",
"=",
"src_url",
"newp",
".",
"domain",
"=",
"domain",
"newp",
".",
"group_name",
"=",
"group_name",
"newp",
".",
"version",
"=",
"version",
"session",
".",
"add",
"(",
"newp",
")",
"else",
":",
"newp_value",
"=",
"{",
"\"name\"",
":",
"name",
",",
"\"description\"",
":",
"desc",
",",
"\"src_url\"",
":",
"src_url",
",",
"\"domain\"",
":",
"domain",
",",
"\"group_name\"",
":",
"group_name",
",",
"\"version\"",
":",
"version",
"}",
"projects",
".",
"update",
"(",
"newp_value",
")",
"session",
".",
"commit",
"(",
")",
"return",
"(",
"projects",
",",
"session",
")"
] | Persist this project in the benchbuild database.
Args:
project: The project we want to persist. | [
"Persist",
"this",
"project",
"in",
"the",
"benchbuild",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L85-L130 |
PolyJIT/benchbuild | benchbuild/utils/db.py | persist_experiment | def persist_experiment(experiment):
"""
Persist this experiment in the benchbuild database.
Args:
experiment: The experiment we want to persist.
"""
from benchbuild.utils.schema import Experiment, Session
session = Session()
cfg_exp = experiment.id
LOG.debug("Using experiment ID stored in config: %s", cfg_exp)
exps = session.query(Experiment).filter(Experiment.id == cfg_exp)
desc = str(CFG["experiment_description"])
name = experiment.name
if exps.count() == 0:
newe = Experiment()
newe.id = cfg_exp
newe.name = name
newe.description = desc
session.add(newe)
ret = newe
else:
exps.update({'name': name, 'description': desc})
ret = exps.first()
try:
session.commit()
except IntegrityError:
session.rollback()
persist_experiment(experiment)
return (ret, session) | python | def persist_experiment(experiment):
"""
Persist this experiment in the benchbuild database.
Args:
experiment: The experiment we want to persist.
"""
from benchbuild.utils.schema import Experiment, Session
session = Session()
cfg_exp = experiment.id
LOG.debug("Using experiment ID stored in config: %s", cfg_exp)
exps = session.query(Experiment).filter(Experiment.id == cfg_exp)
desc = str(CFG["experiment_description"])
name = experiment.name
if exps.count() == 0:
newe = Experiment()
newe.id = cfg_exp
newe.name = name
newe.description = desc
session.add(newe)
ret = newe
else:
exps.update({'name': name, 'description': desc})
ret = exps.first()
try:
session.commit()
except IntegrityError:
session.rollback()
persist_experiment(experiment)
return (ret, session) | [
"def",
"persist_experiment",
"(",
"experiment",
")",
":",
"from",
"benchbuild",
".",
"utils",
".",
"schema",
"import",
"Experiment",
",",
"Session",
"session",
"=",
"Session",
"(",
")",
"cfg_exp",
"=",
"experiment",
".",
"id",
"LOG",
".",
"debug",
"(",
"\"Using experiment ID stored in config: %s\"",
",",
"cfg_exp",
")",
"exps",
"=",
"session",
".",
"query",
"(",
"Experiment",
")",
".",
"filter",
"(",
"Experiment",
".",
"id",
"==",
"cfg_exp",
")",
"desc",
"=",
"str",
"(",
"CFG",
"[",
"\"experiment_description\"",
"]",
")",
"name",
"=",
"experiment",
".",
"name",
"if",
"exps",
".",
"count",
"(",
")",
"==",
"0",
":",
"newe",
"=",
"Experiment",
"(",
")",
"newe",
".",
"id",
"=",
"cfg_exp",
"newe",
".",
"name",
"=",
"name",
"newe",
".",
"description",
"=",
"desc",
"session",
".",
"add",
"(",
"newe",
")",
"ret",
"=",
"newe",
"else",
":",
"exps",
".",
"update",
"(",
"{",
"'name'",
":",
"name",
",",
"'description'",
":",
"desc",
"}",
")",
"ret",
"=",
"exps",
".",
"first",
"(",
")",
"try",
":",
"session",
".",
"commit",
"(",
")",
"except",
"IntegrityError",
":",
"session",
".",
"rollback",
"(",
")",
"persist_experiment",
"(",
"experiment",
")",
"return",
"(",
"ret",
",",
"session",
")"
] | Persist this experiment in the benchbuild database.
Args:
experiment: The experiment we want to persist. | [
"Persist",
"this",
"experiment",
"in",
"the",
"benchbuild",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L133-L167 |
PolyJIT/benchbuild | benchbuild/utils/db.py | persist_time | def persist_time(run, session, timings):
"""
Persist the run results in the database.
Args:
run: The run we attach this timing results to.
session: The db transaction we belong to.
timings: The timing measurements we want to store.
"""
from benchbuild.utils import schema as s
for timing in timings:
session.add(
s.Metric(name="time.user_s", value=timing[0], run_id=run.id))
session.add(
s.Metric(name="time.system_s", value=timing[1], run_id=run.id))
session.add(
s.Metric(name="time.real_s", value=timing[2], run_id=run.id)) | python | def persist_time(run, session, timings):
"""
Persist the run results in the database.
Args:
run: The run we attach this timing results to.
session: The db transaction we belong to.
timings: The timing measurements we want to store.
"""
from benchbuild.utils import schema as s
for timing in timings:
session.add(
s.Metric(name="time.user_s", value=timing[0], run_id=run.id))
session.add(
s.Metric(name="time.system_s", value=timing[1], run_id=run.id))
session.add(
s.Metric(name="time.real_s", value=timing[2], run_id=run.id)) | [
"def",
"persist_time",
"(",
"run",
",",
"session",
",",
"timings",
")",
":",
"from",
"benchbuild",
".",
"utils",
"import",
"schema",
"as",
"s",
"for",
"timing",
"in",
"timings",
":",
"session",
".",
"add",
"(",
"s",
".",
"Metric",
"(",
"name",
"=",
"\"time.user_s\"",
",",
"value",
"=",
"timing",
"[",
"0",
"]",
",",
"run_id",
"=",
"run",
".",
"id",
")",
")",
"session",
".",
"add",
"(",
"s",
".",
"Metric",
"(",
"name",
"=",
"\"time.system_s\"",
",",
"value",
"=",
"timing",
"[",
"1",
"]",
",",
"run_id",
"=",
"run",
".",
"id",
")",
")",
"session",
".",
"add",
"(",
"s",
".",
"Metric",
"(",
"name",
"=",
"\"time.real_s\"",
",",
"value",
"=",
"timing",
"[",
"2",
"]",
",",
"run_id",
"=",
"run",
".",
"id",
")",
")"
] | Persist the run results in the database.
Args:
run: The run we attach this timing results to.
session: The db transaction we belong to.
timings: The timing measurements we want to store. | [
"Persist",
"the",
"run",
"results",
"in",
"the",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L171-L188 |
PolyJIT/benchbuild | benchbuild/utils/db.py | persist_perf | def persist_perf(run, session, svg_path):
"""
Persist the flamegraph in the database.
The flamegraph exists as a SVG image on disk until we persist it in the
database.
Args:
run: The run we attach these perf measurements to.
session: The db transaction we belong to.
svg_path: The path to the SVG file we want to store.
"""
from benchbuild.utils import schema as s
with open(svg_path, 'r') as svg_file:
svg_data = svg_file.read()
session.add(
s.Metadata(name="perf.flamegraph", value=svg_data, run_id=run.id)) | python | def persist_perf(run, session, svg_path):
"""
Persist the flamegraph in the database.
The flamegraph exists as a SVG image on disk until we persist it in the
database.
Args:
run: The run we attach these perf measurements to.
session: The db transaction we belong to.
svg_path: The path to the SVG file we want to store.
"""
from benchbuild.utils import schema as s
with open(svg_path, 'r') as svg_file:
svg_data = svg_file.read()
session.add(
s.Metadata(name="perf.flamegraph", value=svg_data, run_id=run.id)) | [
"def",
"persist_perf",
"(",
"run",
",",
"session",
",",
"svg_path",
")",
":",
"from",
"benchbuild",
".",
"utils",
"import",
"schema",
"as",
"s",
"with",
"open",
"(",
"svg_path",
",",
"'r'",
")",
"as",
"svg_file",
":",
"svg_data",
"=",
"svg_file",
".",
"read",
"(",
")",
"session",
".",
"add",
"(",
"s",
".",
"Metadata",
"(",
"name",
"=",
"\"perf.flamegraph\"",
",",
"value",
"=",
"svg_data",
",",
"run_id",
"=",
"run",
".",
"id",
")",
")"
] | Persist the flamegraph in the database.
The flamegraph exists as a SVG image on disk until we persist it in the
database.
Args:
run: The run we attach these perf measurements to.
session: The db transaction we belong to.
svg_path: The path to the SVG file we want to store. | [
"Persist",
"the",
"flamegraph",
"in",
"the",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L191-L208 |
PolyJIT/benchbuild | benchbuild/utils/db.py | persist_compilestats | def persist_compilestats(run, session, stats):
"""
Persist the run results in the database.
Args:
run: The run we attach the compilestats to.
session: The db transaction we belong to.
stats: The stats we want to store in the database.
"""
for stat in stats:
stat.run_id = run.id
session.add(stat) | python | def persist_compilestats(run, session, stats):
"""
Persist the run results in the database.
Args:
run: The run we attach the compilestats to.
session: The db transaction we belong to.
stats: The stats we want to store in the database.
"""
for stat in stats:
stat.run_id = run.id
session.add(stat) | [
"def",
"persist_compilestats",
"(",
"run",
",",
"session",
",",
"stats",
")",
":",
"for",
"stat",
"in",
"stats",
":",
"stat",
".",
"run_id",
"=",
"run",
".",
"id",
"session",
".",
"add",
"(",
"stat",
")"
] | Persist the run results in the database.
Args:
run: The run we attach the compilestats to.
session: The db transaction we belong to.
stats: The stats we want to store in the database. | [
"Persist",
"the",
"run",
"results",
"in",
"the",
"database",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L211-L222 |
PolyJIT/benchbuild | benchbuild/utils/db.py | persist_config | def persist_config(run, session, cfg):
"""
Persist the configuration in as key-value pairs.
Args:
run: The run we attach the config to.
session: The db transaction we belong to.
cfg: The configuration we want to persist.
"""
from benchbuild.utils import schema as s
for cfg_elem in cfg:
session.add(
s.Config(name=cfg_elem, value=cfg[cfg_elem], run_id=run.id)) | python | def persist_config(run, session, cfg):
"""
Persist the configuration in as key-value pairs.
Args:
run: The run we attach the config to.
session: The db transaction we belong to.
cfg: The configuration we want to persist.
"""
from benchbuild.utils import schema as s
for cfg_elem in cfg:
session.add(
s.Config(name=cfg_elem, value=cfg[cfg_elem], run_id=run.id)) | [
"def",
"persist_config",
"(",
"run",
",",
"session",
",",
"cfg",
")",
":",
"from",
"benchbuild",
".",
"utils",
"import",
"schema",
"as",
"s",
"for",
"cfg_elem",
"in",
"cfg",
":",
"session",
".",
"add",
"(",
"s",
".",
"Config",
"(",
"name",
"=",
"cfg_elem",
",",
"value",
"=",
"cfg",
"[",
"cfg_elem",
"]",
",",
"run_id",
"=",
"run",
".",
"id",
")",
")"
] | Persist the configuration in as key-value pairs.
Args:
run: The run we attach the config to.
session: The db transaction we belong to.
cfg: The configuration we want to persist. | [
"Persist",
"the",
"configuration",
"in",
"as",
"key",
"-",
"value",
"pairs",
"."
] | train | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/db.py#L225-L238 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IORMetricsExtractor.parse_results_header | def parse_results_header(cls, header):
"""Extract columns from the line under "Summary of all tests:"
:param header: content of the results header line
:return: list of string providing columns
"""
header = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', header)
header = header.split(' ')
return header | python | def parse_results_header(cls, header):
"""Extract columns from the line under "Summary of all tests:"
:param header: content of the results header line
:return: list of string providing columns
"""
header = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', header)
header = header.split(' ')
return header | [
"def",
"parse_results_header",
"(",
"cls",
",",
"header",
")",
":",
"header",
"=",
"IORMetricsExtractor",
".",
"RE_MULTIPLE_SPACES",
".",
"sub",
"(",
"' '",
",",
"header",
")",
"header",
"=",
"header",
".",
"split",
"(",
"' '",
")",
"return",
"header"
] | Extract columns from the line under "Summary of all tests:"
:param header: content of the results header line
:return: list of string providing columns | [
"Extract",
"columns",
"from",
"the",
"line",
"under",
"Summary",
"of",
"all",
"tests",
":"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L115-L123 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IORMetricsExtractor.parse_result_line | def parse_result_line(cls, columns, line, metrics):
"""Extract metrics from a result line
:param columns: list of columns specified under line
"Summary of all tests:"
:param line: string of results below the columns line
:param metrics: output dict where metrics are written
"""
line = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', line)
line = line.split(' ')
operation = line[0]
assert len(line) == len(columns)
for i, col in enumerate(line):
col = columns[i]
if col in cls.METAS_IGNORED:
continue
desc = cls.METAS.get(col)
if desc is None:
LOGGER.warn('Unrecognized column: %s', col)
meta = cls.get_meta_name(operation, desc.get('name') or col)
value = desc['metric'].type(line[i])
metrics[meta] = value | python | def parse_result_line(cls, columns, line, metrics):
"""Extract metrics from a result line
:param columns: list of columns specified under line
"Summary of all tests:"
:param line: string of results below the columns line
:param metrics: output dict where metrics are written
"""
line = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', line)
line = line.split(' ')
operation = line[0]
assert len(line) == len(columns)
for i, col in enumerate(line):
col = columns[i]
if col in cls.METAS_IGNORED:
continue
desc = cls.METAS.get(col)
if desc is None:
LOGGER.warn('Unrecognized column: %s', col)
meta = cls.get_meta_name(operation, desc.get('name') or col)
value = desc['metric'].type(line[i])
metrics[meta] = value | [
"def",
"parse_result_line",
"(",
"cls",
",",
"columns",
",",
"line",
",",
"metrics",
")",
":",
"line",
"=",
"IORMetricsExtractor",
".",
"RE_MULTIPLE_SPACES",
".",
"sub",
"(",
"' '",
",",
"line",
")",
"line",
"=",
"line",
".",
"split",
"(",
"' '",
")",
"operation",
"=",
"line",
"[",
"0",
"]",
"assert",
"len",
"(",
"line",
")",
"==",
"len",
"(",
"columns",
")",
"for",
"i",
",",
"col",
"in",
"enumerate",
"(",
"line",
")",
":",
"col",
"=",
"columns",
"[",
"i",
"]",
"if",
"col",
"in",
"cls",
".",
"METAS_IGNORED",
":",
"continue",
"desc",
"=",
"cls",
".",
"METAS",
".",
"get",
"(",
"col",
")",
"if",
"desc",
"is",
"None",
":",
"LOGGER",
".",
"warn",
"(",
"'Unrecognized column: %s'",
",",
"col",
")",
"meta",
"=",
"cls",
".",
"get_meta_name",
"(",
"operation",
",",
"desc",
".",
"get",
"(",
"'name'",
")",
"or",
"col",
")",
"value",
"=",
"desc",
"[",
"'metric'",
"]",
".",
"type",
"(",
"line",
"[",
"i",
"]",
")",
"metrics",
"[",
"meta",
"]",
"=",
"value"
] | Extract metrics from a result line
:param columns: list of columns specified under line
"Summary of all tests:"
:param line: string of results below the columns line
:param metrics: output dict where metrics are written | [
"Extract",
"metrics",
"from",
"a",
"result",
"line",
":",
"param",
"columns",
":",
"list",
"of",
"columns",
"specified",
"under",
"line",
"Summary",
"of",
"all",
"tests",
":",
":",
"param",
"line",
":",
"string",
"of",
"results",
"below",
"the",
"columns",
"line",
":",
"param",
"metrics",
":",
"output",
"dict",
"where",
"metrics",
"are",
"written"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L126-L146 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.apis | def apis(self):
"""List of API to test"""
value = self.attributes['apis']
if isinstance(value, six.string_types):
value = shlex.split(value)
return value | python | def apis(self):
"""List of API to test"""
value = self.attributes['apis']
if isinstance(value, six.string_types):
value = shlex.split(value)
return value | [
"def",
"apis",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"attributes",
"[",
"'apis'",
"]",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"value",
"=",
"shlex",
".",
"split",
"(",
"value",
")",
"return",
"value"
] | List of API to test | [
"List",
"of",
"API",
"to",
"test"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L220-L225 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.pre_execute | def pre_execute(self, execution, context):
"""Make sure the named directory is created if possible"""
path = self._fspath
if path:
path = path.format(
benchmark=context.benchmark,
api=execution['category'],
**execution.get('metas', {})
)
if self.clean_path:
shutil.rmtree(path, ignore_errors=True)
if execution['metas']['file_mode'] == 'onefile':
path = osp.dirname(path)
if not osp.exists(path):
os.makedirs(path) | python | def pre_execute(self, execution, context):
"""Make sure the named directory is created if possible"""
path = self._fspath
if path:
path = path.format(
benchmark=context.benchmark,
api=execution['category'],
**execution.get('metas', {})
)
if self.clean_path:
shutil.rmtree(path, ignore_errors=True)
if execution['metas']['file_mode'] == 'onefile':
path = osp.dirname(path)
if not osp.exists(path):
os.makedirs(path) | [
"def",
"pre_execute",
"(",
"self",
",",
"execution",
",",
"context",
")",
":",
"path",
"=",
"self",
".",
"_fspath",
"if",
"path",
":",
"path",
"=",
"path",
".",
"format",
"(",
"benchmark",
"=",
"context",
".",
"benchmark",
",",
"api",
"=",
"execution",
"[",
"'category'",
"]",
",",
"*",
"*",
"execution",
".",
"get",
"(",
"'metas'",
",",
"{",
"}",
")",
")",
"if",
"self",
".",
"clean_path",
":",
"shutil",
".",
"rmtree",
"(",
"path",
",",
"ignore_errors",
"=",
"True",
")",
"if",
"execution",
"[",
"'metas'",
"]",
"[",
"'file_mode'",
"]",
"==",
"'onefile'",
":",
"path",
"=",
"osp",
".",
"dirname",
"(",
"path",
")",
"if",
"not",
"osp",
".",
"exists",
"(",
"path",
")",
":",
"os",
".",
"makedirs",
"(",
"path",
")"
] | Make sure the named directory is created if possible | [
"Make",
"sure",
"the",
"named",
"directory",
"is",
"created",
"if",
"possible"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L227-L241 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.sizes | def sizes(self):
"""Provides block_size and transfer_size through a list
of dict, for instance: [{'transfer': '1M 4M', 'block': '8M'}]
"""
if self.attributes.get('sizes'):
for settings in self.attributes.get('sizes'):
for pair in itertools.product(
shlex.split(settings['block']), shlex.split(settings['transfer'])
):
yield pair
else:
for pair in itertools.product(self.block_size, self.transfer_size):
yield pair | python | def sizes(self):
"""Provides block_size and transfer_size through a list
of dict, for instance: [{'transfer': '1M 4M', 'block': '8M'}]
"""
if self.attributes.get('sizes'):
for settings in self.attributes.get('sizes'):
for pair in itertools.product(
shlex.split(settings['block']), shlex.split(settings['transfer'])
):
yield pair
else:
for pair in itertools.product(self.block_size, self.transfer_size):
yield pair | [
"def",
"sizes",
"(",
"self",
")",
":",
"if",
"self",
".",
"attributes",
".",
"get",
"(",
"'sizes'",
")",
":",
"for",
"settings",
"in",
"self",
".",
"attributes",
".",
"get",
"(",
"'sizes'",
")",
":",
"for",
"pair",
"in",
"itertools",
".",
"product",
"(",
"shlex",
".",
"split",
"(",
"settings",
"[",
"'block'",
"]",
")",
",",
"shlex",
".",
"split",
"(",
"settings",
"[",
"'transfer'",
"]",
")",
")",
":",
"yield",
"pair",
"else",
":",
"for",
"pair",
"in",
"itertools",
".",
"product",
"(",
"self",
".",
"block_size",
",",
"self",
".",
"transfer_size",
")",
":",
"yield",
"pair"
] | Provides block_size and transfer_size through a list
of dict, for instance: [{'transfer': '1M 4M', 'block': '8M'}] | [
"Provides",
"block_size",
"and",
"transfer_size",
"through",
"a",
"list",
"of",
"dict",
"for",
"instance",
":",
"[",
"{",
"transfer",
":",
"1M",
"4M",
"block",
":",
"8M",
"}",
"]"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L244-L256 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.options | def options(self):
"""Additional options appended to the ior command
type: either string or a list of string
"""
options = self.attributes['options']
if isinstance(options, six.string_types):
options = shlex.split(options)
options = [str(e) for e in options]
return options | python | def options(self):
"""Additional options appended to the ior command
type: either string or a list of string
"""
options = self.attributes['options']
if isinstance(options, six.string_types):
options = shlex.split(options)
options = [str(e) for e in options]
return options | [
"def",
"options",
"(",
"self",
")",
":",
"options",
"=",
"self",
".",
"attributes",
"[",
"'options'",
"]",
"if",
"isinstance",
"(",
"options",
",",
"six",
".",
"string_types",
")",
":",
"options",
"=",
"shlex",
".",
"split",
"(",
"options",
")",
"options",
"=",
"[",
"str",
"(",
"e",
")",
"for",
"e",
"in",
"options",
"]",
"return",
"options"
] | Additional options appended to the ior command
type: either string or a list of string | [
"Additional",
"options",
"appended",
"to",
"the",
"ior",
"command",
"type",
":",
"either",
"string",
"or",
"a",
"list",
"of",
"string"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L302-L310 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.file_mode | def file_mode(self):
"""onefile, fpp, or both"""
fms = self.attributes['file_mode']
eax = set()
if isinstance(fms, six.string_types):
fms = shlex.split(fms)
for fm in fms:
if fm == 'both':
eax.add('fpp')
eax.add('onefile')
elif fm in ['fpp', 'onefile']:
eax.add(fm)
else:
raise Exception('Invalid IOR file mode: ' + fm)
return eax | python | def file_mode(self):
"""onefile, fpp, or both"""
fms = self.attributes['file_mode']
eax = set()
if isinstance(fms, six.string_types):
fms = shlex.split(fms)
for fm in fms:
if fm == 'both':
eax.add('fpp')
eax.add('onefile')
elif fm in ['fpp', 'onefile']:
eax.add(fm)
else:
raise Exception('Invalid IOR file mode: ' + fm)
return eax | [
"def",
"file_mode",
"(",
"self",
")",
":",
"fms",
"=",
"self",
".",
"attributes",
"[",
"'file_mode'",
"]",
"eax",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"fms",
",",
"six",
".",
"string_types",
")",
":",
"fms",
"=",
"shlex",
".",
"split",
"(",
"fms",
")",
"for",
"fm",
"in",
"fms",
":",
"if",
"fm",
"==",
"'both'",
":",
"eax",
".",
"add",
"(",
"'fpp'",
")",
"eax",
".",
"add",
"(",
"'onefile'",
")",
"elif",
"fm",
"in",
"[",
"'fpp'",
",",
"'onefile'",
"]",
":",
"eax",
".",
"add",
"(",
"fm",
")",
"else",
":",
"raise",
"Exception",
"(",
"'Invalid IOR file mode: '",
"+",
"fm",
")",
"return",
"eax"
] | onefile, fpp, or both | [
"onefile",
"fpp",
"or",
"both"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L313-L327 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.block_size | def block_size(self):
"""Contiguous bytes to write per task (e.g.: 8, 4k, 2m, 1g)
"""
bs = self.attributes['block_size']
if isinstance(bs, six.string_types):
bs = shlex.split(bs)
bs = [str(e) for e in bs]
return bs | python | def block_size(self):
"""Contiguous bytes to write per task (e.g.: 8, 4k, 2m, 1g)
"""
bs = self.attributes['block_size']
if isinstance(bs, six.string_types):
bs = shlex.split(bs)
bs = [str(e) for e in bs]
return bs | [
"def",
"block_size",
"(",
"self",
")",
":",
"bs",
"=",
"self",
".",
"attributes",
"[",
"'block_size'",
"]",
"if",
"isinstance",
"(",
"bs",
",",
"six",
".",
"string_types",
")",
":",
"bs",
"=",
"shlex",
".",
"split",
"(",
"bs",
")",
"bs",
"=",
"[",
"str",
"(",
"e",
")",
"for",
"e",
"in",
"bs",
"]",
"return",
"bs"
] | Contiguous bytes to write per task (e.g.: 8, 4k, 2m, 1g) | [
"Contiguous",
"bytes",
"to",
"write",
"per",
"task",
"(",
"e",
".",
"g",
".",
":",
"8",
"4k",
"2m",
"1g",
")"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L330-L337 |
BlueBrain/hpcbench | hpcbench/benchmark/ior.py | IOR.transfer_size | def transfer_size(self):
"""Size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)"""
ts = self.attributes['transfer_size']
if isinstance(ts, six.string_types):
ts = shlex.split(ts)
ts = [str(e) for e in ts]
return ts | python | def transfer_size(self):
"""Size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)"""
ts = self.attributes['transfer_size']
if isinstance(ts, six.string_types):
ts = shlex.split(ts)
ts = [str(e) for e in ts]
return ts | [
"def",
"transfer_size",
"(",
"self",
")",
":",
"ts",
"=",
"self",
".",
"attributes",
"[",
"'transfer_size'",
"]",
"if",
"isinstance",
"(",
"ts",
",",
"six",
".",
"string_types",
")",
":",
"ts",
"=",
"shlex",
".",
"split",
"(",
"ts",
")",
"ts",
"=",
"[",
"str",
"(",
"e",
")",
"for",
"e",
"in",
"ts",
"]",
"return",
"ts"
] | Size of transfer in bytes (e.g.: 8, 4k, 2m, 1g) | [
"Size",
"of",
"transfer",
"in",
"bytes",
"(",
"e",
".",
"g",
".",
":",
"8",
"4k",
"2m",
"1g",
")"
] | train | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/ior.py#L340-L346 |
OzymandiasTheGreat/python-libinput | libinput/constant.py | EventType.is_device | def is_device(self):
"""Macro to check if this event is
a :class:`~libinput.event.DeviceNotifyEvent`.
"""
if self in {type(self).DEVICE_ADDED, type(self).DEVICE_REMOVED}:
return True
else:
return False | python | def is_device(self):
"""Macro to check if this event is
a :class:`~libinput.event.DeviceNotifyEvent`.
"""
if self in {type(self).DEVICE_ADDED, type(self).DEVICE_REMOVED}:
return True
else:
return False | [
"def",
"is_device",
"(",
"self",
")",
":",
"if",
"self",
"in",
"{",
"type",
"(",
"self",
")",
".",
"DEVICE_ADDED",
",",
"type",
"(",
"self",
")",
".",
"DEVICE_REMOVED",
"}",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Macro to check if this event is
a :class:`~libinput.event.DeviceNotifyEvent`. | [
"Macro",
"to",
"check",
"if",
"this",
"event",
"is",
"a",
":",
"class",
":",
"~libinput",
".",
"event",
".",
"DeviceNotifyEvent",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/constant.py#L70-L78 |
OzymandiasTheGreat/python-libinput | libinput/constant.py | EventType.is_pointer | def is_pointer(self):
"""Macro to check if this event is
a :class:`~libinput.event.PointerEvent`.
"""
if self in {type(self).POINTER_MOTION, type(self).POINTER_BUTTON,
type(self).POINTER_MOTION_ABSOLUTE, type(self).POINTER_AXIS}:
return True
else:
return False | python | def is_pointer(self):
"""Macro to check if this event is
a :class:`~libinput.event.PointerEvent`.
"""
if self in {type(self).POINTER_MOTION, type(self).POINTER_BUTTON,
type(self).POINTER_MOTION_ABSOLUTE, type(self).POINTER_AXIS}:
return True
else:
return False | [
"def",
"is_pointer",
"(",
"self",
")",
":",
"if",
"self",
"in",
"{",
"type",
"(",
"self",
")",
".",
"POINTER_MOTION",
",",
"type",
"(",
"self",
")",
".",
"POINTER_BUTTON",
",",
"type",
"(",
"self",
")",
".",
"POINTER_MOTION_ABSOLUTE",
",",
"type",
"(",
"self",
")",
".",
"POINTER_AXIS",
"}",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Macro to check if this event is
a :class:`~libinput.event.PointerEvent`. | [
"Macro",
"to",
"check",
"if",
"this",
"event",
"is",
"a",
":",
"class",
":",
"~libinput",
".",
"event",
".",
"PointerEvent",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/constant.py#L90-L99 |
OzymandiasTheGreat/python-libinput | libinput/constant.py | EventType.is_touch | def is_touch(self):
"""Macro to check if this event is
a :class:`~libinput.event.TouchEvent`.
"""
if self in {type(self).TOUCH_DOWN, type(self).TOUCH_UP,
type(self).TOUCH_MOTION, type(self).TOUCH_CANCEL,
type(self).TOUCH_FRAME}:
return True
else:
return False | python | def is_touch(self):
"""Macro to check if this event is
a :class:`~libinput.event.TouchEvent`.
"""
if self in {type(self).TOUCH_DOWN, type(self).TOUCH_UP,
type(self).TOUCH_MOTION, type(self).TOUCH_CANCEL,
type(self).TOUCH_FRAME}:
return True
else:
return False | [
"def",
"is_touch",
"(",
"self",
")",
":",
"if",
"self",
"in",
"{",
"type",
"(",
"self",
")",
".",
"TOUCH_DOWN",
",",
"type",
"(",
"self",
")",
".",
"TOUCH_UP",
",",
"type",
"(",
"self",
")",
".",
"TOUCH_MOTION",
",",
"type",
"(",
"self",
")",
".",
"TOUCH_CANCEL",
",",
"type",
"(",
"self",
")",
".",
"TOUCH_FRAME",
"}",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Macro to check if this event is
a :class:`~libinput.event.TouchEvent`. | [
"Macro",
"to",
"check",
"if",
"this",
"event",
"is",
"a",
":",
"class",
":",
"~libinput",
".",
"event",
".",
"TouchEvent",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/constant.py#L101-L111 |
OzymandiasTheGreat/python-libinput | libinput/constant.py | EventType.is_tablet_tool | def is_tablet_tool(self):
"""Macro to check if this event is
a :class:`~libinput.event.TabletToolEvent`.
"""
if self in {type(self).TABLET_TOOL_AXIS, type(self).TABLET_TOOL_BUTTON,
type(self).TABLET_TOOL_PROXIMITY, type(self).TABLET_TOOL_TIP}:
return True
else:
return False | python | def is_tablet_tool(self):
"""Macro to check if this event is
a :class:`~libinput.event.TabletToolEvent`.
"""
if self in {type(self).TABLET_TOOL_AXIS, type(self).TABLET_TOOL_BUTTON,
type(self).TABLET_TOOL_PROXIMITY, type(self).TABLET_TOOL_TIP}:
return True
else:
return False | [
"def",
"is_tablet_tool",
"(",
"self",
")",
":",
"if",
"self",
"in",
"{",
"type",
"(",
"self",
")",
".",
"TABLET_TOOL_AXIS",
",",
"type",
"(",
"self",
")",
".",
"TABLET_TOOL_BUTTON",
",",
"type",
"(",
"self",
")",
".",
"TABLET_TOOL_PROXIMITY",
",",
"type",
"(",
"self",
")",
".",
"TABLET_TOOL_TIP",
"}",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Macro to check if this event is
a :class:`~libinput.event.TabletToolEvent`. | [
"Macro",
"to",
"check",
"if",
"this",
"event",
"is",
"a",
":",
"class",
":",
"~libinput",
".",
"event",
".",
"TabletToolEvent",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/constant.py#L113-L122 |
OzymandiasTheGreat/python-libinput | libinput/constant.py | EventType.is_tablet_pad | def is_tablet_pad(self):
"""Macro to check if this event is
a :class:`~libinput.event.TabletPadEvent`.
"""
if self in {type(self).TABLET_PAD_BUTTON, type(self).TABLET_PAD_RING,
type(self).TABLET_PAD_STRIP}:
return True
else:
return False | python | def is_tablet_pad(self):
"""Macro to check if this event is
a :class:`~libinput.event.TabletPadEvent`.
"""
if self in {type(self).TABLET_PAD_BUTTON, type(self).TABLET_PAD_RING,
type(self).TABLET_PAD_STRIP}:
return True
else:
return False | [
"def",
"is_tablet_pad",
"(",
"self",
")",
":",
"if",
"self",
"in",
"{",
"type",
"(",
"self",
")",
".",
"TABLET_PAD_BUTTON",
",",
"type",
"(",
"self",
")",
".",
"TABLET_PAD_RING",
",",
"type",
"(",
"self",
")",
".",
"TABLET_PAD_STRIP",
"}",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Macro to check if this event is
a :class:`~libinput.event.TabletPadEvent`. | [
"Macro",
"to",
"check",
"if",
"this",
"event",
"is",
"a",
":",
"class",
":",
"~libinput",
".",
"event",
".",
"TabletPadEvent",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/constant.py#L124-L133 |
OzymandiasTheGreat/python-libinput | libinput/constant.py | EventType.is_gesture | def is_gesture(self):
"""Macro to check if this event is
a :class:`~libinput.event.GestureEvent`.
"""
if self in {type(self).GESTURE_SWIPE_BEGIN, type(self).GESTURE_SWIPE_END,
type(self).GESTURE_SWIPE_UPDATE, type(self).GESTURE_PINCH_BEGIN,
type(self).GESTURE_PINCH_UPDATE, type(self).GESTURE_PINCH_END}:
return True
else:
return False | python | def is_gesture(self):
"""Macro to check if this event is
a :class:`~libinput.event.GestureEvent`.
"""
if self in {type(self).GESTURE_SWIPE_BEGIN, type(self).GESTURE_SWIPE_END,
type(self).GESTURE_SWIPE_UPDATE, type(self).GESTURE_PINCH_BEGIN,
type(self).GESTURE_PINCH_UPDATE, type(self).GESTURE_PINCH_END}:
return True
else:
return False | [
"def",
"is_gesture",
"(",
"self",
")",
":",
"if",
"self",
"in",
"{",
"type",
"(",
"self",
")",
".",
"GESTURE_SWIPE_BEGIN",
",",
"type",
"(",
"self",
")",
".",
"GESTURE_SWIPE_END",
",",
"type",
"(",
"self",
")",
".",
"GESTURE_SWIPE_UPDATE",
",",
"type",
"(",
"self",
")",
".",
"GESTURE_PINCH_BEGIN",
",",
"type",
"(",
"self",
")",
".",
"GESTURE_PINCH_UPDATE",
",",
"type",
"(",
"self",
")",
".",
"GESTURE_PINCH_END",
"}",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Macro to check if this event is
a :class:`~libinput.event.GestureEvent`. | [
"Macro",
"to",
"check",
"if",
"this",
"event",
"is",
"a",
":",
"class",
":",
"~libinput",
".",
"event",
".",
"GestureEvent",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/constant.py#L135-L145 |
OzymandiasTheGreat/python-libinput | libinput/event.py | Event.device | def device(self):
"""The device associated with this event.
For device added/removed events this is the device added or removed.
For all other device events, this is the device that generated the
event.
Returns:
~libinput.define.Device: Device object.
"""
hdevice = self._libinput.libinput_event_get_device(self._hevent)
return Device(hdevice, self._libinput) | python | def device(self):
"""The device associated with this event.
For device added/removed events this is the device added or removed.
For all other device events, this is the device that generated the
event.
Returns:
~libinput.define.Device: Device object.
"""
hdevice = self._libinput.libinput_event_get_device(self._hevent)
return Device(hdevice, self._libinput) | [
"def",
"device",
"(",
"self",
")",
":",
"hdevice",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_get_device",
"(",
"self",
".",
"_hevent",
")",
"return",
"Device",
"(",
"hdevice",
",",
"self",
".",
"_libinput",
")"
] | The device associated with this event.
For device added/removed events this is the device added or removed.
For all other device events, this is the device that generated the
event.
Returns:
~libinput.define.Device: Device object. | [
"The",
"device",
"associated",
"with",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L53-L65 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.delta | def delta(self):
"""The delta between the last event and the current event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION`, this property
raises :exc:`AttributeError`.
If a device employs pointer acceleration, the delta
returned by this method is the accelerated delta.
Relative motion deltas are to be interpreted as pixel movement of a
standardized mouse. See `Normalization of relative motion`_
for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_pointer_get_dx(self._handle)
delta_y = self._libinput.libinput_event_pointer_get_dy(self._handle)
return delta_x, delta_y | python | def delta(self):
"""The delta between the last event and the current event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION`, this property
raises :exc:`AttributeError`.
If a device employs pointer acceleration, the delta
returned by this method is the accelerated delta.
Relative motion deltas are to be interpreted as pixel movement of a
standardized mouse. See `Normalization of relative motion`_
for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_pointer_get_dx(self._handle)
delta_y = self._libinput.libinput_event_pointer_get_dy(self._handle)
return delta_x, delta_y | [
"def",
"delta",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_MOTION",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"delta_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_dx",
"(",
"self",
".",
"_handle",
")",
"delta_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_dy",
"(",
"self",
".",
"_handle",
")",
"return",
"delta_x",
",",
"delta_y"
] | The delta between the last event and the current event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION`, this property
raises :exc:`AttributeError`.
If a device employs pointer acceleration, the delta
returned by this method is the accelerated delta.
Relative motion deltas are to be interpreted as pixel movement of a
standardized mouse. See `Normalization of relative motion`_
for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
Raises:
AttributeError | [
"The",
"delta",
"between",
"the",
"last",
"event",
"and",
"the",
"current",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L156-L180 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.delta_unaccelerated | def delta_unaccelerated(self):
"""The relative delta of the unaccelerated motion vector of the
current event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION`, this property
raises :exc:`AttributeError`.
Relative unaccelerated motion deltas are raw device coordinates. Note
that these coordinates are subject to the device's native resolution.
Touchpad coordinates represent raw device coordinates in the
(X, Y) resolution of the touchpad.
See `Normalization of relative motion`_ for more details.
Any rotation applied to the device also applies to unaccelerated motion
(see :meth:`~libinput.define.Device.config_rotation_set_angle`).
Returns:
(float, float): The unaccelerated relative (x, y) movement since
the last event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_pointer_get_dx_unaccelerated(
self._handle)
delta_y = self._libinput.libinput_event_pointer_get_dy_unaccelerated(
self._handle)
return delta_x, delta_y | python | def delta_unaccelerated(self):
"""The relative delta of the unaccelerated motion vector of the
current event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION`, this property
raises :exc:`AttributeError`.
Relative unaccelerated motion deltas are raw device coordinates. Note
that these coordinates are subject to the device's native resolution.
Touchpad coordinates represent raw device coordinates in the
(X, Y) resolution of the touchpad.
See `Normalization of relative motion`_ for more details.
Any rotation applied to the device also applies to unaccelerated motion
(see :meth:`~libinput.define.Device.config_rotation_set_angle`).
Returns:
(float, float): The unaccelerated relative (x, y) movement since
the last event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_pointer_get_dx_unaccelerated(
self._handle)
delta_y = self._libinput.libinput_event_pointer_get_dy_unaccelerated(
self._handle)
return delta_x, delta_y | [
"def",
"delta_unaccelerated",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_MOTION",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"delta_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_dx_unaccelerated",
"(",
"self",
".",
"_handle",
")",
"delta_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_dy_unaccelerated",
"(",
"self",
".",
"_handle",
")",
"return",
"delta_x",
",",
"delta_y"
] | The relative delta of the unaccelerated motion vector of the
current event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION`, this property
raises :exc:`AttributeError`.
Relative unaccelerated motion deltas are raw device coordinates. Note
that these coordinates are subject to the device's native resolution.
Touchpad coordinates represent raw device coordinates in the
(X, Y) resolution of the touchpad.
See `Normalization of relative motion`_ for more details.
Any rotation applied to the device also applies to unaccelerated motion
(see :meth:`~libinput.define.Device.config_rotation_set_angle`).
Returns:
(float, float): The unaccelerated relative (x, y) movement since
the last event.
Raises:
AttributeError | [
"The",
"relative",
"delta",
"of",
"the",
"unaccelerated",
"motion",
"vector",
"of",
"the",
"current",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L183-L213 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.absolute_coords | def absolute_coords(self):
"""The current absolute coordinates of the pointer event,
in mm from the top left corner of the device.
To get the corresponding output screen coordinate, use
:meth:`transform_absolute_coords`.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`,
this property raises :exc:`AttributeError`.
Returns:
(float, float): The current absolute coordinates.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION_ABSOLUTE:
raise AttributeError(_wrong_prop.format(self.type))
abs_x = self._libinput.libinput_event_pointer_get_absolute_x(
self._handle)
abs_y = self._libinput.libinput_event_pointer_get_absolute_y(
self._handle)
return abs_x, abs_y | python | def absolute_coords(self):
"""The current absolute coordinates of the pointer event,
in mm from the top left corner of the device.
To get the corresponding output screen coordinate, use
:meth:`transform_absolute_coords`.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`,
this property raises :exc:`AttributeError`.
Returns:
(float, float): The current absolute coordinates.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION_ABSOLUTE:
raise AttributeError(_wrong_prop.format(self.type))
abs_x = self._libinput.libinput_event_pointer_get_absolute_x(
self._handle)
abs_y = self._libinput.libinput_event_pointer_get_absolute_y(
self._handle)
return abs_x, abs_y | [
"def",
"absolute_coords",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_MOTION_ABSOLUTE",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"abs_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_absolute_x",
"(",
"self",
".",
"_handle",
")",
"abs_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_absolute_y",
"(",
"self",
".",
"_handle",
")",
"return",
"abs_x",
",",
"abs_y"
] | The current absolute coordinates of the pointer event,
in mm from the top left corner of the device.
To get the corresponding output screen coordinate, use
:meth:`transform_absolute_coords`.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`,
this property raises :exc:`AttributeError`.
Returns:
(float, float): The current absolute coordinates.
Raises:
AttributeError | [
"The",
"current",
"absolute",
"coordinates",
"of",
"the",
"pointer",
"event",
"in",
"mm",
"from",
"the",
"top",
"left",
"corner",
"of",
"the",
"device",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L216-L239 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.transform_absolute_coords | def transform_absolute_coords(self, width, height):
"""Return the current absolute coordinates of the pointer event,
transformed to screen coordinates.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`,
this method raises :exc:`AttributeError`.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
(float, float): The current absolute (x, y) coordinates transformed
to a screen coordinates.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION_ABSOLUTE:
raise AttributeError(_wrong_meth.format(self.type))
abs_x = self._libinput \
.libinput_event_pointer_get_absolute_x_transformed(
self._handle, width)
abs_y = self._libinput \
.libinput_event_pointer_get_absolute_y_transformed(
self._handle, height)
return abs_x, abs_y | python | def transform_absolute_coords(self, width, height):
"""Return the current absolute coordinates of the pointer event,
transformed to screen coordinates.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`,
this method raises :exc:`AttributeError`.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
(float, float): The current absolute (x, y) coordinates transformed
to a screen coordinates.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_MOTION_ABSOLUTE:
raise AttributeError(_wrong_meth.format(self.type))
abs_x = self._libinput \
.libinput_event_pointer_get_absolute_x_transformed(
self._handle, width)
abs_y = self._libinput \
.libinput_event_pointer_get_absolute_y_transformed(
self._handle, height)
return abs_x, abs_y | [
"def",
"transform_absolute_coords",
"(",
"self",
",",
"width",
",",
"height",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_MOTION_ABSOLUTE",
":",
"raise",
"AttributeError",
"(",
"_wrong_meth",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"abs_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_absolute_x_transformed",
"(",
"self",
".",
"_handle",
",",
"width",
")",
"abs_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_absolute_y_transformed",
"(",
"self",
".",
"_handle",
",",
"height",
")",
"return",
"abs_x",
",",
"abs_y"
] | Return the current absolute coordinates of the pointer event,
transformed to screen coordinates.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`,
this method raises :exc:`AttributeError`.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
(float, float): The current absolute (x, y) coordinates transformed
to a screen coordinates.
Raises:
AttributeError | [
"Return",
"the",
"current",
"absolute",
"coordinates",
"of",
"the",
"pointer",
"event",
"transformed",
"to",
"screen",
"coordinates",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L241-L267 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.button | def button(self):
"""The button that triggered this event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`,
this property raises :exc:`AttributeError`.
Returns:
int: The button triggering this event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_button(self._handle) | python | def button(self):
"""The button that triggered this event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`,
this property raises :exc:`AttributeError`.
Returns:
int: The button triggering this event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_button(self._handle) | [
"def",
"button",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_BUTTON",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_button",
"(",
"self",
".",
"_handle",
")"
] | The button that triggered this event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`,
this property raises :exc:`AttributeError`.
Returns:
int: The button triggering this event.
Raises:
AttributeError | [
"The",
"button",
"that",
"triggered",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L270-L285 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.button_state | def button_state(self):
"""The button state that triggered this event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.ButtonState: The button state triggering this
event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_button_state(
self._handle) | python | def button_state(self):
"""The button state that triggered this event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.ButtonState: The button state triggering this
event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_button_state(
self._handle) | [
"def",
"button_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_BUTTON",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_button_state",
"(",
"self",
".",
"_handle",
")"
] | The button state that triggered this event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.ButtonState: The button state triggering this
event.
Raises:
AttributeError | [
"The",
"button",
"state",
"that",
"triggered",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L288-L305 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.seat_button_count | def seat_button_count(self):
"""The total number of buttons pressed on all devices on the
associated seat after the event was triggered.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property
raises :exc:`AssertionError`.
Returns:
int: The seat wide pressed button count for the key of this event.
Raises:
AssertionError
"""
if self.type != EventType.POINTER_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_seat_button_count(
self._handle) | python | def seat_button_count(self):
"""The total number of buttons pressed on all devices on the
associated seat after the event was triggered.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property
raises :exc:`AssertionError`.
Returns:
int: The seat wide pressed button count for the key of this event.
Raises:
AssertionError
"""
if self.type != EventType.POINTER_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_seat_button_count(
self._handle) | [
"def",
"seat_button_count",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_BUTTON",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_seat_button_count",
"(",
"self",
".",
"_handle",
")"
] | The total number of buttons pressed on all devices on the
associated seat after the event was triggered.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property
raises :exc:`AssertionError`.
Returns:
int: The seat wide pressed button count for the key of this event.
Raises:
AssertionError | [
"The",
"total",
"number",
"of",
"buttons",
"pressed",
"on",
"all",
"devices",
"on",
"the",
"associated",
"seat",
"after",
"the",
"event",
"was",
"triggered",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L308-L325 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.has_axis | def has_axis(self, axis):
"""Check if the event has a valid value for the given axis.
If this method returns True for an axis and :meth:`get_axis_value`
returns a value of 0, the event is a scroll stop event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_AXIS`, this method raises
:exc:`AttributeError`.
Args:
axis (~libinput.constant.PointerAxis): The axis to check.
Returns:
bool: True if this event contains a value for this axis.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_meth.format(self.type))
return self._libinput.libinput_event_pointer_has_axis(
self._handle, axis) | python | def has_axis(self, axis):
"""Check if the event has a valid value for the given axis.
If this method returns True for an axis and :meth:`get_axis_value`
returns a value of 0, the event is a scroll stop event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_AXIS`, this method raises
:exc:`AttributeError`.
Args:
axis (~libinput.constant.PointerAxis): The axis to check.
Returns:
bool: True if this event contains a value for this axis.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_meth.format(self.type))
return self._libinput.libinput_event_pointer_has_axis(
self._handle, axis) | [
"def",
"has_axis",
"(",
"self",
",",
"axis",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_AXIS",
":",
"raise",
"AttributeError",
"(",
"_wrong_meth",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_has_axis",
"(",
"self",
".",
"_handle",
",",
"axis",
")"
] | Check if the event has a valid value for the given axis.
If this method returns True for an axis and :meth:`get_axis_value`
returns a value of 0, the event is a scroll stop event.
For pointer events that are not of type
:attr:`~libinput.constant.EventType.POINTER_AXIS`, this method raises
:exc:`AttributeError`.
Args:
axis (~libinput.constant.PointerAxis): The axis to check.
Returns:
bool: True if this event contains a value for this axis.
Raises:
AttributeError | [
"Check",
"if",
"the",
"event",
"has",
"a",
"valid",
"value",
"for",
"the",
"given",
"axis",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L327-L348 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.get_axis_value | def get_axis_value(self, axis):
"""Return the axis value of the given axis.
The interpretation of the value depends on the axis. For the two
scrolling axes :attr:`~libinput.constant.PointerAxis.SCROLL_VERTICAL`
and :attr:`~libinput.constant.PointerAxis.SCROLL_HORIZONTAL`, the value
of the event is in relative scroll units, with the positive direction
being down or right, respectively. For the interpretation of the value,
see :attr:`axis_source`.
If :meth:`has_axis` returns False for an axis, this method returns 0
for that axis.
For pointer events that are not of type
:attr:`~libinput.constant.Event.POINTER_AXIS`, this method raises
:exc:`AttributeError`.
Args:
axis (~libinput.constant.PointerAxis): The axis who's value to get.
Returns:
float: The axis value of this event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_meth.format(self.type))
return self._libinput.libinput_event_pointer_get_axis_value(
self._handle, axis) | python | def get_axis_value(self, axis):
"""Return the axis value of the given axis.
The interpretation of the value depends on the axis. For the two
scrolling axes :attr:`~libinput.constant.PointerAxis.SCROLL_VERTICAL`
and :attr:`~libinput.constant.PointerAxis.SCROLL_HORIZONTAL`, the value
of the event is in relative scroll units, with the positive direction
being down or right, respectively. For the interpretation of the value,
see :attr:`axis_source`.
If :meth:`has_axis` returns False for an axis, this method returns 0
for that axis.
For pointer events that are not of type
:attr:`~libinput.constant.Event.POINTER_AXIS`, this method raises
:exc:`AttributeError`.
Args:
axis (~libinput.constant.PointerAxis): The axis who's value to get.
Returns:
float: The axis value of this event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_meth.format(self.type))
return self._libinput.libinput_event_pointer_get_axis_value(
self._handle, axis) | [
"def",
"get_axis_value",
"(",
"self",
",",
"axis",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_AXIS",
":",
"raise",
"AttributeError",
"(",
"_wrong_meth",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_axis_value",
"(",
"self",
".",
"_handle",
",",
"axis",
")"
] | Return the axis value of the given axis.
The interpretation of the value depends on the axis. For the two
scrolling axes :attr:`~libinput.constant.PointerAxis.SCROLL_VERTICAL`
and :attr:`~libinput.constant.PointerAxis.SCROLL_HORIZONTAL`, the value
of the event is in relative scroll units, with the positive direction
being down or right, respectively. For the interpretation of the value,
see :attr:`axis_source`.
If :meth:`has_axis` returns False for an axis, this method returns 0
for that axis.
For pointer events that are not of type
:attr:`~libinput.constant.Event.POINTER_AXIS`, this method raises
:exc:`AttributeError`.
Args:
axis (~libinput.constant.PointerAxis): The axis who's value to get.
Returns:
float: The axis value of this event.
Raises:
AttributeError | [
"Return",
"the",
"axis",
"value",
"of",
"the",
"given",
"axis",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L350-L378 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.axis_source | def axis_source(self):
"""The source for a given axis event.
Axis events (scroll events) can be caused by a hardware item such as
a scroll wheel or emulated from other input sources, such as two-finger
or edge scrolling on a touchpad.
If the source is :attr:`~libinput.constant.PointerAxisSource.FINGER`,
libinput guarantees that a scroll sequence is terminated with a scroll
value of 0. A caller may use this information to decide on whether
kinetic scrolling should be triggered on this scroll sequence. The
coordinate system is identical to the cursor movement, i.e. a scroll
value of 1 represents the equivalent relative motion of 1.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`,
no terminating event is guaranteed (though it may happen). Scrolling
is in discrete steps, the value is the angle the wheel moved in
degrees. The default is 15 degrees per wheel click, but some mice may
have differently grained wheels. It is up to the caller how to
interpret such different step sizes.
If the source is :attr:`~libinput.constant.PointerAxisSource.CONTINUOUS`,
no terminating event is guaranteed (though it may happen). The
coordinate system is identical to the cursor movement, i.e. a scroll
value of 1 represents the equivalent relative motion of 1.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL_TILT`,
no terminating event is guaranteed (though it may happen). Scrolling
is in discrete steps and there is no physical equivalent for the value
returned here. For backwards compatibility, the value of this
property is identical to a single mouse wheel rotation by this device
(see the documentation for
:attr:`~libinput.constant.PointerAxisSource.WHEEL` above). Callers
should not use this value but instead exclusively refer to the value
returned by :meth:`get_axis_value_discrete`.
For pointer events that are not of type
:attr:`~libinput.constant.Event.POINTER_AXIS`, this property raises
:exc:`AttributeError`.
Returns:
~libinput.constant.PointerAxisSource: The source for this axis
event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_axis_source(
self._handle) | python | def axis_source(self):
"""The source for a given axis event.
Axis events (scroll events) can be caused by a hardware item such as
a scroll wheel or emulated from other input sources, such as two-finger
or edge scrolling on a touchpad.
If the source is :attr:`~libinput.constant.PointerAxisSource.FINGER`,
libinput guarantees that a scroll sequence is terminated with a scroll
value of 0. A caller may use this information to decide on whether
kinetic scrolling should be triggered on this scroll sequence. The
coordinate system is identical to the cursor movement, i.e. a scroll
value of 1 represents the equivalent relative motion of 1.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`,
no terminating event is guaranteed (though it may happen). Scrolling
is in discrete steps, the value is the angle the wheel moved in
degrees. The default is 15 degrees per wheel click, but some mice may
have differently grained wheels. It is up to the caller how to
interpret such different step sizes.
If the source is :attr:`~libinput.constant.PointerAxisSource.CONTINUOUS`,
no terminating event is guaranteed (though it may happen). The
coordinate system is identical to the cursor movement, i.e. a scroll
value of 1 represents the equivalent relative motion of 1.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL_TILT`,
no terminating event is guaranteed (though it may happen). Scrolling
is in discrete steps and there is no physical equivalent for the value
returned here. For backwards compatibility, the value of this
property is identical to a single mouse wheel rotation by this device
(see the documentation for
:attr:`~libinput.constant.PointerAxisSource.WHEEL` above). Callers
should not use this value but instead exclusively refer to the value
returned by :meth:`get_axis_value_discrete`.
For pointer events that are not of type
:attr:`~libinput.constant.Event.POINTER_AXIS`, this property raises
:exc:`AttributeError`.
Returns:
~libinput.constant.PointerAxisSource: The source for this axis
event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_pointer_get_axis_source(
self._handle) | [
"def",
"axis_source",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_AXIS",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_axis_source",
"(",
"self",
".",
"_handle",
")"
] | The source for a given axis event.
Axis events (scroll events) can be caused by a hardware item such as
a scroll wheel or emulated from other input sources, such as two-finger
or edge scrolling on a touchpad.
If the source is :attr:`~libinput.constant.PointerAxisSource.FINGER`,
libinput guarantees that a scroll sequence is terminated with a scroll
value of 0. A caller may use this information to decide on whether
kinetic scrolling should be triggered on this scroll sequence. The
coordinate system is identical to the cursor movement, i.e. a scroll
value of 1 represents the equivalent relative motion of 1.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`,
no terminating event is guaranteed (though it may happen). Scrolling
is in discrete steps, the value is the angle the wheel moved in
degrees. The default is 15 degrees per wheel click, but some mice may
have differently grained wheels. It is up to the caller how to
interpret such different step sizes.
If the source is :attr:`~libinput.constant.PointerAxisSource.CONTINUOUS`,
no terminating event is guaranteed (though it may happen). The
coordinate system is identical to the cursor movement, i.e. a scroll
value of 1 represents the equivalent relative motion of 1.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL_TILT`,
no terminating event is guaranteed (though it may happen). Scrolling
is in discrete steps and there is no physical equivalent for the value
returned here. For backwards compatibility, the value of this
property is identical to a single mouse wheel rotation by this device
(see the documentation for
:attr:`~libinput.constant.PointerAxisSource.WHEEL` above). Callers
should not use this value but instead exclusively refer to the value
returned by :meth:`get_axis_value_discrete`.
For pointer events that are not of type
:attr:`~libinput.constant.Event.POINTER_AXIS`, this property raises
:exc:`AttributeError`.
Returns:
~libinput.constant.PointerAxisSource: The source for this axis
event.
Raises:
AttributeError | [
"The",
"source",
"for",
"a",
"given",
"axis",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L381-L429 |
OzymandiasTheGreat/python-libinput | libinput/event.py | PointerEvent.get_axis_value_discrete | def get_axis_value_discrete(self, axis):
"""Return the axis value in discrete steps for a given axis event.
How a value translates into a discrete step depends on the source.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`,
the discrete value correspond to the number of physical mouse wheel
clicks.
If the source is :attr:`~libinput.constant.PointerAxisSource.CONTINUOUS`
or :attr:`~libinput.constant.PointerAxisSource.FINGER`, the discrete
value is always 0.
Args:
axis (~libinput.constant.PointerAxis): The axis who's value to get.
Returns:
float: The discrete value for the given event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_meth.format(self.type))
return self._libinput.libinput_event_pointer_get_axis_value_discrete(
self._handle, axis) | python | def get_axis_value_discrete(self, axis):
"""Return the axis value in discrete steps for a given axis event.
How a value translates into a discrete step depends on the source.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`,
the discrete value correspond to the number of physical mouse wheel
clicks.
If the source is :attr:`~libinput.constant.PointerAxisSource.CONTINUOUS`
or :attr:`~libinput.constant.PointerAxisSource.FINGER`, the discrete
value is always 0.
Args:
axis (~libinput.constant.PointerAxis): The axis who's value to get.
Returns:
float: The discrete value for the given event.
Raises:
AttributeError
"""
if self.type != EventType.POINTER_AXIS:
raise AttributeError(_wrong_meth.format(self.type))
return self._libinput.libinput_event_pointer_get_axis_value_discrete(
self._handle, axis) | [
"def",
"get_axis_value_discrete",
"(",
"self",
",",
"axis",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"POINTER_AXIS",
":",
"raise",
"AttributeError",
"(",
"_wrong_meth",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_pointer_get_axis_value_discrete",
"(",
"self",
".",
"_handle",
",",
"axis",
")"
] | Return the axis value in discrete steps for a given axis event.
How a value translates into a discrete step depends on the source.
If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`,
the discrete value correspond to the number of physical mouse wheel
clicks.
If the source is :attr:`~libinput.constant.PointerAxisSource.CONTINUOUS`
or :attr:`~libinput.constant.PointerAxisSource.FINGER`, the discrete
value is always 0.
Args:
axis (~libinput.constant.PointerAxis): The axis who's value to get.
Returns:
float: The discrete value for the given event.
Raises:
AttributeError | [
"Return",
"the",
"axis",
"value",
"in",
"discrete",
"steps",
"for",
"a",
"given",
"axis",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L431-L454 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TouchEvent.slot | def slot(self):
"""The slot of this touch event.
See the kernel's multitouch protocol B documentation for more
information.
If the touch event has no assigned slot, for example if it is from
a single touch device, this property returns -1.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_UP`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION` or
:attr:`~libinput.constant.EventType.TOUCH_CANCEL`, this property
raises :exc:`AttributeError`.
Returns:
int: The slot of this touch event.
Raises:
AttributeError
"""
if self.type == EventType.TOUCH_FRAME:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_touch_get_slot(self._handle) | python | def slot(self):
"""The slot of this touch event.
See the kernel's multitouch protocol B documentation for more
information.
If the touch event has no assigned slot, for example if it is from
a single touch device, this property returns -1.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_UP`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION` or
:attr:`~libinput.constant.EventType.TOUCH_CANCEL`, this property
raises :exc:`AttributeError`.
Returns:
int: The slot of this touch event.
Raises:
AttributeError
"""
if self.type == EventType.TOUCH_FRAME:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_touch_get_slot(self._handle) | [
"def",
"slot",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"==",
"EventType",
".",
"TOUCH_FRAME",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_touch_get_slot",
"(",
"self",
".",
"_handle",
")"
] | The slot of this touch event.
See the kernel's multitouch protocol B documentation for more
information.
If the touch event has no assigned slot, for example if it is from
a single touch device, this property returns -1.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_UP`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION` or
:attr:`~libinput.constant.EventType.TOUCH_CANCEL`, this property
raises :exc:`AttributeError`.
Returns:
int: The slot of this touch event.
Raises:
AttributeError | [
"The",
"slot",
"of",
"this",
"touch",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L574-L597 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TouchEvent.seat_slot | def seat_slot(self):
"""The seat slot of the touch event.
A seat slot is a non-negative seat wide unique identifier of an active
touch point.
Events from single touch devices will be represented as one individual
touch point per device.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_UP`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION` or
:attr:`~libinput.constant.EventType.TOUCH_CANCEL`, this property
raises :exc:`AssertionError`.
Returns:
int: The seat slot of the touch event.
Raises:
AssertionError
"""
if self.type == EventType.TOUCH_FRAME:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_touch_get_seat_slot(self._handle) | python | def seat_slot(self):
"""The seat slot of the touch event.
A seat slot is a non-negative seat wide unique identifier of an active
touch point.
Events from single touch devices will be represented as one individual
touch point per device.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_UP`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION` or
:attr:`~libinput.constant.EventType.TOUCH_CANCEL`, this property
raises :exc:`AssertionError`.
Returns:
int: The seat slot of the touch event.
Raises:
AssertionError
"""
if self.type == EventType.TOUCH_FRAME:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_touch_get_seat_slot(self._handle) | [
"def",
"seat_slot",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"==",
"EventType",
".",
"TOUCH_FRAME",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_touch_get_seat_slot",
"(",
"self",
".",
"_handle",
")"
] | The seat slot of the touch event.
A seat slot is a non-negative seat wide unique identifier of an active
touch point.
Events from single touch devices will be represented as one individual
touch point per device.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_UP`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION` or
:attr:`~libinput.constant.EventType.TOUCH_CANCEL`, this property
raises :exc:`AssertionError`.
Returns:
int: The seat slot of the touch event.
Raises:
AssertionError | [
"The",
"seat",
"slot",
"of",
"the",
"touch",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L600-L623 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TouchEvent.coords | def coords(self):
"""The current absolute coordinates of the touch event,
in mm from the top left corner of the device.
To get the corresponding output screen coordinates, use
:meth:`transform_coords`.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION`, this property
raises :exc:`AttributeError`.
Returns:
(float, float): The current absolute (x, y) coordinates.
Raises:
AttributeError
"""
if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}:
raise AttributeError(_wrong_prop.format(self.type))
x = self._libinput.libinput_event_touch_get_x(self._handle)
y = self._libinput.libinput_event_touch_get_y(self._handle)
return x, y | python | def coords(self):
"""The current absolute coordinates of the touch event,
in mm from the top left corner of the device.
To get the corresponding output screen coordinates, use
:meth:`transform_coords`.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION`, this property
raises :exc:`AttributeError`.
Returns:
(float, float): The current absolute (x, y) coordinates.
Raises:
AttributeError
"""
if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}:
raise AttributeError(_wrong_prop.format(self.type))
x = self._libinput.libinput_event_touch_get_x(self._handle)
y = self._libinput.libinput_event_touch_get_y(self._handle)
return x, y | [
"def",
"coords",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"{",
"EventType",
".",
"TOUCH_DOWN",
",",
"EventType",
".",
"TOUCH_MOTION",
"}",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_touch_get_x",
"(",
"self",
".",
"_handle",
")",
"y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_touch_get_y",
"(",
"self",
".",
"_handle",
")",
"return",
"x",
",",
"y"
] | The current absolute coordinates of the touch event,
in mm from the top left corner of the device.
To get the corresponding output screen coordinates, use
:meth:`transform_coords`.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION`, this property
raises :exc:`AttributeError`.
Returns:
(float, float): The current absolute (x, y) coordinates.
Raises:
AttributeError | [
"The",
"current",
"absolute",
"coordinates",
"of",
"the",
"touch",
"event",
"in",
"mm",
"from",
"the",
"top",
"left",
"corner",
"of",
"the",
"device",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L626-L647 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TouchEvent.transform_coords | def transform_coords(self, width, height):
"""Return the current absolute coordinates of the touch event,
transformed to screen coordinates.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION`, this method
raises :exc:`AttributeError`.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
(float, float): The current absolute (x, y) coordinates transformed
to screen coordinates.
"""
if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}:
raise AttributeError(_wrong_meth.format(self.type))
x = self._libinput.libinput_event_touch_get_x_transformed(
self._handle, width)
y = self._libinput.libinput_event_touch_get_y_transformed(
self._handle, height)
return x, y | python | def transform_coords(self, width, height):
"""Return the current absolute coordinates of the touch event,
transformed to screen coordinates.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION`, this method
raises :exc:`AttributeError`.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
(float, float): The current absolute (x, y) coordinates transformed
to screen coordinates.
"""
if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}:
raise AttributeError(_wrong_meth.format(self.type))
x = self._libinput.libinput_event_touch_get_x_transformed(
self._handle, width)
y = self._libinput.libinput_event_touch_get_y_transformed(
self._handle, height)
return x, y | [
"def",
"transform_coords",
"(",
"self",
",",
"width",
",",
"height",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"{",
"EventType",
".",
"TOUCH_DOWN",
",",
"EventType",
".",
"TOUCH_MOTION",
"}",
":",
"raise",
"AttributeError",
"(",
"_wrong_meth",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_touch_get_x_transformed",
"(",
"self",
".",
"_handle",
",",
"width",
")",
"y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_touch_get_y_transformed",
"(",
"self",
".",
"_handle",
",",
"height",
")",
"return",
"x",
",",
"y"
] | Return the current absolute coordinates of the touch event,
transformed to screen coordinates.
For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`,
:attr:`~libinput.constant.EventType.TOUCH_MOTION`, this method
raises :exc:`AttributeError`.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
(float, float): The current absolute (x, y) coordinates transformed
to screen coordinates. | [
"Return",
"the",
"current",
"absolute",
"coordinates",
"of",
"the",
"touch",
"event",
"transformed",
"to",
"screen",
"coordinates",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L649-L671 |
OzymandiasTheGreat/python-libinput | libinput/event.py | GestureEvent.cancelled | def cancelled(self):
"""Return if the gesture ended normally, or if it was cancelled.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_END` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property
raises :exc:`AttributeError`.
Returns:
bool: :obj:`True` indicating that the gesture was cancelled.
Raises:
AttributeError
"""
if self.type not in {EventType.GESTURE_SWIPE_END,
EventType.GESTURE_PINCH_END}:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_gesture_get_cancelled(self._handle) | python | def cancelled(self):
"""Return if the gesture ended normally, or if it was cancelled.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_END` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property
raises :exc:`AttributeError`.
Returns:
bool: :obj:`True` indicating that the gesture was cancelled.
Raises:
AttributeError
"""
if self.type not in {EventType.GESTURE_SWIPE_END,
EventType.GESTURE_PINCH_END}:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_gesture_get_cancelled(self._handle) | [
"def",
"cancelled",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"{",
"EventType",
".",
"GESTURE_SWIPE_END",
",",
"EventType",
".",
"GESTURE_PINCH_END",
"}",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_cancelled",
"(",
"self",
".",
"_handle",
")"
] | Return if the gesture ended normally, or if it was cancelled.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_END` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property
raises :exc:`AttributeError`.
Returns:
bool: :obj:`True` indicating that the gesture was cancelled.
Raises:
AttributeError | [
"Return",
"if",
"the",
"gesture",
"ended",
"normally",
"or",
"if",
"it",
"was",
"cancelled",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L752-L769 |
OzymandiasTheGreat/python-libinput | libinput/event.py | GestureEvent.delta | def delta(self):
"""The delta between the last event and the current event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
If a device employs pointer acceleration, the delta returned by this
property is the accelerated delta.
Relative motion deltas are normalized to represent those of a device
with 1000dpi resolution. See `Normalization of relative motion`_
for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
"""
if self.type not in {EventType.GESTURE_SWIPE_UPDATE,
EventType.GESTURE_PINCH_UPDATE}:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_gesture_get_dx(self._handle)
delta_y = self._libinput.libinput_event_gesture_get_dy(self._handle)
return delta_x, delta_y | python | def delta(self):
"""The delta between the last event and the current event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
If a device employs pointer acceleration, the delta returned by this
property is the accelerated delta.
Relative motion deltas are normalized to represent those of a device
with 1000dpi resolution. See `Normalization of relative motion`_
for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
"""
if self.type not in {EventType.GESTURE_SWIPE_UPDATE,
EventType.GESTURE_PINCH_UPDATE}:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_gesture_get_dx(self._handle)
delta_y = self._libinput.libinput_event_gesture_get_dy(self._handle)
return delta_x, delta_y | [
"def",
"delta",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"{",
"EventType",
".",
"GESTURE_SWIPE_UPDATE",
",",
"EventType",
".",
"GESTURE_PINCH_UPDATE",
"}",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"delta_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_dx",
"(",
"self",
".",
"_handle",
")",
"delta_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_dy",
"(",
"self",
".",
"_handle",
")",
"return",
"delta_x",
",",
"delta_y"
] | The delta between the last event and the current event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
If a device employs pointer acceleration, the delta returned by this
property is the accelerated delta.
Relative motion deltas are normalized to represent those of a device
with 1000dpi resolution. See `Normalization of relative motion`_
for more details.
Returns:
(float, float): The relative (x, y) movement since the last event. | [
"The",
"delta",
"between",
"the",
"last",
"event",
"and",
"the",
"current",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L772-L796 |
OzymandiasTheGreat/python-libinput | libinput/event.py | GestureEvent.delta_unaccelerated | def delta_unaccelerated(self):
"""The relative delta of the unaccelerated motion vector of
the current event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
Relative unaccelerated motion deltas are normalized to represent those
of a device with 1000dpi resolution. See
`Normalization of relative motion`_ for more details.
Note that unaccelerated events are not equivalent to 'raw' events
as read from the device.
Any rotation applied to the device also applies to gesture motion
(see :meth:`~libinput.define.DeviceConfigRotation.set_angle`).
Returns:
(float, float): The unaccelerated relative (x, y) movement since
the last event.
"""
if self.type not in {EventType.GESTURE_SWIPE_UPDATE,
EventType.GESTURE_PINCH_UPDATE}:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_gesture_get_dx_unaccelerated(
self._handle)
delta_y = self._libinput.libinput_event_gesture_get_dy_unaccelerated(
self._handle)
return delta_x, delta_y | python | def delta_unaccelerated(self):
"""The relative delta of the unaccelerated motion vector of
the current event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
Relative unaccelerated motion deltas are normalized to represent those
of a device with 1000dpi resolution. See
`Normalization of relative motion`_ for more details.
Note that unaccelerated events are not equivalent to 'raw' events
as read from the device.
Any rotation applied to the device also applies to gesture motion
(see :meth:`~libinput.define.DeviceConfigRotation.set_angle`).
Returns:
(float, float): The unaccelerated relative (x, y) movement since
the last event.
"""
if self.type not in {EventType.GESTURE_SWIPE_UPDATE,
EventType.GESTURE_PINCH_UPDATE}:
raise AttributeError(_wrong_prop.format(self.type))
delta_x = self._libinput.libinput_event_gesture_get_dx_unaccelerated(
self._handle)
delta_y = self._libinput.libinput_event_gesture_get_dy_unaccelerated(
self._handle)
return delta_x, delta_y | [
"def",
"delta_unaccelerated",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"{",
"EventType",
".",
"GESTURE_SWIPE_UPDATE",
",",
"EventType",
".",
"GESTURE_PINCH_UPDATE",
"}",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"delta_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_dx_unaccelerated",
"(",
"self",
".",
"_handle",
")",
"delta_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_dy_unaccelerated",
"(",
"self",
".",
"_handle",
")",
"return",
"delta_x",
",",
"delta_y"
] | The relative delta of the unaccelerated motion vector of
the current event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
Relative unaccelerated motion deltas are normalized to represent those
of a device with 1000dpi resolution. See
`Normalization of relative motion`_ for more details.
Note that unaccelerated events are not equivalent to 'raw' events
as read from the device.
Any rotation applied to the device also applies to gesture motion
(see :meth:`~libinput.define.DeviceConfigRotation.set_angle`).
Returns:
(float, float): The unaccelerated relative (x, y) movement since
the last event. | [
"The",
"relative",
"delta",
"of",
"the",
"unaccelerated",
"motion",
"vector",
"of",
"the",
"current",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L799-L829 |
OzymandiasTheGreat/python-libinput | libinput/event.py | GestureEvent.scale | def scale(self):
"""The absolute scale of a pinch gesture, the scale is
the division of the current distance between the fingers and
the distance at the start of the gesture.
The scale begins at 1.0, and if e.g. the fingers moved together by
50% then the scale will become 0.5, if they move twice as far apart
as initially the scale becomes 2.0, etc.
For gesture events that are of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_BEGIN`, this property
returns 1.0.
For gesture events that are of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property
returns the scale value of the most recent
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event
(if any) or 1.0 otherwise.
For all other events this property raises :exc:`AttributeError`.
Returns:
float: The absolute scale of a pinch gesture.
Raises:
AttributeError
"""
if self.type not in {EventType.GESTURE_PINCH_BEGIN,
EventType.GESTURE_PINCH_UPDATE, EventType.GESTURE_PINCH_END}:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_gesture_get_scale(self._handle) | python | def scale(self):
"""The absolute scale of a pinch gesture, the scale is
the division of the current distance between the fingers and
the distance at the start of the gesture.
The scale begins at 1.0, and if e.g. the fingers moved together by
50% then the scale will become 0.5, if they move twice as far apart
as initially the scale becomes 2.0, etc.
For gesture events that are of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_BEGIN`, this property
returns 1.0.
For gesture events that are of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property
returns the scale value of the most recent
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event
(if any) or 1.0 otherwise.
For all other events this property raises :exc:`AttributeError`.
Returns:
float: The absolute scale of a pinch gesture.
Raises:
AttributeError
"""
if self.type not in {EventType.GESTURE_PINCH_BEGIN,
EventType.GESTURE_PINCH_UPDATE, EventType.GESTURE_PINCH_END}:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_gesture_get_scale(self._handle) | [
"def",
"scale",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"not",
"in",
"{",
"EventType",
".",
"GESTURE_PINCH_BEGIN",
",",
"EventType",
".",
"GESTURE_PINCH_UPDATE",
",",
"EventType",
".",
"GESTURE_PINCH_END",
"}",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_scale",
"(",
"self",
".",
"_handle",
")"
] | The absolute scale of a pinch gesture, the scale is
the division of the current distance between the fingers and
the distance at the start of the gesture.
The scale begins at 1.0, and if e.g. the fingers moved together by
50% then the scale will become 0.5, if they move twice as far apart
as initially the scale becomes 2.0, etc.
For gesture events that are of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_BEGIN`, this property
returns 1.0.
For gesture events that are of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property
returns the scale value of the most recent
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event
(if any) or 1.0 otherwise.
For all other events this property raises :exc:`AttributeError`.
Returns:
float: The absolute scale of a pinch gesture.
Raises:
AttributeError | [
"The",
"absolute",
"scale",
"of",
"a",
"pinch",
"gesture",
"the",
"scale",
"is",
"the",
"division",
"of",
"the",
"current",
"distance",
"between",
"the",
"fingers",
"and",
"the",
"distance",
"at",
"the",
"start",
"of",
"the",
"gesture",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L832-L862 |
OzymandiasTheGreat/python-libinput | libinput/event.py | GestureEvent.angle_delta | def angle_delta(self):
"""The angle delta in degrees between the last and the current
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
The angle delta is defined as the change in angle of the line formed
by the 2 fingers of a pinch gesture. Clockwise rotation is represented
by a positive delta, counter-clockwise by a negative delta. If e.g.
the fingers are on the 12 and 6 location of a clock face plate and
they move to the 1 resp. 7 location in a single event then the angle
delta is 30 degrees.
If more than two fingers are present, the angle represents
the rotation around the center of gravity. The calculation of
the center of gravity is implementation-dependent.
Returns:
float: The angle delta since the last event.
Raises:
AttributeError
"""
if self.type != EventType.GESTURE_PINCH_UPDATE:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_gesture_get_angle_delta(
self._handle) | python | def angle_delta(self):
"""The angle delta in degrees between the last and the current
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
The angle delta is defined as the change in angle of the line formed
by the 2 fingers of a pinch gesture. Clockwise rotation is represented
by a positive delta, counter-clockwise by a negative delta. If e.g.
the fingers are on the 12 and 6 location of a clock face plate and
they move to the 1 resp. 7 location in a single event then the angle
delta is 30 degrees.
If more than two fingers are present, the angle represents
the rotation around the center of gravity. The calculation of
the center of gravity is implementation-dependent.
Returns:
float: The angle delta since the last event.
Raises:
AttributeError
"""
if self.type != EventType.GESTURE_PINCH_UPDATE:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_gesture_get_angle_delta(
self._handle) | [
"def",
"angle_delta",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"GESTURE_PINCH_UPDATE",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_gesture_get_angle_delta",
"(",
"self",
".",
"_handle",
")"
] | The angle delta in degrees between the last and the current
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event.
For gesture events that are not of type
:attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this
property raises :exc:`AttributeError`.
The angle delta is defined as the change in angle of the line formed
by the 2 fingers of a pinch gesture. Clockwise rotation is represented
by a positive delta, counter-clockwise by a negative delta. If e.g.
the fingers are on the 12 and 6 location of a clock face plate and
they move to the 1 resp. 7 location in a single event then the angle
delta is 30 degrees.
If more than two fingers are present, the angle represents
the rotation around the center of gravity. The calculation of
the center of gravity is implementation-dependent.
Returns:
float: The angle delta since the last event.
Raises:
AttributeError | [
"The",
"angle",
"delta",
"in",
"degrees",
"between",
"the",
"last",
"and",
"the",
"current",
":",
"attr",
":",
"~libinput",
".",
"constant",
".",
"EventType",
".",
"GESTURE_PINCH_UPDATE",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L865-L893 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.coords | def coords(self):
"""The (X, Y) coordinates of the tablet tool, in mm from
the top left corner of the tablet in its current logical orientation
and whether they have changed in this event.
Use :meth:`transform_coords` for transforming the axes values into
a different coordinate space.
Note:
On some devices, returned value may be negative or larger than
the width of the device. See `Out-of-bounds motion events`_
for more details.
Returns:
((float, float), bool): The current values of the the axes and
whether they have changed.
"""
x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed(
self._handle)
y_changed = self._libinput.libinput_event_tablet_tool_y_has_changed(
self._handle)
x = self._libinput.libinput_event_tablet_tool_get_x(self._handle)
y = self._libinput.libinput_event_tablet_tool_get_y(self._handle)
return (x, y), x_changed or y_changed | python | def coords(self):
"""The (X, Y) coordinates of the tablet tool, in mm from
the top left corner of the tablet in its current logical orientation
and whether they have changed in this event.
Use :meth:`transform_coords` for transforming the axes values into
a different coordinate space.
Note:
On some devices, returned value may be negative or larger than
the width of the device. See `Out-of-bounds motion events`_
for more details.
Returns:
((float, float), bool): The current values of the the axes and
whether they have changed.
"""
x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed(
self._handle)
y_changed = self._libinput.libinput_event_tablet_tool_y_has_changed(
self._handle)
x = self._libinput.libinput_event_tablet_tool_get_x(self._handle)
y = self._libinput.libinput_event_tablet_tool_get_y(self._handle)
return (x, y), x_changed or y_changed | [
"def",
"coords",
"(",
"self",
")",
":",
"x_changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_x_has_changed",
"(",
"self",
".",
"_handle",
")",
"y_changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_y_has_changed",
"(",
"self",
".",
"_handle",
")",
"x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_x",
"(",
"self",
".",
"_handle",
")",
"y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_y",
"(",
"self",
".",
"_handle",
")",
"return",
"(",
"x",
",",
"y",
")",
",",
"x_changed",
"or",
"y_changed"
] | The (X, Y) coordinates of the tablet tool, in mm from
the top left corner of the tablet in its current logical orientation
and whether they have changed in this event.
Use :meth:`transform_coords` for transforming the axes values into
a different coordinate space.
Note:
On some devices, returned value may be negative or larger than
the width of the device. See `Out-of-bounds motion events`_
for more details.
Returns:
((float, float), bool): The current values of the the axes and
whether they have changed. | [
"The",
"(",
"X",
"Y",
")",
"coordinates",
"of",
"the",
"tablet",
"tool",
"in",
"mm",
"from",
"the",
"top",
"left",
"corner",
"of",
"the",
"tablet",
"in",
"its",
"current",
"logical",
"orientation",
"and",
"whether",
"they",
"have",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1040-L1063 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.delta | def delta(self):
"""The delta between the last event and the current event.
If the tool employs pointer acceleration, the delta contained in this
property is the accelerated delta.
This value is in screen coordinate space, the delta is to be
interpreted like the value of :attr:`.PointerEvent.delta`.
See `Relative motion for tablet tools`_ for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
"""
delta_x = self._libinput.libinput_event_tablet_tool_get_dx(self._handle)
delta_y = self._libinput.libinput_event_tablet_tool_get_dy(self._handle)
return delta_x, delta_y | python | def delta(self):
"""The delta between the last event and the current event.
If the tool employs pointer acceleration, the delta contained in this
property is the accelerated delta.
This value is in screen coordinate space, the delta is to be
interpreted like the value of :attr:`.PointerEvent.delta`.
See `Relative motion for tablet tools`_ for more details.
Returns:
(float, float): The relative (x, y) movement since the last event.
"""
delta_x = self._libinput.libinput_event_tablet_tool_get_dx(self._handle)
delta_y = self._libinput.libinput_event_tablet_tool_get_dy(self._handle)
return delta_x, delta_y | [
"def",
"delta",
"(",
"self",
")",
":",
"delta_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_dx",
"(",
"self",
".",
"_handle",
")",
"delta_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_dy",
"(",
"self",
".",
"_handle",
")",
"return",
"delta_x",
",",
"delta_y"
] | The delta between the last event and the current event.
If the tool employs pointer acceleration, the delta contained in this
property is the accelerated delta.
This value is in screen coordinate space, the delta is to be
interpreted like the value of :attr:`.PointerEvent.delta`.
See `Relative motion for tablet tools`_ for more details.
Returns:
(float, float): The relative (x, y) movement since the last event. | [
"The",
"delta",
"between",
"the",
"last",
"event",
"and",
"the",
"current",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1066-L1082 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.pressure | def pressure(self):
"""The current pressure being applied on the tool in use,
normalized to the range [0, 1] and whether it has changed in this event.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis and whether it has
changed.
"""
pressure = self._libinput.libinput_event_tablet_tool_get_pressure(
self._handle)
changed = self._libinput. \
libinput_event_tablet_tool_pressure_has_changed(self._handle)
return pressure, changed | python | def pressure(self):
"""The current pressure being applied on the tool in use,
normalized to the range [0, 1] and whether it has changed in this event.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis and whether it has
changed.
"""
pressure = self._libinput.libinput_event_tablet_tool_get_pressure(
self._handle)
changed = self._libinput. \
libinput_event_tablet_tool_pressure_has_changed(self._handle)
return pressure, changed | [
"def",
"pressure",
"(",
"self",
")",
":",
"pressure",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_pressure",
"(",
"self",
".",
"_handle",
")",
"changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_pressure_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"pressure",
",",
"changed"
] | The current pressure being applied on the tool in use,
normalized to the range [0, 1] and whether it has changed in this event.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis and whether it has
changed. | [
"The",
"current",
"pressure",
"being",
"applied",
"on",
"the",
"tool",
"in",
"use",
"normalized",
"to",
"the",
"range",
"[",
"0",
"1",
"]",
"and",
"whether",
"it",
"has",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1085-L1101 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.distance | def distance(self):
"""The current distance from the tablet's sensor,
normalized to the range [0, 1] and whether it has changed in this event.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis.
"""
distance = self._libinput.libinput_event_tablet_tool_get_distance(
self._handle)
changed = self._libinput. \
libinput_event_tablet_tool_distance_has_changed(self._handle)
return distance, changed | python | def distance(self):
"""The current distance from the tablet's sensor,
normalized to the range [0, 1] and whether it has changed in this event.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis.
"""
distance = self._libinput.libinput_event_tablet_tool_get_distance(
self._handle)
changed = self._libinput. \
libinput_event_tablet_tool_distance_has_changed(self._handle)
return distance, changed | [
"def",
"distance",
"(",
"self",
")",
":",
"distance",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_distance",
"(",
"self",
".",
"_handle",
")",
"changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_distance_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"distance",
",",
"changed"
] | The current distance from the tablet's sensor,
normalized to the range [0, 1] and whether it has changed in this event.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis. | [
"The",
"current",
"distance",
"from",
"the",
"tablet",
"s",
"sensor",
"normalized",
"to",
"the",
"range",
"[",
"0",
"1",
"]",
"and",
"whether",
"it",
"has",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1104-L1119 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.tilt_axes | def tilt_axes(self):
"""The current tilt along the (X, Y) axes of the tablet's
current logical orientation, in degrees off the tablet's Z axis
and whether they have changed in this event.
That is, if the tool is perfectly orthogonal to the tablet,
the tilt angle is 0. When the top tilts towards the logical top/left
of the tablet, the x/y tilt angles are negative, if the top tilts
towards the logical bottom/right of the tablet, the x/y tilt angles
are positive.
If these axes do not exist on the current tool, this property returns
((0, 0), :obj:`False`).
Returns:
((float, float), bool): The current value of the axes in degrees
and whether it has changed.
"""
tilt_x = self._libinput.libinput_event_tablet_tool_get_tilt_x(
self._handle)
tilt_y = self._libinput.libinput_event_tablet_tool_get_tilt_y(
self._handle)
x_changed = self._libinput. \
libinput_event_tablet_tool_tilt_x_has_changed(self._handle)
y_changed = self._libinput. \
libinput_event_tablet_tool_tilt_y_has_changed(self._handle)
return (tilt_x, tilt_y), x_changed or y_changed | python | def tilt_axes(self):
"""The current tilt along the (X, Y) axes of the tablet's
current logical orientation, in degrees off the tablet's Z axis
and whether they have changed in this event.
That is, if the tool is perfectly orthogonal to the tablet,
the tilt angle is 0. When the top tilts towards the logical top/left
of the tablet, the x/y tilt angles are negative, if the top tilts
towards the logical bottom/right of the tablet, the x/y tilt angles
are positive.
If these axes do not exist on the current tool, this property returns
((0, 0), :obj:`False`).
Returns:
((float, float), bool): The current value of the axes in degrees
and whether it has changed.
"""
tilt_x = self._libinput.libinput_event_tablet_tool_get_tilt_x(
self._handle)
tilt_y = self._libinput.libinput_event_tablet_tool_get_tilt_y(
self._handle)
x_changed = self._libinput. \
libinput_event_tablet_tool_tilt_x_has_changed(self._handle)
y_changed = self._libinput. \
libinput_event_tablet_tool_tilt_y_has_changed(self._handle)
return (tilt_x, tilt_y), x_changed or y_changed | [
"def",
"tilt_axes",
"(",
"self",
")",
":",
"tilt_x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_tilt_x",
"(",
"self",
".",
"_handle",
")",
"tilt_y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_tilt_y",
"(",
"self",
".",
"_handle",
")",
"x_changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_tilt_x_has_changed",
"(",
"self",
".",
"_handle",
")",
"y_changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_tilt_y_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"(",
"tilt_x",
",",
"tilt_y",
")",
",",
"x_changed",
"or",
"y_changed"
] | The current tilt along the (X, Y) axes of the tablet's
current logical orientation, in degrees off the tablet's Z axis
and whether they have changed in this event.
That is, if the tool is perfectly orthogonal to the tablet,
the tilt angle is 0. When the top tilts towards the logical top/left
of the tablet, the x/y tilt angles are negative, if the top tilts
towards the logical bottom/right of the tablet, the x/y tilt angles
are positive.
If these axes do not exist on the current tool, this property returns
((0, 0), :obj:`False`).
Returns:
((float, float), bool): The current value of the axes in degrees
and whether it has changed. | [
"The",
"current",
"tilt",
"along",
"the",
"(",
"X",
"Y",
")",
"axes",
"of",
"the",
"tablet",
"s",
"current",
"logical",
"orientation",
"in",
"degrees",
"off",
"the",
"tablet",
"s",
"Z",
"axis",
"and",
"whether",
"they",
"have",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1122-L1149 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.rotation | def rotation(self):
"""The current Z rotation of the tool in degrees, clockwise
from the tool's logical neutral position and whether it has changed
in this event.
For tools of type :attr:`~libinput.constant.TabletToolType.MOUSE`
and :attr:`~libinput.constant.TabletToolType.LENS` the logical
neutral position is pointing to the current logical north
of the tablet. For tools of type
:attr:`~libinput.constant.TabletToolType.BRUSH`, the logical
neutral position is with the buttons pointing up.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis and whether it has
changed.
"""
rotation = self._libinput.libinput_event_tablet_tool_get_rotation(
self._handle)
changed = self._libinput. \
libinput_event_tablet_tool_rotation_has_changed(self._handle)
return rotation, changed | python | def rotation(self):
"""The current Z rotation of the tool in degrees, clockwise
from the tool's logical neutral position and whether it has changed
in this event.
For tools of type :attr:`~libinput.constant.TabletToolType.MOUSE`
and :attr:`~libinput.constant.TabletToolType.LENS` the logical
neutral position is pointing to the current logical north
of the tablet. For tools of type
:attr:`~libinput.constant.TabletToolType.BRUSH`, the logical
neutral position is with the buttons pointing up.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis and whether it has
changed.
"""
rotation = self._libinput.libinput_event_tablet_tool_get_rotation(
self._handle)
changed = self._libinput. \
libinput_event_tablet_tool_rotation_has_changed(self._handle)
return rotation, changed | [
"def",
"rotation",
"(",
"self",
")",
":",
"rotation",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_rotation",
"(",
"self",
".",
"_handle",
")",
"changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_rotation_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"rotation",
",",
"changed"
] | The current Z rotation of the tool in degrees, clockwise
from the tool's logical neutral position and whether it has changed
in this event.
For tools of type :attr:`~libinput.constant.TabletToolType.MOUSE`
and :attr:`~libinput.constant.TabletToolType.LENS` the logical
neutral position is pointing to the current logical north
of the tablet. For tools of type
:attr:`~libinput.constant.TabletToolType.BRUSH`, the logical
neutral position is with the buttons pointing up.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis and whether it has
changed. | [
"The",
"current",
"Z",
"rotation",
"of",
"the",
"tool",
"in",
"degrees",
"clockwise",
"from",
"the",
"tool",
"s",
"logical",
"neutral",
"position",
"and",
"whether",
"it",
"has",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1152-L1176 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.slider_position | def slider_position(self):
"""The current position of the slider on the tool,
normalized to the range [-1, 1] and whether it has changed in this
event.
The logical zero is the neutral position of the slider, or
the logical center of the axis. This axis is available on e.g.
the Wacom Airbrush.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis.
"""
position = self._libinput. \
libinput_event_tablet_tool_get_slider_position(self._handle)
changed = self._libinput.libinput_event_tablet_tool_slider_has_changed(
self._handle)
return position, changed | python | def slider_position(self):
"""The current position of the slider on the tool,
normalized to the range [-1, 1] and whether it has changed in this
event.
The logical zero is the neutral position of the slider, or
the logical center of the axis. This axis is available on e.g.
the Wacom Airbrush.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis.
"""
position = self._libinput. \
libinput_event_tablet_tool_get_slider_position(self._handle)
changed = self._libinput.libinput_event_tablet_tool_slider_has_changed(
self._handle)
return position, changed | [
"def",
"slider_position",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_slider_position",
"(",
"self",
".",
"_handle",
")",
"changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_slider_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"position",
",",
"changed"
] | The current position of the slider on the tool,
normalized to the range [-1, 1] and whether it has changed in this
event.
The logical zero is the neutral position of the slider, or
the logical center of the axis. This axis is available on e.g.
the Wacom Airbrush.
If this axis does not exist on the current tool, this property is
(0, :obj:`False`).
Returns:
(float, bool): The current value of the the axis. | [
"The",
"current",
"position",
"of",
"the",
"slider",
"on",
"the",
"tool",
"normalized",
"to",
"the",
"range",
"[",
"-",
"1",
"1",
"]",
"and",
"whether",
"it",
"has",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1179-L1199 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.wheel_delta | def wheel_delta(self):
"""The delta for the wheel in degrees and whether it has changed in
this event.
Returns:
(float, bool): The delta of the wheel, in degrees, compared to
the last event and whether it has changed.
"""
delta = self._libinput.libinput_event_tablet_tool_get_wheel_delta(
self._handle)
changed = self._libinput.libinput_event_tablet_tool_wheel_has_changed(
self._handle)
return delta, changed | python | def wheel_delta(self):
"""The delta for the wheel in degrees and whether it has changed in
this event.
Returns:
(float, bool): The delta of the wheel, in degrees, compared to
the last event and whether it has changed.
"""
delta = self._libinput.libinput_event_tablet_tool_get_wheel_delta(
self._handle)
changed = self._libinput.libinput_event_tablet_tool_wheel_has_changed(
self._handle)
return delta, changed | [
"def",
"wheel_delta",
"(",
"self",
")",
":",
"delta",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_wheel_delta",
"(",
"self",
".",
"_handle",
")",
"changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_wheel_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"delta",
",",
"changed"
] | The delta for the wheel in degrees and whether it has changed in
this event.
Returns:
(float, bool): The delta of the wheel, in degrees, compared to
the last event and whether it has changed. | [
"The",
"delta",
"for",
"the",
"wheel",
"in",
"degrees",
"and",
"whether",
"it",
"has",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1202-L1215 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.wheel_delta_discrete | def wheel_delta_discrete(self):
"""The delta for the wheel in discrete steps (e.g. wheel clicks) and
whether it has changed in this event.
Returns:
(int, bool): The delta of the wheel, in discrete steps, compared to
the last event and whether it has changed.
"""
delta = self._libinput. \
libinput_event_tablet_tool_get_wheel_delta_discrete(self._handle)
changed = self._libinput.libinput_event_tablet_tool_wheel_has_changed(
self._handle)
return delta, changed | python | def wheel_delta_discrete(self):
"""The delta for the wheel in discrete steps (e.g. wheel clicks) and
whether it has changed in this event.
Returns:
(int, bool): The delta of the wheel, in discrete steps, compared to
the last event and whether it has changed.
"""
delta = self._libinput. \
libinput_event_tablet_tool_get_wheel_delta_discrete(self._handle)
changed = self._libinput.libinput_event_tablet_tool_wheel_has_changed(
self._handle)
return delta, changed | [
"def",
"wheel_delta_discrete",
"(",
"self",
")",
":",
"delta",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_wheel_delta_discrete",
"(",
"self",
".",
"_handle",
")",
"changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_wheel_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"delta",
",",
"changed"
] | The delta for the wheel in discrete steps (e.g. wheel clicks) and
whether it has changed in this event.
Returns:
(int, bool): The delta of the wheel, in discrete steps, compared to
the last event and whether it has changed. | [
"The",
"delta",
"for",
"the",
"wheel",
"in",
"discrete",
"steps",
"(",
"e",
".",
"g",
".",
"wheel",
"clicks",
")",
"and",
"whether",
"it",
"has",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1218-L1231 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.transform_coords | def transform_coords(self, width, height):
"""Return the current absolute (x, y) coordinates of
the tablet tool event, transformed to screen coordinates and
whether they have changed in this event.
Note:
On some devices, returned value may be negative or larger than
the width of the device. See `Out-of-bounds motion events`_
for more details.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
((float, float), bool): The current absolute (x, y) coordinates
transformed to screen coordinates and whether they have changed.
"""
x = self._libinput.libinput_event_tablet_tool_get_x_transformed(
self._handle, width)
y = self._libinput.libinput_event_tablet_tool_get_y_transformed(
self._handle, height)
x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed(
self._handle)
y_changed = self._libinput.libinput_event_tablet_tool_y_has_changed(
self._handle)
return (x, y), x_changed or y_changed | python | def transform_coords(self, width, height):
"""Return the current absolute (x, y) coordinates of
the tablet tool event, transformed to screen coordinates and
whether they have changed in this event.
Note:
On some devices, returned value may be negative or larger than
the width of the device. See `Out-of-bounds motion events`_
for more details.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
((float, float), bool): The current absolute (x, y) coordinates
transformed to screen coordinates and whether they have changed.
"""
x = self._libinput.libinput_event_tablet_tool_get_x_transformed(
self._handle, width)
y = self._libinput.libinput_event_tablet_tool_get_y_transformed(
self._handle, height)
x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed(
self._handle)
y_changed = self._libinput.libinput_event_tablet_tool_y_has_changed(
self._handle)
return (x, y), x_changed or y_changed | [
"def",
"transform_coords",
"(",
"self",
",",
"width",
",",
"height",
")",
":",
"x",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_x_transformed",
"(",
"self",
".",
"_handle",
",",
"width",
")",
"y",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_y_transformed",
"(",
"self",
".",
"_handle",
",",
"height",
")",
"x_changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_x_has_changed",
"(",
"self",
".",
"_handle",
")",
"y_changed",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_y_has_changed",
"(",
"self",
".",
"_handle",
")",
"return",
"(",
"x",
",",
"y",
")",
",",
"x_changed",
"or",
"y_changed"
] | Return the current absolute (x, y) coordinates of
the tablet tool event, transformed to screen coordinates and
whether they have changed in this event.
Note:
On some devices, returned value may be negative or larger than
the width of the device. See `Out-of-bounds motion events`_
for more details.
Args:
width (int): The current output screen width.
height (int): The current output screen height.
Returns:
((float, float), bool): The current absolute (x, y) coordinates
transformed to screen coordinates and whether they have changed. | [
"Return",
"the",
"current",
"absolute",
"(",
"x",
"y",
")",
"coordinates",
"of",
"the",
"tablet",
"tool",
"event",
"transformed",
"to",
"screen",
"coordinates",
"and",
"whether",
"they",
"have",
"changed",
"in",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1233-L1258 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.tool | def tool(self):
"""The tool that was in use during this event.
If the caller keeps a reference to a tool, the tool object will
compare equal to the previously obtained tool object.
Note:
Physical tool tracking requires hardware support. If unavailable,
libinput creates one tool per type per tablet. See
`Tracking unique tools`_ for more details.
Returns:
~libinput.define.TabletTool: The new tool triggering this event.
"""
htablettool = self._libinput.libinput_event_tablet_tool_get_tool(
self._handle)
return TabletTool(htablettool, self._libinput) | python | def tool(self):
"""The tool that was in use during this event.
If the caller keeps a reference to a tool, the tool object will
compare equal to the previously obtained tool object.
Note:
Physical tool tracking requires hardware support. If unavailable,
libinput creates one tool per type per tablet. See
`Tracking unique tools`_ for more details.
Returns:
~libinput.define.TabletTool: The new tool triggering this event.
"""
htablettool = self._libinput.libinput_event_tablet_tool_get_tool(
self._handle)
return TabletTool(htablettool, self._libinput) | [
"def",
"tool",
"(",
"self",
")",
":",
"htablettool",
"=",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_tool",
"(",
"self",
".",
"_handle",
")",
"return",
"TabletTool",
"(",
"htablettool",
",",
"self",
".",
"_libinput",
")"
] | The tool that was in use during this event.
If the caller keeps a reference to a tool, the tool object will
compare equal to the previously obtained tool object.
Note:
Physical tool tracking requires hardware support. If unavailable,
libinput creates one tool per type per tablet. See
`Tracking unique tools`_ for more details.
Returns:
~libinput.define.TabletTool: The new tool triggering this event. | [
"The",
"tool",
"that",
"was",
"in",
"use",
"during",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1261-L1277 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.button | def button(self):
"""The button that triggered this event.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
int: The button triggering this event.
"""
if self.type != EventType.TABLET_TOOL_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_tool_get_button(
self._handle) | python | def button(self):
"""The button that triggered this event.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
int: The button triggering this event.
"""
if self.type != EventType.TABLET_TOOL_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_tool_get_button(
self._handle) | [
"def",
"button",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_TOOL_BUTTON",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_button",
"(",
"self",
".",
"_handle",
")"
] | The button that triggered this event.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
int: The button triggering this event. | [
"The",
"button",
"that",
"triggered",
"this",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1315-L1329 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.button_state | def button_state(self):
"""The button state of the event.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.ButtonState: The button state triggering
this event.
"""
if self.type != EventType.TABLET_TOOL_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_tool_get_button_state(
self._handle) | python | def button_state(self):
"""The button state of the event.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.ButtonState: The button state triggering
this event.
"""
if self.type != EventType.TABLET_TOOL_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_tool_get_button_state(
self._handle) | [
"def",
"button_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_TOOL_BUTTON",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_button_state",
"(",
"self",
".",
"_handle",
")"
] | The button state of the event.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.ButtonState: The button state triggering
this event. | [
"The",
"button",
"state",
"of",
"the",
"event",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1332-L1347 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletToolEvent.seat_button_count | def seat_button_count(self):
"""The total number of buttons pressed on all devices on
the associated seat after the the event was triggered.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
int: The seat wide pressed button count for the key of this event.
"""
if self.type != EventType.TABLET_TOOL_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_tool_get_seat_button_count(
self._handle) | python | def seat_button_count(self):
"""The total number of buttons pressed on all devices on
the associated seat after the the event was triggered.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
int: The seat wide pressed button count for the key of this event.
"""
if self.type != EventType.TABLET_TOOL_BUTTON:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_tool_get_seat_button_count(
self._handle) | [
"def",
"seat_button_count",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_TOOL_BUTTON",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_tool_get_seat_button_count",
"(",
"self",
".",
"_handle",
")"
] | The total number of buttons pressed on all devices on
the associated seat after the the event was triggered.
For events that are not of type
:attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property
raises :exc:`AttributeError`.
Returns:
int: The seat wide pressed button count for the key of this event. | [
"The",
"total",
"number",
"of",
"buttons",
"pressed",
"on",
"all",
"devices",
"on",
"the",
"associated",
"seat",
"after",
"the",
"the",
"event",
"was",
"triggered",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1350-L1365 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletPadEvent.ring_position | def ring_position(self):
"""The current position of the ring, in degrees
counterclockwise from the northern-most point of the ring in
the tablet's current logical orientation.
If the source is
:attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`,
libinput sends a terminating event with a ring value of -1 when
the finger is lifted from the ring. A caller may use this information
to e.g. determine if kinetic scrolling should be triggered.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AttributeError`.
Returns:
float: The current value of the the axis. -1 if the finger was
lifted.
Raises:
AttributeError
"""
if self.type != EventType.TABLET_PAD_RING:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_ring_position(
self._handle) | python | def ring_position(self):
"""The current position of the ring, in degrees
counterclockwise from the northern-most point of the ring in
the tablet's current logical orientation.
If the source is
:attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`,
libinput sends a terminating event with a ring value of -1 when
the finger is lifted from the ring. A caller may use this information
to e.g. determine if kinetic scrolling should be triggered.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AttributeError`.
Returns:
float: The current value of the the axis. -1 if the finger was
lifted.
Raises:
AttributeError
"""
if self.type != EventType.TABLET_PAD_RING:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_ring_position(
self._handle) | [
"def",
"ring_position",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_PAD_RING",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_pad_get_ring_position",
"(",
"self",
".",
"_handle",
")"
] | The current position of the ring, in degrees
counterclockwise from the northern-most point of the ring in
the tablet's current logical orientation.
If the source is
:attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`,
libinput sends a terminating event with a ring value of -1 when
the finger is lifted from the ring. A caller may use this information
to e.g. determine if kinetic scrolling should be triggered.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AttributeError`.
Returns:
float: The current value of the the axis. -1 if the finger was
lifted.
Raises:
AttributeError | [
"The",
"current",
"position",
"of",
"the",
"ring",
"in",
"degrees",
"counterclockwise",
"from",
"the",
"northern",
"-",
"most",
"point",
"of",
"the",
"ring",
"in",
"the",
"tablet",
"s",
"current",
"logical",
"orientation",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1445-L1470 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletPadEvent.ring_number | def ring_number(self):
"""The number of the ring that has changed state,
with 0 being the first ring.
On tablets with only one ring, this method always returns 0.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AssertionError`.
Returns:
int: The index of the ring that changed state.
Raises:
AssertionError
"""
if self.type != EventType.TABLET_PAD_RING:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_ring_number(
self._handle) | python | def ring_number(self):
"""The number of the ring that has changed state,
with 0 being the first ring.
On tablets with only one ring, this method always returns 0.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AssertionError`.
Returns:
int: The index of the ring that changed state.
Raises:
AssertionError
"""
if self.type != EventType.TABLET_PAD_RING:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_ring_number(
self._handle) | [
"def",
"ring_number",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_PAD_RING",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_pad_get_ring_number",
"(",
"self",
".",
"_handle",
")"
] | The number of the ring that has changed state,
with 0 being the first ring.
On tablets with only one ring, this method always returns 0.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AssertionError`.
Returns:
int: The index of the ring that changed state.
Raises:
AssertionError | [
"The",
"number",
"of",
"the",
"ring",
"that",
"has",
"changed",
"state",
"with",
"0",
"being",
"the",
"first",
"ring",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1473-L1492 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletPadEvent.ring_source | def ring_source(self):
"""The source of the interaction with the ring.
If the source is
:attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`,
libinput sends a ring position value of -1 to terminate
the current interaction.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.TabletPadRingAxisSource: The source of the ring
interaction.
Raises:
AttributeError
"""
if self.type != EventType.TABLET_PAD_RING:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_ring_source(
self._handle) | python | def ring_source(self):
"""The source of the interaction with the ring.
If the source is
:attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`,
libinput sends a ring position value of -1 to terminate
the current interaction.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.TabletPadRingAxisSource: The source of the ring
interaction.
Raises:
AttributeError
"""
if self.type != EventType.TABLET_PAD_RING:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_ring_source(
self._handle) | [
"def",
"ring_source",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_PAD_RING",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_pad_get_ring_source",
"(",
"self",
".",
"_handle",
")"
] | The source of the interaction with the ring.
If the source is
:attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`,
libinput sends a ring position value of -1 to terminate
the current interaction.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property
raises :exc:`AttributeError`.
Returns:
~libinput.constant.TabletPadRingAxisSource: The source of the ring
interaction.
Raises:
AttributeError | [
"The",
"source",
"of",
"the",
"interaction",
"with",
"the",
"ring",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1495-L1517 |
OzymandiasTheGreat/python-libinput | libinput/event.py | TabletPadEvent.strip_position | def strip_position(self):
"""The current position of the strip, normalized to
the range [0, 1], with 0 being the top/left-most point in the tablet's
current logical orientation.
If the source is
:attr:`~libinput.constant.TabletPadStripAxisSource.FINGER`,
libinput sends a terminating event with a value of -1 when the finger
is lifted from the strip. A caller may use this information to e.g.
determine if kinetic scrolling should be triggered.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_STRIP`, this property
raises :exc:`AttributeError`.
Returns:
float: The current value of the the axis. -1 if the finger was
lifted.
Raises:
AttributeError
"""
if self.type != EventType.TABLET_PAD_STRIP:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_strip_position(
self._handle) | python | def strip_position(self):
"""The current position of the strip, normalized to
the range [0, 1], with 0 being the top/left-most point in the tablet's
current logical orientation.
If the source is
:attr:`~libinput.constant.TabletPadStripAxisSource.FINGER`,
libinput sends a terminating event with a value of -1 when the finger
is lifted from the strip. A caller may use this information to e.g.
determine if kinetic scrolling should be triggered.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_STRIP`, this property
raises :exc:`AttributeError`.
Returns:
float: The current value of the the axis. -1 if the finger was
lifted.
Raises:
AttributeError
"""
if self.type != EventType.TABLET_PAD_STRIP:
raise AttributeError(_wrong_prop.format(self.type))
return self._libinput.libinput_event_tablet_pad_get_strip_position(
self._handle) | [
"def",
"strip_position",
"(",
"self",
")",
":",
"if",
"self",
".",
"type",
"!=",
"EventType",
".",
"TABLET_PAD_STRIP",
":",
"raise",
"AttributeError",
"(",
"_wrong_prop",
".",
"format",
"(",
"self",
".",
"type",
")",
")",
"return",
"self",
".",
"_libinput",
".",
"libinput_event_tablet_pad_get_strip_position",
"(",
"self",
".",
"_handle",
")"
] | The current position of the strip, normalized to
the range [0, 1], with 0 being the top/left-most point in the tablet's
current logical orientation.
If the source is
:attr:`~libinput.constant.TabletPadStripAxisSource.FINGER`,
libinput sends a terminating event with a value of -1 when the finger
is lifted from the strip. A caller may use this information to e.g.
determine if kinetic scrolling should be triggered.
For events not of type
:attr:`~libinput.constant.EventType.TABLET_PAD_STRIP`, this property
raises :exc:`AttributeError`.
Returns:
float: The current value of the the axis. -1 if the finger was
lifted.
Raises:
AttributeError | [
"The",
"current",
"position",
"of",
"the",
"strip",
"normalized",
"to",
"the",
"range",
"[",
"0",
"1",
"]",
"with",
"0",
"being",
"the",
"top",
"/",
"left",
"-",
"most",
"point",
"in",
"the",
"tablet",
"s",
"current",
"logical",
"orientation",
"."
] | train | https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1520-L1545 |
Subsets and Splits