id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
227,400 | nfcpy/nfcpy | src/nfc/clf/acr122.py | Device.listen_tta | def listen_tta(self, target, timeout):
"""Listen as Type A Target is not supported."""
info = "{device} does not support listen as Type A Target"
raise nfc.clf.UnsupportedTargetError(info.format(device=self)) | python | def listen_tta(self, target, timeout):
"""Listen as Type A Target is not supported."""
info = "{device} does not support listen as Type A Target"
raise nfc.clf.UnsupportedTargetError(info.format(device=self)) | [
"def",
"listen_tta",
"(",
"self",
",",
"target",
",",
"timeout",
")",
":",
"info",
"=",
"\"{device} does not support listen as Type A Target\"",
"raise",
"nfc",
".",
"clf",
".",
"UnsupportedTargetError",
"(",
"info",
".",
"format",
"(",
"device",
"=",
"self",
")... | Listen as Type A Target is not supported. | [
"Listen",
"as",
"Type",
"A",
"Target",
"is",
"not",
"supported",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/acr122.py#L109-L112 |
227,401 | nfcpy/nfcpy | src/nfc/clf/acr122.py | Chipset.command | def command(self, cmd_code, cmd_data, timeout):
"""Send a host command and return the chip response.
"""
log.log(logging.DEBUG-1, self.CMD[cmd_code]+" "+hexlify(cmd_data))
frame = bytearray([0xD4, cmd_code]) + bytearray(cmd_data)
frame = bytearray([0xFF, 0x00, 0x00, 0x00, len(f... | python | def command(self, cmd_code, cmd_data, timeout):
"""Send a host command and return the chip response.
"""
log.log(logging.DEBUG-1, self.CMD[cmd_code]+" "+hexlify(cmd_data))
frame = bytearray([0xD4, cmd_code]) + bytearray(cmd_data)
frame = bytearray([0xFF, 0x00, 0x00, 0x00, len(f... | [
"def",
"command",
"(",
"self",
",",
"cmd_code",
",",
"cmd_data",
",",
"timeout",
")",
":",
"log",
".",
"log",
"(",
"logging",
".",
"DEBUG",
"-",
"1",
",",
"self",
".",
"CMD",
"[",
"cmd_code",
"]",
"+",
"\" \"",
"+",
"hexlify",
"(",
"cmd_data",
")",... | Send a host command and return the chip response. | [
"Send",
"a",
"host",
"command",
"and",
"return",
"the",
"chip",
"response",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/acr122.py#L223-L242 |
227,402 | nfcpy/nfcpy | src/nfc/tag/tt4.py | Type4Tag.format | def format(self, version=None, wipe=None):
"""Erase the NDEF message on a Type 4 Tag.
The :meth:`format` method writes the length of the NDEF
message on a Type 4 Tag to zero, thus the tag will appear to
be empty. If the *wipe* argument is set to some integer then
:meth:`format` ... | python | def format(self, version=None, wipe=None):
"""Erase the NDEF message on a Type 4 Tag.
The :meth:`format` method writes the length of the NDEF
message on a Type 4 Tag to zero, thus the tag will appear to
be empty. If the *wipe* argument is set to some integer then
:meth:`format` ... | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"None",
",",
"wipe",
"=",
"None",
")",
":",
"return",
"super",
"(",
"Type4Tag",
",",
"self",
")",
".",
"format",
"(",
"version",
",",
"wipe",
")"
] | Erase the NDEF message on a Type 4 Tag.
The :meth:`format` method writes the length of the NDEF
message on a Type 4 Tag to zero, thus the tag will appear to
be empty. If the *wipe* argument is set to some integer then
:meth:`format` will also overwrite all user data with that
in... | [
"Erase",
"the",
"NDEF",
"message",
"on",
"a",
"Type",
"4",
"Tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt4.py#L395-L409 |
227,403 | nfcpy/nfcpy | src/nfc/tag/tt4.py | Type4Tag.transceive | def transceive(self, data, timeout=None):
"""Transmit arbitrary data and receive the response.
This is a low level method to send arbitrary data to the
tag. While it should almost always be better to use
:meth:`send_apdu` this is the only way to force a specific
timeout value (w... | python | def transceive(self, data, timeout=None):
"""Transmit arbitrary data and receive the response.
This is a low level method to send arbitrary data to the
tag. While it should almost always be better to use
:meth:`send_apdu` this is the only way to force a specific
timeout value (w... | [
"def",
"transceive",
"(",
"self",
",",
"data",
",",
"timeout",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\">> {0}\"",
".",
"format",
"(",
"hexlify",
"(",
"data",
")",
")",
")",
"data",
"=",
"self",
".",
"_dep",
".",
"exchange",
"(",
"data",... | Transmit arbitrary data and receive the response.
This is a low level method to send arbitrary data to the
tag. While it should almost always be better to use
:meth:`send_apdu` this is the only way to force a specific
timeout value (which is otherwise derived from the Tag's
answ... | [
"Transmit",
"arbitrary",
"data",
"and",
"receive",
"the",
"response",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt4.py#L425-L439 |
227,404 | nfcpy/nfcpy | src/nfc/tag/__init__.py | Tag.format | def format(self, version=None, wipe=None):
"""Format the tag to make it NDEF compatible or erase content.
The :meth:`format` method is highly dependent on the tag type,
product and present status, for example a tag that has been
made read-only with lock bits can no longer be formatted o... | python | def format(self, version=None, wipe=None):
"""Format the tag to make it NDEF compatible or erase content.
The :meth:`format` method is highly dependent on the tag type,
product and present status, for example a tag that has been
made read-only with lock bits can no longer be formatted o... | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"None",
",",
"wipe",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_format\"",
")",
":",
"args",
"=",
"\"version={0!r}, wipe={1!r}\"",
"args",
"=",
"args",
".",
"format",
"(",
"version",
... | Format the tag to make it NDEF compatible or erase content.
The :meth:`format` method is highly dependent on the tag type,
product and present status, for example a tag that has been
made read-only with lock bits can no longer be formatted or
erased.
:meth:`format` creates the ... | [
"Format",
"the",
"tag",
"to",
"make",
"it",
"NDEF",
"compatible",
"or",
"erase",
"content",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/__init__.py#L302-L344 |
227,405 | nfcpy/nfcpy | src/nfc/tag/__init__.py | Tag.protect | def protect(self, password=None, read_protect=False, protect_from=0):
"""Protect a tag against future write or read access.
:meth:`protect` attempts to make a tag readonly for all
readers if *password* is :const:`None`, writeable only after
authentication if a *password* is provided, an... | python | def protect(self, password=None, read_protect=False, protect_from=0):
"""Protect a tag against future write or read access.
:meth:`protect` attempts to make a tag readonly for all
readers if *password* is :const:`None`, writeable only after
authentication if a *password* is provided, an... | [
"def",
"protect",
"(",
"self",
",",
"password",
"=",
"None",
",",
"read_protect",
"=",
"False",
",",
"protect_from",
"=",
"0",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_protect\"",
")",
":",
"args",
"=",
"\"password={0!r}, read_protect={1!r}, protect_fr... | Protect a tag against future write or read access.
:meth:`protect` attempts to make a tag readonly for all
readers if *password* is :const:`None`, writeable only after
authentication if a *password* is provided, and readable only
after authentication if a *password* is provided and the
... | [
"Protect",
"a",
"tag",
"against",
"future",
"write",
"or",
"read",
"access",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/__init__.py#L346-L384 |
227,406 | nfcpy/nfcpy | src/nfc/snep/client.py | SnepClient.get_records | def get_records(self, records=None, timeout=1.0):
"""Get NDEF message records from a SNEP Server.
.. versionadded:: 0.13
The :class:`ndef.Record` list given by *records* is encoded as
the request message octets input to :meth:`get_octets`. The
return value is an :class:`ndef.Re... | python | def get_records(self, records=None, timeout=1.0):
"""Get NDEF message records from a SNEP Server.
.. versionadded:: 0.13
The :class:`ndef.Record` list given by *records* is encoded as
the request message octets input to :meth:`get_octets`. The
return value is an :class:`ndef.Re... | [
"def",
"get_records",
"(",
"self",
",",
"records",
"=",
"None",
",",
"timeout",
"=",
"1.0",
")",
":",
"octets",
"=",
"b''",
".",
"join",
"(",
"ndef",
".",
"message_encoder",
"(",
"records",
")",
")",
"if",
"records",
"else",
"None",
"octets",
"=",
"s... | Get NDEF message records from a SNEP Server.
.. versionadded:: 0.13
The :class:`ndef.Record` list given by *records* is encoded as
the request message octets input to :meth:`get_octets`. The
return value is an :class:`ndef.Record` list decoded from the
response message octets r... | [
"Get",
"NDEF",
"message",
"records",
"from",
"a",
"SNEP",
"Server",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/snep/client.py#L156-L176 |
227,407 | nfcpy/nfcpy | src/nfc/snep/client.py | SnepClient.get_octets | def get_octets(self, octets=None, timeout=1.0):
"""Get NDEF message octets from a SNEP Server.
.. versionadded:: 0.13
If the client has not yet a data link connection with a SNEP
Server, it temporarily connects to the default SNEP Server,
sends the message octets, disconnects a... | python | def get_octets(self, octets=None, timeout=1.0):
"""Get NDEF message octets from a SNEP Server.
.. versionadded:: 0.13
If the client has not yet a data link connection with a SNEP
Server, it temporarily connects to the default SNEP Server,
sends the message octets, disconnects a... | [
"def",
"get_octets",
"(",
"self",
",",
"octets",
"=",
"None",
",",
"timeout",
"=",
"1.0",
")",
":",
"if",
"octets",
"is",
"None",
":",
"# Send NDEF Message with one empty Record.",
"octets",
"=",
"b'\\xd0\\x00\\x00'",
"if",
"not",
"self",
".",
"socket",
":",
... | Get NDEF message octets from a SNEP Server.
.. versionadded:: 0.13
If the client has not yet a data link connection with a SNEP
Server, it temporarily connects to the default SNEP Server,
sends the message octets, disconnects after the server
response, and returns the received ... | [
"Get",
"NDEF",
"message",
"octets",
"from",
"a",
"SNEP",
"Server",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/snep/client.py#L178-L221 |
227,408 | nfcpy/nfcpy | src/nfc/snep/client.py | SnepClient.put | def put(self, ndef_message, timeout=1.0):
"""Send an NDEF message to the server. Temporarily connects to
the default SNEP server if the client is not yet connected.
.. deprecated:: 0.13
Use :meth:`put_records` or :meth:`put_octets`.
"""
if not self.socket:
... | python | def put(self, ndef_message, timeout=1.0):
"""Send an NDEF message to the server. Temporarily connects to
the default SNEP server if the client is not yet connected.
.. deprecated:: 0.13
Use :meth:`put_records` or :meth:`put_octets`.
"""
if not self.socket:
... | [
"def",
"put",
"(",
"self",
",",
"ndef_message",
",",
"timeout",
"=",
"1.0",
")",
":",
"if",
"not",
"self",
".",
"socket",
":",
"try",
":",
"self",
".",
"connect",
"(",
"'urn:nfc:sn:snep'",
")",
"except",
"nfc",
".",
"llcp",
".",
"ConnectRefused",
":",
... | Send an NDEF message to the server. Temporarily connects to
the default SNEP server if the client is not yet connected.
.. deprecated:: 0.13
Use :meth:`put_records` or :meth:`put_octets`. | [
"Send",
"an",
"NDEF",
"message",
"to",
"the",
"server",
".",
"Temporarily",
"connects",
"to",
"the",
"default",
"SNEP",
"server",
"if",
"the",
"client",
"is",
"not",
"yet",
"connected",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/snep/client.py#L223-L252 |
227,409 | nfcpy/nfcpy | src/nfc/snep/client.py | SnepClient.put_records | def put_records(self, records, timeout=1.0):
"""Send NDEF message records to a SNEP Server.
.. versionadded:: 0.13
The :class:`ndef.Record` list given by *records* is encoded
and then send via :meth:`put_octets`. Same as::
import ndef
octets = ndef.message_enco... | python | def put_records(self, records, timeout=1.0):
"""Send NDEF message records to a SNEP Server.
.. versionadded:: 0.13
The :class:`ndef.Record` list given by *records* is encoded
and then send via :meth:`put_octets`. Same as::
import ndef
octets = ndef.message_enco... | [
"def",
"put_records",
"(",
"self",
",",
"records",
",",
"timeout",
"=",
"1.0",
")",
":",
"octets",
"=",
"b''",
".",
"join",
"(",
"ndef",
".",
"message_encoder",
"(",
"records",
")",
")",
"return",
"self",
".",
"put_octets",
"(",
"octets",
",",
"timeout... | Send NDEF message records to a SNEP Server.
.. versionadded:: 0.13
The :class:`ndef.Record` list given by *records* is encoded
and then send via :meth:`put_octets`. Same as::
import ndef
octets = ndef.message_encoder(records)
snep_client.put_octets(octets, ... | [
"Send",
"NDEF",
"message",
"records",
"to",
"a",
"SNEP",
"Server",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/snep/client.py#L254-L268 |
227,410 | nfcpy/nfcpy | src/nfc/clf/rcs380.py | Device.sense_ttb | def sense_ttb(self, target):
"""Sense for a Type B Target is supported for 106, 212 and 424
kbps. However, there may not be any target that understands the
activation command in other than 106 kbps.
"""
log.debug("polling for NFC-B technology")
if target.brty not in ("1... | python | def sense_ttb(self, target):
"""Sense for a Type B Target is supported for 106, 212 and 424
kbps. However, there may not be any target that understands the
activation command in other than 106 kbps.
"""
log.debug("polling for NFC-B technology")
if target.brty not in ("1... | [
"def",
"sense_ttb",
"(",
"self",
",",
"target",
")",
":",
"log",
".",
"debug",
"(",
"\"polling for NFC-B technology\"",
")",
"if",
"target",
".",
"brty",
"not",
"in",
"(",
"\"106B\"",
",",
"\"212B\"",
",",
"\"424B\"",
")",
":",
"message",
"=",
"\"unsupport... | Sense for a Type B Target is supported for 106, 212 and 424
kbps. However, there may not be any target that understands the
activation command in other than 106 kbps. | [
"Sense",
"for",
"a",
"Type",
"B",
"Target",
"is",
"supported",
"for",
"106",
"212",
"and",
"424",
"kbps",
".",
"However",
"there",
"may",
"not",
"be",
"any",
"target",
"that",
"understands",
"the",
"activation",
"command",
"in",
"other",
"than",
"106",
"... | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs380.py#L452-L482 |
227,411 | nfcpy/nfcpy | src/nfc/clf/rcs380.py | Device.sense_ttf | def sense_ttf(self, target):
"""Sense for a Type F Target is supported for 212 and 424 kbps.
"""
log.debug("polling for NFC-F technology")
if target.brty not in ("212F", "424F"):
message = "unsupported bitrate {0}".format(target.brty)
raise nfc.clf.UnsupportedTa... | python | def sense_ttf(self, target):
"""Sense for a Type F Target is supported for 212 and 424 kbps.
"""
log.debug("polling for NFC-F technology")
if target.brty not in ("212F", "424F"):
message = "unsupported bitrate {0}".format(target.brty)
raise nfc.clf.UnsupportedTa... | [
"def",
"sense_ttf",
"(",
"self",
",",
"target",
")",
":",
"log",
".",
"debug",
"(",
"\"polling for NFC-F technology\"",
")",
"if",
"target",
".",
"brty",
"not",
"in",
"(",
"\"212F\"",
",",
"\"424F\"",
")",
":",
"message",
"=",
"\"unsupported bitrate {0}\"",
... | Sense for a Type F Target is supported for 212 and 424 kbps. | [
"Sense",
"for",
"a",
"Type",
"F",
"Target",
"is",
"supported",
"for",
"212",
"and",
"424",
"kbps",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs380.py#L484-L512 |
227,412 | nfcpy/nfcpy | src/nfc/clf/rcs380.py | Device.listen_ttf | def listen_ttf(self, target, timeout):
"""Listen as Type F Target is supported for either 212 or 424 kbps."""
if target.brty not in ('212F', '424F'):
info = "unsupported target bitrate: %r" % target.brty
raise nfc.clf.UnsupportedTargetError(info)
if target.sensf_res is N... | python | def listen_ttf(self, target, timeout):
"""Listen as Type F Target is supported for either 212 or 424 kbps."""
if target.brty not in ('212F', '424F'):
info = "unsupported target bitrate: %r" % target.brty
raise nfc.clf.UnsupportedTargetError(info)
if target.sensf_res is N... | [
"def",
"listen_ttf",
"(",
"self",
",",
"target",
",",
"timeout",
")",
":",
"if",
"target",
".",
"brty",
"not",
"in",
"(",
"'212F'",
",",
"'424F'",
")",
":",
"info",
"=",
"\"unsupported target bitrate: %r\"",
"%",
"target",
".",
"brty",
"raise",
"nfc",
".... | Listen as Type F Target is supported for either 212 or 424 kbps. | [
"Listen",
"as",
"Type",
"F",
"Target",
"is",
"supported",
"for",
"either",
"212",
"or",
"424",
"kbps",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs380.py#L671-L726 |
227,413 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaStandard.request_response | def request_response(self):
"""Verify that a card is still present and get its operating mode.
The Request Response command returns the current operating
state of the card. The operating state changes with the
authentication process, a card is in Mode 0 after power-up or
a Polli... | python | def request_response(self):
"""Verify that a card is still present and get its operating mode.
The Request Response command returns the current operating
state of the card. The operating state changes with the
authentication process, a card is in Mode 0 after power-up or
a Polli... | [
"def",
"request_response",
"(",
"self",
")",
":",
"a",
",",
"b",
",",
"e",
"=",
"self",
".",
"pmm",
"[",
"3",
"]",
"&",
"7",
",",
"self",
".",
"pmm",
"[",
"3",
"]",
">>",
"3",
"&",
"7",
",",
"self",
".",
"pmm",
"[",
"3",
"]",
">>",
"6",
... | Verify that a card is still present and get its operating mode.
The Request Response command returns the current operating
state of the card. The operating state changes with the
authentication process, a card is in Mode 0 after power-up or
a Polling command, transitions to Mode 1 with ... | [
"Verify",
"that",
"a",
"card",
"is",
"still",
"present",
"and",
"get",
"its",
"operating",
"mode",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L258-L279 |
227,414 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaStandard.search_service_code | def search_service_code(self, service_index):
"""Search for a service code that corresponds to an index.
The Search Service Code command provides access to the
iterable list of services and areas within the activated
system. The *service_index* argument may be any value from 0
t... | python | def search_service_code(self, service_index):
"""Search for a service code that corresponds to an index.
The Search Service Code command provides access to the
iterable list of services and areas within the activated
system. The *service_index* argument may be any value from 0
t... | [
"def",
"search_service_code",
"(",
"self",
",",
"service_index",
")",
":",
"log",
".",
"debug",
"(",
"\"search service code index {0}\"",
".",
"format",
"(",
"service_index",
")",
")",
"# The maximum response time is given by the value of PMM[3].",
"# Some cards (like RC-S860... | Search for a service code that corresponds to an index.
The Search Service Code command provides access to the
iterable list of services and areas within the activated
system. The *service_index* argument may be any value from 0
to 0xffff. As long as there is a service or area found for... | [
"Search",
"for",
"a",
"service",
"code",
"that",
"corresponds",
"to",
"an",
"index",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L281-L323 |
227,415 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaStandard.request_system_code | def request_system_code(self):
"""Return all system codes that are registered in the card.
A card has one or more system codes that correspond to logical
partitions (systems). Each system has a system code that could
be used in a polling command to activate that system. The
syst... | python | def request_system_code(self):
"""Return all system codes that are registered in the card.
A card has one or more system codes that correspond to logical
partitions (systems). Each system has a system code that could
be used in a polling command to activate that system. The
syst... | [
"def",
"request_system_code",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"request system code list\"",
")",
"a",
",",
"e",
"=",
"self",
".",
"pmm",
"[",
"3",
"]",
"&",
"7",
",",
"self",
".",
"pmm",
"[",
"3",
"]",
">>",
"6",
"timeout",
"=",
... | Return all system codes that are registered in the card.
A card has one or more system codes that correspond to logical
partitions (systems). Each system has a system code that could
be used in a polling command to activate that system. The
system codes responded by the card are returne... | [
"Return",
"all",
"system",
"codes",
"that",
"are",
"registered",
"in",
"the",
"card",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L325-L347 |
227,416 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLite.protect | def protect(self, password=None, read_protect=False, protect_from=0):
"""Protect a FeliCa Lite Tag.
A FeliCa Lite Tag can be provisioned with a custom password
(or the default manufacturer key if the password is an empty
string or bytearray) to ensure that data retrieved by future
... | python | def protect(self, password=None, read_protect=False, protect_from=0):
"""Protect a FeliCa Lite Tag.
A FeliCa Lite Tag can be provisioned with a custom password
(or the default manufacturer key if the password is an empty
string or bytearray) to ensure that data retrieved by future
... | [
"def",
"protect",
"(",
"self",
",",
"password",
"=",
"None",
",",
"read_protect",
"=",
"False",
",",
"protect_from",
"=",
"0",
")",
":",
"return",
"super",
"(",
"FelicaLite",
",",
"self",
")",
".",
"protect",
"(",
"password",
",",
"read_protect",
",",
... | Protect a FeliCa Lite Tag.
A FeliCa Lite Tag can be provisioned with a custom password
(or the default manufacturer key if the password is an empty
string or bytearray) to ensure that data retrieved by future
read operations, after authentication, is genuine. Read
protection is ... | [
"Protect",
"a",
"FeliCa",
"Lite",
"Tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L492-L513 |
227,417 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLite.format | def format(self, version=0x10, wipe=None):
"""Format a FeliCa Lite Tag for NDEF.
"""
return super(FelicaLite, self).format(version, wipe) | python | def format(self, version=0x10, wipe=None):
"""Format a FeliCa Lite Tag for NDEF.
"""
return super(FelicaLite, self).format(version, wipe) | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"0x10",
",",
"wipe",
"=",
"None",
")",
":",
"return",
"super",
"(",
"FelicaLite",
",",
"self",
")",
".",
"format",
"(",
"version",
",",
"wipe",
")"
] | Format a FeliCa Lite Tag for NDEF. | [
"Format",
"a",
"FeliCa",
"Lite",
"Tag",
"for",
"NDEF",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L626-L630 |
227,418 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLite.read_without_mac | def read_without_mac(self, *blocks):
"""Read a number of data blocks without integrity check.
This method accepts a variable number of integer arguments as
the block numbers to read. The blocks are read with service
code 0x000B (NDEF).
Tag command errors raise :exc:`~nfc.tag.Ta... | python | def read_without_mac(self, *blocks):
"""Read a number of data blocks without integrity check.
This method accepts a variable number of integer arguments as
the block numbers to read. The blocks are read with service
code 0x000B (NDEF).
Tag command errors raise :exc:`~nfc.tag.Ta... | [
"def",
"read_without_mac",
"(",
"self",
",",
"*",
"blocks",
")",
":",
"log",
".",
"debug",
"(",
"\"read {0} block(s) without mac\"",
".",
"format",
"(",
"len",
"(",
"blocks",
")",
")",
")",
"service_list",
"=",
"[",
"tt3",
".",
"ServiceCode",
"(",
"0",
"... | Read a number of data blocks without integrity check.
This method accepts a variable number of integer arguments as
the block numbers to read. The blocks are read with service
code 0x000B (NDEF).
Tag command errors raise :exc:`~nfc.tag.TagCommandError`. | [
"Read",
"a",
"number",
"of",
"data",
"blocks",
"without",
"integrity",
"check",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L680-L693 |
227,419 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLite.read_with_mac | def read_with_mac(self, *blocks):
"""Read a number of data blocks with integrity check.
This method accepts a variable number of integer arguments as
the block numbers to read. The blocks are read with service
code 0x000B (NDEF). Along with the requested block data the
tag retur... | python | def read_with_mac(self, *blocks):
"""Read a number of data blocks with integrity check.
This method accepts a variable number of integer arguments as
the block numbers to read. The blocks are read with service
code 0x000B (NDEF). Along with the requested block data the
tag retur... | [
"def",
"read_with_mac",
"(",
"self",
",",
"*",
"blocks",
")",
":",
"log",
".",
"debug",
"(",
"\"read {0} block(s) with mac\"",
".",
"format",
"(",
"len",
"(",
"blocks",
")",
")",
")",
"if",
"self",
".",
"_sk",
"is",
"None",
"or",
"self",
".",
"_iv",
... | Read a number of data blocks with integrity check.
This method accepts a variable number of integer arguments as
the block numbers to read. The blocks are read with service
code 0x000B (NDEF). Along with the requested block data the
tag returns a message authentication code that is veri... | [
"Read",
"a",
"number",
"of",
"data",
"blocks",
"with",
"integrity",
"check",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L695-L725 |
227,420 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLite.write_without_mac | def write_without_mac(self, data, block):
"""Write a data block without integrity check.
This is the standard write method for a FeliCa Lite. The
16-byte string or bytearray *data* is written to the numbered
*block* in service 0x0009 (NDEF write service). ::
data = bytearra... | python | def write_without_mac(self, data, block):
"""Write a data block without integrity check.
This is the standard write method for a FeliCa Lite. The
16-byte string or bytearray *data* is written to the numbered
*block* in service 0x0009 (NDEF write service). ::
data = bytearra... | [
"def",
"write_without_mac",
"(",
"self",
",",
"data",
",",
"block",
")",
":",
"# Write a single data block without a mac. Write with mac is",
"# only supported by FeliCa Lite-S.",
"assert",
"len",
"(",
"data",
")",
"==",
"16",
"and",
"type",
"(",
"block",
")",
"is",
... | Write a data block without integrity check.
This is the standard write method for a FeliCa Lite. The
16-byte string or bytearray *data* is written to the numbered
*block* in service 0x0009 (NDEF write service). ::
data = bytearray(range(16)) # 0x00, 0x01, ... 0x0F
try: ... | [
"Write",
"a",
"data",
"block",
"without",
"integrity",
"check",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L727-L748 |
227,421 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLiteS.authenticate | def authenticate(self, password):
"""Mutually authenticate with a FeliCa Lite-S Tag.
FeliCa Lite-S supports enhanced security functions, one of
them is the mutual authentication performed by this
method. The first part of mutual authentication is to
authenticate the tag with :me... | python | def authenticate(self, password):
"""Mutually authenticate with a FeliCa Lite-S Tag.
FeliCa Lite-S supports enhanced security functions, one of
them is the mutual authentication performed by this
method. The first part of mutual authentication is to
authenticate the tag with :me... | [
"def",
"authenticate",
"(",
"self",
",",
"password",
")",
":",
"if",
"super",
"(",
"FelicaLiteS",
",",
"self",
")",
".",
"authenticate",
"(",
"password",
")",
":",
"# At this point we have achieved internal authentication,",
"# i.e we know that the tag has the same card k... | Mutually authenticate with a FeliCa Lite-S Tag.
FeliCa Lite-S supports enhanced security functions, one of
them is the mutual authentication performed by this
method. The first part of mutual authentication is to
authenticate the tag with :meth:`FelicaLite.authenticate`. If
succ... | [
"Mutually",
"authenticate",
"with",
"a",
"FeliCa",
"Lite",
"-",
"S",
"Tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L882-L926 |
227,422 | nfcpy/nfcpy | src/nfc/tag/tt3_sony.py | FelicaLiteS.write_with_mac | def write_with_mac(self, data, block):
"""Write one data block with additional integrity check.
If prior to calling this method the tag was not authenticated,
a :exc:`RuntimeError` exception is raised.
Command execution errors raise :exc:`~nfc.tag.TagCommandError`.
"""
... | python | def write_with_mac(self, data, block):
"""Write one data block with additional integrity check.
If prior to calling this method the tag was not authenticated,
a :exc:`RuntimeError` exception is raised.
Command execution errors raise :exc:`~nfc.tag.TagCommandError`.
"""
... | [
"def",
"write_with_mac",
"(",
"self",
",",
"data",
",",
"block",
")",
":",
"# Write a single data block protected with a mac. The card",
"# will only accept the write if it computed the same mac.",
"log",
".",
"debug",
"(",
"\"write 1 block with mac\"",
")",
"if",
"len",
"(",... | Write one data block with additional integrity check.
If prior to calling this method the tag was not authenticated,
a :exc:`RuntimeError` exception is raised.
Command execution errors raise :exc:`~nfc.tag.TagCommandError`. | [
"Write",
"one",
"data",
"block",
"with",
"additional",
"integrity",
"check",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3_sony.py#L928-L966 |
227,423 | nfcpy/nfcpy | src/nfc/ndef/record.py | Record._read | def _read(self, f):
"""Parse an NDEF record from a file-like object."""
try:
self.header = ord(f.read(1))
except TypeError:
log.debug("buffer underflow at offset {0}".format(f.tell()))
raise LengthError("insufficient data to parse")
m... | python | def _read(self, f):
"""Parse an NDEF record from a file-like object."""
try:
self.header = ord(f.read(1))
except TypeError:
log.debug("buffer underflow at offset {0}".format(f.tell()))
raise LengthError("insufficient data to parse")
m... | [
"def",
"_read",
"(",
"self",
",",
"f",
")",
":",
"try",
":",
"self",
".",
"header",
"=",
"ord",
"(",
"f",
".",
"read",
"(",
"1",
")",
")",
"except",
"TypeError",
":",
"log",
".",
"debug",
"(",
"\"buffer underflow at offset {0}\"",
".",
"format",
"(",... | Parse an NDEF record from a file-like object. | [
"Parse",
"an",
"NDEF",
"record",
"from",
"a",
"file",
"-",
"like",
"object",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/record.py#L91-L146 |
227,424 | nfcpy/nfcpy | src/nfc/ndef/record.py | Record._write | def _write(self, f):
"""Serialize an NDEF record to a file-like object."""
log.debug("writing ndef record at offset {0}".format(f.tell()))
record_type = self.type
record_name = self.name
record_data = self.data
if record_type == '':
header_flags = 0;... | python | def _write(self, f):
"""Serialize an NDEF record to a file-like object."""
log.debug("writing ndef record at offset {0}".format(f.tell()))
record_type = self.type
record_name = self.name
record_data = self.data
if record_type == '':
header_flags = 0;... | [
"def",
"_write",
"(",
"self",
",",
"f",
")",
":",
"log",
".",
"debug",
"(",
"\"writing ndef record at offset {0}\"",
".",
"format",
"(",
"f",
".",
"tell",
"(",
")",
")",
")",
"record_type",
"=",
"self",
".",
"type",
"record_name",
"=",
"self",
".",
"na... | Serialize an NDEF record to a file-like object. | [
"Serialize",
"an",
"NDEF",
"record",
"to",
"a",
"file",
"-",
"like",
"object",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/record.py#L148-L193 |
227,425 | nfcpy/nfcpy | src/nfc/tag/tt3.py | ServiceCode.pack | def pack(self):
"""Pack the service code for transmission. Returns a 2 byte string."""
sn, sa = self.number, self.attribute
return pack("<H", (sn & 0x3ff) << 6 | (sa & 0x3f)) | python | def pack(self):
"""Pack the service code for transmission. Returns a 2 byte string."""
sn, sa = self.number, self.attribute
return pack("<H", (sn & 0x3ff) << 6 | (sa & 0x3f)) | [
"def",
"pack",
"(",
"self",
")",
":",
"sn",
",",
"sa",
"=",
"self",
".",
"number",
",",
"self",
".",
"attribute",
"return",
"pack",
"(",
"\"<H\"",
",",
"(",
"sn",
"&",
"0x3ff",
")",
"<<",
"6",
"|",
"(",
"sa",
"&",
"0x3f",
")",
")"
] | Pack the service code for transmission. Returns a 2 byte string. | [
"Pack",
"the",
"service",
"code",
"for",
"transmission",
".",
"Returns",
"a",
"2",
"byte",
"string",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L97-L100 |
227,426 | nfcpy/nfcpy | src/nfc/tag/tt3.py | BlockCode.pack | def pack(self):
"""Pack the block code for transmission. Returns a 2-3 byte string."""
bn, am, sx = self.number, self.access, self.service
return chr(bool(bn < 256) << 7 | (am & 0x7) << 4 | (sx & 0xf)) + \
(chr(bn) if bn < 256 else pack("<H", bn)) | python | def pack(self):
"""Pack the block code for transmission. Returns a 2-3 byte string."""
bn, am, sx = self.number, self.access, self.service
return chr(bool(bn < 256) << 7 | (am & 0x7) << 4 | (sx & 0xf)) + \
(chr(bn) if bn < 256 else pack("<H", bn)) | [
"def",
"pack",
"(",
"self",
")",
":",
"bn",
",",
"am",
",",
"sx",
"=",
"self",
".",
"number",
",",
"self",
".",
"access",
",",
"self",
".",
"service",
"return",
"chr",
"(",
"bool",
"(",
"bn",
"<",
"256",
")",
"<<",
"7",
"|",
"(",
"am",
"&",
... | Pack the block code for transmission. Returns a 2-3 byte string. | [
"Pack",
"the",
"block",
"code",
"for",
"transmission",
".",
"Returns",
"a",
"2",
"-",
"3",
"byte",
"string",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L129-L133 |
227,427 | nfcpy/nfcpy | src/nfc/tag/tt3.py | Type3Tag.dump_service | def dump_service(self, sc):
"""Read all data blocks of a given service.
:meth:`dump_service` reads all data blocks from the service
with service code *sc* and returns a list of strings suitable
for printing. The number of strings returned does not
necessarily reflect the number ... | python | def dump_service(self, sc):
"""Read all data blocks of a given service.
:meth:`dump_service` reads all data blocks from the service
with service code *sc* and returns a list of strings suitable
for printing. The number of strings returned does not
necessarily reflect the number ... | [
"def",
"dump_service",
"(",
"self",
",",
"sc",
")",
":",
"def",
"lprint",
"(",
"fmt",
",",
"data",
",",
"index",
")",
":",
"ispchr",
"=",
"lambda",
"x",
":",
"x",
">=",
"32",
"and",
"x",
"<=",
"126",
"# noqa: E731",
"def",
"print_bytes",
"(",
"octe... | Read all data blocks of a given service.
:meth:`dump_service` reads all data blocks from the service
with service code *sc* and returns a list of strings suitable
for printing. The number of strings returned does not
necessarily reflect the number of data blocks because a range
... | [
"Read",
"all",
"data",
"blocks",
"of",
"a",
"given",
"service",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L284-L335 |
227,428 | nfcpy/nfcpy | src/nfc/tag/tt3.py | Type3Tag.format | def format(self, version=None, wipe=None):
"""Format and blank an NFC Forum Type 3 Tag.
A generic NFC Forum Type 3 Tag can be (re)formatted if it is
in either one of blank, initialized or readwrite state. By
formatting, all contents of the attribute information block is
overwrit... | python | def format(self, version=None, wipe=None):
"""Format and blank an NFC Forum Type 3 Tag.
A generic NFC Forum Type 3 Tag can be (re)formatted if it is
in either one of blank, initialized or readwrite state. By
formatting, all contents of the attribute information block is
overwrit... | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"None",
",",
"wipe",
"=",
"None",
")",
":",
"return",
"super",
"(",
"Type3Tag",
",",
"self",
")",
".",
"format",
"(",
"version",
",",
"wipe",
")"
] | Format and blank an NFC Forum Type 3 Tag.
A generic NFC Forum Type 3 Tag can be (re)formatted if it is
in either one of blank, initialized or readwrite state. By
formatting, all contents of the attribute information block is
overwritten with values determined. The number of user data
... | [
"Format",
"and",
"blank",
"an",
"NFC",
"Forum",
"Type",
"3",
"Tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L337-L359 |
227,429 | nfcpy/nfcpy | src/nfc/tag/tt3.py | Type3Tag.polling | def polling(self, system_code=0xffff, request_code=0, time_slots=0):
"""Aquire and identify a card.
The Polling command is used to detect the Type 3 Tags in the
field. It is also used for initialization and anti-collision.
The *system_code* identifies the card system to acquire. A
... | python | def polling(self, system_code=0xffff, request_code=0, time_slots=0):
"""Aquire and identify a card.
The Polling command is used to detect the Type 3 Tags in the
field. It is also used for initialization and anti-collision.
The *system_code* identifies the card system to acquire. A
... | [
"def",
"polling",
"(",
"self",
",",
"system_code",
"=",
"0xffff",
",",
"request_code",
"=",
"0",
",",
"time_slots",
"=",
"0",
")",
":",
"log",
".",
"debug",
"(",
"\"polling for system 0x{0:04x}\"",
".",
"format",
"(",
"system_code",
")",
")",
"if",
"time_s... | Aquire and identify a card.
The Polling command is used to detect the Type 3 Tags in the
field. It is also used for initialization and anti-collision.
The *system_code* identifies the card system to acquire. A
card can have multiple systems. The first system that matches
*syste... | [
"Aquire",
"and",
"identify",
"a",
"card",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L452-L513 |
227,430 | nfcpy/nfcpy | src/nfc/tag/tt3.py | Type3Tag.read_from_ndef_service | def read_from_ndef_service(self, *blocks):
"""Read block data from an NDEF compatible tag.
This is a convinience method to read block data from a tag
that has system code 0x12FC (NDEF). For other tags this method
simply returns :const:`None`. All arguments are block numbers
to r... | python | def read_from_ndef_service(self, *blocks):
"""Read block data from an NDEF compatible tag.
This is a convinience method to read block data from a tag
that has system code 0x12FC (NDEF). For other tags this method
simply returns :const:`None`. All arguments are block numbers
to r... | [
"def",
"read_from_ndef_service",
"(",
"self",
",",
"*",
"blocks",
")",
":",
"if",
"self",
".",
"sys",
"==",
"0x12FC",
":",
"sc_list",
"=",
"[",
"ServiceCode",
"(",
"0",
",",
"0b001011",
")",
"]",
"bc_list",
"=",
"[",
"BlockCode",
"(",
"n",
")",
"for"... | Read block data from an NDEF compatible tag.
This is a convinience method to read block data from a tag
that has system code 0x12FC (NDEF). For other tags this method
simply returns :const:`None`. All arguments are block numbers
to read. To actually pass a list of block numbers requires... | [
"Read",
"block",
"data",
"from",
"an",
"NDEF",
"compatible",
"tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L568-L587 |
227,431 | nfcpy/nfcpy | src/nfc/tag/tt3.py | Type3Tag.write_without_encryption | def write_without_encryption(self, service_list, block_list, data):
"""Write data blocks to unencrypted services.
This method sends a Write Without Encryption command to the
tag. The data blocks to overwrite are indicated by a sequence
of :class:`~nfc.tag.tt3.BlockCode` objects in the p... | python | def write_without_encryption(self, service_list, block_list, data):
"""Write data blocks to unencrypted services.
This method sends a Write Without Encryption command to the
tag. The data blocks to overwrite are indicated by a sequence
of :class:`~nfc.tag.tt3.BlockCode` objects in the p... | [
"def",
"write_without_encryption",
"(",
"self",
",",
"service_list",
",",
"block_list",
",",
"data",
")",
":",
"a",
",",
"b",
",",
"e",
"=",
"self",
".",
"pmm",
"[",
"6",
"]",
"&",
"7",
",",
"self",
".",
"pmm",
"[",
"6",
"]",
">>",
"3",
"&",
"7... | Write data blocks to unencrypted services.
This method sends a Write Without Encryption command to the
tag. The data blocks to overwrite are indicated by a sequence
of :class:`~nfc.tag.tt3.BlockCode` objects in the parameter
*block_list*. Each block code must reference one of the
... | [
"Write",
"data",
"blocks",
"to",
"unencrypted",
"services",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L589-L642 |
227,432 | nfcpy/nfcpy | src/nfc/tag/tt3.py | Type3Tag.write_to_ndef_service | def write_to_ndef_service(self, data, *blocks):
"""Write block data to an NDEF compatible tag.
This is a convinience method to write block data to a tag that
has system code 0x12FC (NDEF). For other tags this method
simply does nothing. The *data* to write must be a string or
by... | python | def write_to_ndef_service(self, data, *blocks):
"""Write block data to an NDEF compatible tag.
This is a convinience method to write block data to a tag that
has system code 0x12FC (NDEF). For other tags this method
simply does nothing. The *data* to write must be a string or
by... | [
"def",
"write_to_ndef_service",
"(",
"self",
",",
"data",
",",
"*",
"blocks",
")",
":",
"if",
"self",
".",
"sys",
"==",
"0x12FC",
":",
"sc_list",
"=",
"[",
"ServiceCode",
"(",
"0",
",",
"0b001001",
")",
"]",
"bc_list",
"=",
"[",
"BlockCode",
"(",
"n"... | Write block data to an NDEF compatible tag.
This is a convinience method to write block data to a tag that
has system code 0x12FC (NDEF). For other tags this method
simply does nothing. The *data* to write must be a string or
bytearray with length equal ``16 * len(blocks)``. All
... | [
"Write",
"block",
"data",
"to",
"an",
"NDEF",
"compatible",
"tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt3.py#L644-L665 |
227,433 | nfcpy/nfcpy | src/nfc/clf/__init__.py | ContactlessFrontend.close | def close(self):
"""Close the contacless reader device."""
with self.lock:
if self.device is not None:
try:
self.device.close()
except IOError:
pass
self.device = None | python | def close(self):
"""Close the contacless reader device."""
with self.lock:
if self.device is not None:
try:
self.device.close()
except IOError:
pass
self.device = None | [
"def",
"close",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"device",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"device",
".",
"close",
"(",
")",
"except",
"IOError",
":",
"pass",
"self",
".",
"device",
"=... | Close the contacless reader device. | [
"Close",
"the",
"contacless",
"reader",
"device",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/__init__.py#L155-L163 |
227,434 | cloudnativelabs/kube-shell | kubeshell/parser.py | Parser.build | def build(self, root, schema):
""" Build the syntax tree for kubectl command line """
if schema.get("subcommands") and schema["subcommands"]:
for subcmd, childSchema in schema["subcommands"].items():
child = CommandTree(node=subcmd)
child = self.build(child, c... | python | def build(self, root, schema):
""" Build the syntax tree for kubectl command line """
if schema.get("subcommands") and schema["subcommands"]:
for subcmd, childSchema in schema["subcommands"].items():
child = CommandTree(node=subcmd)
child = self.build(child, c... | [
"def",
"build",
"(",
"self",
",",
"root",
",",
"schema",
")",
":",
"if",
"schema",
".",
"get",
"(",
"\"subcommands\"",
")",
"and",
"schema",
"[",
"\"subcommands\"",
"]",
":",
"for",
"subcmd",
",",
"childSchema",
"in",
"schema",
"[",
"\"subcommands\"",
"]... | Build the syntax tree for kubectl command line | [
"Build",
"the",
"syntax",
"tree",
"for",
"kubectl",
"command",
"line"
] | adc801d165e87fe62f82b074ec49996954c3fbe8 | https://github.com/cloudnativelabs/kube-shell/blob/adc801d165e87fe62f82b074ec49996954c3fbe8/kubeshell/parser.py#L45-L61 |
227,435 | cloudnativelabs/kube-shell | kubeshell/parser.py | Parser.parse_tokens | def parse_tokens(self, tokens):
""" Parse a sequence of tokens
returns tuple of (parsed tokens, suggestions)
"""
if len(tokens) == 1:
return list(), tokens, {"kubectl": self.ast.help}
else:
tokens.reverse()
parsed, unparsed, suggestions = self.tre... | python | def parse_tokens(self, tokens):
""" Parse a sequence of tokens
returns tuple of (parsed tokens, suggestions)
"""
if len(tokens) == 1:
return list(), tokens, {"kubectl": self.ast.help}
else:
tokens.reverse()
parsed, unparsed, suggestions = self.tre... | [
"def",
"parse_tokens",
"(",
"self",
",",
"tokens",
")",
":",
"if",
"len",
"(",
"tokens",
")",
"==",
"1",
":",
"return",
"list",
"(",
")",
",",
"tokens",
",",
"{",
"\"kubectl\"",
":",
"self",
".",
"ast",
".",
"help",
"}",
"else",
":",
"tokens",
".... | Parse a sequence of tokens
returns tuple of (parsed tokens, suggestions) | [
"Parse",
"a",
"sequence",
"of",
"tokens"
] | adc801d165e87fe62f82b074ec49996954c3fbe8 | https://github.com/cloudnativelabs/kube-shell/blob/adc801d165e87fe62f82b074ec49996954c3fbe8/kubeshell/parser.py#L69-L90 |
227,436 | cloudnativelabs/kube-shell | kubeshell/parser.py | Parser.treewalk | def treewalk(self, root, parsed, unparsed):
""" Recursively walks the syntax tree at root and returns
the items parsed, unparsed and possible suggestions """
suggestions = dict()
if not unparsed:
logger.debug("no tokens left unparsed. returning %s, %s", parsed, suggestions)
... | python | def treewalk(self, root, parsed, unparsed):
""" Recursively walks the syntax tree at root and returns
the items parsed, unparsed and possible suggestions """
suggestions = dict()
if not unparsed:
logger.debug("no tokens left unparsed. returning %s, %s", parsed, suggestions)
... | [
"def",
"treewalk",
"(",
"self",
",",
"root",
",",
"parsed",
",",
"unparsed",
")",
":",
"suggestions",
"=",
"dict",
"(",
")",
"if",
"not",
"unparsed",
":",
"logger",
".",
"debug",
"(",
"\"no tokens left unparsed. returning %s, %s\"",
",",
"parsed",
",",
"sugg... | Recursively walks the syntax tree at root and returns
the items parsed, unparsed and possible suggestions | [
"Recursively",
"walks",
"the",
"syntax",
"tree",
"at",
"root",
"and",
"returns",
"the",
"items",
"parsed",
"unparsed",
"and",
"possible",
"suggestions"
] | adc801d165e87fe62f82b074ec49996954c3fbe8 | https://github.com/cloudnativelabs/kube-shell/blob/adc801d165e87fe62f82b074ec49996954c3fbe8/kubeshell/parser.py#L92-L128 |
227,437 | cloudnativelabs/kube-shell | kubeshell/parser.py | Parser.evalOptions | def evalOptions(self, root, parsed, unparsed):
""" Evaluate only the options and return flags as suggestions """
logger.debug("parsing options at tree: %s with p:%s, u:%s", root.node, parsed, unparsed)
suggestions = dict()
token = unparsed.pop().strip()
parts = token.partition('... | python | def evalOptions(self, root, parsed, unparsed):
""" Evaluate only the options and return flags as suggestions """
logger.debug("parsing options at tree: %s with p:%s, u:%s", root.node, parsed, unparsed)
suggestions = dict()
token = unparsed.pop().strip()
parts = token.partition('... | [
"def",
"evalOptions",
"(",
"self",
",",
"root",
",",
"parsed",
",",
"unparsed",
")",
":",
"logger",
".",
"debug",
"(",
"\"parsing options at tree: %s with p:%s, u:%s\"",
",",
"root",
".",
"node",
",",
"parsed",
",",
"unparsed",
")",
"suggestions",
"=",
"dict",... | Evaluate only the options and return flags as suggestions | [
"Evaluate",
"only",
"the",
"options",
"and",
"return",
"flags",
"as",
"suggestions"
] | adc801d165e87fe62f82b074ec49996954c3fbe8 | https://github.com/cloudnativelabs/kube-shell/blob/adc801d165e87fe62f82b074ec49996954c3fbe8/kubeshell/parser.py#L136-L165 |
227,438 | olofk/fusesoc | fusesoc/utils.py | setup_logging | def setup_logging(level, monchrome=False, log_file=None):
'''
Utility function for setting up logging.
'''
# Logging to file
if log_file:
logging.basicConfig(filename=log_file, filemode='w',
level=logging.DEBUG)
# Pretty color terminal logging
ch = loggin... | python | def setup_logging(level, monchrome=False, log_file=None):
'''
Utility function for setting up logging.
'''
# Logging to file
if log_file:
logging.basicConfig(filename=log_file, filemode='w',
level=logging.DEBUG)
# Pretty color terminal logging
ch = loggin... | [
"def",
"setup_logging",
"(",
"level",
",",
"monchrome",
"=",
"False",
",",
"log_file",
"=",
"None",
")",
":",
"# Logging to file",
"if",
"log_file",
":",
"logging",
".",
"basicConfig",
"(",
"filename",
"=",
"log_file",
",",
"filemode",
"=",
"'w'",
",",
"le... | Utility function for setting up logging. | [
"Utility",
"function",
"for",
"setting",
"up",
"logging",
"."
] | e30c6a30f6e4c2f4a568b3e8f53edce64b4481cd | https://github.com/olofk/fusesoc/blob/e30c6a30f6e4c2f4a568b3e8f53edce64b4481cd/fusesoc/utils.py#L84-L110 |
227,439 | olofk/fusesoc | fusesoc/edalizer.py | Ttptttg.generate | def generate(self, cache_root):
"""Run a parametrized generator
Args:
cache_root (str): The directory where to store the generated cores
Returns:
list: Cores created by the generator
"""
generator_cwd = os.path.join(cache_root, 'generated', self.vlnv.san... | python | def generate(self, cache_root):
"""Run a parametrized generator
Args:
cache_root (str): The directory where to store the generated cores
Returns:
list: Cores created by the generator
"""
generator_cwd = os.path.join(cache_root, 'generated', self.vlnv.san... | [
"def",
"generate",
"(",
"self",
",",
"cache_root",
")",
":",
"generator_cwd",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_root",
",",
"'generated'",
",",
"self",
".",
"vlnv",
".",
"sanitized_name",
")",
"generator_input_file",
"=",
"os",
".",
"path",
... | Run a parametrized generator
Args:
cache_root (str): The directory where to store the generated cores
Returns:
list: Cores created by the generator | [
"Run",
"a",
"parametrized",
"generator"
] | e30c6a30f6e4c2f4a568b3e8f53edce64b4481cd | https://github.com/olofk/fusesoc/blob/e30c6a30f6e4c2f4a568b3e8f53edce64b4481cd/fusesoc/edalizer.py#L165-L203 |
227,440 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/fields.py | Field._range_check | def _range_check(self, value, min_value, max_value):
'''
Utility method to check that the given value is between min_value and max_value.
'''
if value < min_value or value > max_value:
raise ValueError('%s out of range - %s is not between %s and %s' % (self.__class__.__name__... | python | def _range_check(self, value, min_value, max_value):
'''
Utility method to check that the given value is between min_value and max_value.
'''
if value < min_value or value > max_value:
raise ValueError('%s out of range - %s is not between %s and %s' % (self.__class__.__name__... | [
"def",
"_range_check",
"(",
"self",
",",
"value",
",",
"min_value",
",",
"max_value",
")",
":",
"if",
"value",
"<",
"min_value",
"or",
"value",
">",
"max_value",
":",
"raise",
"ValueError",
"(",
"'%s out of range - %s is not between %s and %s'",
"%",
"(",
"self"... | Utility method to check that the given value is between min_value and max_value. | [
"Utility",
"method",
"to",
"check",
"that",
"the",
"given",
"value",
"is",
"between",
"min_value",
"and",
"max_value",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/fields.py#L52-L57 |
227,441 | Infinidat/infi.clickhouse_orm | scripts/generate_ref.py | _get_default_arg | def _get_default_arg(args, defaults, arg_index):
""" Method that determines if an argument has default value or not,
and if yes what is the default value for the argument
:param args: array of arguments, eg: ['first_arg', 'second_arg', 'third_arg']
:param defaults: array of default values, eg: (42, 'so... | python | def _get_default_arg(args, defaults, arg_index):
""" Method that determines if an argument has default value or not,
and if yes what is the default value for the argument
:param args: array of arguments, eg: ['first_arg', 'second_arg', 'third_arg']
:param defaults: array of default values, eg: (42, 'so... | [
"def",
"_get_default_arg",
"(",
"args",
",",
"defaults",
",",
"arg_index",
")",
":",
"if",
"not",
"defaults",
":",
"return",
"DefaultArgSpec",
"(",
"False",
",",
"None",
")",
"args_with_no_defaults",
"=",
"len",
"(",
"args",
")",
"-",
"len",
"(",
"defaults... | Method that determines if an argument has default value or not,
and if yes what is the default value for the argument
:param args: array of arguments, eg: ['first_arg', 'second_arg', 'third_arg']
:param defaults: array of default values, eg: (42, 'something')
:param arg_index: index of the argument in ... | [
"Method",
"that",
"determines",
"if",
"an",
"argument",
"has",
"default",
"value",
"or",
"not",
"and",
"if",
"yes",
"what",
"is",
"the",
"default",
"value",
"for",
"the",
"argument"
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/scripts/generate_ref.py#L7-L30 |
227,442 | Infinidat/infi.clickhouse_orm | scripts/generate_ref.py | get_method_sig | def get_method_sig(method):
""" Given a function, it returns a string that pretty much looks how the
function signature would be written in python.
:param method: a python method
:return: A string similar describing the pythong method signature.
eg: "my_method(first_argArg, second_arg=42, third_arg... | python | def get_method_sig(method):
""" Given a function, it returns a string that pretty much looks how the
function signature would be written in python.
:param method: a python method
:return: A string similar describing the pythong method signature.
eg: "my_method(first_argArg, second_arg=42, third_arg... | [
"def",
"get_method_sig",
"(",
"method",
")",
":",
"# The return value of ArgSpec is a bit weird, as the list of arguments and",
"# list of defaults are returned in separate array.",
"# eg: ArgSpec(args=['first_arg', 'second_arg', 'third_arg'],",
"# varargs=None, keywords=None, defaults=(42, 'somet... | Given a function, it returns a string that pretty much looks how the
function signature would be written in python.
:param method: a python method
:return: A string similar describing the pythong method signature.
eg: "my_method(first_argArg, second_arg=42, third_arg='something')" | [
"Given",
"a",
"function",
"it",
"returns",
"a",
"string",
"that",
"pretty",
"much",
"looks",
"how",
"the",
"function",
"signature",
"would",
"be",
"written",
"in",
"python",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/scripts/generate_ref.py#L32-L65 |
227,443 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/query.py | AggregateQuerySet.group_by | def group_by(self, *args):
"""
This method lets you specify the grouping fields explicitly. The `args` must
be names of grouping fields or calculated fields that this queryset was
created with.
"""
for name in args:
assert name in self._fields or name in self.... | python | def group_by(self, *args):
"""
This method lets you specify the grouping fields explicitly. The `args` must
be names of grouping fields or calculated fields that this queryset was
created with.
"""
for name in args:
assert name in self._fields or name in self.... | [
"def",
"group_by",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"name",
"in",
"args",
":",
"assert",
"name",
"in",
"self",
".",
"_fields",
"or",
"name",
"in",
"self",
".",
"_calculated_fields",
",",
"'Cannot group by `%s` since it is not included in the query... | This method lets you specify the grouping fields explicitly. The `args` must
be names of grouping fields or calculated fields that this queryset was
created with. | [
"This",
"method",
"lets",
"you",
"specify",
"the",
"grouping",
"fields",
"explicitly",
".",
"The",
"args",
"must",
"be",
"names",
"of",
"grouping",
"fields",
"or",
"calculated",
"fields",
"that",
"this",
"queryset",
"was",
"created",
"with",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/query.py#L554-L565 |
227,444 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/query.py | AggregateQuerySet.select_fields_as_sql | def select_fields_as_sql(self):
"""
Returns the selected fields or expressions as a SQL string.
"""
return comma_join(list(self._fields) + ['%s AS %s' % (v, k) for k, v in self._calculated_fields.items()]) | python | def select_fields_as_sql(self):
"""
Returns the selected fields or expressions as a SQL string.
"""
return comma_join(list(self._fields) + ['%s AS %s' % (v, k) for k, v in self._calculated_fields.items()]) | [
"def",
"select_fields_as_sql",
"(",
"self",
")",
":",
"return",
"comma_join",
"(",
"list",
"(",
"self",
".",
"_fields",
")",
"+",
"[",
"'%s AS %s'",
"%",
"(",
"v",
",",
"k",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_calculated_fields",
".",
"it... | Returns the selected fields or expressions as a SQL string. | [
"Returns",
"the",
"selected",
"fields",
"or",
"expressions",
"as",
"a",
"SQL",
"string",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/query.py#L579-L583 |
227,445 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/query.py | AggregateQuerySet.count | def count(self):
"""
Returns the number of rows after aggregation.
"""
sql = u'SELECT count() FROM (%s)' % self.as_sql()
raw = self._database.raw(sql)
return int(raw) if raw else 0 | python | def count(self):
"""
Returns the number of rows after aggregation.
"""
sql = u'SELECT count() FROM (%s)' % self.as_sql()
raw = self._database.raw(sql)
return int(raw) if raw else 0 | [
"def",
"count",
"(",
"self",
")",
":",
"sql",
"=",
"u'SELECT count() FROM (%s)'",
"%",
"self",
".",
"as_sql",
"(",
")",
"raw",
"=",
"self",
".",
"_database",
".",
"raw",
"(",
"sql",
")",
"return",
"int",
"(",
"raw",
")",
"if",
"raw",
"else",
"0"
] | Returns the number of rows after aggregation. | [
"Returns",
"the",
"number",
"of",
"rows",
"after",
"aggregation",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/query.py#L588-L594 |
227,446 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/models.py | Model.set_database | def set_database(self, db):
'''
Sets the `Database` that this model instance belongs to.
This is done automatically when the instance is read from the database or written to it.
'''
# This can not be imported globally due to circular import
from .database import Database
... | python | def set_database(self, db):
'''
Sets the `Database` that this model instance belongs to.
This is done automatically when the instance is read from the database or written to it.
'''
# This can not be imported globally due to circular import
from .database import Database
... | [
"def",
"set_database",
"(",
"self",
",",
"db",
")",
":",
"# This can not be imported globally due to circular import",
"from",
".",
"database",
"import",
"Database",
"assert",
"isinstance",
"(",
"db",
",",
"Database",
")",
",",
"\"database must be database.Database instan... | Sets the `Database` that this model instance belongs to.
This is done automatically when the instance is read from the database or written to it. | [
"Sets",
"the",
"Database",
"that",
"this",
"model",
"instance",
"belongs",
"to",
".",
"This",
"is",
"done",
"automatically",
"when",
"the",
"instance",
"is",
"read",
"from",
"the",
"database",
"or",
"written",
"to",
"it",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L153-L161 |
227,447 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/models.py | Model.from_tsv | def from_tsv(cls, line, field_names, timezone_in_use=pytz.utc, database=None):
'''
Create a model instance from a tab-separated line. The line may or may not include a newline.
The `field_names` list must match the fields defined in the model, but does not have to include all of them.
-... | python | def from_tsv(cls, line, field_names, timezone_in_use=pytz.utc, database=None):
'''
Create a model instance from a tab-separated line. The line may or may not include a newline.
The `field_names` list must match the fields defined in the model, but does not have to include all of them.
-... | [
"def",
"from_tsv",
"(",
"cls",
",",
"line",
",",
"field_names",
",",
"timezone_in_use",
"=",
"pytz",
".",
"utc",
",",
"database",
"=",
"None",
")",
":",
"from",
"six",
"import",
"next",
"values",
"=",
"iter",
"(",
"parse_tsv",
"(",
"line",
")",
")",
... | Create a model instance from a tab-separated line. The line may or may not include a newline.
The `field_names` list must match the fields defined in the model, but does not have to include all of them.
- `line`: the TSV-formatted data.
- `field_names`: names of the model fields in the data.
... | [
"Create",
"a",
"model",
"instance",
"from",
"a",
"tab",
"-",
"separated",
"line",
".",
"The",
"line",
"may",
"or",
"may",
"not",
"include",
"a",
"newline",
".",
"The",
"field_names",
"list",
"must",
"match",
"the",
"fields",
"defined",
"in",
"the",
"mode... | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L207-L228 |
227,448 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/models.py | Model.to_tsv | def to_tsv(self, include_readonly=True):
'''
Returns the instance's column values as a tab-separated line. A newline is not included.
- `include_readonly`: if false, returns only fields that can be inserted into database.
'''
data = self.__dict__
fields = self.fields(wri... | python | def to_tsv(self, include_readonly=True):
'''
Returns the instance's column values as a tab-separated line. A newline is not included.
- `include_readonly`: if false, returns only fields that can be inserted into database.
'''
data = self.__dict__
fields = self.fields(wri... | [
"def",
"to_tsv",
"(",
"self",
",",
"include_readonly",
"=",
"True",
")",
":",
"data",
"=",
"self",
".",
"__dict__",
"fields",
"=",
"self",
".",
"fields",
"(",
"writable",
"=",
"not",
"include_readonly",
")",
"return",
"'\\t'",
".",
"join",
"(",
"field",
... | Returns the instance's column values as a tab-separated line. A newline is not included.
- `include_readonly`: if false, returns only fields that can be inserted into database. | [
"Returns",
"the",
"instance",
"s",
"column",
"values",
"as",
"a",
"tab",
"-",
"separated",
"line",
".",
"A",
"newline",
"is",
"not",
"included",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L230-L238 |
227,449 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/models.py | Model.to_dict | def to_dict(self, include_readonly=True, field_names=None):
'''
Returns the instance's column values as a dict.
- `include_readonly`: if false, returns only fields that can be inserted into database.
- `field_names`: an iterable of field names to return (optional)
'''
fi... | python | def to_dict(self, include_readonly=True, field_names=None):
'''
Returns the instance's column values as a dict.
- `include_readonly`: if false, returns only fields that can be inserted into database.
- `field_names`: an iterable of field names to return (optional)
'''
fi... | [
"def",
"to_dict",
"(",
"self",
",",
"include_readonly",
"=",
"True",
",",
"field_names",
"=",
"None",
")",
":",
"fields",
"=",
"self",
".",
"fields",
"(",
"writable",
"=",
"not",
"include_readonly",
")",
"if",
"field_names",
"is",
"not",
"None",
":",
"fi... | Returns the instance's column values as a dict.
- `include_readonly`: if false, returns only fields that can be inserted into database.
- `field_names`: an iterable of field names to return (optional) | [
"Returns",
"the",
"instance",
"s",
"column",
"values",
"as",
"a",
"dict",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L240-L253 |
227,450 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/utils.py | import_submodules | def import_submodules(package_name):
"""
Import all submodules of a module.
"""
import importlib, pkgutil
package = importlib.import_module(package_name)
return {
name: importlib.import_module(package_name + '.' + name)
for _, name, _ in pkgutil.iter_modules(package.__path__)
... | python | def import_submodules(package_name):
"""
Import all submodules of a module.
"""
import importlib, pkgutil
package = importlib.import_module(package_name)
return {
name: importlib.import_module(package_name + '.' + name)
for _, name, _ in pkgutil.iter_modules(package.__path__)
... | [
"def",
"import_submodules",
"(",
"package_name",
")",
":",
"import",
"importlib",
",",
"pkgutil",
"package",
"=",
"importlib",
".",
"import_module",
"(",
"package_name",
")",
"return",
"{",
"name",
":",
"importlib",
".",
"import_module",
"(",
"package_name",
"+"... | Import all submodules of a module. | [
"Import",
"all",
"submodules",
"of",
"a",
"module",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/utils.py#L84-L93 |
227,451 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | ServerError.get_error_code_msg | def get_error_code_msg(cls, full_error_message):
"""
Extract the code and message of the exception that clickhouse-server generated.
See the list of error codes here:
https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/ErrorCodes.cpp
"""
for pattern in cls.E... | python | def get_error_code_msg(cls, full_error_message):
"""
Extract the code and message of the exception that clickhouse-server generated.
See the list of error codes here:
https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/ErrorCodes.cpp
"""
for pattern in cls.E... | [
"def",
"get_error_code_msg",
"(",
"cls",
",",
"full_error_message",
")",
":",
"for",
"pattern",
"in",
"cls",
".",
"ERROR_PATTERNS",
":",
"match",
"=",
"pattern",
".",
"match",
"(",
"full_error_message",
")",
"if",
"match",
":",
"# assert match.group('type1') == ma... | Extract the code and message of the exception that clickhouse-server generated.
See the list of error codes here:
https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/ErrorCodes.cpp | [
"Extract",
"the",
"code",
"and",
"message",
"of",
"the",
"exception",
"that",
"clickhouse",
"-",
"server",
"generated",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L58-L71 |
227,452 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.create_table | def create_table(self, model_class):
'''
Creates a table for the given model class, if it does not exist already.
'''
if model_class.is_system_model():
raise DatabaseException("You can't create system table")
if getattr(model_class, 'engine') is None:
rais... | python | def create_table(self, model_class):
'''
Creates a table for the given model class, if it does not exist already.
'''
if model_class.is_system_model():
raise DatabaseException("You can't create system table")
if getattr(model_class, 'engine') is None:
rais... | [
"def",
"create_table",
"(",
"self",
",",
"model_class",
")",
":",
"if",
"model_class",
".",
"is_system_model",
"(",
")",
":",
"raise",
"DatabaseException",
"(",
"\"You can't create system table\"",
")",
"if",
"getattr",
"(",
"model_class",
",",
"'engine'",
")",
... | Creates a table for the given model class, if it does not exist already. | [
"Creates",
"a",
"table",
"for",
"the",
"given",
"model",
"class",
"if",
"it",
"does",
"not",
"exist",
"already",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L136-L144 |
227,453 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.drop_table | def drop_table(self, model_class):
'''
Drops the database table of the given model class, if it exists.
'''
if model_class.is_system_model():
raise DatabaseException("You can't drop system table")
self._send(model_class.drop_table_sql(self)) | python | def drop_table(self, model_class):
'''
Drops the database table of the given model class, if it exists.
'''
if model_class.is_system_model():
raise DatabaseException("You can't drop system table")
self._send(model_class.drop_table_sql(self)) | [
"def",
"drop_table",
"(",
"self",
",",
"model_class",
")",
":",
"if",
"model_class",
".",
"is_system_model",
"(",
")",
":",
"raise",
"DatabaseException",
"(",
"\"You can't drop system table\"",
")",
"self",
".",
"_send",
"(",
"model_class",
".",
"drop_table_sql",
... | Drops the database table of the given model class, if it exists. | [
"Drops",
"the",
"database",
"table",
"of",
"the",
"given",
"model",
"class",
"if",
"it",
"exists",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L146-L152 |
227,454 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.does_table_exist | def does_table_exist(self, model_class):
'''
Checks whether a table for the given model class already exists.
Note that this only checks for existence of a table with the expected name.
'''
sql = "SELECT count() FROM system.tables WHERE database = '%s' AND name = '%s'"
r ... | python | def does_table_exist(self, model_class):
'''
Checks whether a table for the given model class already exists.
Note that this only checks for existence of a table with the expected name.
'''
sql = "SELECT count() FROM system.tables WHERE database = '%s' AND name = '%s'"
r ... | [
"def",
"does_table_exist",
"(",
"self",
",",
"model_class",
")",
":",
"sql",
"=",
"\"SELECT count() FROM system.tables WHERE database = '%s' AND name = '%s'\"",
"r",
"=",
"self",
".",
"_send",
"(",
"sql",
"%",
"(",
"self",
".",
"db_name",
",",
"model_class",
".",
... | Checks whether a table for the given model class already exists.
Note that this only checks for existence of a table with the expected name. | [
"Checks",
"whether",
"a",
"table",
"for",
"the",
"given",
"model",
"class",
"already",
"exists",
".",
"Note",
"that",
"this",
"only",
"checks",
"for",
"existence",
"of",
"a",
"table",
"with",
"the",
"expected",
"name",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L154-L161 |
227,455 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.insert | def insert(self, model_instances, batch_size=1000):
'''
Insert records into the database.
- `model_instances`: any iterable containing instances of a single model class.
- `batch_size`: number of records to send per chunk (use a lower number if your records are very large).
'''
... | python | def insert(self, model_instances, batch_size=1000):
'''
Insert records into the database.
- `model_instances`: any iterable containing instances of a single model class.
- `batch_size`: number of records to send per chunk (use a lower number if your records are very large).
'''
... | [
"def",
"insert",
"(",
"self",
",",
"model_instances",
",",
"batch_size",
"=",
"1000",
")",
":",
"from",
"six",
"import",
"next",
"from",
"io",
"import",
"BytesIO",
"i",
"=",
"iter",
"(",
"model_instances",
")",
"try",
":",
"first_instance",
"=",
"next",
... | Insert records into the database.
- `model_instances`: any iterable containing instances of a single model class.
- `batch_size`: number of records to send per chunk (use a lower number if your records are very large). | [
"Insert",
"records",
"into",
"the",
"database",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L177-L222 |
227,456 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.count | def count(self, model_class, conditions=None):
'''
Counts the number of records in the model's table.
- `model_class`: the model to count.
- `conditions`: optional SQL conditions (contents of the WHERE clause).
'''
query = 'SELECT count() FROM $table'
if conditio... | python | def count(self, model_class, conditions=None):
'''
Counts the number of records in the model's table.
- `model_class`: the model to count.
- `conditions`: optional SQL conditions (contents of the WHERE clause).
'''
query = 'SELECT count() FROM $table'
if conditio... | [
"def",
"count",
"(",
"self",
",",
"model_class",
",",
"conditions",
"=",
"None",
")",
":",
"query",
"=",
"'SELECT count() FROM $table'",
"if",
"conditions",
":",
"query",
"+=",
"' WHERE '",
"+",
"conditions",
"query",
"=",
"self",
".",
"_substitute",
"(",
"q... | Counts the number of records in the model's table.
- `model_class`: the model to count.
- `conditions`: optional SQL conditions (contents of the WHERE clause). | [
"Counts",
"the",
"number",
"of",
"records",
"in",
"the",
"model",
"s",
"table",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L224-L236 |
227,457 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.select | def select(self, query, model_class=None, settings=None):
'''
Performs a query and returns a generator of model instances.
- `query`: the SQL query to execute.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.... | python | def select(self, query, model_class=None, settings=None):
'''
Performs a query and returns a generator of model instances.
- `query`: the SQL query to execute.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.... | [
"def",
"select",
"(",
"self",
",",
"query",
",",
"model_class",
"=",
"None",
",",
"settings",
"=",
"None",
")",
":",
"query",
"+=",
"' FORMAT TabSeparatedWithNamesAndTypes'",
"query",
"=",
"self",
".",
"_substitute",
"(",
"query",
",",
"model_class",
")",
"r... | Performs a query and returns a generator of model instances.
- `query`: the SQL query to execute.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.
- `settings`: query settings to send as HTTP GET parameters | [
"Performs",
"a",
"query",
"and",
"returns",
"a",
"generator",
"of",
"model",
"instances",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L238-L257 |
227,458 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.raw | def raw(self, query, settings=None, stream=False):
'''
Performs a query and returns its output as text.
- `query`: the SQL query to execute.
- `settings`: query settings to send as HTTP GET parameters
- `stream`: if true, the HTTP response from ClickHouse will be streamed.
... | python | def raw(self, query, settings=None, stream=False):
'''
Performs a query and returns its output as text.
- `query`: the SQL query to execute.
- `settings`: query settings to send as HTTP GET parameters
- `stream`: if true, the HTTP response from ClickHouse will be streamed.
... | [
"def",
"raw",
"(",
"self",
",",
"query",
",",
"settings",
"=",
"None",
",",
"stream",
"=",
"False",
")",
":",
"query",
"=",
"self",
".",
"_substitute",
"(",
"query",
",",
"None",
")",
"return",
"self",
".",
"_send",
"(",
"query",
",",
"settings",
"... | Performs a query and returns its output as text.
- `query`: the SQL query to execute.
- `settings`: query settings to send as HTTP GET parameters
- `stream`: if true, the HTTP response from ClickHouse will be streamed. | [
"Performs",
"a",
"query",
"and",
"returns",
"its",
"output",
"as",
"text",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L259-L268 |
227,459 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.paginate | def paginate(self, model_class, order_by, page_num=1, page_size=100, conditions=None, settings=None):
'''
Selects records and returns a single page of model instances.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.... | python | def paginate(self, model_class, order_by, page_num=1, page_size=100, conditions=None, settings=None):
'''
Selects records and returns a single page of model instances.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.... | [
"def",
"paginate",
"(",
"self",
",",
"model_class",
",",
"order_by",
",",
"page_num",
"=",
"1",
",",
"page_size",
"=",
"100",
",",
"conditions",
"=",
"None",
",",
"settings",
"=",
"None",
")",
":",
"count",
"=",
"self",
".",
"count",
"(",
"model_class"... | Selects records and returns a single page of model instances.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.
- `order_by`: columns to use for sorting the query (contents of the ORDER BY clause).
- `page_num`: the p... | [
"Selects",
"records",
"and",
"returns",
"a",
"single",
"page",
"of",
"model",
"instances",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L270-L304 |
227,460 | Infinidat/infi.clickhouse_orm | src/infi/clickhouse_orm/database.py | Database.migrate | def migrate(self, migrations_package_name, up_to=9999):
'''
Executes schema migrations.
- `migrations_package_name` - fully qualified name of the Python package
containing the migrations.
- `up_to` - number of the last migration to apply.
'''
from .migrations i... | python | def migrate(self, migrations_package_name, up_to=9999):
'''
Executes schema migrations.
- `migrations_package_name` - fully qualified name of the Python package
containing the migrations.
- `up_to` - number of the last migration to apply.
'''
from .migrations i... | [
"def",
"migrate",
"(",
"self",
",",
"migrations_package_name",
",",
"up_to",
"=",
"9999",
")",
":",
"from",
".",
"migrations",
"import",
"MigrationHistory",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'migrations'",
")",
"applied_migrations",
"=",
"self",
... | Executes schema migrations.
- `migrations_package_name` - fully qualified name of the Python package
containing the migrations.
- `up_to` - number of the last migration to apply. | [
"Executes",
"schema",
"migrations",
"."
] | 595f2023e334e3925a5c3fbfdd6083a5992a7169 | https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L306-L325 |
227,461 | pyusb/pyusb | usb/core.py | _try_get_string | def _try_get_string(dev, index, langid = None, default_str_i0 = "",
default_access_error = "Error Accessing String"):
""" try to get a string, but return a string no matter what
"""
if index == 0 :
string = default_str_i0
else:
try:
if langid is None:
... | python | def _try_get_string(dev, index, langid = None, default_str_i0 = "",
default_access_error = "Error Accessing String"):
""" try to get a string, but return a string no matter what
"""
if index == 0 :
string = default_str_i0
else:
try:
if langid is None:
... | [
"def",
"_try_get_string",
"(",
"dev",
",",
"index",
",",
"langid",
"=",
"None",
",",
"default_str_i0",
"=",
"\"\"",
",",
"default_access_error",
"=",
"\"Error Accessing String\"",
")",
":",
"if",
"index",
"==",
"0",
":",
"string",
"=",
"default_str_i0",
"else"... | try to get a string, but return a string no matter what | [
"try",
"to",
"get",
"a",
"string",
"but",
"return",
"a",
"string",
"no",
"matter",
"what"
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L52-L66 |
227,462 | pyusb/pyusb | usb/core.py | _try_lookup | def _try_lookup(table, value, default = ""):
""" try to get a string from the lookup table, return "" instead of key
error
"""
try:
string = table[ value ]
except KeyError:
string = default
return string | python | def _try_lookup(table, value, default = ""):
""" try to get a string from the lookup table, return "" instead of key
error
"""
try:
string = table[ value ]
except KeyError:
string = default
return string | [
"def",
"_try_lookup",
"(",
"table",
",",
"value",
",",
"default",
"=",
"\"\"",
")",
":",
"try",
":",
"string",
"=",
"table",
"[",
"value",
"]",
"except",
"KeyError",
":",
"string",
"=",
"default",
"return",
"string"
] | try to get a string from the lookup table, return "" instead of key
error | [
"try",
"to",
"get",
"a",
"string",
"from",
"the",
"lookup",
"table",
"return",
"instead",
"of",
"key",
"error"
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L68-L76 |
227,463 | pyusb/pyusb | usb/core.py | find | def find(find_all=False, backend = None, custom_match = None, **args):
r"""Find an USB device and return it.
find() is the function used to discover USB devices. You can pass as
arguments any combination of the USB Device Descriptor fields to match a
device. For example:
find(idVendor=0x3f4, idPr... | python | def find(find_all=False, backend = None, custom_match = None, **args):
r"""Find an USB device and return it.
find() is the function used to discover USB devices. You can pass as
arguments any combination of the USB Device Descriptor fields to match a
device. For example:
find(idVendor=0x3f4, idPr... | [
"def",
"find",
"(",
"find_all",
"=",
"False",
",",
"backend",
"=",
"None",
",",
"custom_match",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"def",
"device_iter",
"(",
"*",
"*",
"kwargs",
")",
":",
"for",
"dev",
"in",
"backend",
".",
"enumerate_devi... | r"""Find an USB device and return it.
find() is the function used to discover USB devices. You can pass as
arguments any combination of the USB Device Descriptor fields to match a
device. For example:
find(idVendor=0x3f4, idProduct=0x2009)
will return the Device object for the device with idVend... | [
"r",
"Find",
"an",
"USB",
"device",
"and",
"return",
"it",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1179-L1273 |
227,464 | pyusb/pyusb | usb/core.py | show_devices | def show_devices(verbose=False, **kwargs):
"""Show information about connected devices.
The verbose flag sets to verbose or not.
**kwargs are passed directly to the find() function.
"""
kwargs["find_all"] = True
devices = find(**kwargs)
strings = ""
for device in devices:
if not... | python | def show_devices(verbose=False, **kwargs):
"""Show information about connected devices.
The verbose flag sets to verbose or not.
**kwargs are passed directly to the find() function.
"""
kwargs["find_all"] = True
devices = find(**kwargs)
strings = ""
for device in devices:
if not... | [
"def",
"show_devices",
"(",
"verbose",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"find_all\"",
"]",
"=",
"True",
"devices",
"=",
"find",
"(",
"*",
"*",
"kwargs",
")",
"strings",
"=",
"\"\"",
"for",
"device",
"in",
"devices",
"... | Show information about connected devices.
The verbose flag sets to verbose or not.
**kwargs are passed directly to the find() function. | [
"Show",
"information",
"about",
"connected",
"devices",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1275-L1291 |
227,465 | pyusb/pyusb | usb/core.py | Device.langids | def langids(self):
""" Return the USB device's supported language ID codes.
These are 16-bit codes familiar to Windows developers, where for
example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org
developer site for more info. String requests using a LANGID not
i... | python | def langids(self):
""" Return the USB device's supported language ID codes.
These are 16-bit codes familiar to Windows developers, where for
example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org
developer site for more info. String requests using a LANGID not
i... | [
"def",
"langids",
"(",
"self",
")",
":",
"if",
"self",
".",
"_langids",
"is",
"None",
":",
"try",
":",
"self",
".",
"_langids",
"=",
"util",
".",
"get_langids",
"(",
"self",
")",
"except",
"USBError",
":",
"self",
".",
"_langids",
"=",
"(",
")",
"r... | Return the USB device's supported language ID codes.
These are 16-bit codes familiar to Windows developers, where for
example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org
developer site for more info. String requests using a LANGID not
in this array should not be sent... | [
"Return",
"the",
"USB",
"device",
"s",
"supported",
"language",
"ID",
"codes",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L794-L810 |
227,466 | pyusb/pyusb | usb/core.py | Device.serial_number | def serial_number(self):
""" Return the USB device's serial number string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use.
"""
if self._serial_number is None:
self._serial_number = util.... | python | def serial_number(self):
""" Return the USB device's serial number string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use.
"""
if self._serial_number is None:
self._serial_number = util.... | [
"def",
"serial_number",
"(",
"self",
")",
":",
"if",
"self",
".",
"_serial_number",
"is",
"None",
":",
"self",
".",
"_serial_number",
"=",
"util",
".",
"get_string",
"(",
"self",
",",
"self",
".",
"iSerialNumber",
")",
"return",
"self",
".",
"_serial_numbe... | Return the USB device's serial number string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use. | [
"Return",
"the",
"USB",
"device",
"s",
"serial",
"number",
"string",
"descriptor",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L813-L821 |
227,467 | pyusb/pyusb | usb/core.py | Device.product | def product(self):
""" Return the USB device's product string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use.
"""
if self._product is None:
self._product = util.get_string(self, self.iP... | python | def product(self):
""" Return the USB device's product string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use.
"""
if self._product is None:
self._product = util.get_string(self, self.iP... | [
"def",
"product",
"(",
"self",
")",
":",
"if",
"self",
".",
"_product",
"is",
"None",
":",
"self",
".",
"_product",
"=",
"util",
".",
"get_string",
"(",
"self",
",",
"self",
".",
"iProduct",
")",
"return",
"self",
".",
"_product"
] | Return the USB device's product string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use. | [
"Return",
"the",
"USB",
"device",
"s",
"product",
"string",
"descriptor",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L824-L832 |
227,468 | pyusb/pyusb | usb/core.py | Device.parent | def parent(self):
""" Return the parent device. """
if self._has_parent is None:
_parent = self._ctx.backend.get_parent(self._ctx.dev)
self._has_parent = _parent is not None
if self._has_parent:
self._parent = Device(_parent, self._ctx.backend)
... | python | def parent(self):
""" Return the parent device. """
if self._has_parent is None:
_parent = self._ctx.backend.get_parent(self._ctx.dev)
self._has_parent = _parent is not None
if self._has_parent:
self._parent = Device(_parent, self._ctx.backend)
... | [
"def",
"parent",
"(",
"self",
")",
":",
"if",
"self",
".",
"_has_parent",
"is",
"None",
":",
"_parent",
"=",
"self",
".",
"_ctx",
".",
"backend",
".",
"get_parent",
"(",
"self",
".",
"_ctx",
".",
"dev",
")",
"self",
".",
"_has_parent",
"=",
"_parent"... | Return the parent device. | [
"Return",
"the",
"parent",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L835-L844 |
227,469 | pyusb/pyusb | usb/core.py | Device.manufacturer | def manufacturer(self):
""" Return the USB device's manufacturer string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use.
"""
if self._manufacturer is None:
self._manufacturer = util.get_... | python | def manufacturer(self):
""" Return the USB device's manufacturer string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use.
"""
if self._manufacturer is None:
self._manufacturer = util.get_... | [
"def",
"manufacturer",
"(",
"self",
")",
":",
"if",
"self",
".",
"_manufacturer",
"is",
"None",
":",
"self",
".",
"_manufacturer",
"=",
"util",
".",
"get_string",
"(",
"self",
",",
"self",
".",
"iManufacturer",
")",
"return",
"self",
".",
"_manufacturer"
] | Return the USB device's manufacturer string descriptor.
This property will cause some USB traffic the first time it is accessed
and cache the resulting value for future use. | [
"Return",
"the",
"USB",
"device",
"s",
"manufacturer",
"string",
"descriptor",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L847-L855 |
227,470 | pyusb/pyusb | usb/core.py | Device.set_interface_altsetting | def set_interface_altsetting(self, interface = None, alternate_setting = None):
r"""Set the alternate setting for an interface.
When you want to use an interface and it has more than one alternate
setting, you should call this method to select the appropriate
alternate setting. If you c... | python | def set_interface_altsetting(self, interface = None, alternate_setting = None):
r"""Set the alternate setting for an interface.
When you want to use an interface and it has more than one alternate
setting, you should call this method to select the appropriate
alternate setting. If you c... | [
"def",
"set_interface_altsetting",
"(",
"self",
",",
"interface",
"=",
"None",
",",
"alternate_setting",
"=",
"None",
")",
":",
"self",
".",
"_ctx",
".",
"managed_set_interface",
"(",
"self",
",",
"interface",
",",
"alternate_setting",
")"
] | r"""Set the alternate setting for an interface.
When you want to use an interface and it has more than one alternate
setting, you should call this method to select the appropriate
alternate setting. If you call the method without one or the two
parameters, it will be selected the first ... | [
"r",
"Set",
"the",
"alternate",
"setting",
"for",
"an",
"interface",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L879-L904 |
227,471 | pyusb/pyusb | usb/core.py | Device.reset | def reset(self):
r"""Reset the device."""
self._ctx.managed_open()
self._ctx.dispose(self, False)
self._ctx.backend.reset_device(self._ctx.handle)
self._ctx.dispose(self, True) | python | def reset(self):
r"""Reset the device."""
self._ctx.managed_open()
self._ctx.dispose(self, False)
self._ctx.backend.reset_device(self._ctx.handle)
self._ctx.dispose(self, True) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_ctx",
".",
"managed_open",
"(",
")",
"self",
".",
"_ctx",
".",
"dispose",
"(",
"self",
",",
"False",
")",
"self",
".",
"_ctx",
".",
"backend",
".",
"reset_device",
"(",
"self",
".",
"_ctx",
".",... | r"""Reset the device. | [
"r",
"Reset",
"the",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L913-L918 |
227,472 | pyusb/pyusb | usb/core.py | Device.ctrl_transfer | def ctrl_transfer(self, bmRequestType, bRequest, wValue=0, wIndex=0,
data_or_wLength = None, timeout = None):
r"""Do a control transfer on the endpoint 0.
This method is used to issue a control transfer over the endpoint 0
(endpoint 0 is required to always be a control endpoint).
... | python | def ctrl_transfer(self, bmRequestType, bRequest, wValue=0, wIndex=0,
data_or_wLength = None, timeout = None):
r"""Do a control transfer on the endpoint 0.
This method is used to issue a control transfer over the endpoint 0
(endpoint 0 is required to always be a control endpoint).
... | [
"def",
"ctrl_transfer",
"(",
"self",
",",
"bmRequestType",
",",
"bRequest",
",",
"wValue",
"=",
"0",
",",
"wIndex",
"=",
"0",
",",
"data_or_wLength",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"buff",
"=",
"util",
".",
"create_buff... | r"""Do a control transfer on the endpoint 0.
This method is used to issue a control transfer over the endpoint 0
(endpoint 0 is required to always be a control endpoint).
The parameters bmRequestType, bRequest, wValue and wIndex are the same
of the USB Standard Control Request format.
... | [
"r",
"Do",
"a",
"control",
"transfer",
"on",
"the",
"endpoint",
"0",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L999-L1053 |
227,473 | pyusb/pyusb | usb/core.py | Device.is_kernel_driver_active | def is_kernel_driver_active(self, interface):
r"""Determine if there is kernel driver associated with the interface.
If a kernel driver is active, the object will be unable to perform
I/O.
The interface parameter is the device interface number to check.
"""
self._ctx.ma... | python | def is_kernel_driver_active(self, interface):
r"""Determine if there is kernel driver associated with the interface.
If a kernel driver is active, the object will be unable to perform
I/O.
The interface parameter is the device interface number to check.
"""
self._ctx.ma... | [
"def",
"is_kernel_driver_active",
"(",
"self",
",",
"interface",
")",
":",
"self",
".",
"_ctx",
".",
"managed_open",
"(",
")",
"return",
"self",
".",
"_ctx",
".",
"backend",
".",
"is_kernel_driver_active",
"(",
"self",
".",
"_ctx",
".",
"handle",
",",
"int... | r"""Determine if there is kernel driver associated with the interface.
If a kernel driver is active, the object will be unable to perform
I/O.
The interface parameter is the device interface number to check. | [
"r",
"Determine",
"if",
"there",
"is",
"kernel",
"driver",
"associated",
"with",
"the",
"interface",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1055-L1066 |
227,474 | pyusb/pyusb | usb/core.py | Device.detach_kernel_driver | def detach_kernel_driver(self, interface):
r"""Detach a kernel driver.
If successful, you will then be able to perform I/O.
The interface parameter is the device interface number to detach the
driver from.
"""
self._ctx.managed_open()
self._ctx.backend.detach_ke... | python | def detach_kernel_driver(self, interface):
r"""Detach a kernel driver.
If successful, you will then be able to perform I/O.
The interface parameter is the device interface number to detach the
driver from.
"""
self._ctx.managed_open()
self._ctx.backend.detach_ke... | [
"def",
"detach_kernel_driver",
"(",
"self",
",",
"interface",
")",
":",
"self",
".",
"_ctx",
".",
"managed_open",
"(",
")",
"self",
".",
"_ctx",
".",
"backend",
".",
"detach_kernel_driver",
"(",
"self",
".",
"_ctx",
".",
"handle",
",",
"interface",
")"
] | r"""Detach a kernel driver.
If successful, you will then be able to perform I/O.
The interface parameter is the device interface number to detach the
driver from. | [
"r",
"Detach",
"a",
"kernel",
"driver",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1068-L1079 |
227,475 | pyusb/pyusb | usb/libloader.py | load_library | def load_library(lib, name=None, lib_cls=None):
"""Loads a library. Catches and logs exceptions.
Returns: the loaded library or None
arguments:
* lib -- path to/name of the library to be loaded
* name -- the library's identifier (for logging)
Defaults to None.
... | python | def load_library(lib, name=None, lib_cls=None):
"""Loads a library. Catches and logs exceptions.
Returns: the loaded library or None
arguments:
* lib -- path to/name of the library to be loaded
* name -- the library's identifier (for logging)
Defaults to None.
... | [
"def",
"load_library",
"(",
"lib",
",",
"name",
"=",
"None",
",",
"lib_cls",
"=",
"None",
")",
":",
"try",
":",
"if",
"lib_cls",
":",
"return",
"lib_cls",
"(",
"lib",
")",
"else",
":",
"return",
"ctypes",
".",
"CDLL",
"(",
"lib",
")",
"except",
"Ex... | Loads a library. Catches and logs exceptions.
Returns: the loaded library or None
arguments:
* lib -- path to/name of the library to be loaded
* name -- the library's identifier (for logging)
Defaults to None.
* lib_cls -- library class. Defaults to None (-> cty... | [
"Loads",
"a",
"library",
".",
"Catches",
"and",
"logs",
"exceptions",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/libloader.py#L88-L115 |
227,476 | pyusb/pyusb | usb/libloader.py | load_locate_library | def load_locate_library(candidates, cygwin_lib, name,
win_cls=None, cygwin_cls=None, others_cls=None,
find_library=None, check_symbols=None):
"""Locates and loads a library.
Returns: the loaded library
arguments:
* candidates -- candidates list for lo... | python | def load_locate_library(candidates, cygwin_lib, name,
win_cls=None, cygwin_cls=None, others_cls=None,
find_library=None, check_symbols=None):
"""Locates and loads a library.
Returns: the loaded library
arguments:
* candidates -- candidates list for lo... | [
"def",
"load_locate_library",
"(",
"candidates",
",",
"cygwin_lib",
",",
"name",
",",
"win_cls",
"=",
"None",
",",
"cygwin_cls",
"=",
"None",
",",
"others_cls",
"=",
"None",
",",
"find_library",
"=",
"None",
",",
"check_symbols",
"=",
"None",
")",
":",
"if... | Locates and loads a library.
Returns: the loaded library
arguments:
* candidates -- candidates list for locate_library()
* cygwin_lib -- name of the cygwin library
* name -- lib identifier (for logging). Defaults to None.
* win_cls -- class that is used to instantiate the ... | [
"Locates",
"and",
"loads",
"a",
"library",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/libloader.py#L117-L177 |
227,477 | pyusb/pyusb | usb/control.py | get_status | def get_status(dev, recipient = None):
r"""Return the status for the specified recipient.
dev is the Device object to which the request will be
sent to.
The recipient can be None (on which the status will be queried
from the device), an Interface or Endpoint descriptors.
The status value is r... | python | def get_status(dev, recipient = None):
r"""Return the status for the specified recipient.
dev is the Device object to which the request will be
sent to.
The recipient can be None (on which the status will be queried
from the device), an Interface or Endpoint descriptors.
The status value is r... | [
"def",
"get_status",
"(",
"dev",
",",
"recipient",
"=",
"None",
")",
":",
"bmRequestType",
",",
"wIndex",
"=",
"_parse_recipient",
"(",
"recipient",
",",
"util",
".",
"CTRL_IN",
")",
"ret",
"=",
"dev",
".",
"ctrl_transfer",
"(",
"bmRequestType",
"=",
"bmRe... | r"""Return the status for the specified recipient.
dev is the Device object to which the request will be
sent to.
The recipient can be None (on which the status will be queried
from the device), an Interface or Endpoint descriptors.
The status value is returned as an integer with the lower
wo... | [
"r",
"Return",
"the",
"status",
"for",
"the",
"specified",
"recipient",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L79-L96 |
227,478 | pyusb/pyusb | usb/control.py | get_descriptor | def get_descriptor(dev, desc_size, desc_type, desc_index, wIndex = 0):
r"""Return the specified descriptor.
dev is the Device object to which the request will be
sent to.
desc_size is the descriptor size.
desc_type and desc_index are the descriptor type and index,
respectively. wIndex index i... | python | def get_descriptor(dev, desc_size, desc_type, desc_index, wIndex = 0):
r"""Return the specified descriptor.
dev is the Device object to which the request will be
sent to.
desc_size is the descriptor size.
desc_type and desc_index are the descriptor type and index,
respectively. wIndex index i... | [
"def",
"get_descriptor",
"(",
"dev",
",",
"desc_size",
",",
"desc_type",
",",
"desc_index",
",",
"wIndex",
"=",
"0",
")",
":",
"wValue",
"=",
"desc_index",
"|",
"(",
"desc_type",
"<<",
"8",
")",
"bmRequestType",
"=",
"util",
".",
"build_request_type",
"(",... | r"""Return the specified descriptor.
dev is the Device object to which the request will be
sent to.
desc_size is the descriptor size.
desc_type and desc_index are the descriptor type and index,
respectively. wIndex index is used for string descriptors
and represents the Language ID. For other... | [
"r",
"Return",
"the",
"specified",
"descriptor",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L135-L160 |
227,479 | pyusb/pyusb | usb/control.py | set_descriptor | def set_descriptor(dev, desc, desc_type, desc_index, wIndex = None):
r"""Update an existing descriptor or add a new one.
dev is the Device object to which the request will be
sent to.
The desc parameter is the descriptor to be sent to the device.
desc_type and desc_index are the descriptor type an... | python | def set_descriptor(dev, desc, desc_type, desc_index, wIndex = None):
r"""Update an existing descriptor or add a new one.
dev is the Device object to which the request will be
sent to.
The desc parameter is the descriptor to be sent to the device.
desc_type and desc_index are the descriptor type an... | [
"def",
"set_descriptor",
"(",
"dev",
",",
"desc",
",",
"desc_type",
",",
"desc_index",
",",
"wIndex",
"=",
"None",
")",
":",
"wValue",
"=",
"desc_index",
"|",
"(",
"desc_type",
"<<",
"8",
")",
"bmRequestType",
"=",
"util",
".",
"build_request_type",
"(",
... | r"""Update an existing descriptor or add a new one.
dev is the Device object to which the request will be
sent to.
The desc parameter is the descriptor to be sent to the device.
desc_type and desc_index are the descriptor type and index,
respectively. wIndex index is used for string descriptors
... | [
"r",
"Update",
"an",
"existing",
"descriptor",
"or",
"add",
"a",
"new",
"one",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L162-L186 |
227,480 | pyusb/pyusb | usb/control.py | get_configuration | def get_configuration(dev):
r"""Get the current active configuration of the device.
dev is the Device object to which the request will be
sent to.
This function differs from the Device.get_active_configuration
method because the later may use cached data, while this
function always does a devi... | python | def get_configuration(dev):
r"""Get the current active configuration of the device.
dev is the Device object to which the request will be
sent to.
This function differs from the Device.get_active_configuration
method because the later may use cached data, while this
function always does a devi... | [
"def",
"get_configuration",
"(",
"dev",
")",
":",
"bmRequestType",
"=",
"util",
".",
"build_request_type",
"(",
"util",
".",
"CTRL_IN",
",",
"util",
".",
"CTRL_TYPE_STANDARD",
",",
"util",
".",
"CTRL_RECIPIENT_DEVICE",
")",
"return",
"dev",
".",
"ctrl_transfer",... | r"""Get the current active configuration of the device.
dev is the Device object to which the request will be
sent to.
This function differs from the Device.get_active_configuration
method because the later may use cached data, while this
function always does a device request. | [
"r",
"Get",
"the",
"current",
"active",
"configuration",
"of",
"the",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L188-L206 |
227,481 | pyusb/pyusb | usb/control.py | get_interface | def get_interface(dev, bInterfaceNumber):
r"""Get the current alternate setting of the interface.
dev is the Device object to which the request will be
sent to.
"""
bmRequestType = util.build_request_type(
util.CTRL_IN,
util.CTRL_TYPE_STANDARD... | python | def get_interface(dev, bInterfaceNumber):
r"""Get the current alternate setting of the interface.
dev is the Device object to which the request will be
sent to.
"""
bmRequestType = util.build_request_type(
util.CTRL_IN,
util.CTRL_TYPE_STANDARD... | [
"def",
"get_interface",
"(",
"dev",
",",
"bInterfaceNumber",
")",
":",
"bmRequestType",
"=",
"util",
".",
"build_request_type",
"(",
"util",
".",
"CTRL_IN",
",",
"util",
".",
"CTRL_TYPE_STANDARD",
",",
"util",
".",
"CTRL_RECIPIENT_INTERFACE",
")",
"return",
"dev... | r"""Get the current alternate setting of the interface.
dev is the Device object to which the request will be
sent to. | [
"r",
"Get",
"the",
"current",
"alternate",
"setting",
"of",
"the",
"interface",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L216-L231 |
227,482 | pyusb/pyusb | tools/vcp_terminal.py | configInputQueue | def configInputQueue():
""" configure a queue for accepting characters and return the queue
"""
def captureInput(iqueue):
while True:
c = getch()
if c == '\x03' or c == '\x04': # end on ctrl+c / ctrl+d
log.debug("Break received (\\x{0:02X})".format(ord(c)))... | python | def configInputQueue():
""" configure a queue for accepting characters and return the queue
"""
def captureInput(iqueue):
while True:
c = getch()
if c == '\x03' or c == '\x04': # end on ctrl+c / ctrl+d
log.debug("Break received (\\x{0:02X})".format(ord(c)))... | [
"def",
"configInputQueue",
"(",
")",
":",
"def",
"captureInput",
"(",
"iqueue",
")",
":",
"while",
"True",
":",
"c",
"=",
"getch",
"(",
")",
"if",
"c",
"==",
"'\\x03'",
"or",
"c",
"==",
"'\\x04'",
":",
"# end on ctrl+c / ctrl+d",
"log",
".",
"debug",
"... | configure a queue for accepting characters and return the queue | [
"configure",
"a",
"queue",
"for",
"accepting",
"characters",
"and",
"return",
"the",
"queue"
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L518-L537 |
227,483 | pyusb/pyusb | tools/vcp_terminal.py | fmt_text | def fmt_text(text):
""" convert characters that aren't printable to hex format
"""
PRINTABLE_CHAR = set(
list(range(ord(' '), ord('~') + 1)) + [ord('\r'), ord('\n')])
newtext = ("\\x{:02X}".format(
c) if c not in PRINTABLE_CHAR else chr(c) for c in text)
textlines = "\r\n".join(l.str... | python | def fmt_text(text):
""" convert characters that aren't printable to hex format
"""
PRINTABLE_CHAR = set(
list(range(ord(' '), ord('~') + 1)) + [ord('\r'), ord('\n')])
newtext = ("\\x{:02X}".format(
c) if c not in PRINTABLE_CHAR else chr(c) for c in text)
textlines = "\r\n".join(l.str... | [
"def",
"fmt_text",
"(",
"text",
")",
":",
"PRINTABLE_CHAR",
"=",
"set",
"(",
"list",
"(",
"range",
"(",
"ord",
"(",
"' '",
")",
",",
"ord",
"(",
"'~'",
")",
"+",
"1",
")",
")",
"+",
"[",
"ord",
"(",
"'\\r'",
")",
",",
"ord",
"(",
"'\\n'",
")"... | convert characters that aren't printable to hex format | [
"convert",
"characters",
"that",
"aren",
"t",
"printable",
"to",
"hex",
"format"
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L540-L549 |
227,484 | pyusb/pyusb | tools/vcp_terminal.py | ftdi_to_clkbits | def ftdi_to_clkbits(baudrate): # from libftdi
"""
10,27 => divisor = 10000, rate = 300
88,13 => divisor = 5000, rate = 600
C4,09 => divisor = 2500, rate = 1200
E2,04 => divisor = 1250, rate = 2,400
71,02 => divisor = 625, rate = 4,800
38,41 => divisor = 312.5, rate = 9,600
D0,80 => divi... | python | def ftdi_to_clkbits(baudrate): # from libftdi
"""
10,27 => divisor = 10000, rate = 300
88,13 => divisor = 5000, rate = 600
C4,09 => divisor = 2500, rate = 1200
E2,04 => divisor = 1250, rate = 2,400
71,02 => divisor = 625, rate = 4,800
38,41 => divisor = 312.5, rate = 9,600
D0,80 => divi... | [
"def",
"ftdi_to_clkbits",
"(",
"baudrate",
")",
":",
"# from libftdi",
"clk",
"=",
"48000000",
"clk_div",
"=",
"16",
"frac_code",
"=",
"[",
"0",
",",
"3",
",",
"2",
",",
"4",
",",
"1",
",",
"5",
",",
"6",
",",
"7",
"]",
"actual_baud",
"=",
"0",
"... | 10,27 => divisor = 10000, rate = 300
88,13 => divisor = 5000, rate = 600
C4,09 => divisor = 2500, rate = 1200
E2,04 => divisor = 1250, rate = 2,400
71,02 => divisor = 625, rate = 4,800
38,41 => divisor = 312.5, rate = 9,600
D0,80 => divisor = 208.25, rate = 14406
9C,80 => divisor = 156, rate... | [
"10",
"27",
"=",
">",
"divisor",
"=",
"10000",
"rate",
"=",
"300",
"88",
"13",
"=",
">",
"divisor",
"=",
"5000",
"rate",
"=",
"600",
"C4",
"09",
"=",
">",
"divisor",
"=",
"2500",
"rate",
"=",
"1200",
"E2",
"04",
"=",
">",
"divisor",
"=",
"1250"... | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L576-L617 |
227,485 | pyusb/pyusb | tools/vcp_terminal.py | ComPort._read | def _read(self):
""" check ep for data, add it to queue and sleep for interval """
while self._rxactive:
try:
rv = self._ep_in.read(self._ep_in.wMaxPacketSize)
if self._isFTDI:
status = rv[:2] # FTDI prepends 2 flow control characters,
... | python | def _read(self):
""" check ep for data, add it to queue and sleep for interval """
while self._rxactive:
try:
rv = self._ep_in.read(self._ep_in.wMaxPacketSize)
if self._isFTDI:
status = rv[:2] # FTDI prepends 2 flow control characters,
... | [
"def",
"_read",
"(",
"self",
")",
":",
"while",
"self",
".",
"_rxactive",
":",
"try",
":",
"rv",
"=",
"self",
".",
"_ep_in",
".",
"read",
"(",
"self",
".",
"_ep_in",
".",
"wMaxPacketSize",
")",
"if",
"self",
".",
"_isFTDI",
":",
"status",
"=",
"rv"... | check ep for data, add it to queue and sleep for interval | [
"check",
"ep",
"for",
"data",
"add",
"it",
"to",
"queue",
"and",
"sleep",
"for",
"interval"
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L187-L206 |
227,486 | pyusb/pyusb | tools/vcp_terminal.py | ComPort._resetFTDI | def _resetFTDI(self):
""" reset the FTDI device
"""
if not self._isFTDI:
return
txdir = 0 # 0:OUT, 1:IN
req_type = 2 # 0:std, 1:class, 2:vendor
recipient = 0 # 0:device, 1:interface, 2:endpoint, 3:other
req_type = (txdir << 7) + ... | python | def _resetFTDI(self):
""" reset the FTDI device
"""
if not self._isFTDI:
return
txdir = 0 # 0:OUT, 1:IN
req_type = 2 # 0:std, 1:class, 2:vendor
recipient = 0 # 0:device, 1:interface, 2:endpoint, 3:other
req_type = (txdir << 7) + ... | [
"def",
"_resetFTDI",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_isFTDI",
":",
"return",
"txdir",
"=",
"0",
"# 0:OUT, 1:IN",
"req_type",
"=",
"2",
"# 0:std, 1:class, 2:vendor",
"recipient",
"=",
"0",
"# 0:device, 1:interface, 2:endpoint, 3:other",
"req_type",... | reset the FTDI device | [
"reset",
"the",
"FTDI",
"device"
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L359-L373 |
227,487 | pyusb/pyusb | usb/legacy.py | busses | def busses():
r"""Returns a tuple with the usb busses."""
return (Bus(g) for k, g in groupby(
sorted(core.find(find_all=True), key=lambda d: d.bus),
lambda d: d.bus)) | python | def busses():
r"""Returns a tuple with the usb busses."""
return (Bus(g) for k, g in groupby(
sorted(core.find(find_all=True), key=lambda d: d.bus),
lambda d: d.bus)) | [
"def",
"busses",
"(",
")",
":",
"return",
"(",
"Bus",
"(",
"g",
")",
"for",
"k",
",",
"g",
"in",
"groupby",
"(",
"sorted",
"(",
"core",
".",
"find",
"(",
"find_all",
"=",
"True",
")",
",",
"key",
"=",
"lambda",
"d",
":",
"d",
".",
"bus",
")",... | r"""Returns a tuple with the usb busses. | [
"r",
"Returns",
"a",
"tuple",
"with",
"the",
"usb",
"busses",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L337-L341 |
227,488 | pyusb/pyusb | usb/legacy.py | DeviceHandle.bulkWrite | def bulkWrite(self, endpoint, buffer, timeout = 100):
r"""Perform a bulk write request to the endpoint specified.
Arguments:
endpoint: endpoint number.
buffer: sequence data buffer to write.
This parameter can be any sequence type.
... | python | def bulkWrite(self, endpoint, buffer, timeout = 100):
r"""Perform a bulk write request to the endpoint specified.
Arguments:
endpoint: endpoint number.
buffer: sequence data buffer to write.
This parameter can be any sequence type.
... | [
"def",
"bulkWrite",
"(",
"self",
",",
"endpoint",
",",
"buffer",
",",
"timeout",
"=",
"100",
")",
":",
"return",
"self",
".",
"dev",
".",
"write",
"(",
"endpoint",
",",
"buffer",
",",
"timeout",
")"
] | r"""Perform a bulk write request to the endpoint specified.
Arguments:
endpoint: endpoint number.
buffer: sequence data buffer to write.
This parameter can be any sequence type.
timeout: operation timeout in milliseconds. (default: 100... | [
"r",
"Perform",
"a",
"bulk",
"write",
"request",
"to",
"the",
"endpoint",
"specified",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L131-L141 |
227,489 | pyusb/pyusb | usb/legacy.py | DeviceHandle.bulkRead | def bulkRead(self, endpoint, size, timeout = 100):
r"""Performs a bulk read request to the endpoint specified.
Arguments:
endpoint: endpoint number.
size: number of bytes to read.
timeout: operation timeout in milliseconds. (default: 100)
... | python | def bulkRead(self, endpoint, size, timeout = 100):
r"""Performs a bulk read request to the endpoint specified.
Arguments:
endpoint: endpoint number.
size: number of bytes to read.
timeout: operation timeout in milliseconds. (default: 100)
... | [
"def",
"bulkRead",
"(",
"self",
",",
"endpoint",
",",
"size",
",",
"timeout",
"=",
"100",
")",
":",
"return",
"self",
".",
"dev",
".",
"read",
"(",
"endpoint",
",",
"size",
",",
"timeout",
")"
] | r"""Performs a bulk read request to the endpoint specified.
Arguments:
endpoint: endpoint number.
size: number of bytes to read.
timeout: operation timeout in milliseconds. (default: 100)
Returns a tuple with the data read. | [
"r",
"Performs",
"a",
"bulk",
"read",
"request",
"to",
"the",
"endpoint",
"specified",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L143-L152 |
227,490 | pyusb/pyusb | usb/legacy.py | DeviceHandle.interruptWrite | def interruptWrite(self, endpoint, buffer, timeout = 100):
r"""Perform a interrupt write request to the endpoint specified.
Arguments:
endpoint: endpoint number.
buffer: sequence data buffer to write.
This parameter can be any sequence type.
... | python | def interruptWrite(self, endpoint, buffer, timeout = 100):
r"""Perform a interrupt write request to the endpoint specified.
Arguments:
endpoint: endpoint number.
buffer: sequence data buffer to write.
This parameter can be any sequence type.
... | [
"def",
"interruptWrite",
"(",
"self",
",",
"endpoint",
",",
"buffer",
",",
"timeout",
"=",
"100",
")",
":",
"return",
"self",
".",
"dev",
".",
"write",
"(",
"endpoint",
",",
"buffer",
",",
"timeout",
")"
] | r"""Perform a interrupt write request to the endpoint specified.
Arguments:
endpoint: endpoint number.
buffer: sequence data buffer to write.
This parameter can be any sequence type.
timeout: operation timeout in milliseconds. (default... | [
"r",
"Perform",
"a",
"interrupt",
"write",
"request",
"to",
"the",
"endpoint",
"specified",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L154-L164 |
227,491 | pyusb/pyusb | usb/legacy.py | DeviceHandle.interruptRead | def interruptRead(self, endpoint, size, timeout = 100):
r"""Performs a interrupt read request to the endpoint specified.
Arguments:
endpoint: endpoint number.
size: number of bytes to read.
timeout: operation timeout in milliseconds. (default: 100)
... | python | def interruptRead(self, endpoint, size, timeout = 100):
r"""Performs a interrupt read request to the endpoint specified.
Arguments:
endpoint: endpoint number.
size: number of bytes to read.
timeout: operation timeout in milliseconds. (default: 100)
... | [
"def",
"interruptRead",
"(",
"self",
",",
"endpoint",
",",
"size",
",",
"timeout",
"=",
"100",
")",
":",
"return",
"self",
".",
"dev",
".",
"read",
"(",
"endpoint",
",",
"size",
",",
"timeout",
")"
] | r"""Performs a interrupt read request to the endpoint specified.
Arguments:
endpoint: endpoint number.
size: number of bytes to read.
timeout: operation timeout in milliseconds. (default: 100)
Returns a tuple with the data read. | [
"r",
"Performs",
"a",
"interrupt",
"read",
"request",
"to",
"the",
"endpoint",
"specified",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L166-L175 |
227,492 | pyusb/pyusb | usb/legacy.py | DeviceHandle.controlMsg | def controlMsg(self, requestType, request, buffer, value = 0, index = 0, timeout = 100):
r"""Perform a control request to the default control pipe on a device.
Arguments:
requestType: specifies the direction of data flow, the type
of request, and the recipient.
... | python | def controlMsg(self, requestType, request, buffer, value = 0, index = 0, timeout = 100):
r"""Perform a control request to the default control pipe on a device.
Arguments:
requestType: specifies the direction of data flow, the type
of request, and the recipient.
... | [
"def",
"controlMsg",
"(",
"self",
",",
"requestType",
",",
"request",
",",
"buffer",
",",
"value",
"=",
"0",
",",
"index",
"=",
"0",
",",
"timeout",
"=",
"100",
")",
":",
"return",
"self",
".",
"dev",
".",
"ctrl_transfer",
"(",
"requestType",
",",
"r... | r"""Perform a control request to the default control pipe on a device.
Arguments:
requestType: specifies the direction of data flow, the type
of request, and the recipient.
request: specifies the request.
buffer: if the transfer is a write transfer, ... | [
"r",
"Perform",
"a",
"control",
"request",
"to",
"the",
"default",
"control",
"pipe",
"on",
"a",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L177-L198 |
227,493 | pyusb/pyusb | usb/legacy.py | DeviceHandle.claimInterface | def claimInterface(self, interface):
r"""Claims the interface with the Operating System.
Arguments:
interface: interface number or an Interface object.
"""
if isinstance(interface, Interface):
interface = interface.interfaceNumber
util.claim_interface(se... | python | def claimInterface(self, interface):
r"""Claims the interface with the Operating System.
Arguments:
interface: interface number or an Interface object.
"""
if isinstance(interface, Interface):
interface = interface.interfaceNumber
util.claim_interface(se... | [
"def",
"claimInterface",
"(",
"self",
",",
"interface",
")",
":",
"if",
"isinstance",
"(",
"interface",
",",
"Interface",
")",
":",
"interface",
"=",
"interface",
".",
"interfaceNumber",
"util",
".",
"claim_interface",
"(",
"self",
".",
"dev",
",",
"interfac... | r"""Claims the interface with the Operating System.
Arguments:
interface: interface number or an Interface object. | [
"r",
"Claims",
"the",
"interface",
"with",
"the",
"Operating",
"System",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L208-L218 |
227,494 | pyusb/pyusb | usb/legacy.py | DeviceHandle.releaseInterface | def releaseInterface(self):
r"""Release an interface previously claimed with claimInterface."""
util.release_interface(self.dev, self.__claimed_interface)
self.__claimed_interface = -1 | python | def releaseInterface(self):
r"""Release an interface previously claimed with claimInterface."""
util.release_interface(self.dev, self.__claimed_interface)
self.__claimed_interface = -1 | [
"def",
"releaseInterface",
"(",
"self",
")",
":",
"util",
".",
"release_interface",
"(",
"self",
".",
"dev",
",",
"self",
".",
"__claimed_interface",
")",
"self",
".",
"__claimed_interface",
"=",
"-",
"1"
] | r"""Release an interface previously claimed with claimInterface. | [
"r",
"Release",
"an",
"interface",
"previously",
"claimed",
"with",
"claimInterface",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L220-L223 |
227,495 | pyusb/pyusb | usb/legacy.py | DeviceHandle.setConfiguration | def setConfiguration(self, configuration):
r"""Set the active configuration of a device.
Arguments:
configuration: a configuration value or a Configuration object.
"""
if isinstance(configuration, Configuration):
configuration = configuration.value
self.d... | python | def setConfiguration(self, configuration):
r"""Set the active configuration of a device.
Arguments:
configuration: a configuration value or a Configuration object.
"""
if isinstance(configuration, Configuration):
configuration = configuration.value
self.d... | [
"def",
"setConfiguration",
"(",
"self",
",",
"configuration",
")",
":",
"if",
"isinstance",
"(",
"configuration",
",",
"Configuration",
")",
":",
"configuration",
"=",
"configuration",
".",
"value",
"self",
".",
"dev",
".",
"set_configuration",
"(",
"configurati... | r"""Set the active configuration of a device.
Arguments:
configuration: a configuration value or a Configuration object. | [
"r",
"Set",
"the",
"active",
"configuration",
"of",
"a",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L238-L247 |
227,496 | pyusb/pyusb | usb/legacy.py | DeviceHandle.setAltInterface | def setAltInterface(self, alternate):
r"""Sets the active alternate setting of the current interface.
Arguments:
alternate: an alternate setting number or an Interface object.
"""
if isinstance(alternate, Interface):
alternate = alternate.alternateSetting
... | python | def setAltInterface(self, alternate):
r"""Sets the active alternate setting of the current interface.
Arguments:
alternate: an alternate setting number or an Interface object.
"""
if isinstance(alternate, Interface):
alternate = alternate.alternateSetting
... | [
"def",
"setAltInterface",
"(",
"self",
",",
"alternate",
")",
":",
"if",
"isinstance",
"(",
"alternate",
",",
"Interface",
")",
":",
"alternate",
"=",
"alternate",
".",
"alternateSetting",
"self",
".",
"dev",
".",
"set_interface_altsetting",
"(",
"self",
".",
... | r"""Sets the active alternate setting of the current interface.
Arguments:
alternate: an alternate setting number or an Interface object. | [
"r",
"Sets",
"the",
"active",
"alternate",
"setting",
"of",
"the",
"current",
"interface",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L249-L258 |
227,497 | pyusb/pyusb | usb/legacy.py | DeviceHandle.getString | def getString(self, index, length, langid = None):
r"""Retrieve the string descriptor specified by index
and langid from a device.
Arguments:
index: index of descriptor in the device.
length: number of bytes of the string (ignored)
langid: Language ID. If... | python | def getString(self, index, length, langid = None):
r"""Retrieve the string descriptor specified by index
and langid from a device.
Arguments:
index: index of descriptor in the device.
length: number of bytes of the string (ignored)
langid: Language ID. If... | [
"def",
"getString",
"(",
"self",
",",
"index",
",",
"length",
",",
"langid",
"=",
"None",
")",
":",
"return",
"util",
".",
"get_string",
"(",
"self",
".",
"dev",
",",
"index",
",",
"langid",
")",
".",
"encode",
"(",
"'ascii'",
")"
] | r"""Retrieve the string descriptor specified by index
and langid from a device.
Arguments:
index: index of descriptor in the device.
length: number of bytes of the string (ignored)
langid: Language ID. If it is omitted, the first
language will... | [
"r",
"Retrieve",
"the",
"string",
"descriptor",
"specified",
"by",
"index",
"and",
"langid",
"from",
"a",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L260-L270 |
227,498 | pyusb/pyusb | usb/legacy.py | DeviceHandle.getDescriptor | def getDescriptor(self, desc_type, desc_index, length, endpoint = -1):
r"""Retrieves a descriptor from the device identified by the type
and index of the descriptor.
Arguments:
desc_type: descriptor type.
desc_index: index of the descriptor.
len: descriptor l... | python | def getDescriptor(self, desc_type, desc_index, length, endpoint = -1):
r"""Retrieves a descriptor from the device identified by the type
and index of the descriptor.
Arguments:
desc_type: descriptor type.
desc_index: index of the descriptor.
len: descriptor l... | [
"def",
"getDescriptor",
"(",
"self",
",",
"desc_type",
",",
"desc_index",
",",
"length",
",",
"endpoint",
"=",
"-",
"1",
")",
":",
"return",
"control",
".",
"get_descriptor",
"(",
"self",
".",
"dev",
",",
"length",
",",
"desc_type",
",",
"desc_index",
")... | r"""Retrieves a descriptor from the device identified by the type
and index of the descriptor.
Arguments:
desc_type: descriptor type.
desc_index: index of the descriptor.
len: descriptor length.
endpoint: ignored. | [
"r",
"Retrieves",
"a",
"descriptor",
"from",
"the",
"device",
"identified",
"by",
"the",
"type",
"and",
"index",
"of",
"the",
"descriptor",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L272-L282 |
227,499 | pyusb/pyusb | usb/backend/__init__.py | IBackend.get_endpoint_descriptor | def get_endpoint_descriptor(self, dev, ep, intf, alt, config):
r"""Return an endpoint descriptor of the given device.
The object returned is required to have all the Endpoint Descriptor
fields acessible as member variables. They must be convertible (but
not required to be equal) to the ... | python | def get_endpoint_descriptor(self, dev, ep, intf, alt, config):
r"""Return an endpoint descriptor of the given device.
The object returned is required to have all the Endpoint Descriptor
fields acessible as member variables. They must be convertible (but
not required to be equal) to the ... | [
"def",
"get_endpoint_descriptor",
"(",
"self",
",",
"dev",
",",
"ep",
",",
"intf",
",",
"alt",
",",
"config",
")",
":",
"_not_implemented",
"(",
"self",
".",
"get_endpoint_descriptor",
")"
] | r"""Return an endpoint descriptor of the given device.
The object returned is required to have all the Endpoint Descriptor
fields acessible as member variables. They must be convertible (but
not required to be equal) to the int type.
The ep parameter is the endpoint logical index (not ... | [
"r",
"Return",
"an",
"endpoint",
"descriptor",
"of",
"the",
"given",
"device",
"."
] | ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9 | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L140-L151 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.