repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pybluez/pybluez | bluetooth/btcommon.py | to_full_uuid | def to_full_uuid (uuid):
"""
converts a short 16-bit or 32-bit reserved UUID to a full 128-bit Bluetooth
UUID.
"""
if not is_valid_uuid (uuid): raise ValueError ("invalid UUID")
if len (uuid) == 4:
return "0000%s-0000-1000-8000-00805F9B34FB" % uuid
elif len (uuid) == 8:
retur... | python | def to_full_uuid (uuid):
"""
converts a short 16-bit or 32-bit reserved UUID to a full 128-bit Bluetooth
UUID.
"""
if not is_valid_uuid (uuid): raise ValueError ("invalid UUID")
if len (uuid) == 4:
return "0000%s-0000-1000-8000-00805F9B34FB" % uuid
elif len (uuid) == 8:
retur... | [
"def",
"to_full_uuid",
"(",
"uuid",
")",
":",
"if",
"not",
"is_valid_uuid",
"(",
"uuid",
")",
":",
"raise",
"ValueError",
"(",
"\"invalid UUID\"",
")",
"if",
"len",
"(",
"uuid",
")",
"==",
"4",
":",
"return",
"\"0000%s-0000-1000-8000-00805F9B34FB\"",
"%",
"u... | converts a short 16-bit or 32-bit reserved UUID to a full 128-bit Bluetooth
UUID. | [
"converts",
"a",
"short",
"16",
"-",
"bit",
"or",
"32",
"-",
"bit",
"reserved",
"UUID",
"to",
"a",
"full",
"128",
"-",
"bit",
"Bluetooth",
"UUID",
"."
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/bluetooth/btcommon.py#L234-L245 | train |
pybluez/pybluez | bluetooth/bluez.py | DeviceDiscoverer.cancel_inquiry | def cancel_inquiry (self):
"""
Call this method to cancel an inquiry in process. inquiry_complete
will still be called.
"""
self.names_to_find = {}
if self.is_inquiring:
try:
_bt.hci_send_cmd (self.sock, _bt.OGF_LINK_CTL, \
... | python | def cancel_inquiry (self):
"""
Call this method to cancel an inquiry in process. inquiry_complete
will still be called.
"""
self.names_to_find = {}
if self.is_inquiring:
try:
_bt.hci_send_cmd (self.sock, _bt.OGF_LINK_CTL, \
... | [
"def",
"cancel_inquiry",
"(",
"self",
")",
":",
"self",
".",
"names_to_find",
"=",
"{",
"}",
"if",
"self",
".",
"is_inquiring",
":",
"try",
":",
"_bt",
".",
"hci_send_cmd",
"(",
"self",
".",
"sock",
",",
"_bt",
".",
"OGF_LINK_CTL",
",",
"_bt",
".",
"... | Call this method to cancel an inquiry in process. inquiry_complete
will still be called. | [
"Call",
"this",
"method",
"to",
"cancel",
"an",
"inquiry",
"in",
"process",
".",
"inquiry_complete",
"will",
"still",
"be",
"called",
"."
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/bluetooth/bluez.py#L451-L468 | train |
pybluez/pybluez | bluetooth/bluez.py | DeviceDiscoverer.device_discovered | def device_discovered (self, address, device_class, rssi, name):
"""
Called when a bluetooth device is discovered.
address is the bluetooth address of the device
device_class is the Class of Device, as specified in [1]
passed in as a 3-byte string
name is ... | python | def device_discovered (self, address, device_class, rssi, name):
"""
Called when a bluetooth device is discovered.
address is the bluetooth address of the device
device_class is the Class of Device, as specified in [1]
passed in as a 3-byte string
name is ... | [
"def",
"device_discovered",
"(",
"self",
",",
"address",
",",
"device_class",
",",
"rssi",
",",
"name",
")",
":",
"if",
"name",
":",
"print",
"(",
"(",
"\"found: %s - %s (class 0x%X, rssi %s)\"",
"%",
"(",
"address",
",",
"name",
",",
"device_class",
",",
"r... | Called when a bluetooth device is discovered.
address is the bluetooth address of the device
device_class is the Class of Device, as specified in [1]
passed in as a 3-byte string
name is the user-friendly name of the device if lookup_names was
set when the inquiry... | [
"Called",
"when",
"a",
"bluetooth",
"device",
"is",
"discovered",
"."
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/bluetooth/bluez.py#L646-L668 | train |
pybluez/pybluez | examples/advanced/write-inquiry-scan.py | read_inquiry_scan_activity | def read_inquiry_scan_activity(sock):
"""returns the current inquiry scan interval and window,
or -1 on failure"""
# save current filter
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
# Setup socket filter to receive only events related to the
# read_inquiry_mode command
... | python | def read_inquiry_scan_activity(sock):
"""returns the current inquiry scan interval and window,
or -1 on failure"""
# save current filter
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
# Setup socket filter to receive only events related to the
# read_inquiry_mode command
... | [
"def",
"read_inquiry_scan_activity",
"(",
"sock",
")",
":",
"# save current filter",
"old_filter",
"=",
"sock",
".",
"getsockopt",
"(",
"bluez",
".",
"SOL_HCI",
",",
"bluez",
".",
"HCI_FILTER",
",",
"14",
")",
"# Setup socket filter to receive only events related to the... | returns the current inquiry scan interval and window,
or -1 on failure | [
"returns",
"the",
"current",
"inquiry",
"scan",
"interval",
"and",
"window",
"or",
"-",
"1",
"on",
"failure"
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/examples/advanced/write-inquiry-scan.py#L6-L36 | train |
pybluez/pybluez | examples/advanced/write-inquiry-scan.py | write_inquiry_scan_activity | def write_inquiry_scan_activity(sock, interval, window):
"""returns 0 on success, -1 on failure"""
# save current filter
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
# Setup socket filter to receive only events related to the
# write_inquiry_mode command
flt = bluez.hci_fi... | python | def write_inquiry_scan_activity(sock, interval, window):
"""returns 0 on success, -1 on failure"""
# save current filter
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
# Setup socket filter to receive only events related to the
# write_inquiry_mode command
flt = bluez.hci_fi... | [
"def",
"write_inquiry_scan_activity",
"(",
"sock",
",",
"interval",
",",
"window",
")",
":",
"# save current filter",
"old_filter",
"=",
"sock",
".",
"getsockopt",
"(",
"bluez",
".",
"SOL_HCI",
",",
"bluez",
".",
"HCI_FILTER",
",",
"14",
")",
"# Setup socket fil... | returns 0 on success, -1 on failure | [
"returns",
"0",
"on",
"success",
"-",
"1",
"on",
"failure"
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/examples/advanced/write-inquiry-scan.py#L38-L65 | train |
pybluez/pybluez | examples/advanced/inquiry-with-rssi.py | read_inquiry_mode | def read_inquiry_mode(sock):
"""returns the current mode, or -1 on failure"""
# save current filter
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
# Setup socket filter to receive only events related to the
# read_inquiry_mode command
flt = bluez.hci_filter_new()
opcode ... | python | def read_inquiry_mode(sock):
"""returns the current mode, or -1 on failure"""
# save current filter
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
# Setup socket filter to receive only events related to the
# read_inquiry_mode command
flt = bluez.hci_filter_new()
opcode ... | [
"def",
"read_inquiry_mode",
"(",
"sock",
")",
":",
"# save current filter",
"old_filter",
"=",
"sock",
".",
"getsockopt",
"(",
"bluez",
".",
"SOL_HCI",
",",
"bluez",
".",
"HCI_FILTER",
",",
"14",
")",
"# Setup socket filter to receive only events related to the",
"# r... | returns the current mode, or -1 on failure | [
"returns",
"the",
"current",
"mode",
"or",
"-",
"1",
"on",
"failure"
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/examples/advanced/inquiry-with-rssi.py#L16-L42 | train |
pybluez/pybluez | macos/_lightbluecommon.py | splitclass | def splitclass(classofdevice):
"""
Splits the given class of device to return a 3-item tuple with the
major service class, major device class and minor device class values.
These values indicate the device's major services and the type of the
device (e.g. mobile phone, laptop, etc.). If you google ... | python | def splitclass(classofdevice):
"""
Splits the given class of device to return a 3-item tuple with the
major service class, major device class and minor device class values.
These values indicate the device's major services and the type of the
device (e.g. mobile phone, laptop, etc.). If you google ... | [
"def",
"splitclass",
"(",
"classofdevice",
")",
":",
"if",
"not",
"isinstance",
"(",
"classofdevice",
",",
"int",
")",
":",
"try",
":",
"classofdevice",
"=",
"int",
"(",
"classofdevice",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"raise"... | Splits the given class of device to return a 3-item tuple with the
major service class, major device class and minor device class values.
These values indicate the device's major services and the type of the
device (e.g. mobile phone, laptop, etc.). If you google for
"assigned numbers bluetooth baseban... | [
"Splits",
"the",
"given",
"class",
"of",
"device",
"to",
"return",
"a",
"3",
"-",
"item",
"tuple",
"with",
"the",
"major",
"service",
"class",
"major",
"device",
"class",
"and",
"minor",
"device",
"class",
"values",
"."
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/macos/_lightbluecommon.py#L43-L69 | train |
pybluez/pybluez | macos/_lightblue.py | _searchservices | def _searchservices(device, name=None, uuid=None, uuidbad=None):
"""
Searches the given IOBluetoothDevice using the specified parameters.
Returns an empty list if the device has no services.
uuid should be IOBluetoothSDPUUID object.
"""
if not isinstance(device, _IOBluetooth.IOBluetoothDevice):... | python | def _searchservices(device, name=None, uuid=None, uuidbad=None):
"""
Searches the given IOBluetoothDevice using the specified parameters.
Returns an empty list if the device has no services.
uuid should be IOBluetoothSDPUUID object.
"""
if not isinstance(device, _IOBluetooth.IOBluetoothDevice):... | [
"def",
"_searchservices",
"(",
"device",
",",
"name",
"=",
"None",
",",
"uuid",
"=",
"None",
",",
"uuidbad",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"device",
",",
"_IOBluetooth",
".",
"IOBluetoothDevice",
")",
":",
"raise",
"ValueError",
... | Searches the given IOBluetoothDevice using the specified parameters.
Returns an empty list if the device has no services.
uuid should be IOBluetoothSDPUUID object. | [
"Searches",
"the",
"given",
"IOBluetoothDevice",
"using",
"the",
"specified",
"parameters",
".",
"Returns",
"an",
"empty",
"list",
"if",
"the",
"device",
"has",
"no",
"services",
"."
] | e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9 | https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/macos/_lightblue.py#L485-L515 | train |
bambinos/bambi | bambi/backends/pymc.py | PyMC3BackEnd.reset | def reset(self):
'''
Reset PyMC3 model and all tracked distributions and parameters.
'''
self.model = pm.Model()
self.mu = None
self.par_groups = {} | python | def reset(self):
'''
Reset PyMC3 model and all tracked distributions and parameters.
'''
self.model = pm.Model()
self.mu = None
self.par_groups = {} | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"model",
"=",
"pm",
".",
"Model",
"(",
")",
"self",
".",
"mu",
"=",
"None",
"self",
".",
"par_groups",
"=",
"{",
"}"
] | Reset PyMC3 model and all tracked distributions and parameters. | [
"Reset",
"PyMC3",
"model",
"and",
"all",
"tracked",
"distributions",
"and",
"parameters",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/backends/pymc.py#L37-L43 | train |
bambinos/bambi | bambi/backends/pymc.py | PyMC3BackEnd._build_dist | def _build_dist(self, spec, label, dist, **kwargs):
''' Build and return a PyMC3 Distribution. '''
if isinstance(dist, string_types):
if hasattr(pm, dist):
dist = getattr(pm, dist)
elif dist in self.dists:
dist = self.dists[dist]
else:
... | python | def _build_dist(self, spec, label, dist, **kwargs):
''' Build and return a PyMC3 Distribution. '''
if isinstance(dist, string_types):
if hasattr(pm, dist):
dist = getattr(pm, dist)
elif dist in self.dists:
dist = self.dists[dist]
else:
... | [
"def",
"_build_dist",
"(",
"self",
",",
"spec",
",",
"label",
",",
"dist",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"dist",
",",
"string_types",
")",
":",
"if",
"hasattr",
"(",
"pm",
",",
"dist",
")",
":",
"dist",
"=",
"getattr",... | Build and return a PyMC3 Distribution. | [
"Build",
"and",
"return",
"a",
"PyMC3",
"Distribution",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/backends/pymc.py#L45-L73 | train |
bambinos/bambi | bambi/results.py | MCMCResults.to_df | def to_df(self, varnames=None, ranefs=False, transformed=False,
chains=None):
'''
Returns the MCMC samples in a nice, neat pandas DataFrame with all MCMC chains
concatenated.
Args:
varnames (list): List of variable names to include; if None
(def... | python | def to_df(self, varnames=None, ranefs=False, transformed=False,
chains=None):
'''
Returns the MCMC samples in a nice, neat pandas DataFrame with all MCMC chains
concatenated.
Args:
varnames (list): List of variable names to include; if None
(def... | [
"def",
"to_df",
"(",
"self",
",",
"varnames",
"=",
"None",
",",
"ranefs",
"=",
"False",
",",
"transformed",
"=",
"False",
",",
"chains",
"=",
"None",
")",
":",
"# filter out unwanted variables",
"names",
"=",
"self",
".",
"_filter_names",
"(",
"varnames",
... | Returns the MCMC samples in a nice, neat pandas DataFrame with all MCMC chains
concatenated.
Args:
varnames (list): List of variable names to include; if None
(default), all eligible variables are included.
ranefs (bool): Whether or not to include random effects ... | [
"Returns",
"the",
"MCMC",
"samples",
"in",
"a",
"nice",
"neat",
"pandas",
"DataFrame",
"with",
"all",
"MCMC",
"chains",
"concatenated",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/results.py#L369-L402 | train |
bambinos/bambi | bambi/diagnostics.py | autocov | def autocov(x):
"""Compute autocovariance estimates for every lag for the input array.
Args:
x (array-like): An array containing MCMC samples.
Returns:
np.ndarray: An array of the same size as the input array.
"""
acorr = autocorr(x)
varx = np.var(x, ddof=1) * (len(x) - 1) / l... | python | def autocov(x):
"""Compute autocovariance estimates for every lag for the input array.
Args:
x (array-like): An array containing MCMC samples.
Returns:
np.ndarray: An array of the same size as the input array.
"""
acorr = autocorr(x)
varx = np.var(x, ddof=1) * (len(x) - 1) / l... | [
"def",
"autocov",
"(",
"x",
")",
":",
"acorr",
"=",
"autocorr",
"(",
"x",
")",
"varx",
"=",
"np",
".",
"var",
"(",
"x",
",",
"ddof",
"=",
"1",
")",
"*",
"(",
"len",
"(",
"x",
")",
"-",
"1",
")",
"/",
"len",
"(",
"x",
")",
"acov",
"=",
"... | Compute autocovariance estimates for every lag for the input array.
Args:
x (array-like): An array containing MCMC samples.
Returns:
np.ndarray: An array of the same size as the input array. | [
"Compute",
"autocovariance",
"estimates",
"for",
"every",
"lag",
"for",
"the",
"input",
"array",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/diagnostics.py#L30-L43 | train |
bambinos/bambi | bambi/models.py | Model.reset | def reset(self):
'''
Reset list of terms and y-variable.
'''
self.terms = OrderedDict()
self.y = None
self.backend = None
self.added_terms = []
self._added_priors = {}
self.completes = []
self.clean_data = None | python | def reset(self):
'''
Reset list of terms and y-variable.
'''
self.terms = OrderedDict()
self.y = None
self.backend = None
self.added_terms = []
self._added_priors = {}
self.completes = []
self.clean_data = None | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"terms",
"=",
"OrderedDict",
"(",
")",
"self",
".",
"y",
"=",
"None",
"self",
".",
"backend",
"=",
"None",
"self",
".",
"added_terms",
"=",
"[",
"]",
"self",
".",
"_added_priors",
"=",
"{",
"}",
... | Reset list of terms and y-variable. | [
"Reset",
"list",
"of",
"terms",
"and",
"y",
"-",
"variable",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L83-L93 | train |
bambinos/bambi | bambi/models.py | Model.fit | def fit(self, fixed=None, random=None, priors=None, family='gaussian',
link=None, run=True, categorical=None, backend=None, **kwargs):
'''Fit the model using the specified BackEnd.
Args:
fixed (str): Optional formula specification of fixed effects.
random (list): Opt... | python | def fit(self, fixed=None, random=None, priors=None, family='gaussian',
link=None, run=True, categorical=None, backend=None, **kwargs):
'''Fit the model using the specified BackEnd.
Args:
fixed (str): Optional formula specification of fixed effects.
random (list): Opt... | [
"def",
"fit",
"(",
"self",
",",
"fixed",
"=",
"None",
",",
"random",
"=",
"None",
",",
"priors",
"=",
"None",
",",
"family",
"=",
"'gaussian'",
",",
"link",
"=",
"None",
",",
"run",
"=",
"True",
",",
"categorical",
"=",
"None",
",",
"backend",
"=",... | Fit the model using the specified BackEnd.
Args:
fixed (str): Optional formula specification of fixed effects.
random (list): Optional list-based specification of random effects.
priors (dict): Optional specification of priors for one or more
terms. A dict wh... | [
"Fit",
"the",
"model",
"using",
"the",
"specified",
"BackEnd",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L236-L286 | train |
bambinos/bambi | bambi/models.py | Model.add | def add(self, fixed=None, random=None, priors=None, family='gaussian',
link=None, categorical=None, append=True):
'''Adds one or more terms to the model via an R-like formula syntax.
Args:
fixed (str): Optional formula specification of fixed effects.
random (list): O... | python | def add(self, fixed=None, random=None, priors=None, family='gaussian',
link=None, categorical=None, append=True):
'''Adds one or more terms to the model via an R-like formula syntax.
Args:
fixed (str): Optional formula specification of fixed effects.
random (list): O... | [
"def",
"add",
"(",
"self",
",",
"fixed",
"=",
"None",
",",
"random",
"=",
"None",
",",
"priors",
"=",
"None",
",",
"family",
"=",
"'gaussian'",
",",
"link",
"=",
"None",
",",
"categorical",
"=",
"None",
",",
"append",
"=",
"True",
")",
":",
"data",... | Adds one or more terms to the model via an R-like formula syntax.
Args:
fixed (str): Optional formula specification of fixed effects.
random (list): Optional list-based specification of random effects.
priors (dict): Optional specification of priors for one or more
... | [
"Adds",
"one",
"or",
"more",
"terms",
"to",
"the",
"model",
"via",
"an",
"R",
"-",
"like",
"formula",
"syntax",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L288-L372 | train |
bambinos/bambi | bambi/models.py | Model.set_priors | def set_priors(self, priors=None, fixed=None, random=None,
match_derived_names=True):
'''Set priors for one or more existing terms.
Args:
priors (dict): Dict of priors to update. Keys are names of terms
to update; values are the new priors (either a Prior ... | python | def set_priors(self, priors=None, fixed=None, random=None,
match_derived_names=True):
'''Set priors for one or more existing terms.
Args:
priors (dict): Dict of priors to update. Keys are names of terms
to update; values are the new priors (either a Prior ... | [
"def",
"set_priors",
"(",
"self",
",",
"priors",
"=",
"None",
",",
"fixed",
"=",
"None",
",",
"random",
"=",
"None",
",",
"match_derived_names",
"=",
"True",
")",
":",
"# save arguments to pass to _set_priors() at build time",
"kwargs",
"=",
"dict",
"(",
"zip",
... | Set priors for one or more existing terms.
Args:
priors (dict): Dict of priors to update. Keys are names of terms
to update; values are the new priors (either a Prior instance,
or an int or float that scales the default priors). Note that
a tuple can ... | [
"Set",
"priors",
"for",
"one",
"or",
"more",
"existing",
"terms",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L576-L605 | train |
bambinos/bambi | bambi/models.py | Model.fixed_terms | def fixed_terms(self):
'''Return dict of all and only fixed effects in model.'''
return {k: v for (k, v) in self.terms.items() if not v.random} | python | def fixed_terms(self):
'''Return dict of all and only fixed effects in model.'''
return {k: v for (k, v) in self.terms.items() if not v.random} | [
"def",
"fixed_terms",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"(",
"k",
",",
"v",
")",
"in",
"self",
".",
"terms",
".",
"items",
"(",
")",
"if",
"not",
"v",
".",
"random",
"}"
] | Return dict of all and only fixed effects in model. | [
"Return",
"dict",
"of",
"all",
"and",
"only",
"fixed",
"effects",
"in",
"model",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L722-L724 | train |
bambinos/bambi | bambi/models.py | Model.random_terms | def random_terms(self):
'''Return dict of all and only random effects in model.'''
return {k: v for (k, v) in self.terms.items() if v.random} | python | def random_terms(self):
'''Return dict of all and only random effects in model.'''
return {k: v for (k, v) in self.terms.items() if v.random} | [
"def",
"random_terms",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"(",
"k",
",",
"v",
")",
"in",
"self",
".",
"terms",
".",
"items",
"(",
")",
"if",
"v",
".",
"random",
"}"
] | Return dict of all and only random effects in model. | [
"Return",
"dict",
"of",
"all",
"and",
"only",
"random",
"effects",
"in",
"model",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L727-L729 | train |
bambinos/bambi | bambi/priors.py | Prior.update | def update(self, **kwargs):
'''Update the model arguments with additional arguments.
Args:
kwargs (dict): Optional keyword arguments to add to prior args.
'''
# Backends expect numpy arrays, so make sure all numeric values are
# represented as such.
kwargs =... | python | def update(self, **kwargs):
'''Update the model arguments with additional arguments.
Args:
kwargs (dict): Optional keyword arguments to add to prior args.
'''
# Backends expect numpy arrays, so make sure all numeric values are
# represented as such.
kwargs =... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Backends expect numpy arrays, so make sure all numeric values are",
"# represented as such.",
"kwargs",
"=",
"{",
"k",
":",
"(",
"np",
".",
"array",
"(",
"v",
")",
"if",
"isinstance",
"(",
"v",
... | Update the model arguments with additional arguments.
Args:
kwargs (dict): Optional keyword arguments to add to prior args. | [
"Update",
"the",
"model",
"arguments",
"with",
"additional",
"arguments",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/priors.py#L59-L70 | train |
bambinos/bambi | bambi/priors.py | PriorFactory.get | def get(self, dist=None, term=None, family=None):
'''Retrieve default prior for a named distribution, term type, or family.
Args:
dist (str): Name of desired distribution. Note that the name is
the key in the defaults dictionary, not the name of the
Distribut... | python | def get(self, dist=None, term=None, family=None):
'''Retrieve default prior for a named distribution, term type, or family.
Args:
dist (str): Name of desired distribution. Note that the name is
the key in the defaults dictionary, not the name of the
Distribut... | [
"def",
"get",
"(",
"self",
",",
"dist",
"=",
"None",
",",
"term",
"=",
"None",
",",
"family",
"=",
"None",
")",
":",
"if",
"dist",
"is",
"not",
"None",
":",
"if",
"dist",
"not",
"in",
"self",
".",
"dists",
":",
"raise",
"ValueError",
"(",
"\"'%s'... | Retrieve default prior for a named distribution, term type, or family.
Args:
dist (str): Name of desired distribution. Note that the name is
the key in the defaults dictionary, not the name of the
Distribution object used to construct the prior.
term (str... | [
"Retrieve",
"default",
"prior",
"for",
"a",
"named",
"distribution",
"term",
"type",
"or",
"family",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/priors.py#L153-L181 | train |
bambinos/bambi | bambi/backends/stan.py | StanBackEnd.reset | def reset(self):
'''
Reset Stan model and all tracked distributions and parameters.
'''
self.parameters = []
self.transformed_parameters = []
self.expressions = []
self.data = []
self.transformed_data = []
self.X = {}
self.model = []
... | python | def reset(self):
'''
Reset Stan model and all tracked distributions and parameters.
'''
self.parameters = []
self.transformed_parameters = []
self.expressions = []
self.data = []
self.transformed_data = []
self.X = {}
self.model = []
... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"parameters",
"=",
"[",
"]",
"self",
".",
"transformed_parameters",
"=",
"[",
"]",
"self",
".",
"expressions",
"=",
"[",
"]",
"self",
".",
"data",
"=",
"[",
"]",
"self",
".",
"transformed_data",
"="... | Reset Stan model and all tracked distributions and parameters. | [
"Reset",
"Stan",
"model",
"and",
"all",
"tracked",
"distributions",
"and",
"parameters",
"."
] | b4a0ced917968bb99ca20915317417d708387946 | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/backends/stan.py#L63-L80 | train |
nfcpy/nfcpy | src/nfc/clf/rcs956.py | Chipset.reset_mode | def reset_mode(self):
"""Send a Reset command to set the operation mode to 0."""
self.command(0x18, b"\x01", timeout=0.1)
self.transport.write(Chipset.ACK)
time.sleep(0.010) | python | def reset_mode(self):
"""Send a Reset command to set the operation mode to 0."""
self.command(0x18, b"\x01", timeout=0.1)
self.transport.write(Chipset.ACK)
time.sleep(0.010) | [
"def",
"reset_mode",
"(",
"self",
")",
":",
"self",
".",
"command",
"(",
"0x18",
",",
"b\"\\x01\"",
",",
"timeout",
"=",
"0.1",
")",
"self",
".",
"transport",
".",
"write",
"(",
"Chipset",
".",
"ACK",
")",
"time",
".",
"sleep",
"(",
"0.010",
")"
] | Send a Reset command to set the operation mode to 0. | [
"Send",
"a",
"Reset",
"command",
"to",
"set",
"the",
"operation",
"mode",
"to",
"0",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs956.py#L149-L153 | train |
nfcpy/nfcpy | src/nfc/clf/rcs956.py | Device.sense_ttb | def sense_ttb(self, target):
"""Activate the RF field and probe for a Type B Target.
The RC-S956 can discover Type B Targets (Type 4B Tag) at 106
kbps. For a Type 4B Tag the firmware automatically sends an
ATTRIB command that configures the use of DID and 64 byte
maximum frame s... | python | def sense_ttb(self, target):
"""Activate the RF field and probe for a Type B Target.
The RC-S956 can discover Type B Targets (Type 4B Tag) at 106
kbps. For a Type 4B Tag the firmware automatically sends an
ATTRIB command that configures the use of DID and 64 byte
maximum frame s... | [
"def",
"sense_ttb",
"(",
"self",
",",
"target",
")",
":",
"return",
"super",
"(",
"Device",
",",
"self",
")",
".",
"sense_ttb",
"(",
"target",
",",
"did",
"=",
"b'\\x01'",
")"
] | Activate the RF field and probe for a Type B Target.
The RC-S956 can discover Type B Targets (Type 4B Tag) at 106
kbps. For a Type 4B Tag the firmware automatically sends an
ATTRIB command that configures the use of DID and 64 byte
maximum frame size. The driver reverts this configurati... | [
"Activate",
"the",
"RF",
"field",
"and",
"probe",
"for",
"a",
"Type",
"B",
"Target",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs956.py#L231-L242 | train |
nfcpy/nfcpy | src/nfc/clf/rcs956.py | Device.sense_dep | def sense_dep(self, target):
"""Search for a DEP Target in active or passive communication mode.
"""
# Set timeout for PSL_RES and ATR_RES
self.chipset.rf_configuration(0x02, b"\x0B\x0B\x0A")
return super(Device, self).sense_dep(target) | python | def sense_dep(self, target):
"""Search for a DEP Target in active or passive communication mode.
"""
# Set timeout for PSL_RES and ATR_RES
self.chipset.rf_configuration(0x02, b"\x0B\x0B\x0A")
return super(Device, self).sense_dep(target) | [
"def",
"sense_dep",
"(",
"self",
",",
"target",
")",
":",
"# Set timeout for PSL_RES and ATR_RES",
"self",
".",
"chipset",
".",
"rf_configuration",
"(",
"0x02",
",",
"b\"\\x0B\\x0B\\x0A\"",
")",
"return",
"super",
"(",
"Device",
",",
"self",
")",
".",
"sense_dep... | Search for a DEP Target in active or passive communication mode. | [
"Search",
"for",
"a",
"DEP",
"Target",
"in",
"active",
"or",
"passive",
"communication",
"mode",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs956.py#L250-L256 | train |
nfcpy/nfcpy | src/nfc/handover/client.py | HandoverClient.send | def send(self, message):
"""Send a handover request message to the remote server."""
log.debug("sending '{0}' message".format(message.type))
send_miu = self.socket.getsockopt(nfc.llcp.SO_SNDMIU)
try:
data = str(message)
except nfc.llcp.EncodeError as e:
lo... | python | def send(self, message):
"""Send a handover request message to the remote server."""
log.debug("sending '{0}' message".format(message.type))
send_miu = self.socket.getsockopt(nfc.llcp.SO_SNDMIU)
try:
data = str(message)
except nfc.llcp.EncodeError as e:
lo... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"log",
".",
"debug",
"(",
"\"sending '{0}' message\"",
".",
"format",
"(",
"message",
".",
"type",
")",
")",
"send_miu",
"=",
"self",
".",
"socket",
".",
"getsockopt",
"(",
"nfc",
".",
"llcp",
".",
... | Send a handover request message to the remote server. | [
"Send",
"a",
"handover",
"request",
"message",
"to",
"the",
"remote",
"server",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/handover/client.py#L59-L68 | train |
nfcpy/nfcpy | src/nfc/handover/client.py | HandoverClient.recv | def recv(self, timeout=None):
"""Receive a handover select message from the remote server."""
message = self._recv(timeout)
if message and message.type == "urn:nfc:wkt:Hs":
log.debug("received '{0}' message".format(message.type))
return nfc.ndef.HandoverSelectMessage(mess... | python | def recv(self, timeout=None):
"""Receive a handover select message from the remote server."""
message = self._recv(timeout)
if message and message.type == "urn:nfc:wkt:Hs":
log.debug("received '{0}' message".format(message.type))
return nfc.ndef.HandoverSelectMessage(mess... | [
"def",
"recv",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"message",
"=",
"self",
".",
"_recv",
"(",
"timeout",
")",
"if",
"message",
"and",
"message",
".",
"type",
"==",
"\"urn:nfc:wkt:Hs\"",
":",
"log",
".",
"debug",
"(",
"\"received '{0}' mes... | Receive a handover select message from the remote server. | [
"Receive",
"a",
"handover",
"select",
"message",
"from",
"the",
"remote",
"server",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/handover/client.py#L78-L86 | train |
nfcpy/nfcpy | src/nfc/clf/pn531.py | Device.sense_ttb | def sense_ttb(self, target):
"""Sense for a Type B Target is not supported."""
info = "{device} does not support sense for Type B Target"
raise nfc.clf.UnsupportedTargetError(info.format(device=self)) | python | def sense_ttb(self, target):
"""Sense for a Type B Target is not supported."""
info = "{device} does not support sense for Type B Target"
raise nfc.clf.UnsupportedTargetError(info.format(device=self)) | [
"def",
"sense_ttb",
"(",
"self",
",",
"target",
")",
":",
"info",
"=",
"\"{device} does not support sense for Type B Target\"",
"raise",
"nfc",
".",
"clf",
".",
"UnsupportedTargetError",
"(",
"info",
".",
"format",
"(",
"device",
"=",
"self",
")",
")"
] | Sense for a Type B Target is not supported. | [
"Sense",
"for",
"a",
"Type",
"B",
"Target",
"is",
"not",
"supported",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/pn531.py#L231-L234 | train |
nfcpy/nfcpy | src/nfc/clf/pn531.py | Device.sense_dep | def sense_dep(self, target):
"""Search for a DEP Target in active communication mode.
Because the PN531 does not implement the extended frame syntax
for host controller communication, it can not support the
maximum payload size of 254 byte. The driver handles this by
modifying t... | python | def sense_dep(self, target):
"""Search for a DEP Target in active communication mode.
Because the PN531 does not implement the extended frame syntax
for host controller communication, it can not support the
maximum payload size of 254 byte. The driver handles this by
modifying t... | [
"def",
"sense_dep",
"(",
"self",
",",
"target",
")",
":",
"if",
"target",
".",
"atr_req",
"[",
"15",
"]",
"&",
"0x30",
"==",
"0x30",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"must reduce the max payload size in atr_req\"",
")",
"target",
".",
"atr_r... | Search for a DEP Target in active communication mode.
Because the PN531 does not implement the extended frame syntax
for host controller communication, it can not support the
maximum payload size of 254 byte. The driver handles this by
modifying the length-reduction values in atr_req an... | [
"Search",
"for",
"a",
"DEP",
"Target",
"in",
"active",
"communication",
"mode",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/pn531.py#L242-L263 | train |
nfcpy/nfcpy | src/nfc/tag/tt2_nxp.py | NTAG203.protect | def protect(self, password=None, read_protect=False, protect_from=0):
"""Set lock bits to disable future memory modifications.
If *password* is None, all memory pages except the 16-bit
counter in page 41 are protected by setting the relevant lock
bits (note that lock bits can not be res... | python | def protect(self, password=None, read_protect=False, protect_from=0):
"""Set lock bits to disable future memory modifications.
If *password* is None, all memory pages except the 16-bit
counter in page 41 are protected by setting the relevant lock
bits (note that lock bits can not be res... | [
"def",
"protect",
"(",
"self",
",",
"password",
"=",
"None",
",",
"read_protect",
"=",
"False",
",",
"protect_from",
"=",
"0",
")",
":",
"return",
"super",
"(",
"NTAG203",
",",
"self",
")",
".",
"protect",
"(",
"password",
",",
"read_protect",
",",
"pr... | Set lock bits to disable future memory modifications.
If *password* is None, all memory pages except the 16-bit
counter in page 41 are protected by setting the relevant lock
bits (note that lock bits can not be reset). If valid NDEF
management data is found in page 4, protect() also set... | [
"Set",
"lock",
"bits",
"to",
"disable",
"future",
"memory",
"modifications",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2_nxp.py#L268-L283 | train |
nfcpy/nfcpy | src/nfc/tag/tt2_nxp.py | NTAG21x.signature | def signature(self):
"""The 32-byte ECC tag signature programmed at chip production. The
signature is provided as a string and can only be read.
The signature attribute is always loaded from the tag when it
is accessed, i.e. it is not cached. If communication with the
tag fails ... | python | def signature(self):
"""The 32-byte ECC tag signature programmed at chip production. The
signature is provided as a string and can only be read.
The signature attribute is always loaded from the tag when it
is accessed, i.e. it is not cached. If communication with the
tag fails ... | [
"def",
"signature",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"read tag signature\"",
")",
"try",
":",
"return",
"bytes",
"(",
"self",
".",
"transceive",
"(",
"b\"\\x3C\\x00\"",
")",
")",
"except",
"tt2",
".",
"Type2TagCommandError",
":",
"return",
... | The 32-byte ECC tag signature programmed at chip production. The
signature is provided as a string and can only be read.
The signature attribute is always loaded from the tag when it
is accessed, i.e. it is not cached. If communication with the
tag fails for some reason the signature at... | [
"The",
"32",
"-",
"byte",
"ECC",
"tag",
"signature",
"programmed",
"at",
"chip",
"production",
".",
"The",
"signature",
"is",
"provided",
"as",
"a",
"string",
"and",
"can",
"only",
"be",
"read",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2_nxp.py#L330-L344 | train |
nfcpy/nfcpy | src/nfc/tag/tt2_nxp.py | NTAG21x.protect | def protect(self, password=None, read_protect=False, protect_from=0):
"""Set password protection or permanent lock bits.
If the *password* argument is None, all memory pages will be
protected by setting the relevant lock bits (note that lock
bits can not be reset). If valid NDEF managem... | python | def protect(self, password=None, read_protect=False, protect_from=0):
"""Set password protection or permanent lock bits.
If the *password* argument is None, all memory pages will be
protected by setting the relevant lock bits (note that lock
bits can not be reset). If valid NDEF managem... | [
"def",
"protect",
"(",
"self",
",",
"password",
"=",
"None",
",",
"read_protect",
"=",
"False",
",",
"protect_from",
"=",
"0",
")",
":",
"args",
"=",
"(",
"password",
",",
"read_protect",
",",
"protect_from",
")",
"return",
"super",
"(",
"NTAG21x",
",",
... | Set password protection or permanent lock bits.
If the *password* argument is None, all memory pages will be
protected by setting the relevant lock bits (note that lock
bits can not be reset). If valid NDEF management data is
found, protect() also sets the NDEF write flag to read-only.
... | [
"Set",
"password",
"protection",
"or",
"permanent",
"lock",
"bits",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2_nxp.py#L346-L374 | train |
nfcpy/nfcpy | src/nfc/clf/device.py | Device.mute | def mute(self):
"""Mutes all existing communication, most notably the device will no
longer generate a 13.56 MHz carrier signal when operating as
Initiator.
"""
fname = "mute"
cname = self.__class__.__module__ + '.' + self.__class__.__name__
raise NotImplementedE... | python | def mute(self):
"""Mutes all existing communication, most notably the device will no
longer generate a 13.56 MHz carrier signal when operating as
Initiator.
"""
fname = "mute"
cname = self.__class__.__module__ + '.' + self.__class__.__name__
raise NotImplementedE... | [
"def",
"mute",
"(",
"self",
")",
":",
"fname",
"=",
"\"mute\"",
"cname",
"=",
"self",
".",
"__class__",
".",
"__module__",
"+",
"'.'",
"+",
"self",
".",
"__class__",
".",
"__name__",
"raise",
"NotImplementedError",
"(",
"\"%s.%s() is required\"",
"%",
"(",
... | Mutes all existing communication, most notably the device will no
longer generate a 13.56 MHz carrier signal when operating as
Initiator. | [
"Mutes",
"all",
"existing",
"communication",
"most",
"notably",
"the",
"device",
"will",
"no",
"longer",
"generate",
"a",
"13",
".",
"56",
"MHz",
"carrier",
"signal",
"when",
"operating",
"as",
"Initiator",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/device.py#L174-L182 | train |
nfcpy/nfcpy | src/nfc/clf/device.py | Device.listen_tta | def listen_tta(self, target, timeout):
"""Listen as Type A Target.
Waits to receive a SENS_REQ command at the bitrate set by
**target.brty** and sends the **target.sens_res**
response. Depending on the SENS_RES bytes, the Initiator then
sends an RID_CMD (SENS_RES coded for a Typ... | python | def listen_tta(self, target, timeout):
"""Listen as Type A Target.
Waits to receive a SENS_REQ command at the bitrate set by
**target.brty** and sends the **target.sens_res**
response. Depending on the SENS_RES bytes, the Initiator then
sends an RID_CMD (SENS_RES coded for a Typ... | [
"def",
"listen_tta",
"(",
"self",
",",
"target",
",",
"timeout",
")",
":",
"fname",
"=",
"\"listen_tta\"",
"cname",
"=",
"self",
".",
"__class__",
".",
"__module__",
"+",
"'.'",
"+",
"self",
".",
"__class__",
".",
"__name__",
"raise",
"NotImplementedError",
... | Listen as Type A Target.
Waits to receive a SENS_REQ command at the bitrate set by
**target.brty** and sends the **target.sens_res**
response. Depending on the SENS_RES bytes, the Initiator then
sends an RID_CMD (SENS_RES coded for a Type 1 Tag) or SDD_REQ
and SEL_REQ (SENS_RES ... | [
"Listen",
"as",
"Type",
"A",
"Target",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/device.py#L324-L369 | train |
nfcpy/nfcpy | src/nfc/clf/device.py | Device.send_cmd_recv_rsp | def send_cmd_recv_rsp(self, target, data, timeout):
"""Exchange data with a remote Target
Sends command *data* to the remote *target* discovered in the
most recent call to one of the sense_xxx() methods. Note that
*target* becomes invalid with any call to mute(), sense_xxx()
or ... | python | def send_cmd_recv_rsp(self, target, data, timeout):
"""Exchange data with a remote Target
Sends command *data* to the remote *target* discovered in the
most recent call to one of the sense_xxx() methods. Note that
*target* becomes invalid with any call to mute(), sense_xxx()
or ... | [
"def",
"send_cmd_recv_rsp",
"(",
"self",
",",
"target",
",",
"data",
",",
"timeout",
")",
":",
"fname",
"=",
"\"send_cmd_recv_rsp\"",
"cname",
"=",
"self",
".",
"__class__",
".",
"__module__",
"+",
"'.'",
"+",
"self",
".",
"__class__",
".",
"__name__",
"ra... | Exchange data with a remote Target
Sends command *data* to the remote *target* discovered in the
most recent call to one of the sense_xxx() methods. Note that
*target* becomes invalid with any call to mute(), sense_xxx()
or listen_xxx()
Arguments:
target (nfc.clf.Rem... | [
"Exchange",
"data",
"with",
"a",
"remote",
"Target"
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/device.py#L496-L526 | train |
nfcpy/nfcpy | src/nfc/clf/device.py | Device.get_max_recv_data_size | def get_max_recv_data_size(self, target):
"""Returns the maximum number of data bytes for receiving.
The maximum number of data bytes acceptable for receiving with
either :meth:`send_cmd_recv_rsp` or :meth:`send_rsp_recv_cmd`.
The value reflects the local device capabilities for receivi... | python | def get_max_recv_data_size(self, target):
"""Returns the maximum number of data bytes for receiving.
The maximum number of data bytes acceptable for receiving with
either :meth:`send_cmd_recv_rsp` or :meth:`send_rsp_recv_cmd`.
The value reflects the local device capabilities for receivi... | [
"def",
"get_max_recv_data_size",
"(",
"self",
",",
"target",
")",
":",
"fname",
"=",
"\"get_max_recv_data_size\"",
"cname",
"=",
"self",
".",
"__class__",
".",
"__module__",
"+",
"'.'",
"+",
"self",
".",
"__class__",
".",
"__name__",
"raise",
"NotImplementedErro... | Returns the maximum number of data bytes for receiving.
The maximum number of data bytes acceptable for receiving with
either :meth:`send_cmd_recv_rsp` or :meth:`send_rsp_recv_cmd`.
The value reflects the local device capabilities for receiving
in the mode determined by *target*. It doe... | [
"Returns",
"the",
"maximum",
"number",
"of",
"data",
"bytes",
"for",
"receiving",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/device.py#L583-L604 | train |
nfcpy/nfcpy | src/nfc/tag/tt2.py | Type2Tag.format | def format(self, version=None, wipe=None):
"""Erase the NDEF message on a Type 2 Tag.
The :meth:`format` method will reset the length of the NDEF
message on a type 2 tag to zero, thus the tag will appear to
be empty. Additionally, if the *wipe* argument is set to some
integer th... | python | def format(self, version=None, wipe=None):
"""Erase the NDEF message on a Type 2 Tag.
The :meth:`format` method will reset the length of the NDEF
message on a type 2 tag to zero, thus the tag will appear to
be empty. Additionally, if the *wipe* argument is set to some
integer th... | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"None",
",",
"wipe",
"=",
"None",
")",
":",
"return",
"super",
"(",
"Type2Tag",
",",
"self",
")",
".",
"format",
"(",
"version",
",",
"wipe",
")"
] | Erase the NDEF message on a Type 2 Tag.
The :meth:`format` method will reset the length of the NDEF
message on a type 2 tag to zero, thus the tag will appear to
be empty. Additionally, if the *wipe* argument is set to some
integer then :meth:`format` will overwrite all user date that
... | [
"Erase",
"the",
"NDEF",
"message",
"on",
"a",
"Type",
"2",
"Tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L346-L368 | train |
nfcpy/nfcpy | src/nfc/tag/tt2.py | Type2Tag.protect | def protect(self, password=None, read_protect=False, protect_from=0):
"""Protect the tag against write access, i.e. make it read-only.
:meth:`Type2Tag.protect` switches an NFC Forum Type 2 Tag to
read-only state by setting all lock bits to 1. This operation
can not be reversed. If the t... | python | def protect(self, password=None, read_protect=False, protect_from=0):
"""Protect the tag against write access, i.e. make it read-only.
:meth:`Type2Tag.protect` switches an NFC Forum Type 2 Tag to
read-only state by setting all lock bits to 1. This operation
can not be reversed. If the t... | [
"def",
"protect",
"(",
"self",
",",
"password",
"=",
"None",
",",
"read_protect",
"=",
"False",
",",
"protect_from",
"=",
"0",
")",
":",
"return",
"super",
"(",
"Type2Tag",
",",
"self",
")",
".",
"protect",
"(",
"password",
",",
"read_protect",
",",
"p... | Protect the tag against write access, i.e. make it read-only.
:meth:`Type2Tag.protect` switches an NFC Forum Type 2 Tag to
read-only state by setting all lock bits to 1. This operation
can not be reversed. If the tag is not an NFC Forum Tag,
i.e. it is not formatted with an NDEF Capabil... | [
"Protect",
"the",
"tag",
"against",
"write",
"access",
"i",
".",
"e",
".",
"make",
"it",
"read",
"-",
"only",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L385-L402 | train |
nfcpy/nfcpy | src/nfc/tag/tt2.py | Type2Tag.read | def read(self, page):
"""Send a READ command to retrieve data from the tag.
The *page* argument specifies the offset in multiples of 4
bytes (i.e. page number 1 will return bytes 4 to 19). The data
returned is a byte array of length 16 or None if the block is
outside the readabl... | python | def read(self, page):
"""Send a READ command to retrieve data from the tag.
The *page* argument specifies the offset in multiples of 4
bytes (i.e. page number 1 will return bytes 4 to 19). The data
returned is a byte array of length 16 or None if the block is
outside the readabl... | [
"def",
"read",
"(",
"self",
",",
"page",
")",
":",
"log",
".",
"debug",
"(",
"\"read pages {0} to {1}\"",
".",
"format",
"(",
"page",
",",
"page",
"+",
"3",
")",
")",
"data",
"=",
"self",
".",
"transceive",
"(",
"\"\\x30\"",
"+",
"chr",
"(",
"page",
... | Send a READ command to retrieve data from the tag.
The *page* argument specifies the offset in multiples of 4
bytes (i.e. page number 1 will return bytes 4 to 19). The data
returned is a byte array of length 16 or None if the block is
outside the readable memory range.
Command ... | [
"Send",
"a",
"READ",
"command",
"to",
"retrieve",
"data",
"from",
"the",
"tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L468-L494 | train |
nfcpy/nfcpy | src/nfc/tag/tt2.py | Type2Tag.write | def write(self, page, data):
"""Send a WRITE command to store data on the tag.
The *page* argument specifies the offset in multiples of 4
bytes. The *data* argument must be a string or bytearray of
length 4.
Command execution errors raise :exc:`Type2TagCommandError`.
"... | python | def write(self, page, data):
"""Send a WRITE command to store data on the tag.
The *page* argument specifies the offset in multiples of 4
bytes. The *data* argument must be a string or bytearray of
length 4.
Command execution errors raise :exc:`Type2TagCommandError`.
"... | [
"def",
"write",
"(",
"self",
",",
"page",
",",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"!=",
"4",
":",
"raise",
"ValueError",
"(",
"\"data must be a four byte string or array\"",
")",
"log",
".",
"debug",
"(",
"\"write {0} to page {1}\"",
".",
"form... | Send a WRITE command to store data on the tag.
The *page* argument specifies the offset in multiples of 4
bytes. The *data* argument must be a string or bytearray of
length 4.
Command execution errors raise :exc:`Type2TagCommandError`. | [
"Send",
"a",
"WRITE",
"command",
"to",
"store",
"data",
"on",
"the",
"tag",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L496-L520 | train |
nfcpy/nfcpy | src/nfc/tag/tt2.py | Type2Tag.sector_select | def sector_select(self, sector):
"""Send a SECTOR_SELECT command to switch the 1K address sector.
The command is only send to the tag if the *sector* number is
different from the currently selected sector number (set to 0
when the tag instance is created). If the command was
suc... | python | def sector_select(self, sector):
"""Send a SECTOR_SELECT command to switch the 1K address sector.
The command is only send to the tag if the *sector* number is
different from the currently selected sector number (set to 0
when the tag instance is created). If the command was
suc... | [
"def",
"sector_select",
"(",
"self",
",",
"sector",
")",
":",
"if",
"sector",
"!=",
"self",
".",
"_current_sector",
":",
"log",
".",
"debug",
"(",
"\"select sector {0} (pages {1} to {2})\"",
".",
"format",
"(",
"sector",
",",
"sector",
"<<",
"10",
",",
"(",
... | Send a SECTOR_SELECT command to switch the 1K address sector.
The command is only send to the tag if the *sector* number is
different from the currently selected sector number (set to 0
when the tag instance is created). If the command was
successful, the currently selected sector numbe... | [
"Send",
"a",
"SECTOR_SELECT",
"command",
"to",
"switch",
"the",
"1K",
"address",
"sector",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L522-L559 | train |
nfcpy/nfcpy | src/nfc/tag/tt2.py | Type2Tag.transceive | def transceive(self, data, timeout=0.1, retries=2):
"""Send a Type 2 Tag command and receive the response.
:meth:`transceive` is a type 2 tag specific wrapper around the
:meth:`nfc.ContactlessFrontend.exchange` method. It can be
used to send custom commands as a sequence of *data* bytes... | python | def transceive(self, data, timeout=0.1, retries=2):
"""Send a Type 2 Tag command and receive the response.
:meth:`transceive` is a type 2 tag specific wrapper around the
:meth:`nfc.ContactlessFrontend.exchange` method. It can be
used to send custom commands as a sequence of *data* bytes... | [
"def",
"transceive",
"(",
"self",
",",
"data",
",",
"timeout",
"=",
"0.1",
",",
"retries",
"=",
"2",
")",
":",
"log",
".",
"debug",
"(",
"\">> {0} ({1:f}s)\"",
".",
"format",
"(",
"hexlify",
"(",
"data",
")",
",",
"timeout",
")",
")",
"if",
"not",
... | Send a Type 2 Tag command and receive the response.
:meth:`transceive` is a type 2 tag specific wrapper around the
:meth:`nfc.ContactlessFrontend.exchange` method. It can be
used to send custom commands as a sequence of *data* bytes to
the tag and receive the response data bytes. If *ti... | [
"Send",
"a",
"Type",
"2",
"Tag",
"command",
"and",
"receive",
"the",
"response",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt2.py#L561-L603 | train |
nfcpy/nfcpy | src/nfc/llcp/socket.py | Socket.setsockopt | def setsockopt(self, option, value):
"""Set the value of the given socket option and return the
current value which may have been corrected if it was out of
bounds."""
return self.llc.setsockopt(self._tco, option, value) | python | def setsockopt(self, option, value):
"""Set the value of the given socket option and return the
current value which may have been corrected if it was out of
bounds."""
return self.llc.setsockopt(self._tco, option, value) | [
"def",
"setsockopt",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"return",
"self",
".",
"llc",
".",
"setsockopt",
"(",
"self",
".",
"_tco",
",",
"option",
",",
"value",
")"
] | Set the value of the given socket option and return the
current value which may have been corrected if it was out of
bounds. | [
"Set",
"the",
"value",
"of",
"the",
"given",
"socket",
"option",
"and",
"return",
"the",
"current",
"value",
"which",
"may",
"have",
"been",
"corrected",
"if",
"it",
"was",
"out",
"of",
"bounds",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/llcp/socket.py#L64-L68 | train |
nfcpy/nfcpy | src/nfc/llcp/socket.py | Socket.accept | def accept(self):
"""Accept a connection. The socket must be bound to an address
and listening for connections. The return value is a new
socket object usable to send and receive data on the
connection."""
socket = Socket(self._llc, None)
socket._tco = self.llc.accept(sel... | python | def accept(self):
"""Accept a connection. The socket must be bound to an address
and listening for connections. The return value is a new
socket object usable to send and receive data on the
connection."""
socket = Socket(self._llc, None)
socket._tco = self.llc.accept(sel... | [
"def",
"accept",
"(",
"self",
")",
":",
"socket",
"=",
"Socket",
"(",
"self",
".",
"_llc",
",",
"None",
")",
"socket",
".",
"_tco",
"=",
"self",
".",
"llc",
".",
"accept",
"(",
"self",
".",
"_tco",
")",
"return",
"socket"
] | Accept a connection. The socket must be bound to an address
and listening for connections. The return value is a new
socket object usable to send and receive data on the
connection. | [
"Accept",
"a",
"connection",
".",
"The",
"socket",
"must",
"be",
"bound",
"to",
"an",
"address",
"and",
"listening",
"for",
"connections",
".",
"The",
"return",
"value",
"is",
"a",
"new",
"socket",
"object",
"usable",
"to",
"send",
"and",
"receive",
"data"... | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/llcp/socket.py#L102-L109 | train |
nfcpy/nfcpy | src/nfc/llcp/socket.py | Socket.send | def send(self, data, flags=0):
"""Send data to the socket. The socket must be connected to a remote
socket. Returns a boolean value that indicates success or
failure. A false value is typically an indication that the
socket or connection was closed.
"""
return self.llc.s... | python | def send(self, data, flags=0):
"""Send data to the socket. The socket must be connected to a remote
socket. Returns a boolean value that indicates success or
failure. A false value is typically an indication that the
socket or connection was closed.
"""
return self.llc.s... | [
"def",
"send",
"(",
"self",
",",
"data",
",",
"flags",
"=",
"0",
")",
":",
"return",
"self",
".",
"llc",
".",
"send",
"(",
"self",
".",
"_tco",
",",
"data",
",",
"flags",
")"
] | Send data to the socket. The socket must be connected to a remote
socket. Returns a boolean value that indicates success or
failure. A false value is typically an indication that the
socket or connection was closed. | [
"Send",
"data",
"to",
"the",
"socket",
".",
"The",
"socket",
"must",
"be",
"connected",
"to",
"a",
"remote",
"socket",
".",
"Returns",
"a",
"boolean",
"value",
"that",
"indicates",
"success",
"or",
"failure",
".",
"A",
"false",
"value",
"is",
"typically",
... | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/llcp/socket.py#L111-L118 | train |
nfcpy/nfcpy | src/nfc/llcp/socket.py | Socket.sendto | def sendto(self, data, addr, flags=0):
"""Send data to the socket. The socket should not be connected
to a remote socket, since the destination socket is specified
by addr. Returns a boolean value that indicates success
or failure. Failure to send is generally an indication that
... | python | def sendto(self, data, addr, flags=0):
"""Send data to the socket. The socket should not be connected
to a remote socket, since the destination socket is specified
by addr. Returns a boolean value that indicates success
or failure. Failure to send is generally an indication that
... | [
"def",
"sendto",
"(",
"self",
",",
"data",
",",
"addr",
",",
"flags",
"=",
"0",
")",
":",
"return",
"self",
".",
"llc",
".",
"sendto",
"(",
"self",
".",
"_tco",
",",
"data",
",",
"addr",
",",
"flags",
")"
] | Send data to the socket. The socket should not be connected
to a remote socket, since the destination socket is specified
by addr. Returns a boolean value that indicates success
or failure. Failure to send is generally an indication that
the socket was closed. | [
"Send",
"data",
"to",
"the",
"socket",
".",
"The",
"socket",
"should",
"not",
"be",
"connected",
"to",
"a",
"remote",
"socket",
"since",
"the",
"destination",
"socket",
"is",
"specified",
"by",
"addr",
".",
"Returns",
"a",
"boolean",
"value",
"that",
"indi... | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/llcp/socket.py#L120-L126 | train |
nfcpy/nfcpy | src/nfc/ndef/bt_record.py | BluetoothConfigRecord.simple_pairing_hash | def simple_pairing_hash(self):
"""Simple Pairing Hash C. Received and transmitted as EIR type
0x0E. Set to None if not received or not to be transmitted.
Raises nfc.ndef.DecodeError if the received value or
nfc.ndef.EncodeError if the assigned value is not a sequence
of 16 octets... | python | def simple_pairing_hash(self):
"""Simple Pairing Hash C. Received and transmitted as EIR type
0x0E. Set to None if not received or not to be transmitted.
Raises nfc.ndef.DecodeError if the received value or
nfc.ndef.EncodeError if the assigned value is not a sequence
of 16 octets... | [
"def",
"simple_pairing_hash",
"(",
"self",
")",
":",
"try",
":",
"if",
"len",
"(",
"self",
".",
"eir",
"[",
"0x0E",
"]",
")",
"!=",
"16",
":",
"raise",
"DecodeError",
"(",
"\"wrong length of simple pairing hash\"",
")",
"return",
"bytearray",
"(",
"self",
... | Simple Pairing Hash C. Received and transmitted as EIR type
0x0E. Set to None if not received or not to be transmitted.
Raises nfc.ndef.DecodeError if the received value or
nfc.ndef.EncodeError if the assigned value is not a sequence
of 16 octets. | [
"Simple",
"Pairing",
"Hash",
"C",
".",
"Received",
"and",
"transmitted",
"as",
"EIR",
"type",
"0x0E",
".",
"Set",
"to",
"None",
"if",
"not",
"received",
"or",
"not",
"to",
"be",
"transmitted",
".",
"Raises",
"nfc",
".",
"ndef",
".",
"DecodeError",
"if",
... | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/bt_record.py#L101-L112 | train |
nfcpy/nfcpy | src/nfc/ndef/bt_record.py | BluetoothConfigRecord.simple_pairing_rand | def simple_pairing_rand(self):
"""Simple Pairing Randomizer R. Received and transmitted as
EIR type 0x0F. Set to None if not received or not to be
transmitted. Raises nfc.ndef.DecodeError if the received value
or nfc.ndef.EncodeError if the assigned value is not a
sequence of 16 ... | python | def simple_pairing_rand(self):
"""Simple Pairing Randomizer R. Received and transmitted as
EIR type 0x0F. Set to None if not received or not to be
transmitted. Raises nfc.ndef.DecodeError if the received value
or nfc.ndef.EncodeError if the assigned value is not a
sequence of 16 ... | [
"def",
"simple_pairing_rand",
"(",
"self",
")",
":",
"try",
":",
"if",
"len",
"(",
"self",
".",
"eir",
"[",
"0x0F",
"]",
")",
"!=",
"16",
":",
"raise",
"DecodeError",
"(",
"\"wrong length of simple pairing hash\"",
")",
"return",
"bytearray",
"(",
"self",
... | Simple Pairing Randomizer R. Received and transmitted as
EIR type 0x0F. Set to None if not received or not to be
transmitted. Raises nfc.ndef.DecodeError if the received value
or nfc.ndef.EncodeError if the assigned value is not a
sequence of 16 octets. | [
"Simple",
"Pairing",
"Randomizer",
"R",
".",
"Received",
"and",
"transmitted",
"as",
"EIR",
"type",
"0x0F",
".",
"Set",
"to",
"None",
"if",
"not",
"received",
"or",
"not",
"to",
"be",
"transmitted",
".",
"Raises",
"nfc",
".",
"ndef",
".",
"DecodeError",
... | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/bt_record.py#L124-L135 | train |
nfcpy/nfcpy | src/nfc/ndef/handover.py | HandoverRequestMessage.add_carrier | def add_carrier(self, carrier_record, power_state, aux_data_records=None):
"""Add a new carrier to the handover request message.
:param carrier_record: a record providing carrier information
:param power_state: a string describing the carrier power state
:param aux_data_records: list of... | python | def add_carrier(self, carrier_record, power_state, aux_data_records=None):
"""Add a new carrier to the handover request message.
:param carrier_record: a record providing carrier information
:param power_state: a string describing the carrier power state
:param aux_data_records: list of... | [
"def",
"add_carrier",
"(",
"self",
",",
"carrier_record",
",",
"power_state",
",",
"aux_data_records",
"=",
"None",
")",
":",
"carrier",
"=",
"Carrier",
"(",
"carrier_record",
",",
"power_state",
")",
"if",
"aux_data_records",
"is",
"not",
"None",
":",
"for",
... | Add a new carrier to the handover request message.
:param carrier_record: a record providing carrier information
:param power_state: a string describing the carrier power state
:param aux_data_records: list of auxiliary data records
:type carrier_record: :class:`nfc.ndef.Record`
... | [
"Add",
"a",
"new",
"carrier",
"to",
"the",
"handover",
"request",
"message",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/handover.py#L172-L189 | train |
nfcpy/nfcpy | src/nfc/ndef/handover.py | HandoverSelectMessage.pretty | def pretty(self, indent=0):
"""Returns a string with a formatted representation that might
be considered pretty-printable."""
indent = indent * ' '
lines = list()
version_string = "{v.major}.{v.minor}".format(v=self.version)
lines.append(("handover version", version_strin... | python | def pretty(self, indent=0):
"""Returns a string with a formatted representation that might
be considered pretty-printable."""
indent = indent * ' '
lines = list()
version_string = "{v.major}.{v.minor}".format(v=self.version)
lines.append(("handover version", version_strin... | [
"def",
"pretty",
"(",
"self",
",",
"indent",
"=",
"0",
")",
":",
"indent",
"=",
"indent",
"*",
"' '",
"lines",
"=",
"list",
"(",
")",
"version_string",
"=",
"\"{v.major}.{v.minor}\"",
".",
"format",
"(",
"v",
"=",
"self",
".",
"version",
")",
"lines",
... | Returns a string with a formatted representation that might
be considered pretty-printable. | [
"Returns",
"a",
"string",
"with",
"a",
"formatted",
"representation",
"that",
"might",
"be",
"considered",
"pretty",
"-",
"printable",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/handover.py#L431-L468 | train |
nfcpy/nfcpy | src/nfc/dep.py | Target.activate | def activate(self, timeout=None, **options):
"""Activate DEP communication as a target."""
if timeout is None:
timeout = 1.0
gbt = options.get('gbt', '')[0:47]
lrt = min(max(0, options.get('lrt', 3)), 3)
rwt = min(max(0, options.get('rwt', 8)), 14)
pp = (lrt... | python | def activate(self, timeout=None, **options):
"""Activate DEP communication as a target."""
if timeout is None:
timeout = 1.0
gbt = options.get('gbt', '')[0:47]
lrt = min(max(0, options.get('lrt', 3)), 3)
rwt = min(max(0, options.get('rwt', 8)), 14)
pp = (lrt... | [
"def",
"activate",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"1.0",
"gbt",
"=",
"options",
".",
"get",
"(",
"'gbt'",
",",
"''",
")",
"[",
"0",
":",
"47",
"]... | Activate DEP communication as a target. | [
"Activate",
"DEP",
"communication",
"as",
"a",
"target",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/dep.py#L417-L460 | train |
nfcpy/nfcpy | src/nfc/ndef/message.py | Message.pretty | def pretty(self):
"""Returns a message representation that might be considered
pretty-printable."""
lines = list()
for index, record in enumerate(self._records):
lines.append(("record {0}".format(index+1),))
lines.append((" type", repr(record.type)))
... | python | def pretty(self):
"""Returns a message representation that might be considered
pretty-printable."""
lines = list()
for index, record in enumerate(self._records):
lines.append(("record {0}".format(index+1),))
lines.append((" type", repr(record.type)))
... | [
"def",
"pretty",
"(",
"self",
")",
":",
"lines",
"=",
"list",
"(",
")",
"for",
"index",
",",
"record",
"in",
"enumerate",
"(",
"self",
".",
"_records",
")",
":",
"lines",
".",
"append",
"(",
"(",
"\"record {0}\"",
".",
"format",
"(",
"index",
"+",
... | Returns a message representation that might be considered
pretty-printable. | [
"Returns",
"a",
"message",
"representation",
"that",
"might",
"be",
"considered",
"pretty",
"-",
"printable",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/ndef/message.py#L161-L173 | train |
nfcpy/nfcpy | src/nfc/tag/tt1_broadcom.py | Topaz.format | def format(self, version=None, wipe=None):
"""Format a Topaz tag for NDEF use.
The implementation of :meth:`nfc.tag.Tag.format` for a Topaz
tag creates a capability container and an NDEF TLV with length
zero. Data bytes of the NDEF data area are left untouched
unless the wipe ar... | python | def format(self, version=None, wipe=None):
"""Format a Topaz tag for NDEF use.
The implementation of :meth:`nfc.tag.Tag.format` for a Topaz
tag creates a capability container and an NDEF TLV with length
zero. Data bytes of the NDEF data area are left untouched
unless the wipe ar... | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"None",
",",
"wipe",
"=",
"None",
")",
":",
"return",
"super",
"(",
"Topaz",
",",
"self",
")",
".",
"format",
"(",
"version",
",",
"wipe",
")"
] | Format a Topaz tag for NDEF use.
The implementation of :meth:`nfc.tag.Tag.format` for a Topaz
tag creates a capability container and an NDEF TLV with length
zero. Data bytes of the NDEF data area are left untouched
unless the wipe argument is set. | [
"Format",
"a",
"Topaz",
"tag",
"for",
"NDEF",
"use",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt1_broadcom.py#L40-L49 | train |
nfcpy/nfcpy | src/nfc/tag/tt1_broadcom.py | Topaz512.format | def format(self, version=None, wipe=None):
"""Format a Topaz-512 tag for NDEF use.
The implementation of :meth:`nfc.tag.Tag.format` for a
Topaz-512 tag creates a capability container, a Lock Control
and a Memory Control TLV, and an NDEF TLV with length
zero. Data bytes of the ND... | python | def format(self, version=None, wipe=None):
"""Format a Topaz-512 tag for NDEF use.
The implementation of :meth:`nfc.tag.Tag.format` for a
Topaz-512 tag creates a capability container, a Lock Control
and a Memory Control TLV, and an NDEF TLV with length
zero. Data bytes of the ND... | [
"def",
"format",
"(",
"self",
",",
"version",
"=",
"None",
",",
"wipe",
"=",
"None",
")",
":",
"return",
"super",
"(",
"Topaz512",
",",
"self",
")",
".",
"format",
"(",
"version",
",",
"wipe",
")"
] | Format a Topaz-512 tag for NDEF use.
The implementation of :meth:`nfc.tag.Tag.format` for a
Topaz-512 tag creates a capability container, a Lock Control
and a Memory Control TLV, and an NDEF TLV with length
zero. Data bytes of the NDEF data area are left untouched
unless the wip... | [
"Format",
"a",
"Topaz",
"-",
"512",
"tag",
"for",
"NDEF",
"use",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt1_broadcom.py#L100-L110 | train |
nfcpy/nfcpy | src/nfc/tag/tt1.py | Type1Tag.read_all | def read_all(self):
"""Returns the 2 byte Header ROM and all 120 byte static memory.
"""
log.debug("read all static memory")
cmd = "\x00\x00\x00" + self.uid
return self.transceive(cmd) | python | def read_all(self):
"""Returns the 2 byte Header ROM and all 120 byte static memory.
"""
log.debug("read all static memory")
cmd = "\x00\x00\x00" + self.uid
return self.transceive(cmd) | [
"def",
"read_all",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"read all static memory\"",
")",
"cmd",
"=",
"\"\\x00\\x00\\x00\"",
"+",
"self",
".",
"uid",
"return",
"self",
".",
"transceive",
"(",
"cmd",
")"
] | Returns the 2 byte Header ROM and all 120 byte static memory. | [
"Returns",
"the",
"2",
"byte",
"Header",
"ROM",
"and",
"all",
"120",
"byte",
"static",
"memory",
"."
] | 6649146d1afdd5e82b2b6b1ea00aa58d50785117 | https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/tag/tt1.py#L387-L392 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.