id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
234,500 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py | ComputeAuth._GetGsScopes | def _GetGsScopes(self):
"""Return all Google Storage scopes available on this VM."""
service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key)
try:
scopes = service_accounts[self.service_account]['scopes']
return list(GS_SCOPES.intersection(set(scopes))) if scopes else None
... | python | def _GetGsScopes(self):
"""Return all Google Storage scopes available on this VM."""
service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key)
try:
scopes = service_accounts[self.service_account]['scopes']
return list(GS_SCOPES.intersection(set(scopes))) if scopes else None
... | [
"def",
"_GetGsScopes",
"(",
"self",
")",
":",
"service_accounts",
"=",
"self",
".",
"watcher",
".",
"GetMetadata",
"(",
"metadata_key",
"=",
"self",
".",
"metadata_key",
")",
"try",
":",
"scopes",
"=",
"service_accounts",
"[",
"self",
".",
"service_account",
... | Return all Google Storage scopes available on this VM. | [
"Return",
"all",
"Google",
"Storage",
"scopes",
"available",
"on",
"this",
"VM",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py#L50-L57 |
234,501 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py | ComputeAuth._GetAccessToken | def _GetAccessToken(self):
"""Return an OAuth 2.0 access token for Google Storage."""
service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key)
try:
return service_accounts[self.service_account]['token']['access_token']
except KeyError:
return None | python | def _GetAccessToken(self):
"""Return an OAuth 2.0 access token for Google Storage."""
service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key)
try:
return service_accounts[self.service_account]['token']['access_token']
except KeyError:
return None | [
"def",
"_GetAccessToken",
"(",
"self",
")",
":",
"service_accounts",
"=",
"self",
".",
"watcher",
".",
"GetMetadata",
"(",
"metadata_key",
"=",
"self",
".",
"metadata_key",
")",
"try",
":",
"return",
"service_accounts",
"[",
"self",
".",
"service_account",
"]"... | Return an OAuth 2.0 access token for Google Storage. | [
"Return",
"an",
"OAuth",
"2",
".",
"0",
"access",
"token",
"for",
"Google",
"Storage",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/compute_auth.py#L59-L65 |
234,502 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/clock_skew/clock_skew_daemon.py | ClockSkewDaemon.HandleClockSync | def HandleClockSync(self, response):
"""Called when clock drift token changes.
Args:
response: string, the metadata response with the new drift token value.
"""
self.logger.info('Clock drift token has changed: %s.', response)
self.distro_utils.HandleClockSync(self.logger) | python | def HandleClockSync(self, response):
"""Called when clock drift token changes.
Args:
response: string, the metadata response with the new drift token value.
"""
self.logger.info('Clock drift token has changed: %s.', response)
self.distro_utils.HandleClockSync(self.logger) | [
"def",
"HandleClockSync",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Clock drift token has changed: %s.'",
",",
"response",
")",
"self",
".",
"distro_utils",
".",
"HandleClockSync",
"(",
"self",
".",
"logger",
")"
] | Called when clock drift token changes.
Args:
response: string, the metadata response with the new drift token value. | [
"Called",
"when",
"clock",
"drift",
"token",
"changes",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/clock_skew/clock_skew_daemon.py#L56-L63 |
234,503 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py | Utils._DisableNetworkManager | def _DisableNetworkManager(self, interfaces, logger):
"""Disable network manager management on a list of network interfaces.
Args:
interfaces: list of string, the output device names enable.
logger: logger object, used to write to SysLog and serial port.
"""
for interface in interfaces:
... | python | def _DisableNetworkManager(self, interfaces, logger):
"""Disable network manager management on a list of network interfaces.
Args:
interfaces: list of string, the output device names enable.
logger: logger object, used to write to SysLog and serial port.
"""
for interface in interfaces:
... | [
"def",
"_DisableNetworkManager",
"(",
"self",
",",
"interfaces",
",",
"logger",
")",
":",
"for",
"interface",
"in",
"interfaces",
":",
"interface_config",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"network_path",
",",
"'ifcfg-%s'",
"%",
"interfa... | Disable network manager management on a list of network interfaces.
Args:
interfaces: list of string, the output device names enable.
logger: logger object, used to write to SysLog and serial port. | [
"Disable",
"network",
"manager",
"management",
"on",
"a",
"list",
"of",
"network",
"interfaces",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py#L47-L75 |
234,504 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py | Utils._ModifyInterface | def _ModifyInterface(
self, interface_config, config_key, config_value, replace=False):
"""Write a value to a config file if not already present.
Args:
interface_config: string, the path to a config file.
config_key: string, the configuration key to set.
config_value: string, the value ... | python | def _ModifyInterface(
self, interface_config, config_key, config_value, replace=False):
"""Write a value to a config file if not already present.
Args:
interface_config: string, the path to a config file.
config_key: string, the configuration key to set.
config_value: string, the value ... | [
"def",
"_ModifyInterface",
"(",
"self",
",",
"interface_config",
",",
"config_key",
",",
"config_value",
",",
"replace",
"=",
"False",
")",
":",
"config_entry",
"=",
"'%s=%s'",
"%",
"(",
"config_key",
",",
"config_value",
")",
"if",
"not",
"open",
"(",
"inte... | Write a value to a config file if not already present.
Args:
interface_config: string, the path to a config file.
config_key: string, the configuration key to set.
config_value: string, the value to set for the configuration key.
replace: bool, replace the configuration option if already pr... | [
"Write",
"a",
"value",
"to",
"a",
"config",
"file",
"if",
"not",
"already",
"present",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/el_7/utils.py#L77-L93 |
234,505 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._HasExpired | def _HasExpired(self, key):
"""Check whether an SSH key has expired.
Uses Google-specific semantics of the OpenSSH public key format's comment
field to determine if an SSH key is past its expiration timestamp, and
therefore no longer to be trusted. This format is still subject to change.
Reliance o... | python | def _HasExpired(self, key):
"""Check whether an SSH key has expired.
Uses Google-specific semantics of the OpenSSH public key format's comment
field to determine if an SSH key is past its expiration timestamp, and
therefore no longer to be trusted. This format is still subject to change.
Reliance o... | [
"def",
"_HasExpired",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Processing key: %s.'",
",",
"key",
")",
"try",
":",
"schema",
",",
"json_str",
"=",
"key",
".",
"split",
"(",
"None",
",",
"3",
")",
"[",
"2",
":",... | Check whether an SSH key has expired.
Uses Google-specific semantics of the OpenSSH public key format's comment
field to determine if an SSH key is past its expiration timestamp, and
therefore no longer to be trusted. This format is still subject to change.
Reliance on it in any way is at your own risk... | [
"Check",
"whether",
"an",
"SSH",
"key",
"has",
"expired",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L78-L128 |
234,506 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._ParseAccountsData | def _ParseAccountsData(self, account_data):
"""Parse the SSH key data into a user map.
Args:
account_data: string, the metadata server SSH key attributes data.
Returns:
dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}.
"""
if not account_data:
return {}
l... | python | def _ParseAccountsData(self, account_data):
"""Parse the SSH key data into a user map.
Args:
account_data: string, the metadata server SSH key attributes data.
Returns:
dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}.
"""
if not account_data:
return {}
l... | [
"def",
"_ParseAccountsData",
"(",
"self",
",",
"account_data",
")",
":",
"if",
"not",
"account_data",
":",
"return",
"{",
"}",
"lines",
"=",
"[",
"line",
"for",
"line",
"in",
"account_data",
".",
"splitlines",
"(",
")",
"if",
"line",
"]",
"user_map",
"="... | Parse the SSH key data into a user map.
Args:
account_data: string, the metadata server SSH key attributes data.
Returns:
dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}. | [
"Parse",
"the",
"SSH",
"key",
"data",
"into",
"a",
"user",
"map",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L130-L159 |
234,507 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._GetInstanceAndProjectAttributes | def _GetInstanceAndProjectAttributes(self, metadata_dict):
"""Get dictionaries for instance and project attributes.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
tuple, two dictionaries for instance and project attributes.
"""
metadata_dict = met... | python | def _GetInstanceAndProjectAttributes(self, metadata_dict):
"""Get dictionaries for instance and project attributes.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
tuple, two dictionaries for instance and project attributes.
"""
metadata_dict = met... | [
"def",
"_GetInstanceAndProjectAttributes",
"(",
"self",
",",
"metadata_dict",
")",
":",
"metadata_dict",
"=",
"metadata_dict",
"or",
"{",
"}",
"try",
":",
"instance_data",
"=",
"metadata_dict",
"[",
"'instance'",
"]",
"[",
"'attributes'",
"]",
"except",
"KeyError"... | Get dictionaries for instance and project attributes.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
tuple, two dictionaries for instance and project attributes. | [
"Get",
"dictionaries",
"for",
"instance",
"and",
"project",
"attributes",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L161-L184 |
234,508 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._GetAccountsData | def _GetAccountsData(self, metadata_dict):
"""Get the user accounts specified in metadata server contents.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}.
"""
instance_data, pro... | python | def _GetAccountsData(self, metadata_dict):
"""Get the user accounts specified in metadata server contents.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}.
"""
instance_data, pro... | [
"def",
"_GetAccountsData",
"(",
"self",
",",
"metadata_dict",
")",
":",
"instance_data",
",",
"project_data",
"=",
"self",
".",
"_GetInstanceAndProjectAttributes",
"(",
"metadata_dict",
")",
"valid_keys",
"=",
"[",
"instance_data",
".",
"get",
"(",
"'sshKeys'",
")... | Get the user accounts specified in metadata server contents.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
dict, a mapping of the form: {'username': ['sshkey1, 'sshkey2', ...]}. | [
"Get",
"the",
"user",
"accounts",
"specified",
"in",
"metadata",
"server",
"contents",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L186-L203 |
234,509 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._UpdateUsers | def _UpdateUsers(self, update_users):
"""Provision and update Linux user accounts based on account metadata.
Args:
update_users: dict, authorized users mapped to their public SSH keys.
"""
for user, ssh_keys in update_users.items():
if not user or user in self.invalid_users:
continu... | python | def _UpdateUsers(self, update_users):
"""Provision and update Linux user accounts based on account metadata.
Args:
update_users: dict, authorized users mapped to their public SSH keys.
"""
for user, ssh_keys in update_users.items():
if not user or user in self.invalid_users:
continu... | [
"def",
"_UpdateUsers",
"(",
"self",
",",
"update_users",
")",
":",
"for",
"user",
",",
"ssh_keys",
"in",
"update_users",
".",
"items",
"(",
")",
":",
"if",
"not",
"user",
"or",
"user",
"in",
"self",
".",
"invalid_users",
":",
"continue",
"configured_keys",... | Provision and update Linux user accounts based on account metadata.
Args:
update_users: dict, authorized users mapped to their public SSH keys. | [
"Provision",
"and",
"update",
"Linux",
"user",
"accounts",
"based",
"on",
"account",
"metadata",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L205-L219 |
234,510 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._RemoveUsers | def _RemoveUsers(self, remove_users):
"""Deprovision Linux user accounts that do not appear in account metadata.
Args:
remove_users: list, the username strings of the Linux accounts to remove.
"""
for username in remove_users:
self.utils.RemoveUser(username)
self.user_ssh_keys.pop(use... | python | def _RemoveUsers(self, remove_users):
"""Deprovision Linux user accounts that do not appear in account metadata.
Args:
remove_users: list, the username strings of the Linux accounts to remove.
"""
for username in remove_users:
self.utils.RemoveUser(username)
self.user_ssh_keys.pop(use... | [
"def",
"_RemoveUsers",
"(",
"self",
",",
"remove_users",
")",
":",
"for",
"username",
"in",
"remove_users",
":",
"self",
".",
"utils",
".",
"RemoveUser",
"(",
"username",
")",
"self",
".",
"user_ssh_keys",
".",
"pop",
"(",
"username",
",",
"None",
")",
"... | Deprovision Linux user accounts that do not appear in account metadata.
Args:
remove_users: list, the username strings of the Linux accounts to remove. | [
"Deprovision",
"Linux",
"user",
"accounts",
"that",
"do",
"not",
"appear",
"in",
"account",
"metadata",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L221-L230 |
234,511 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon._GetEnableOsLoginValue | def _GetEnableOsLoginValue(self, metadata_dict):
"""Get the value of the enable-oslogin metadata key.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
bool, True if OS Login is enabled for VM access.
"""
instance_data, project_data = self._GetInstan... | python | def _GetEnableOsLoginValue(self, metadata_dict):
"""Get the value of the enable-oslogin metadata key.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
bool, True if OS Login is enabled for VM access.
"""
instance_data, project_data = self._GetInstan... | [
"def",
"_GetEnableOsLoginValue",
"(",
"self",
",",
"metadata_dict",
")",
":",
"instance_data",
",",
"project_data",
"=",
"self",
".",
"_GetInstanceAndProjectAttributes",
"(",
"metadata_dict",
")",
"instance_value",
"=",
"instance_data",
".",
"get",
"(",
"'enable-oslog... | Get the value of the enable-oslogin metadata key.
Args:
metadata_dict: json, the deserialized contents of the metadata server.
Returns:
bool, True if OS Login is enabled for VM access. | [
"Get",
"the",
"value",
"of",
"the",
"enable",
"-",
"oslogin",
"metadata",
"key",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L232-L247 |
234,512 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py | AccountsDaemon.HandleAccounts | def HandleAccounts(self, result):
"""Called when there are changes to the contents of the metadata server.
Args:
result: json, the deserialized contents of the metadata server.
"""
self.logger.debug('Checking for changes to user accounts.')
configured_users = self.utils.GetConfiguredUsers()
... | python | def HandleAccounts(self, result):
"""Called when there are changes to the contents of the metadata server.
Args:
result: json, the deserialized contents of the metadata server.
"""
self.logger.debug('Checking for changes to user accounts.')
configured_users = self.utils.GetConfiguredUsers()
... | [
"def",
"HandleAccounts",
"(",
"self",
",",
"result",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Checking for changes to user accounts.'",
")",
"configured_users",
"=",
"self",
".",
"utils",
".",
"GetConfiguredUsers",
"(",
")",
"enable_oslogin",
"=",
"... | Called when there are changes to the contents of the metadata server.
Args:
result: json, the deserialized contents of the metadata server. | [
"Called",
"when",
"there",
"are",
"changes",
"to",
"the",
"contents",
"of",
"the",
"metadata",
"server",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L266-L285 |
234,513 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/file_utils.py | _SetSELinuxContext | def _SetSELinuxContext(path):
"""Set the appropriate SELinux context, if SELinux tools are installed.
Calls /sbin/restorecon on the provided path to set the SELinux context as
specified by policy. This call does not operate recursively.
Only some OS configurations use SELinux. It is therefore acceptable for
... | python | def _SetSELinuxContext(path):
"""Set the appropriate SELinux context, if SELinux tools are installed.
Calls /sbin/restorecon on the provided path to set the SELinux context as
specified by policy. This call does not operate recursively.
Only some OS configurations use SELinux. It is therefore acceptable for
... | [
"def",
"_SetSELinuxContext",
"(",
"path",
")",
":",
"restorecon",
"=",
"'/sbin/restorecon'",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"restorecon",
")",
"and",
"os",
".",
"access",
"(",
"restorecon",
",",
"os",
".",
"X_OK",
")",
":",
"subprocess",
".... | Set the appropriate SELinux context, if SELinux tools are installed.
Calls /sbin/restorecon on the provided path to set the SELinux context as
specified by policy. This call does not operate recursively.
Only some OS configurations use SELinux. It is therefore acceptable for
restorecon to be missing, in which... | [
"Set",
"the",
"appropriate",
"SELinux",
"context",
"if",
"SELinux",
"tools",
"are",
"installed",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L25-L39 |
234,514 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/file_utils.py | SetPermissions | def SetPermissions(path, mode=None, uid=None, gid=None, mkdir=False):
"""Set the permissions and ownership of a path.
Args:
path: string, the path for which owner ID and group ID needs to be setup.
mode: octal string, the permissions to set on the path.
uid: int, the owner ID to be set for the path.
... | python | def SetPermissions(path, mode=None, uid=None, gid=None, mkdir=False):
"""Set the permissions and ownership of a path.
Args:
path: string, the path for which owner ID and group ID needs to be setup.
mode: octal string, the permissions to set on the path.
uid: int, the owner ID to be set for the path.
... | [
"def",
"SetPermissions",
"(",
"path",
",",
"mode",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"gid",
"=",
"None",
",",
"mkdir",
"=",
"False",
")",
":",
"if",
"mkdir",
"and",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"os",
... | Set the permissions and ownership of a path.
Args:
path: string, the path for which owner ID and group ID needs to be setup.
mode: octal string, the permissions to set on the path.
uid: int, the owner ID to be set for the path.
gid: int, the group ID to be set for the path.
mkdir: bool, True if t... | [
"Set",
"the",
"permissions",
"and",
"ownership",
"of",
"a",
"path",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L42-L58 |
234,515 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/file_utils.py | Lock | def Lock(fd, path, blocking):
"""Lock the provided file descriptor.
Args:
fd: int, the file descriptor of the file to lock.
path: string, the name of the file to lock.
blocking: bool, whether the function should return immediately.
Raises:
IOError, raised from flock while attempting to lock a fi... | python | def Lock(fd, path, blocking):
"""Lock the provided file descriptor.
Args:
fd: int, the file descriptor of the file to lock.
path: string, the name of the file to lock.
blocking: bool, whether the function should return immediately.
Raises:
IOError, raised from flock while attempting to lock a fi... | [
"def",
"Lock",
"(",
"fd",
",",
"path",
",",
"blocking",
")",
":",
"operation",
"=",
"fcntl",
".",
"LOCK_EX",
"if",
"blocking",
"else",
"fcntl",
".",
"LOCK_EX",
"|",
"fcntl",
".",
"LOCK_NB",
"try",
":",
"fcntl",
".",
"flock",
"(",
"fd",
",",
"operatio... | Lock the provided file descriptor.
Args:
fd: int, the file descriptor of the file to lock.
path: string, the name of the file to lock.
blocking: bool, whether the function should return immediately.
Raises:
IOError, raised from flock while attempting to lock a file. | [
"Lock",
"the",
"provided",
"file",
"descriptor",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L61-L79 |
234,516 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/file_utils.py | Unlock | def Unlock(fd, path):
"""Release the lock on the file.
Args:
fd: int, the file descriptor of the file to unlock.
path: string, the name of the file to lock.
Raises:
IOError, raised from flock while attempting to release a file lock.
"""
try:
fcntl.flock(fd, fcntl.LOCK_UN | fcntl.LOCK_NB)
e... | python | def Unlock(fd, path):
"""Release the lock on the file.
Args:
fd: int, the file descriptor of the file to unlock.
path: string, the name of the file to lock.
Raises:
IOError, raised from flock while attempting to release a file lock.
"""
try:
fcntl.flock(fd, fcntl.LOCK_UN | fcntl.LOCK_NB)
e... | [
"def",
"Unlock",
"(",
"fd",
",",
"path",
")",
":",
"try",
":",
"fcntl",
".",
"flock",
"(",
"fd",
",",
"fcntl",
".",
"LOCK_UN",
"|",
"fcntl",
".",
"LOCK_NB",
")",
"except",
"IOError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"errno",
".",
... | Release the lock on the file.
Args:
fd: int, the file descriptor of the file to unlock.
path: string, the name of the file to lock.
Raises:
IOError, raised from flock while attempting to release a file lock. | [
"Release",
"the",
"lock",
"on",
"the",
"file",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L82-L98 |
234,517 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/file_utils.py | LockFile | def LockFile(path, blocking=False):
"""Interface to flock-based file locking to prevent concurrent executions.
Args:
path: string, the name of the file to lock.
blocking: bool, whether the function should return immediately.
Yields:
None, yields when a lock on the file is obtained.
Raises:
IO... | python | def LockFile(path, blocking=False):
"""Interface to flock-based file locking to prevent concurrent executions.
Args:
path: string, the name of the file to lock.
blocking: bool, whether the function should return immediately.
Yields:
None, yields when a lock on the file is obtained.
Raises:
IO... | [
"def",
"LockFile",
"(",
"path",
",",
"blocking",
"=",
"False",
")",
":",
"fd",
"=",
"os",
".",
"open",
"(",
"path",
",",
"os",
".",
"O_CREAT",
")",
"try",
":",
"Lock",
"(",
"fd",
",",
"path",
",",
"blocking",
")",
"yield",
"finally",
":",
"try",
... | Interface to flock-based file locking to prevent concurrent executions.
Args:
path: string, the name of the file to lock.
blocking: bool, whether the function should return immediately.
Yields:
None, yields when a lock on the file is obtained.
Raises:
IOError, raised from flock locking operatio... | [
"Interface",
"to",
"flock",
"-",
"based",
"file",
"locking",
"to",
"prevent",
"concurrent",
"executions",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/file_utils.py#L102-L124 |
234,518 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | RetryOnUnavailable | def RetryOnUnavailable(func):
"""Function decorator to retry on a service unavailable exception."""
@functools.wraps(func)
def Wrapper(*args, **kwargs):
while True:
try:
response = func(*args, **kwargs)
except (httpclient.HTTPException, socket.error, urlerror.URLError) as e:
time.... | python | def RetryOnUnavailable(func):
"""Function decorator to retry on a service unavailable exception."""
@functools.wraps(func)
def Wrapper(*args, **kwargs):
while True:
try:
response = func(*args, **kwargs)
except (httpclient.HTTPException, socket.error, urlerror.URLError) as e:
time.... | [
"def",
"RetryOnUnavailable",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"Wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"while",
"True",
":",
"try",
":",
"response",
"=",
"func",
"(",
"*",
"args"... | Function decorator to retry on a service unavailable exception. | [
"Function",
"decorator",
"to",
"retry",
"on",
"a",
"service",
"unavailable",
"exception",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L43-L64 |
234,519 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | MetadataWatcher._GetMetadataRequest | def _GetMetadataRequest(self, metadata_url, params=None, timeout=None):
"""Performs a GET request with the metadata headers.
Args:
metadata_url: string, the URL to perform a GET request on.
params: dictionary, the query parameters in the GET request.
timeout: int, timeout in seconds for metad... | python | def _GetMetadataRequest(self, metadata_url, params=None, timeout=None):
"""Performs a GET request with the metadata headers.
Args:
metadata_url: string, the URL to perform a GET request on.
params: dictionary, the query parameters in the GET request.
timeout: int, timeout in seconds for metad... | [
"def",
"_GetMetadataRequest",
"(",
"self",
",",
"metadata_url",
",",
"params",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"'Metadata-Flavor'",
":",
"'Google'",
"}",
"params",
"=",
"urlparse",
".",
"urlencode",
"(",
"params",
"... | Performs a GET request with the metadata headers.
Args:
metadata_url: string, the URL to perform a GET request on.
params: dictionary, the query parameters in the GET request.
timeout: int, timeout in seconds for metadata requests.
Returns:
HTTP response from the GET request.
Rais... | [
"Performs",
"a",
"GET",
"request",
"with",
"the",
"metadata",
"headers",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L82-L102 |
234,520 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | MetadataWatcher._UpdateEtag | def _UpdateEtag(self, response):
"""Update the etag from an API response.
Args:
response: HTTP response with a header field.
Returns:
bool, True if the etag in the response header updated.
"""
etag = response.headers.get('etag', self.etag)
etag_updated = self.etag != etag
self.... | python | def _UpdateEtag(self, response):
"""Update the etag from an API response.
Args:
response: HTTP response with a header field.
Returns:
bool, True if the etag in the response header updated.
"""
etag = response.headers.get('etag', self.etag)
etag_updated = self.etag != etag
self.... | [
"def",
"_UpdateEtag",
"(",
"self",
",",
"response",
")",
":",
"etag",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"'etag'",
",",
"self",
".",
"etag",
")",
"etag_updated",
"=",
"self",
".",
"etag",
"!=",
"etag",
"self",
".",
"etag",
"=",
"etag",... | Update the etag from an API response.
Args:
response: HTTP response with a header field.
Returns:
bool, True if the etag in the response header updated. | [
"Update",
"the",
"etag",
"from",
"an",
"API",
"response",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L104-L116 |
234,521 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | MetadataWatcher._GetMetadataUpdate | def _GetMetadataUpdate(
self, metadata_key='', recursive=True, wait=True, timeout=None):
"""Request the contents of metadata server and deserialize the response.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadat... | python | def _GetMetadataUpdate(
self, metadata_key='', recursive=True, wait=True, timeout=None):
"""Request the contents of metadata server and deserialize the response.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadat... | [
"def",
"_GetMetadataUpdate",
"(",
"self",
",",
"metadata_key",
"=",
"''",
",",
"recursive",
"=",
"True",
",",
"wait",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"metadata_key",
"=",
"os",
".",
"path",
".",
"join",
"(",
"metadata_key",
",",
"''... | Request the contents of metadata server and deserialize the response.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata changes.
wait: bool, True if we should wait for a metadata change.
timeout: int, timeout... | [
"Request",
"the",
"contents",
"of",
"metadata",
"server",
"and",
"deserialize",
"the",
"response",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L118-L153 |
234,522 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | MetadataWatcher._HandleMetadataUpdate | def _HandleMetadataUpdate(
self, metadata_key='', recursive=True, wait=True, timeout=None,
retry=True):
"""Wait for a successful metadata response.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata change... | python | def _HandleMetadataUpdate(
self, metadata_key='', recursive=True, wait=True, timeout=None,
retry=True):
"""Wait for a successful metadata response.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata change... | [
"def",
"_HandleMetadataUpdate",
"(",
"self",
",",
"metadata_key",
"=",
"''",
",",
"recursive",
"=",
"True",
",",
"wait",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"retry",
"=",
"True",
")",
":",
"exception",
"=",
"None",
"while",
"True",
":",
"try... | Wait for a successful metadata response.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata changes.
wait: bool, True if we should wait for a metadata change.
timeout: int, timeout in seconds for returning met... | [
"Wait",
"for",
"a",
"successful",
"metadata",
"response",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L155-L183 |
234,523 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | MetadataWatcher.WatchMetadata | def WatchMetadata(
self, handler, metadata_key='', recursive=True, timeout=None):
"""Watch for changes to the contents of the metadata server.
Args:
handler: callable, a function to call with the updated metadata contents.
metadata_key: string, the metadata key to watch for changes.
rec... | python | def WatchMetadata(
self, handler, metadata_key='', recursive=True, timeout=None):
"""Watch for changes to the contents of the metadata server.
Args:
handler: callable, a function to call with the updated metadata contents.
metadata_key: string, the metadata key to watch for changes.
rec... | [
"def",
"WatchMetadata",
"(",
"self",
",",
"handler",
",",
"metadata_key",
"=",
"''",
",",
"recursive",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"while",
"True",
":",
"response",
"=",
"self",
".",
"_HandleMetadataUpdate",
"(",
"metadata_key",
"="... | Watch for changes to the contents of the metadata server.
Args:
handler: callable, a function to call with the updated metadata contents.
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata changes.
timeout: int, tim... | [
"Watch",
"for",
"changes",
"to",
"the",
"contents",
"of",
"the",
"metadata",
"server",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L185-L202 |
234,524 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py | MetadataWatcher.GetMetadata | def GetMetadata(
self, metadata_key='', recursive=True, timeout=None, retry=True):
"""Retrieve the contents of metadata server for a metadata key.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata changes.
... | python | def GetMetadata(
self, metadata_key='', recursive=True, timeout=None, retry=True):
"""Retrieve the contents of metadata server for a metadata key.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata changes.
... | [
"def",
"GetMetadata",
"(",
"self",
",",
"metadata_key",
"=",
"''",
",",
"recursive",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"retry",
"=",
"True",
")",
":",
"return",
"self",
".",
"_HandleMetadataUpdate",
"(",
"metadata_key",
"=",
"metadata_key",
",... | Retrieve the contents of metadata server for a metadata key.
Args:
metadata_key: string, the metadata key to watch for changes.
recursive: bool, True if we should recursively watch for metadata changes.
timeout: int, timeout in seconds for returning metadata output.
retry: bool, True if we ... | [
"Retrieve",
"the",
"contents",
"of",
"metadata",
"server",
"for",
"a",
"metadata",
"key",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/metadata_watcher.py#L204-L219 |
234,525 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py | IpForwarding._LogForwardedIpChanges | def _LogForwardedIpChanges(
self, configured, desired, to_add, to_remove, interface):
"""Log the planned IP address changes.
Args:
configured: list, the IP address strings already configured.
desired: list, the IP address strings that will be configured.
to_add: list, the forwarded IP a... | python | def _LogForwardedIpChanges(
self, configured, desired, to_add, to_remove, interface):
"""Log the planned IP address changes.
Args:
configured: list, the IP address strings already configured.
desired: list, the IP address strings that will be configured.
to_add: list, the forwarded IP a... | [
"def",
"_LogForwardedIpChanges",
"(",
"self",
",",
"configured",
",",
"desired",
",",
"to_add",
",",
"to_remove",
",",
"interface",
")",
":",
"if",
"not",
"to_add",
"and",
"not",
"to_remove",
":",
"return",
"self",
".",
"logger",
".",
"info",
"(",
"'Changi... | Log the planned IP address changes.
Args:
configured: list, the IP address strings already configured.
desired: list, the IP address strings that will be configured.
to_add: list, the forwarded IP address strings to configure.
to_remove: list, the forwarded IP address strings to delete.
... | [
"Log",
"the",
"planned",
"IP",
"address",
"changes",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L45-L61 |
234,526 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py | IpForwarding._AddForwardedIps | def _AddForwardedIps(self, forwarded_ips, interface):
"""Configure the forwarded IP address on the network interface.
Args:
forwarded_ips: list, the forwarded IP address strings to configure.
interface: string, the output device to use.
"""
for address in forwarded_ips:
self.ip_forwar... | python | def _AddForwardedIps(self, forwarded_ips, interface):
"""Configure the forwarded IP address on the network interface.
Args:
forwarded_ips: list, the forwarded IP address strings to configure.
interface: string, the output device to use.
"""
for address in forwarded_ips:
self.ip_forwar... | [
"def",
"_AddForwardedIps",
"(",
"self",
",",
"forwarded_ips",
",",
"interface",
")",
":",
"for",
"address",
"in",
"forwarded_ips",
":",
"self",
".",
"ip_forwarding_utils",
".",
"AddForwardedIp",
"(",
"address",
",",
"interface",
")"
] | Configure the forwarded IP address on the network interface.
Args:
forwarded_ips: list, the forwarded IP address strings to configure.
interface: string, the output device to use. | [
"Configure",
"the",
"forwarded",
"IP",
"address",
"on",
"the",
"network",
"interface",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L63-L71 |
234,527 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py | IpForwarding._RemoveForwardedIps | def _RemoveForwardedIps(self, forwarded_ips, interface):
"""Remove the forwarded IP addresses from the network interface.
Args:
forwarded_ips: list, the forwarded IP address strings to delete.
interface: string, the output device to use.
"""
for address in forwarded_ips:
self.ip_forwa... | python | def _RemoveForwardedIps(self, forwarded_ips, interface):
"""Remove the forwarded IP addresses from the network interface.
Args:
forwarded_ips: list, the forwarded IP address strings to delete.
interface: string, the output device to use.
"""
for address in forwarded_ips:
self.ip_forwa... | [
"def",
"_RemoveForwardedIps",
"(",
"self",
",",
"forwarded_ips",
",",
"interface",
")",
":",
"for",
"address",
"in",
"forwarded_ips",
":",
"self",
".",
"ip_forwarding_utils",
".",
"RemoveForwardedIp",
"(",
"address",
",",
"interface",
")"
] | Remove the forwarded IP addresses from the network interface.
Args:
forwarded_ips: list, the forwarded IP address strings to delete.
interface: string, the output device to use. | [
"Remove",
"the",
"forwarded",
"IP",
"addresses",
"from",
"the",
"network",
"interface",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L73-L81 |
234,528 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py | IpForwarding.HandleForwardedIps | def HandleForwardedIps(self, interface, forwarded_ips, interface_ip=None):
"""Handle changes to the forwarded IPs on a network interface.
Args:
interface: string, the output device to configure.
forwarded_ips: list, the forwarded IP address strings desired.
interface_ip: string, current inter... | python | def HandleForwardedIps(self, interface, forwarded_ips, interface_ip=None):
"""Handle changes to the forwarded IPs on a network interface.
Args:
interface: string, the output device to configure.
forwarded_ips: list, the forwarded IP address strings desired.
interface_ip: string, current inter... | [
"def",
"HandleForwardedIps",
"(",
"self",
",",
"interface",
",",
"forwarded_ips",
",",
"interface_ip",
"=",
"None",
")",
":",
"desired",
"=",
"self",
".",
"ip_forwarding_utils",
".",
"ParseForwardedIps",
"(",
"forwarded_ips",
")",
"configured",
"=",
"self",
".",... | Handle changes to the forwarded IPs on a network interface.
Args:
interface: string, the output device to configure.
forwarded_ips: list, the forwarded IP address strings desired.
interface_ip: string, current interface ip address. | [
"Handle",
"changes",
"to",
"the",
"forwarded",
"IPs",
"on",
"a",
"network",
"interface",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/ip_forwarding/ip_forwarding.py#L83-L99 |
234,529 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py | Utils._WriteIfcfg | def _WriteIfcfg(self, interfaces, logger):
"""Write ifcfg files for multi-NIC support.
Overwrites the files. This allows us to update ifcfg-* in the future.
Disable the network setup to override this behavior and customize the
configurations.
Args:
interfaces: list of string, the output devi... | python | def _WriteIfcfg(self, interfaces, logger):
"""Write ifcfg files for multi-NIC support.
Overwrites the files. This allows us to update ifcfg-* in the future.
Disable the network setup to override this behavior and customize the
configurations.
Args:
interfaces: list of string, the output devi... | [
"def",
"_WriteIfcfg",
"(",
"self",
",",
"interfaces",
",",
"logger",
")",
":",
"for",
"interface",
"in",
"interfaces",
":",
"interface_config",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"network_path",
",",
"'ifcfg-%s'",
"%",
"interface",
")",... | Write ifcfg files for multi-NIC support.
Overwrites the files. This allows us to update ifcfg-* in the future.
Disable the network setup to override this behavior and customize the
configurations.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, u... | [
"Write",
"ifcfg",
"files",
"for",
"multi",
"-",
"NIC",
"support",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py#L47-L71 |
234,530 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py | Utils._Ifup | def _Ifup(self, interfaces, logger):
"""Activate network interfaces.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, used to write to SysLog and serial port.
"""
ifup = ['/usr/sbin/wicked', 'ifup', '--timeout', '1']
try:
subprocess.check... | python | def _Ifup(self, interfaces, logger):
"""Activate network interfaces.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, used to write to SysLog and serial port.
"""
ifup = ['/usr/sbin/wicked', 'ifup', '--timeout', '1']
try:
subprocess.check... | [
"def",
"_Ifup",
"(",
"self",
",",
"interfaces",
",",
"logger",
")",
":",
"ifup",
"=",
"[",
"'/usr/sbin/wicked'",
",",
"'ifup'",
",",
"'--timeout'",
",",
"'1'",
"]",
"try",
":",
"subprocess",
".",
"check_call",
"(",
"ifup",
"+",
"interfaces",
")",
"except... | Activate network interfaces.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, used to write to SysLog and serial port. | [
"Activate",
"network",
"interfaces",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py#L73-L84 |
234,531 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py | NetworkDaemon.HandleNetworkInterfaces | def HandleNetworkInterfaces(self, result):
"""Called when network interface metadata changes.
Args:
result: dict, the metadata response with the network interfaces.
"""
network_interfaces = self._ExtractInterfaceMetadata(result)
if self.network_setup_enabled:
self.network_setup.EnableN... | python | def HandleNetworkInterfaces(self, result):
"""Called when network interface metadata changes.
Args:
result: dict, the metadata response with the network interfaces.
"""
network_interfaces = self._ExtractInterfaceMetadata(result)
if self.network_setup_enabled:
self.network_setup.EnableN... | [
"def",
"HandleNetworkInterfaces",
"(",
"self",
",",
"result",
")",
":",
"network_interfaces",
"=",
"self",
".",
"_ExtractInterfaceMetadata",
"(",
"result",
")",
"if",
"self",
".",
"network_setup_enabled",
":",
"self",
".",
"network_setup",
".",
"EnableNetworkInterfa... | Called when network interface metadata changes.
Args:
result: dict, the metadata response with the network interfaces. | [
"Called",
"when",
"network",
"interface",
"metadata",
"changes",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py#L84-L99 |
234,532 | GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py | NetworkDaemon._ExtractInterfaceMetadata | def _ExtractInterfaceMetadata(self, metadata):
"""Extracts network interface metadata.
Args:
metadata: dict, the metadata response with the new network interfaces.
Returns:
list, a list of NetworkInterface objects.
"""
interfaces = []
for network_interface in metadata:
mac_ad... | python | def _ExtractInterfaceMetadata(self, metadata):
"""Extracts network interface metadata.
Args:
metadata: dict, the metadata response with the new network interfaces.
Returns:
list, a list of NetworkInterface objects.
"""
interfaces = []
for network_interface in metadata:
mac_ad... | [
"def",
"_ExtractInterfaceMetadata",
"(",
"self",
",",
"metadata",
")",
":",
"interfaces",
"=",
"[",
"]",
"for",
"network_interface",
"in",
"metadata",
":",
"mac_address",
"=",
"network_interface",
".",
"get",
"(",
"'mac'",
")",
"interface",
"=",
"self",
".",
... | Extracts network interface metadata.
Args:
metadata: dict, the metadata response with the new network interfaces.
Returns:
list, a list of NetworkInterface objects. | [
"Extracts",
"network",
"interface",
"metadata",
"."
] | 53ea8cd069fb4d9a1984d1c167e54c133033f8da | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py#L101-L126 |
234,533 | sendgrid/python-http-client | python_http_client/client.py | Client._build_url | def _build_url(self, query_params):
"""Build the final URL to be passed to urllib
:param query_params: A dictionary of all the query parameters
:type query_params: dictionary
:return: string
"""
url = ''
count = 0
while count < len(self._url_path):
... | python | def _build_url(self, query_params):
"""Build the final URL to be passed to urllib
:param query_params: A dictionary of all the query parameters
:type query_params: dictionary
:return: string
"""
url = ''
count = 0
while count < len(self._url_path):
... | [
"def",
"_build_url",
"(",
"self",
",",
"query_params",
")",
":",
"url",
"=",
"''",
"count",
"=",
"0",
"while",
"count",
"<",
"len",
"(",
"self",
".",
"_url_path",
")",
":",
"url",
"+=",
"'/{}'",
".",
"format",
"(",
"self",
".",
"_url_path",
"[",
"c... | Build the final URL to be passed to urllib
:param query_params: A dictionary of all the query parameters
:type query_params: dictionary
:return: string | [
"Build",
"the",
"final",
"URL",
"to",
"be",
"passed",
"to",
"urllib"
] | fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d | https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L107-L132 |
234,534 | sendgrid/python-http-client | python_http_client/client.py | Client._build_client | def _build_client(self, name=None):
"""Make a new Client object
:param name: Name of the url segment
:type name: string
:return: A Client object
"""
url_path = self._url_path + [name] if name else self._url_path
return Client(host=self.host,
... | python | def _build_client(self, name=None):
"""Make a new Client object
:param name: Name of the url segment
:type name: string
:return: A Client object
"""
url_path = self._url_path + [name] if name else self._url_path
return Client(host=self.host,
... | [
"def",
"_build_client",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"url_path",
"=",
"self",
".",
"_url_path",
"+",
"[",
"name",
"]",
"if",
"name",
"else",
"self",
".",
"_url_path",
"return",
"Client",
"(",
"host",
"=",
"self",
".",
"host",
",",... | Make a new Client object
:param name: Name of the url segment
:type name: string
:return: A Client object | [
"Make",
"a",
"new",
"Client",
"object"
] | fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d | https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L143-L156 |
234,535 | sendgrid/python-http-client | python_http_client/client.py | Client._make_request | def _make_request(self, opener, request, timeout=None):
"""Make the API call and return the response. This is separated into
it's own function, so we can mock it easily for testing.
:param opener:
:type opener:
:param request: url payload to request
:type request: url... | python | def _make_request(self, opener, request, timeout=None):
"""Make the API call and return the response. This is separated into
it's own function, so we can mock it easily for testing.
:param opener:
:type opener:
:param request: url payload to request
:type request: url... | [
"def",
"_make_request",
"(",
"self",
",",
"opener",
",",
"request",
",",
"timeout",
"=",
"None",
")",
":",
"timeout",
"=",
"timeout",
"or",
"self",
".",
"timeout",
"try",
":",
"return",
"opener",
".",
"open",
"(",
"request",
",",
"timeout",
"=",
"timeo... | Make the API call and return the response. This is separated into
it's own function, so we can mock it easily for testing.
:param opener:
:type opener:
:param request: url payload to request
:type request: urllib.Request object
:param timeout: timeout value or None
... | [
"Make",
"the",
"API",
"call",
"and",
"return",
"the",
"response",
".",
"This",
"is",
"separated",
"into",
"it",
"s",
"own",
"function",
"so",
"we",
"can",
"mock",
"it",
"easily",
"for",
"testing",
"."
] | fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d | https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L158-L176 |
234,536 | junzis/pyModeS | pyModeS/decoder/bds/bds08.py | category | def category(msg):
"""Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: category number
"""
if common.typecode(msg) < 1 or common.typecode(msg) > 4:
raise RuntimeError("%s: Not a identification message" % msg)
msgbin = comm... | python | def category(msg):
"""Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: category number
"""
if common.typecode(msg) < 1 or common.typecode(msg) > 4:
raise RuntimeError("%s: Not a identification message" % msg)
msgbin = comm... | [
"def",
"category",
"(",
"msg",
")",
":",
"if",
"common",
".",
"typecode",
"(",
"msg",
")",
"<",
"1",
"or",
"common",
".",
"typecode",
"(",
"msg",
")",
">",
"4",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a identification message\"",
"%",
"msg",
")",
... | Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: category number | [
"Aircraft",
"category",
"number"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds08.py#L26-L40 |
234,537 | junzis/pyModeS | pyModeS/decoder/bds/bds05.py | airborne_position | def airborne_position(msg0, msg1, t0, t1):
"""Decode airborn position from a pair of even and odd position message
Args:
msg0 (string): even message (28 bytes hexadecimal string)
msg1 (string): odd message (28 bytes hexadecimal string)
t0 (int): timestamps for the even message
t... | python | def airborne_position(msg0, msg1, t0, t1):
"""Decode airborn position from a pair of even and odd position message
Args:
msg0 (string): even message (28 bytes hexadecimal string)
msg1 (string): odd message (28 bytes hexadecimal string)
t0 (int): timestamps for the even message
t... | [
"def",
"airborne_position",
"(",
"msg0",
",",
"msg1",
",",
"t0",
",",
"t1",
")",
":",
"mb0",
"=",
"common",
".",
"hex2bin",
"(",
"msg0",
")",
"[",
"32",
":",
"]",
"mb1",
"=",
"common",
".",
"hex2bin",
"(",
"msg1",
")",
"[",
"32",
":",
"]",
"# 1... | Decode airborn position from a pair of even and odd position message
Args:
msg0 (string): even message (28 bytes hexadecimal string)
msg1 (string): odd message (28 bytes hexadecimal string)
t0 (int): timestamps for the even message
t1 (int): timestamps for the odd message
Retur... | [
"Decode",
"airborn",
"position",
"from",
"a",
"pair",
"of",
"even",
"and",
"odd",
"position",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds05.py#L27-L85 |
234,538 | junzis/pyModeS | pyModeS/decoder/bds/bds05.py | airborne_position_with_ref | def airborne_position_with_ref(msg, lat_ref, lon_ref):
"""Decode airborne position with only one message,
knowing reference nearby location, such as previously calculated location,
ground station, or airport location, etc. The reference position shall
be with in 180NM of the true position.
Args:
... | python | def airborne_position_with_ref(msg, lat_ref, lon_ref):
"""Decode airborne position with only one message,
knowing reference nearby location, such as previously calculated location,
ground station, or airport location, etc. The reference position shall
be with in 180NM of the true position.
Args:
... | [
"def",
"airborne_position_with_ref",
"(",
"msg",
",",
"lat_ref",
",",
"lon_ref",
")",
":",
"mb",
"=",
"common",
".",
"hex2bin",
"(",
"msg",
")",
"[",
"32",
":",
"]",
"cprlat",
"=",
"common",
".",
"bin2int",
"(",
"mb",
"[",
"22",
":",
"39",
"]",
")"... | Decode airborne position with only one message,
knowing reference nearby location, such as previously calculated location,
ground station, or airport location, etc. The reference position shall
be with in 180NM of the true position.
Args:
msg (string): even message (28 bytes hexadecimal string)... | [
"Decode",
"airborne",
"position",
"with",
"only",
"one",
"message",
"knowing",
"reference",
"nearby",
"location",
"such",
"as",
"previously",
"calculated",
"location",
"ground",
"station",
"or",
"airport",
"location",
"etc",
".",
"The",
"reference",
"position",
"s... | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds05.py#L88-L129 |
234,539 | junzis/pyModeS | pyModeS/decoder/common.py | hex2bin | def hex2bin(hexstr):
"""Convert a hexdecimal string to binary string, with zero fillings. """
num_of_bits = len(hexstr) * 4
binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits))
return binstr | python | def hex2bin(hexstr):
"""Convert a hexdecimal string to binary string, with zero fillings. """
num_of_bits = len(hexstr) * 4
binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits))
return binstr | [
"def",
"hex2bin",
"(",
"hexstr",
")",
":",
"num_of_bits",
"=",
"len",
"(",
"hexstr",
")",
"*",
"4",
"binstr",
"=",
"bin",
"(",
"int",
"(",
"hexstr",
",",
"16",
")",
")",
"[",
"2",
":",
"]",
".",
"zfill",
"(",
"int",
"(",
"num_of_bits",
")",
")"... | Convert a hexdecimal string to binary string, with zero fillings. | [
"Convert",
"a",
"hexdecimal",
"string",
"to",
"binary",
"string",
"with",
"zero",
"fillings",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L4-L8 |
234,540 | junzis/pyModeS | pyModeS/decoder/common.py | icao | def icao(msg):
"""Calculate the ICAO address from an Mode-S message
with DF4, DF5, DF20, DF21
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
String: ICAO address in 6 bytes hexadecimal string
"""
DF = df(msg)
if DF in (11, 17, 18):
addr = msg[2:8... | python | def icao(msg):
"""Calculate the ICAO address from an Mode-S message
with DF4, DF5, DF20, DF21
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
String: ICAO address in 6 bytes hexadecimal string
"""
DF = df(msg)
if DF in (11, 17, 18):
addr = msg[2:8... | [
"def",
"icao",
"(",
"msg",
")",
":",
"DF",
"=",
"df",
"(",
"msg",
")",
"if",
"DF",
"in",
"(",
"11",
",",
"17",
",",
"18",
")",
":",
"addr",
"=",
"msg",
"[",
"2",
":",
"8",
"]",
"elif",
"DF",
"in",
"(",
"0",
",",
"4",
",",
"5",
",",
"1... | Calculate the ICAO address from an Mode-S message
with DF4, DF5, DF20, DF21
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
String: ICAO address in 6 bytes hexadecimal string | [
"Calculate",
"the",
"ICAO",
"address",
"from",
"an",
"Mode",
"-",
"S",
"message",
"with",
"DF4",
"DF5",
"DF20",
"DF21"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L79-L101 |
234,541 | junzis/pyModeS | pyModeS/decoder/common.py | gray2int | def gray2int(graystr):
"""Convert greycode to binary"""
num = bin2int(graystr)
num ^= (num >> 8)
num ^= (num >> 4)
num ^= (num >> 2)
num ^= (num >> 1)
return num | python | def gray2int(graystr):
"""Convert greycode to binary"""
num = bin2int(graystr)
num ^= (num >> 8)
num ^= (num >> 4)
num ^= (num >> 2)
num ^= (num >> 1)
return num | [
"def",
"gray2int",
"(",
"graystr",
")",
":",
"num",
"=",
"bin2int",
"(",
"graystr",
")",
"num",
"^=",
"(",
"num",
">>",
"8",
")",
"num",
"^=",
"(",
"num",
">>",
"4",
")",
"num",
"^=",
"(",
"num",
">>",
"2",
")",
"num",
"^=",
"(",
"num",
">>",... | Convert greycode to binary | [
"Convert",
"greycode",
"to",
"binary"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L268-L275 |
234,542 | junzis/pyModeS | pyModeS/decoder/common.py | allzeros | def allzeros(msg):
"""check if the data bits are all zeros
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
d = hex2bin(data(msg))
if bin2int(d) > 0:
return False
else:
return True | python | def allzeros(msg):
"""check if the data bits are all zeros
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
d = hex2bin(data(msg))
if bin2int(d) > 0:
return False
else:
return True | [
"def",
"allzeros",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"bin2int",
"(",
"d",
")",
">",
"0",
":",
"return",
"False",
"else",
":",
"return",
"True"
] | check if the data bits are all zeros
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"check",
"if",
"the",
"data",
"bits",
"are",
"all",
"zeros"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L283-L297 |
234,543 | junzis/pyModeS | pyModeS/decoder/common.py | wrongstatus | def wrongstatus(data, sb, msb, lsb):
"""Check if the status bit and field bits are consistency. This Function
is used for checking BDS code versions.
"""
# status bit, most significant bit, least significant bit
status = int(data[sb-1])
value = bin2int(data[msb-1:lsb])
if not status:
... | python | def wrongstatus(data, sb, msb, lsb):
"""Check if the status bit and field bits are consistency. This Function
is used for checking BDS code versions.
"""
# status bit, most significant bit, least significant bit
status = int(data[sb-1])
value = bin2int(data[msb-1:lsb])
if not status:
... | [
"def",
"wrongstatus",
"(",
"data",
",",
"sb",
",",
"msb",
",",
"lsb",
")",
":",
"# status bit, most significant bit, least significant bit",
"status",
"=",
"int",
"(",
"data",
"[",
"sb",
"-",
"1",
"]",
")",
"value",
"=",
"bin2int",
"(",
"data",
"[",
"msb",... | Check if the status bit and field bits are consistency. This Function
is used for checking BDS code versions. | [
"Check",
"if",
"the",
"status",
"bit",
"and",
"field",
"bits",
"are",
"consistency",
".",
"This",
"Function",
"is",
"used",
"for",
"checking",
"BDS",
"code",
"versions",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L300-L313 |
234,544 | junzis/pyModeS | pyModeS/decoder/adsb.py | version | def version(msg):
"""ADS-B Version
Args:
msg (string): 28 bytes hexadecimal message string, TC = 31
Returns:
int: version number
"""
tc = typecode(msg)
if tc != 31:
raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg)
msgbin = common.h... | python | def version(msg):
"""ADS-B Version
Args:
msg (string): 28 bytes hexadecimal message string, TC = 31
Returns:
int: version number
"""
tc = typecode(msg)
if tc != 31:
raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg)
msgbin = common.h... | [
"def",
"version",
"(",
"msg",
")",
":",
"tc",
"=",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"!=",
"31",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a status operation message, expecting TC = 31\"",
"%",
"msg",
")",
"msgbin",
"=",
"common",
".",
"hex2bin",
... | ADS-B Version
Args:
msg (string): 28 bytes hexadecimal message string, TC = 31
Returns:
int: version number | [
"ADS",
"-",
"B",
"Version"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L194-L211 |
234,545 | junzis/pyModeS | pyModeS/decoder/adsb.py | nic_v1 | def nic_v1(msg, NICs):
"""Calculate NIC, navigation integrity category, for ADS-B version 1
Args:
msg (string): 28 bytes hexadecimal message string
NICs (int or string): NIC supplement
Returns:
int or string: Horizontal Radius of Containment
int or string: Vertical Protecti... | python | def nic_v1(msg, NICs):
"""Calculate NIC, navigation integrity category, for ADS-B version 1
Args:
msg (string): 28 bytes hexadecimal message string
NICs (int or string): NIC supplement
Returns:
int or string: Horizontal Radius of Containment
int or string: Vertical Protecti... | [
"def",
"nic_v1",
"(",
"msg",
",",
"NICs",
")",
":",
"if",
"typecode",
"(",
"msg",
")",
"<",
"5",
"or",
"typecode",
"(",
"msg",
")",
">",
"22",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a surface position message (5<TC<8), \\\n airborne position mess... | Calculate NIC, navigation integrity category, for ADS-B version 1
Args:
msg (string): 28 bytes hexadecimal message string
NICs (int or string): NIC supplement
Returns:
int or string: Horizontal Radius of Containment
int or string: Vertical Protection Limit | [
"Calculate",
"NIC",
"navigation",
"integrity",
"category",
"for",
"ADS",
"-",
"B",
"version",
"1"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L278-L308 |
234,546 | junzis/pyModeS | pyModeS/decoder/adsb.py | nic_v2 | def nic_v2(msg, NICa, NICbc):
"""Calculate NIC, navigation integrity category, for ADS-B version 2
Args:
msg (string): 28 bytes hexadecimal message string
NICa (int or string): NIC supplement - A
NICbc (int or srting): NIC supplement - B or C
Returns:
int or string: Horizon... | python | def nic_v2(msg, NICa, NICbc):
"""Calculate NIC, navigation integrity category, for ADS-B version 2
Args:
msg (string): 28 bytes hexadecimal message string
NICa (int or string): NIC supplement - A
NICbc (int or srting): NIC supplement - B or C
Returns:
int or string: Horizon... | [
"def",
"nic_v2",
"(",
"msg",
",",
"NICa",
",",
"NICbc",
")",
":",
"if",
"typecode",
"(",
"msg",
")",
"<",
"5",
"or",
"typecode",
"(",
"msg",
")",
">",
"22",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a surface position message (5<TC<8), \\\n airb... | Calculate NIC, navigation integrity category, for ADS-B version 2
Args:
msg (string): 28 bytes hexadecimal message string
NICa (int or string): NIC supplement - A
NICbc (int or srting): NIC supplement - B or C
Returns:
int or string: Horizontal Radius of Containment | [
"Calculate",
"NIC",
"navigation",
"integrity",
"category",
"for",
"ADS",
"-",
"B",
"version",
"2"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L311-L345 |
234,547 | junzis/pyModeS | pyModeS/decoder/adsb.py | nic_s | def nic_s(msg):
"""Obtain NIC supplement bit, TC=31 message
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NICs number (0 or 1)
"""
tc = typecode(msg)
if tc != 31:
raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg)
... | python | def nic_s(msg):
"""Obtain NIC supplement bit, TC=31 message
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NICs number (0 or 1)
"""
tc = typecode(msg)
if tc != 31:
raise RuntimeError("%s: Not a status operation message, expecting TC = 31" % msg)
... | [
"def",
"nic_s",
"(",
"msg",
")",
":",
"tc",
"=",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"!=",
"31",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a status operation message, expecting TC = 31\"",
"%",
"msg",
")",
"msgbin",
"=",
"common",
".",
"hex2bin",
"(... | Obtain NIC supplement bit, TC=31 message
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NICs number (0 or 1) | [
"Obtain",
"NIC",
"supplement",
"bit",
"TC",
"=",
"31",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L348-L365 |
234,548 | junzis/pyModeS | pyModeS/decoder/adsb.py | nic_b | def nic_b(msg):
"""Obtain NICb, navigation integrity category supplement-b
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NICb number (0 or 1)
"""
tc = typecode(msg)
if tc < 9 or tc > 18:
raise RuntimeError("%s: Not a airborne position message, e... | python | def nic_b(msg):
"""Obtain NICb, navigation integrity category supplement-b
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NICb number (0 or 1)
"""
tc = typecode(msg)
if tc < 9 or tc > 18:
raise RuntimeError("%s: Not a airborne position message, e... | [
"def",
"nic_b",
"(",
"msg",
")",
":",
"tc",
"=",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"<",
"9",
"or",
"tc",
">",
"18",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a airborne position message, expecting 8<TC<19\"",
"%",
"msg",
")",
"msgbin",
"=",
"com... | Obtain NICb, navigation integrity category supplement-b
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: NICb number (0 or 1) | [
"Obtain",
"NICb",
"navigation",
"integrity",
"category",
"supplement",
"-",
"b"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L389-L406 |
234,549 | junzis/pyModeS | pyModeS/decoder/adsb.py | nac_p | def nac_p(msg):
"""Calculate NACp, Navigation Accuracy Category - Position
Args:
msg (string): 28 bytes hexadecimal message string, TC = 29 or 31
Returns:
int or string: 95% horizontal accuracy bounds, Estimated Position Uncertainty
int or string: 95% vertical accuracy bounds, Vert... | python | def nac_p(msg):
"""Calculate NACp, Navigation Accuracy Category - Position
Args:
msg (string): 28 bytes hexadecimal message string, TC = 29 or 31
Returns:
int or string: 95% horizontal accuracy bounds, Estimated Position Uncertainty
int or string: 95% vertical accuracy bounds, Vert... | [
"def",
"nac_p",
"(",
"msg",
")",
":",
"tc",
"=",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"not",
"in",
"[",
"29",
",",
"31",
"]",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a target state and status message, \\\n or operation status mess... | Calculate NACp, Navigation Accuracy Category - Position
Args:
msg (string): 28 bytes hexadecimal message string, TC = 29 or 31
Returns:
int or string: 95% horizontal accuracy bounds, Estimated Position Uncertainty
int or string: 95% vertical accuracy bounds, Vertical Estimated Position... | [
"Calculate",
"NACp",
"Navigation",
"Accuracy",
"Category",
"-",
"Position"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L409-L438 |
234,550 | junzis/pyModeS | pyModeS/decoder/adsb.py | nac_v | def nac_v(msg):
"""Calculate NACv, Navigation Accuracy Category - Velocity
Args:
msg (string): 28 bytes hexadecimal message string, TC = 19
Returns:
int or string: 95% horizontal accuracy bounds for velocity, Horizontal Figure of Merit
int or string: 95% vertical accuracy bounds fo... | python | def nac_v(msg):
"""Calculate NACv, Navigation Accuracy Category - Velocity
Args:
msg (string): 28 bytes hexadecimal message string, TC = 19
Returns:
int or string: 95% horizontal accuracy bounds for velocity, Horizontal Figure of Merit
int or string: 95% vertical accuracy bounds fo... | [
"def",
"nac_v",
"(",
"msg",
")",
":",
"tc",
"=",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"!=",
"19",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not an airborne velocity message, expecting TC = 19\"",
"%",
"msg",
")",
"msgbin",
"=",
"common",
".",
"hex2bin",
... | Calculate NACv, Navigation Accuracy Category - Velocity
Args:
msg (string): 28 bytes hexadecimal message string, TC = 19
Returns:
int or string: 95% horizontal accuracy bounds for velocity, Horizontal Figure of Merit
int or string: 95% vertical accuracy bounds for velocity, Vertical Fi... | [
"Calculate",
"NACv",
"Navigation",
"Accuracy",
"Category",
"-",
"Velocity"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L441-L465 |
234,551 | junzis/pyModeS | pyModeS/decoder/adsb.py | sil | def sil(msg, version):
"""Calculate SIL, Surveillance Integrity Level
Args:
msg (string): 28 bytes hexadecimal message string with TC = 29, 31
Returns:
int or string: Probability of exceeding Horizontal Radius of Containment RCu
int or string: Probability of exceeding Vertical Inte... | python | def sil(msg, version):
"""Calculate SIL, Surveillance Integrity Level
Args:
msg (string): 28 bytes hexadecimal message string with TC = 29, 31
Returns:
int or string: Probability of exceeding Horizontal Radius of Containment RCu
int or string: Probability of exceeding Vertical Inte... | [
"def",
"sil",
"(",
"msg",
",",
"version",
")",
":",
"tc",
"=",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"not",
"in",
"[",
"29",
",",
"31",
"]",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a target state and status messag, \\\n or oper... | Calculate SIL, Surveillance Integrity Level
Args:
msg (string): 28 bytes hexadecimal message string with TC = 29, 31
Returns:
int or string: Probability of exceeding Horizontal Radius of Containment RCu
int or string: Probability of exceeding Vertical Integrity Containment Region VPL
... | [
"Calculate",
"SIL",
"Surveillance",
"Integrity",
"Level"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/adsb.py#L468-L511 |
234,552 | junzis/pyModeS | pyModeS/decoder/bds/bds50.py | roll50 | def roll50(msg):
"""Roll angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
float: angle in degrees,
negative->left wing down, positive->right wing down
"""
d = hex2bin(data(msg))
if d[0] == '0':
return None
... | python | def roll50(msg):
"""Roll angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
float: angle in degrees,
negative->left wing down, positive->right wing down
"""
d = hex2bin(data(msg))
if d[0] == '0':
return None
... | [
"def",
"roll50",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"0",
"]",
"==",
"'0'",
":",
"return",
"None",
"sign",
"=",
"int",
"(",
"d",
"[",
"1",
"]",
")",
"# 1 -> left wing down",
"value",
"="... | Roll angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
float: angle in degrees,
negative->left wing down, positive->right wing down | [
"Roll",
"angle",
"BDS",
"5",
"0",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds50.py#L76-L98 |
234,553 | junzis/pyModeS | pyModeS/decoder/bds/bds50.py | trk50 | def trk50(msg):
"""True track angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
float: angle in degrees to true north (from 0 to 360)
"""
d = hex2bin(data(msg))
if d[11] == '0':
return None
sign = int(d[12]) # 1 -> w... | python | def trk50(msg):
"""True track angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
float: angle in degrees to true north (from 0 to 360)
"""
d = hex2bin(data(msg))
if d[11] == '0':
return None
sign = int(d[12]) # 1 -> w... | [
"def",
"trk50",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"11",
"]",
"==",
"'0'",
":",
"return",
"None",
"sign",
"=",
"int",
"(",
"d",
"[",
"12",
"]",
")",
"# 1 -> west",
"value",
"=",
"bin2... | True track angle, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
float: angle in degrees to true north (from 0 to 360) | [
"True",
"track",
"angle",
"BDS",
"5",
"0",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds50.py#L101-L127 |
234,554 | junzis/pyModeS | pyModeS/decoder/bds/bds50.py | gs50 | def gs50(msg):
"""Ground speed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
int: ground speed in knots
"""
d = hex2bin(data(msg))
if d[23] == '0':
return None
spd = bin2int(d[24:34]) * 2 # kts
return spd | python | def gs50(msg):
"""Ground speed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
int: ground speed in knots
"""
d = hex2bin(data(msg))
if d[23] == '0':
return None
spd = bin2int(d[24:34]) * 2 # kts
return spd | [
"def",
"gs50",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"23",
"]",
"==",
"'0'",
":",
"return",
"None",
"spd",
"=",
"bin2int",
"(",
"d",
"[",
"24",
":",
"34",
"]",
")",
"*",
"2",
"# kts",
... | Ground speed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
int: ground speed in knots | [
"Ground",
"speed",
"BDS",
"5",
"0",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds50.py#L130-L145 |
234,555 | junzis/pyModeS | pyModeS/decoder/bds/bds50.py | tas50 | def tas50(msg):
"""Aircraft true airspeed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
int: true airspeed in knots
"""
d = hex2bin(data(msg))
if d[45] == '0':
return None
tas = bin2int(d[46:56]) * 2 # kts
return t... | python | def tas50(msg):
"""Aircraft true airspeed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
int: true airspeed in knots
"""
d = hex2bin(data(msg))
if d[45] == '0':
return None
tas = bin2int(d[46:56]) * 2 # kts
return t... | [
"def",
"tas50",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"45",
"]",
"==",
"'0'",
":",
"return",
"None",
"tas",
"=",
"bin2int",
"(",
"d",
"[",
"46",
":",
"56",
"]",
")",
"*",
"2",
"# kts",... | Aircraft true airspeed, BDS 5,0 message
Args:
msg (String): 28 bytes hexadecimal message (BDS50) string
Returns:
int: true airspeed in knots | [
"Aircraft",
"true",
"airspeed",
"BDS",
"5",
"0",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds50.py#L174-L189 |
234,556 | junzis/pyModeS | pyModeS/decoder/bds/bds53.py | ias53 | def ias53(msg):
"""Indicated airspeed, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
int: indicated arispeed in knots
"""
d = hex2bin(data(msg))
if d[12] == '0':
return None
ias = bin2int(d[13:23]) # knots
return ias | python | def ias53(msg):
"""Indicated airspeed, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
int: indicated arispeed in knots
"""
d = hex2bin(data(msg))
if d[12] == '0':
return None
ias = bin2int(d[13:23]) # knots
return ias | [
"def",
"ias53",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"12",
"]",
"==",
"'0'",
":",
"return",
"None",
"ias",
"=",
"bin2int",
"(",
"d",
"[",
"13",
":",
"23",
"]",
")",
"# knots",
"return",... | Indicated airspeed, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
int: indicated arispeed in knots | [
"Indicated",
"airspeed",
"DBS",
"5",
"3",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds53.py#L106-L121 |
234,557 | junzis/pyModeS | pyModeS/decoder/bds/bds53.py | mach53 | def mach53(msg):
"""MACH number, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
float: MACH number
"""
d = hex2bin(data(msg))
if d[23] == '0':
return None
mach = bin2int(d[24:33]) * 0.008
return round(mach, 3) | python | def mach53(msg):
"""MACH number, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
float: MACH number
"""
d = hex2bin(data(msg))
if d[23] == '0':
return None
mach = bin2int(d[24:33]) * 0.008
return round(mach, 3) | [
"def",
"mach53",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"23",
"]",
"==",
"'0'",
":",
"return",
"None",
"mach",
"=",
"bin2int",
"(",
"d",
"[",
"24",
":",
"33",
"]",
")",
"*",
"0.008",
"r... | MACH number, DBS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
float: MACH number | [
"MACH",
"number",
"DBS",
"5",
"3",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds53.py#L124-L139 |
234,558 | junzis/pyModeS | pyModeS/decoder/bds/bds53.py | tas53 | def tas53(msg):
"""Aircraft true airspeed, BDS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
float: true airspeed in knots
"""
d = hex2bin(data(msg))
if d[33] == '0':
return None
tas = bin2int(d[34:46]) * 0.5 # kts
return round(tas, 1... | python | def tas53(msg):
"""Aircraft true airspeed, BDS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
float: true airspeed in knots
"""
d = hex2bin(data(msg))
if d[33] == '0':
return None
tas = bin2int(d[34:46]) * 0.5 # kts
return round(tas, 1... | [
"def",
"tas53",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"33",
"]",
"==",
"'0'",
":",
"return",
"None",
"tas",
"=",
"bin2int",
"(",
"d",
"[",
"34",
":",
"46",
"]",
")",
"*",
"0.5",
"# kts... | Aircraft true airspeed, BDS 5,3 message
Args:
msg (String): 28 bytes hexadecimal message
Returns:
float: true airspeed in knots | [
"Aircraft",
"true",
"airspeed",
"BDS",
"5",
"3",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds53.py#L142-L157 |
234,559 | junzis/pyModeS | pyModeS/extra/tcpclient.py | BaseClient.read_skysense_buffer | def read_skysense_buffer(self):
"""Skysense stream format.
::
----------------------------------------------------------------------------------
Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS
--------------------------------------... | python | def read_skysense_buffer(self):
"""Skysense stream format.
::
----------------------------------------------------------------------------------
Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS
--------------------------------------... | [
"def",
"read_skysense_buffer",
"(",
"self",
")",
":",
"SS_MSGLENGTH",
"=",
"24",
"SS_STARTCHAR",
"=",
"0x24",
"if",
"len",
"(",
"self",
".",
"buffer",
")",
"<=",
"SS_MSGLENGTH",
":",
"return",
"None",
"messages",
"=",
"[",
"]",
"while",
"len",
"(",
"self... | Skysense stream format.
::
----------------------------------------------------------------------------------
Field SS MS MS MS MS MS MS MS MS MS MS MS MS MS MS TS TS TS TS TS TS RS RS RS
---------------------------------------------------------------------------------... | [
"Skysense",
"stream",
"format",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/tcpclient.py#L147-L233 |
234,560 | junzis/pyModeS | pyModeS/decoder/bds/bds10.py | is10 | def is10(msg):
"""Check if a message is likely to be BDS code 1,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# first 8 bits must be 0x10
if d[0:8] != '00010000... | python | def is10(msg):
"""Check if a message is likely to be BDS code 1,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# first 8 bits must be 0x10
if d[0:8] != '00010000... | [
"def",
"is10",
"(",
"msg",
")",
":",
"if",
"allzeros",
"(",
"msg",
")",
":",
"return",
"False",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"# first 8 bits must be 0x10",
"if",
"d",
"[",
"0",
":",
"8",
"]",
"!=",
"'00010000'",
":",
"ret... | Check if a message is likely to be BDS code 1,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"Check",
"if",
"a",
"message",
"is",
"likely",
"to",
"be",
"BDS",
"code",
"1",
"0"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds10.py#L24-L53 |
234,561 | junzis/pyModeS | pyModeS/decoder/bds/bds17.py | is17 | def is17(msg):
"""Check if a message is likely to be BDS code 1,7
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
if bin2int(d[28:56]) != 0:
return False
c... | python | def is17(msg):
"""Check if a message is likely to be BDS code 1,7
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
if bin2int(d[28:56]) != 0:
return False
c... | [
"def",
"is17",
"(",
"msg",
")",
":",
"if",
"allzeros",
"(",
"msg",
")",
":",
"return",
"False",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"bin2int",
"(",
"d",
"[",
"28",
":",
"56",
"]",
")",
"!=",
"0",
":",
"return",
"Fals... | Check if a message is likely to be BDS code 1,7
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"Check",
"if",
"a",
"message",
"is",
"likely",
"to",
"be",
"BDS",
"code",
"1",
"7"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds17.py#L27-L56 |
234,562 | junzis/pyModeS | pyModeS/decoder/bds/bds17.py | cap17 | def cap17(msg):
"""Extract capacities from BDS 1,7 message
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
list: list of suport BDS codes
"""
allbds = ['05', '06', '07', '08', '09', '0A', '20', '21', '40', '41',
'42', '43', '44', '45', '48', '50', '51... | python | def cap17(msg):
"""Extract capacities from BDS 1,7 message
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
list: list of suport BDS codes
"""
allbds = ['05', '06', '07', '08', '09', '0A', '20', '21', '40', '41',
'42', '43', '44', '45', '48', '50', '51... | [
"def",
"cap17",
"(",
"msg",
")",
":",
"allbds",
"=",
"[",
"'05'",
",",
"'06'",
",",
"'07'",
",",
"'08'",
",",
"'09'",
",",
"'0A'",
",",
"'20'",
",",
"'21'",
",",
"'40'",
",",
"'41'",
",",
"'42'",
",",
"'43'",
",",
"'44'",
",",
"'45'",
",",
"'... | Extract capacities from BDS 1,7 message
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
list: list of suport BDS codes | [
"Extract",
"capacities",
"from",
"BDS",
"1",
"7",
"message"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds17.py#L58-L75 |
234,563 | junzis/pyModeS | pyModeS/streamer/stream.py | Stream.get_aircraft | def get_aircraft(self):
"""all aircraft that are stored in memeory"""
acs = self.acs
icaos = list(acs.keys())
for icao in icaos:
if acs[icao]['lat'] is None:
acs.pop(icao)
return acs | python | def get_aircraft(self):
"""all aircraft that are stored in memeory"""
acs = self.acs
icaos = list(acs.keys())
for icao in icaos:
if acs[icao]['lat'] is None:
acs.pop(icao)
return acs | [
"def",
"get_aircraft",
"(",
"self",
")",
":",
"acs",
"=",
"self",
".",
"acs",
"icaos",
"=",
"list",
"(",
"acs",
".",
"keys",
"(",
")",
")",
"for",
"icao",
"in",
"icaos",
":",
"if",
"acs",
"[",
"icao",
"]",
"[",
"'lat'",
"]",
"is",
"None",
":",
... | all aircraft that are stored in memeory | [
"all",
"aircraft",
"that",
"are",
"stored",
"in",
"memeory"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/streamer/stream.py#L248-L255 |
234,564 | junzis/pyModeS | pyModeS/decoder/bds/bds09.py | altitude_diff | def altitude_diff(msg):
"""Decode the differece between GNSS and barometric altitude
Args:
msg (string): 28 bytes hexadecimal message string, TC=19
Returns:
int: Altitude difference in ft. Negative value indicates GNSS altitude
below barometric altitude.
"""
tc = common... | python | def altitude_diff(msg):
"""Decode the differece between GNSS and barometric altitude
Args:
msg (string): 28 bytes hexadecimal message string, TC=19
Returns:
int: Altitude difference in ft. Negative value indicates GNSS altitude
below barometric altitude.
"""
tc = common... | [
"def",
"altitude_diff",
"(",
"msg",
")",
":",
"tc",
"=",
"common",
".",
"typecode",
"(",
"msg",
")",
"if",
"tc",
"!=",
"19",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a airborne velocity message, expecting TC=19\"",
"%",
"msg",
")",
"msgbin",
"=",
"common"... | Decode the differece between GNSS and barometric altitude
Args:
msg (string): 28 bytes hexadecimal message string, TC=19
Returns:
int: Altitude difference in ft. Negative value indicates GNSS altitude
below barometric altitude. | [
"Decode",
"the",
"differece",
"between",
"GNSS",
"and",
"barometric",
"altitude"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds09.py#L93-L115 |
234,565 | junzis/pyModeS | pyModeS/decoder/bds/__init__.py | is50or60 | def is50or60(msg, spd_ref, trk_ref, alt_ref):
"""Use reference ground speed and trk to determine BDS50 and DBS60.
Args:
msg (String): 28 bytes hexadecimal message string
spd_ref (float): reference speed (ADS-B ground speed), kts
trk_ref (float): reference track (ADS-B track angle), deg
... | python | def is50or60(msg, spd_ref, trk_ref, alt_ref):
"""Use reference ground speed and trk to determine BDS50 and DBS60.
Args:
msg (String): 28 bytes hexadecimal message string
spd_ref (float): reference speed (ADS-B ground speed), kts
trk_ref (float): reference track (ADS-B track angle), deg
... | [
"def",
"is50or60",
"(",
"msg",
",",
"spd_ref",
",",
"trk_ref",
",",
"alt_ref",
")",
":",
"def",
"vxy",
"(",
"v",
",",
"angle",
")",
":",
"vx",
"=",
"v",
"*",
"np",
".",
"sin",
"(",
"np",
".",
"radians",
"(",
"angle",
")",
")",
"vy",
"=",
"v",... | Use reference ground speed and trk to determine BDS50 and DBS60.
Args:
msg (String): 28 bytes hexadecimal message string
spd_ref (float): reference speed (ADS-B ground speed), kts
trk_ref (float): reference track (ADS-B track angle), deg
alt_ref (float): reference altitude (ADS-B al... | [
"Use",
"reference",
"ground",
"speed",
"and",
"trk",
"to",
"determine",
"BDS50",
"and",
"DBS60",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/__init__.py#L30-L89 |
234,566 | junzis/pyModeS | pyModeS/decoder/bds/__init__.py | infer | def infer(msg, mrar=False):
"""Estimate the most likely BDS code of an message.
Args:
msg (String): 28 bytes hexadecimal message string
mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False.
Returns:
String or None: BDS version, or possible versions, or None if ... | python | def infer(msg, mrar=False):
"""Estimate the most likely BDS code of an message.
Args:
msg (String): 28 bytes hexadecimal message string
mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False.
Returns:
String or None: BDS version, or possible versions, or None if ... | [
"def",
"infer",
"(",
"msg",
",",
"mrar",
"=",
"False",
")",
":",
"df",
"=",
"common",
".",
"df",
"(",
"msg",
")",
"if",
"common",
".",
"allzeros",
"(",
"msg",
")",
":",
"return",
"'EMPTY'",
"# For ADS-B / Mode-S extended squitter",
"if",
"df",
"==",
"1... | Estimate the most likely BDS code of an message.
Args:
msg (String): 28 bytes hexadecimal message string
mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False.
Returns:
String or None: BDS version, or possible versions, or None if nothing matches. | [
"Estimate",
"the",
"most",
"likely",
"BDS",
"code",
"of",
"an",
"message",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/__init__.py#L92-L154 |
234,567 | junzis/pyModeS | pyModeS/decoder/bds/bds40.py | is40 | def is40(msg):
"""Check if a message is likely to be BDS code 4,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 1, 14, and 27
if wrongstatus(d, 1, 2... | python | def is40(msg):
"""Check if a message is likely to be BDS code 4,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 1, 14, and 27
if wrongstatus(d, 1, 2... | [
"def",
"is40",
"(",
"msg",
")",
":",
"if",
"allzeros",
"(",
"msg",
")",
":",
"return",
"False",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"# status bit 1, 14, and 27",
"if",
"wrongstatus",
"(",
"d",
",",
"1",
",",
"2",
",",
"13",
")",... | Check if a message is likely to be BDS code 4,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"Check",
"if",
"a",
"message",
"is",
"likely",
"to",
"be",
"BDS",
"code",
"4",
"0"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds40.py#L25-L65 |
234,568 | junzis/pyModeS | pyModeS/decoder/bds/bds40.py | alt40fms | def alt40fms(msg):
"""Selected altitude, FMS
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
int: altitude in feet
"""
d = hex2bin(data(msg))
if d[13] == '0':
return None
alt = bin2int(d[14:26]) * 16 # ft
return alt | python | def alt40fms(msg):
"""Selected altitude, FMS
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
int: altitude in feet
"""
d = hex2bin(data(msg))
if d[13] == '0':
return None
alt = bin2int(d[14:26]) * 16 # ft
return alt | [
"def",
"alt40fms",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"13",
"]",
"==",
"'0'",
":",
"return",
"None",
"alt",
"=",
"bin2int",
"(",
"d",
"[",
"14",
":",
"26",
"]",
")",
"*",
"16",
"# f... | Selected altitude, FMS
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
int: altitude in feet | [
"Selected",
"altitude",
"FMS"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds40.py#L86-L101 |
234,569 | junzis/pyModeS | pyModeS/decoder/bds/bds40.py | p40baro | def p40baro(msg):
"""Barometric pressure setting
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
float: pressure in millibar
"""
d = hex2bin(data(msg))
if d[26] == '0':
return None
p = bin2int(d[27:39]) * 0.1 + 800 # millibar
return... | python | def p40baro(msg):
"""Barometric pressure setting
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
float: pressure in millibar
"""
d = hex2bin(data(msg))
if d[26] == '0':
return None
p = bin2int(d[27:39]) * 0.1 + 800 # millibar
return... | [
"def",
"p40baro",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"26",
"]",
"==",
"'0'",
":",
"return",
"None",
"p",
"=",
"bin2int",
"(",
"d",
"[",
"27",
":",
"39",
"]",
")",
"*",
"0.1",
"+",
... | Barometric pressure setting
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
float: pressure in millibar | [
"Barometric",
"pressure",
"setting"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds40.py#L104-L119 |
234,570 | junzis/pyModeS | pyModeS/decoder/bds/bds44.py | is44 | def is44(msg):
"""Check if a message is likely to be BDS code 4,4.
Meteorological routine air report
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 5... | python | def is44(msg):
"""Check if a message is likely to be BDS code 4,4.
Meteorological routine air report
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 5... | [
"def",
"is44",
"(",
"msg",
")",
":",
"if",
"allzeros",
"(",
"msg",
")",
":",
"return",
"False",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"# status bit 5, 35, 47, 50",
"if",
"wrongstatus",
"(",
"d",
",",
"5",
",",
"6",
",",
"23",
")",... | Check if a message is likely to be BDS code 4,4.
Meteorological routine air report
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"Check",
"if",
"a",
"message",
"is",
"likely",
"to",
"be",
"BDS",
"code",
"4",
"4",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds44.py#L25-L67 |
234,571 | junzis/pyModeS | pyModeS/decoder/bds/bds44.py | wind44 | def wind44(msg):
"""Wind speed and direction.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
(int, float): speed (kt), direction (degree)
"""
d = hex2bin(data(msg))
status = int(d[4])
if not status:
return None
speed = bin2int(d[5:14]) # k... | python | def wind44(msg):
"""Wind speed and direction.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
(int, float): speed (kt), direction (degree)
"""
d = hex2bin(data(msg))
status = int(d[4])
if not status:
return None
speed = bin2int(d[5:14]) # k... | [
"def",
"wind44",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"status",
"=",
"int",
"(",
"d",
"[",
"4",
"]",
")",
"if",
"not",
"status",
":",
"return",
"None",
"speed",
"=",
"bin2int",
"(",
"d",
"[",
"5",
":",... | Wind speed and direction.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
(int, float): speed (kt), direction (degree) | [
"Wind",
"speed",
"and",
"direction",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds44.py#L70-L89 |
234,572 | junzis/pyModeS | pyModeS/decoder/bds/bds44.py | p44 | def p44(msg):
"""Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa
"""
d = hex2bin(data(msg))
if d[34] == '0':
return None
p = bin2int(d[35:46]) # hPa
return p | python | def p44(msg):
"""Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa
"""
d = hex2bin(data(msg))
if d[34] == '0':
return None
p = bin2int(d[35:46]) # hPa
return p | [
"def",
"p44",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"34",
"]",
"==",
"'0'",
":",
"return",
"None",
"p",
"=",
"bin2int",
"(",
"d",
"[",
"35",
":",
"46",
"]",
")",
"# hPa",
"return",
"p"... | Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa | [
"Static",
"pressure",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds44.py#L121-L138 |
234,573 | junzis/pyModeS | pyModeS/decoder/bds/bds60.py | is60 | def is60(msg):
"""Check if a message is likely to be BDS code 6,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 1, 13, 24, 35, 46
if wrongstatus(d, ... | python | def is60(msg):
"""Check if a message is likely to be BDS code 6,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 1, 13, 24, 35, 46
if wrongstatus(d, ... | [
"def",
"is60",
"(",
"msg",
")",
":",
"if",
"allzeros",
"(",
"msg",
")",
":",
"return",
"False",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"# status bit 1, 13, 24, 35, 46",
"if",
"wrongstatus",
"(",
"d",
",",
"1",
",",
"2",
",",
"12",
... | Check if a message is likely to be BDS code 6,0
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"Check",
"if",
"a",
"message",
"is",
"likely",
"to",
"be",
"BDS",
"code",
"6",
"0"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds60.py#L24-L72 |
234,574 | junzis/pyModeS | pyModeS/decoder/bds/bds60.py | hdg60 | def hdg60(msg):
"""Megnetic heading of aircraft
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
float: heading in degrees to megnetic north (from 0 to 360)
"""
d = hex2bin(data(msg))
if d[0] == '0':
return None
sign = int(d[1]) # 1 -> w... | python | def hdg60(msg):
"""Megnetic heading of aircraft
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
float: heading in degrees to megnetic north (from 0 to 360)
"""
d = hex2bin(data(msg))
if d[0] == '0':
return None
sign = int(d[1]) # 1 -> w... | [
"def",
"hdg60",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"0",
"]",
"==",
"'0'",
":",
"return",
"None",
"sign",
"=",
"int",
"(",
"d",
"[",
"1",
"]",
")",
"# 1 -> west",
"value",
"=",
"bin2in... | Megnetic heading of aircraft
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
float: heading in degrees to megnetic north (from 0 to 360) | [
"Megnetic",
"heading",
"of",
"aircraft"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds60.py#L75-L101 |
234,575 | junzis/pyModeS | pyModeS/decoder/bds/bds60.py | mach60 | def mach60(msg):
"""Aircraft MACH number
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
float: MACH number
"""
d = hex2bin(data(msg))
if d[23] == '0':
return None
mach = bin2int(d[24:34]) * 2.048 / 512.0
return round(mach, 3) | python | def mach60(msg):
"""Aircraft MACH number
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
float: MACH number
"""
d = hex2bin(data(msg))
if d[23] == '0':
return None
mach = bin2int(d[24:34]) * 2.048 / 512.0
return round(mach, 3) | [
"def",
"mach60",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"23",
"]",
"==",
"'0'",
":",
"return",
"None",
"mach",
"=",
"bin2int",
"(",
"d",
"[",
"24",
":",
"34",
"]",
")",
"*",
"2.048",
"/... | Aircraft MACH number
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
float: MACH number | [
"Aircraft",
"MACH",
"number"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds60.py#L122-L137 |
234,576 | junzis/pyModeS | pyModeS/decoder/bds/bds60.py | vr60baro | def vr60baro(msg):
"""Vertical rate from barometric measurement, this value may be very noisy.
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
int: vertical rate in feet/minutes
"""
d = hex2bin(data(msg))
if d[34] == '0':
return None
sign ... | python | def vr60baro(msg):
"""Vertical rate from barometric measurement, this value may be very noisy.
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
int: vertical rate in feet/minutes
"""
d = hex2bin(data(msg))
if d[34] == '0':
return None
sign ... | [
"def",
"vr60baro",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"34",
"]",
"==",
"'0'",
":",
"return",
"None",
"sign",
"=",
"int",
"(",
"d",
"[",
"35",
"]",
")",
"# 1 -> negative value, two's complem... | Vertical rate from barometric measurement, this value may be very noisy.
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string
Returns:
int: vertical rate in feet/minutes | [
"Vertical",
"rate",
"from",
"barometric",
"measurement",
"this",
"value",
"may",
"be",
"very",
"noisy",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds60.py#L140-L163 |
234,577 | junzis/pyModeS | pyModeS/decoder/bds/bds45.py | is45 | def is45(msg):
"""Check if a message is likely to be BDS code 4,5.
Meteorological hazard report
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 1, 4, ... | python | def is45(msg):
"""Check if a message is likely to be BDS code 4,5.
Meteorological hazard report
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
if allzeros(msg):
return False
d = hex2bin(data(msg))
# status bit 1, 4, ... | [
"def",
"is45",
"(",
"msg",
")",
":",
"if",
"allzeros",
"(",
"msg",
")",
":",
"return",
"False",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"# status bit 1, 4, 7, 10, 13, 16, 27, 39",
"if",
"wrongstatus",
"(",
"d",
",",
"1",
",",
"2",
",",
... | Check if a message is likely to be BDS code 4,5.
Meteorological hazard report
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"Check",
"if",
"a",
"message",
"is",
"likely",
"to",
"be",
"BDS",
"code",
"4",
"5",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds45.py#L25-L76 |
234,578 | junzis/pyModeS | pyModeS/decoder/bds/bds45.py | ws45 | def ws45(msg):
"""Wind shear.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
"""
d = hex2bin(data(msg))
if d[3] == '0':
return None
ws = bin2int(d[4:6])
return ws | python | def ws45(msg):
"""Wind shear.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
"""
d = hex2bin(data(msg))
if d[3] == '0':
return None
ws = bin2int(d[4:6])
return ws | [
"def",
"ws45",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"3",
"]",
"==",
"'0'",
":",
"return",
"None",
"ws",
"=",
"bin2int",
"(",
"d",
"[",
"4",
":",
"6",
"]",
")",
"return",
"ws"
] | Wind shear.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe | [
"Wind",
"shear",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds45.py#L97-L112 |
234,579 | junzis/pyModeS | pyModeS/decoder/bds/bds45.py | wv45 | def wv45(msg):
"""Wake vortex.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
"""
d = hex2bin(data(msg))
if d[12] == '0':
return None
ws = bin2int(d[13:15])
return ws | python | def wv45(msg):
"""Wake vortex.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe
"""
d = hex2bin(data(msg))
if d[12] == '0':
return None
ws = bin2int(d[13:15])
return ws | [
"def",
"wv45",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"12",
"]",
"==",
"'0'",
":",
"return",
"None",
"ws",
"=",
"bin2int",
"(",
"d",
"[",
"13",
":",
"15",
"]",
")",
"return",
"ws"
] | Wake vortex.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe | [
"Wake",
"vortex",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds45.py#L151-L166 |
234,580 | junzis/pyModeS | pyModeS/decoder/bds/bds45.py | p45 | def p45(msg):
"""Average static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa
"""
d = hex2bin(data(msg))
if d[26] == '0':
return None
p = bin2int(d[27:38]) # hPa
return p | python | def p45(msg):
"""Average static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa
"""
d = hex2bin(data(msg))
if d[26] == '0':
return None
p = bin2int(d[27:38]) # hPa
return p | [
"def",
"p45",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"26",
"]",
"==",
"'0'",
":",
"return",
"None",
"p",
"=",
"bin2int",
"(",
"d",
"[",
"27",
":",
"38",
"]",
")",
"# hPa",
"return",
"p"... | Average static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa | [
"Average",
"static",
"pressure",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds45.py#L193-L207 |
234,581 | junzis/pyModeS | pyModeS/decoder/bds/bds45.py | rh45 | def rh45(msg):
"""Radio height.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: radio height in ft
"""
d = hex2bin(data(msg))
if d[38] == '0':
return None
rh = bin2int(d[39:51]) * 16
return rh | python | def rh45(msg):
"""Radio height.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: radio height in ft
"""
d = hex2bin(data(msg))
if d[38] == '0':
return None
rh = bin2int(d[39:51]) * 16
return rh | [
"def",
"rh45",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"d",
"[",
"38",
"]",
"==",
"'0'",
":",
"return",
"None",
"rh",
"=",
"bin2int",
"(",
"d",
"[",
"39",
":",
"51",
"]",
")",
"*",
"16",
"return",... | Radio height.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: radio height in ft | [
"Radio",
"height",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds45.py#L210-L224 |
234,582 | junzis/pyModeS | pyModeS/extra/aero.py | vsound | def vsound(H):
"""Speed of sound"""
T = temperature(H)
a = np.sqrt(gamma * R * T)
return a | python | def vsound(H):
"""Speed of sound"""
T = temperature(H)
a = np.sqrt(gamma * R * T)
return a | [
"def",
"vsound",
"(",
"H",
")",
":",
"T",
"=",
"temperature",
"(",
"H",
")",
"a",
"=",
"np",
".",
"sqrt",
"(",
"gamma",
"*",
"R",
"*",
"T",
")",
"return",
"a"
] | Speed of sound | [
"Speed",
"of",
"sound"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L78-L82 |
234,583 | junzis/pyModeS | pyModeS/extra/aero.py | distance | def distance(lat1, lon1, lat2, lon2, H=0):
"""
Compute spherical distance from spherical coordinates.
For two locations in spherical coordinates
(1, theta, phi) and (1, theta', phi')
cosine( arc length ) =
sin phi sin phi' cos(theta-theta') + cos phi cos phi'
distance = rho * arc length
... | python | def distance(lat1, lon1, lat2, lon2, H=0):
"""
Compute spherical distance from spherical coordinates.
For two locations in spherical coordinates
(1, theta, phi) and (1, theta', phi')
cosine( arc length ) =
sin phi sin phi' cos(theta-theta') + cos phi cos phi'
distance = rho * arc length
... | [
"def",
"distance",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
",",
"H",
"=",
"0",
")",
":",
"# phi = 90 - latitude",
"phi1",
"=",
"np",
".",
"radians",
"(",
"90.0",
"-",
"lat1",
")",
"phi2",
"=",
"np",
".",
"radians",
"(",
"90.0",
"-",
"... | Compute spherical distance from spherical coordinates.
For two locations in spherical coordinates
(1, theta, phi) and (1, theta', phi')
cosine( arc length ) =
sin phi sin phi' cos(theta-theta') + cos phi cos phi'
distance = rho * arc length | [
"Compute",
"spherical",
"distance",
"from",
"spherical",
"coordinates",
"."
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L85-L109 |
234,584 | junzis/pyModeS | pyModeS/extra/aero.py | tas2mach | def tas2mach(Vtas, H):
"""True Airspeed to Mach number"""
a = vsound(H)
Mach = Vtas/a
return Mach | python | def tas2mach(Vtas, H):
"""True Airspeed to Mach number"""
a = vsound(H)
Mach = Vtas/a
return Mach | [
"def",
"tas2mach",
"(",
"Vtas",
",",
"H",
")",
":",
"a",
"=",
"vsound",
"(",
"H",
")",
"Mach",
"=",
"Vtas",
"/",
"a",
"return",
"Mach"
] | True Airspeed to Mach number | [
"True",
"Airspeed",
"to",
"Mach",
"number"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L129-L133 |
234,585 | junzis/pyModeS | pyModeS/extra/aero.py | mach2tas | def mach2tas(Mach, H):
"""Mach number to True Airspeed"""
a = vsound(H)
Vtas = Mach*a
return Vtas | python | def mach2tas(Mach, H):
"""Mach number to True Airspeed"""
a = vsound(H)
Vtas = Mach*a
return Vtas | [
"def",
"mach2tas",
"(",
"Mach",
",",
"H",
")",
":",
"a",
"=",
"vsound",
"(",
"H",
")",
"Vtas",
"=",
"Mach",
"*",
"a",
"return",
"Vtas"
] | Mach number to True Airspeed | [
"Mach",
"number",
"to",
"True",
"Airspeed"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L136-L140 |
234,586 | junzis/pyModeS | pyModeS/extra/aero.py | tas2eas | def tas2eas(Vtas, H):
"""True Airspeed to Equivalent Airspeed"""
rho = density(H)
Veas = Vtas * np.sqrt(rho/rho0)
return Veas | python | def tas2eas(Vtas, H):
"""True Airspeed to Equivalent Airspeed"""
rho = density(H)
Veas = Vtas * np.sqrt(rho/rho0)
return Veas | [
"def",
"tas2eas",
"(",
"Vtas",
",",
"H",
")",
":",
"rho",
"=",
"density",
"(",
"H",
")",
"Veas",
"=",
"Vtas",
"*",
"np",
".",
"sqrt",
"(",
"rho",
"/",
"rho0",
")",
"return",
"Veas"
] | True Airspeed to Equivalent Airspeed | [
"True",
"Airspeed",
"to",
"Equivalent",
"Airspeed"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L150-L154 |
234,587 | junzis/pyModeS | pyModeS/extra/aero.py | cas2tas | def cas2tas(Vcas, H):
"""Calibrated Airspeed to True Airspeed"""
p, rho, T = atmos(H)
qdyn = p0*((1.+rho0*Vcas*Vcas/(7.*p0))**3.5-1.)
Vtas = np.sqrt(7.*p/rho*((1.+qdyn/p)**(2./7.)-1.))
return Vtas | python | def cas2tas(Vcas, H):
"""Calibrated Airspeed to True Airspeed"""
p, rho, T = atmos(H)
qdyn = p0*((1.+rho0*Vcas*Vcas/(7.*p0))**3.5-1.)
Vtas = np.sqrt(7.*p/rho*((1.+qdyn/p)**(2./7.)-1.))
return Vtas | [
"def",
"cas2tas",
"(",
"Vcas",
",",
"H",
")",
":",
"p",
",",
"rho",
",",
"T",
"=",
"atmos",
"(",
"H",
")",
"qdyn",
"=",
"p0",
"*",
"(",
"(",
"1.",
"+",
"rho0",
"*",
"Vcas",
"*",
"Vcas",
"/",
"(",
"7.",
"*",
"p0",
")",
")",
"**",
"3.5",
... | Calibrated Airspeed to True Airspeed | [
"Calibrated",
"Airspeed",
"to",
"True",
"Airspeed"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L157-L162 |
234,588 | junzis/pyModeS | pyModeS/extra/aero.py | mach2cas | def mach2cas(Mach, H):
"""Mach number to Calibrated Airspeed"""
Vtas = mach2tas(Mach, H)
Vcas = tas2cas(Vtas, H)
return Vcas | python | def mach2cas(Mach, H):
"""Mach number to Calibrated Airspeed"""
Vtas = mach2tas(Mach, H)
Vcas = tas2cas(Vtas, H)
return Vcas | [
"def",
"mach2cas",
"(",
"Mach",
",",
"H",
")",
":",
"Vtas",
"=",
"mach2tas",
"(",
"Mach",
",",
"H",
")",
"Vcas",
"=",
"tas2cas",
"(",
"Vtas",
",",
"H",
")",
"return",
"Vcas"
] | Mach number to Calibrated Airspeed | [
"Mach",
"number",
"to",
"Calibrated",
"Airspeed"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L173-L177 |
234,589 | junzis/pyModeS | pyModeS/extra/aero.py | cas2mach | def cas2mach(Vcas, H):
"""Calibrated Airspeed to Mach number"""
Vtas = cas2tas(Vcas, H)
Mach = tas2mach(Vtas, H)
return Mach | python | def cas2mach(Vcas, H):
"""Calibrated Airspeed to Mach number"""
Vtas = cas2tas(Vcas, H)
Mach = tas2mach(Vtas, H)
return Mach | [
"def",
"cas2mach",
"(",
"Vcas",
",",
"H",
")",
":",
"Vtas",
"=",
"cas2tas",
"(",
"Vcas",
",",
"H",
")",
"Mach",
"=",
"tas2mach",
"(",
"Vtas",
",",
"H",
")",
"return",
"Mach"
] | Calibrated Airspeed to Mach number | [
"Calibrated",
"Airspeed",
"to",
"Mach",
"number"
] | 8cd5655a04b08171a9ad5f1ffd232b7e0178ea53 | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/extra/aero.py#L180-L184 |
234,590 | agusmakmun/django-markdown-editor | martor/views.py | markdown_search_user | def markdown_search_user(request):
"""
Json usernames of the users registered & actived.
url(method=get):
/martor/search-user/?username={username}
Response:
error:
- `status` is status code (204)
- `error` is error message.
success:
- `status... | python | def markdown_search_user(request):
"""
Json usernames of the users registered & actived.
url(method=get):
/martor/search-user/?username={username}
Response:
error:
- `status` is status code (204)
- `error` is error message.
success:
- `status... | [
"def",
"markdown_search_user",
"(",
"request",
")",
":",
"data",
"=",
"{",
"}",
"username",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'username'",
")",
"if",
"username",
"is",
"not",
"None",
"and",
"username",
"!=",
"''",
"and",
"' '",
"not",
"in",... | Json usernames of the users registered & actived.
url(method=get):
/martor/search-user/?username={username}
Response:
error:
- `status` is status code (204)
- `error` is error message.
success:
- `status` is status code (204)
- `data` is ... | [
"Json",
"usernames",
"of",
"the",
"users",
"registered",
"&",
"actived",
"."
] | 5ef9b947d247d05dfd1d14dff44c5a6e83372985 | https://github.com/agusmakmun/django-markdown-editor/blob/5ef9b947d247d05dfd1d14dff44c5a6e83372985/martor/views.py#L37-L85 |
234,591 | agusmakmun/django-markdown-editor | martor/extensions/mention.py | MentionPattern.handleMatch | def handleMatch(self, m):
username = self.unescape(m.group(2))
"""Makesure `username` is registered and actived."""
if MARTOR_ENABLE_CONFIGS['mention'] == 'true':
if username in [u.username for u in User.objects.exclude(is_active=False)]:
url = '{0}{1}/'.format(MARTO... | python | def handleMatch(self, m):
username = self.unescape(m.group(2))
"""Makesure `username` is registered and actived."""
if MARTOR_ENABLE_CONFIGS['mention'] == 'true':
if username in [u.username for u in User.objects.exclude(is_active=False)]:
url = '{0}{1}/'.format(MARTO... | [
"def",
"handleMatch",
"(",
"self",
",",
"m",
")",
":",
"username",
"=",
"self",
".",
"unescape",
"(",
"m",
".",
"group",
"(",
"2",
")",
")",
"if",
"MARTOR_ENABLE_CONFIGS",
"[",
"'mention'",
"]",
"==",
"'true'",
":",
"if",
"username",
"in",
"[",
"u",
... | Makesure `username` is registered and actived. | [
"Makesure",
"username",
"is",
"registered",
"and",
"actived",
"."
] | 5ef9b947d247d05dfd1d14dff44c5a6e83372985 | https://github.com/agusmakmun/django-markdown-editor/blob/5ef9b947d247d05dfd1d14dff44c5a6e83372985/martor/extensions/mention.py#L24-L35 |
234,592 | agusmakmun/django-markdown-editor | martor/utils.py | markdownify | def markdownify(markdown_content):
"""
Render the markdown content to HTML.
Basic:
>>> from martor.utils import markdownify
>>> content = ""
>>> markdownify(content)
'<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'... | python | def markdownify(markdown_content):
"""
Render the markdown content to HTML.
Basic:
>>> from martor.utils import markdownify
>>> content = ""
>>> markdownify(content)
'<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'... | [
"def",
"markdownify",
"(",
"markdown_content",
")",
":",
"try",
":",
"return",
"markdown",
".",
"markdown",
"(",
"markdown_content",
",",
"safe_mode",
"=",
"MARTOR_MARKDOWN_SAFE_MODE",
",",
"extensions",
"=",
"MARTOR_MARKDOWN_EXTENSIONS",
",",
"extension_configs",
"="... | Render the markdown content to HTML.
Basic:
>>> from martor.utils import markdownify
>>> content = ""
>>> markdownify(content)
'<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'
>>> | [
"Render",
"the",
"markdown",
"content",
"to",
"HTML",
"."
] | 5ef9b947d247d05dfd1d14dff44c5a6e83372985 | https://github.com/agusmakmun/django-markdown-editor/blob/5ef9b947d247d05dfd1d14dff44c5a6e83372985/martor/utils.py#L17-L37 |
234,593 | APSL/puput | puput/urls.py | get_entry_url | def get_entry_url(entry, blog_page, root_page):
"""
Get the entry url given and entry page a blog page instances.
It will use an url or another depending if blog_page is the root page.
"""
if root_page == blog_page:
return reverse('entry_page_serve', kwargs={
'year': entry.date.s... | python | def get_entry_url(entry, blog_page, root_page):
"""
Get the entry url given and entry page a blog page instances.
It will use an url or another depending if blog_page is the root page.
"""
if root_page == blog_page:
return reverse('entry_page_serve', kwargs={
'year': entry.date.s... | [
"def",
"get_entry_url",
"(",
"entry",
",",
"blog_page",
",",
"root_page",
")",
":",
"if",
"root_page",
"==",
"blog_page",
":",
"return",
"reverse",
"(",
"'entry_page_serve'",
",",
"kwargs",
"=",
"{",
"'year'",
":",
"entry",
".",
"date",
".",
"strftime",
"(... | Get the entry url given and entry page a blog page instances.
It will use an url or another depending if blog_page is the root page. | [
"Get",
"the",
"entry",
"url",
"given",
"and",
"entry",
"page",
"a",
"blog",
"page",
"instances",
".",
"It",
"will",
"use",
"an",
"url",
"or",
"another",
"depending",
"if",
"blog_page",
"is",
"the",
"root",
"page",
"."
] | c3294f6bb0dd784f881ce9e3089cbf40d0528e47 | https://github.com/APSL/puput/blob/c3294f6bb0dd784f881ce9e3089cbf40d0528e47/puput/urls.py#L63-L88 |
234,594 | APSL/puput | puput/urls.py | get_feeds_url | def get_feeds_url(blog_page, root_page):
"""
Get the feeds urls a blog page instance.
It will use an url or another depending if blog_page is the root page.
"""
if root_page == blog_page:
return reverse('blog_page_feed')
else:
blog_path = strip_prefix_and_ending_slash(blog_page.s... | python | def get_feeds_url(blog_page, root_page):
"""
Get the feeds urls a blog page instance.
It will use an url or another depending if blog_page is the root page.
"""
if root_page == blog_page:
return reverse('blog_page_feed')
else:
blog_path = strip_prefix_and_ending_slash(blog_page.s... | [
"def",
"get_feeds_url",
"(",
"blog_page",
",",
"root_page",
")",
":",
"if",
"root_page",
"==",
"blog_page",
":",
"return",
"reverse",
"(",
"'blog_page_feed'",
")",
"else",
":",
"blog_path",
"=",
"strip_prefix_and_ending_slash",
"(",
"blog_page",
".",
"specific",
... | Get the feeds urls a blog page instance.
It will use an url or another depending if blog_page is the root page. | [
"Get",
"the",
"feeds",
"urls",
"a",
"blog",
"page",
"instance",
".",
"It",
"will",
"use",
"an",
"url",
"or",
"another",
"depending",
"if",
"blog_page",
"is",
"the",
"root",
"page",
"."
] | c3294f6bb0dd784f881ce9e3089cbf40d0528e47 | https://github.com/APSL/puput/blob/c3294f6bb0dd784f881ce9e3089cbf40d0528e47/puput/urls.py#L91-L100 |
234,595 | cs50/check50 | check50/__main__.py | install_dependencies | def install_dependencies(dependencies, verbose=False):
"""Install all packages in dependency list via pip."""
if not dependencies:
return
stdout = stderr = None if verbose else subprocess.DEVNULL
with tempfile.TemporaryDirectory() as req_dir:
req_file = Path(req_dir) / "requirements.txt... | python | def install_dependencies(dependencies, verbose=False):
"""Install all packages in dependency list via pip."""
if not dependencies:
return
stdout = stderr = None if verbose else subprocess.DEVNULL
with tempfile.TemporaryDirectory() as req_dir:
req_file = Path(req_dir) / "requirements.txt... | [
"def",
"install_dependencies",
"(",
"dependencies",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"not",
"dependencies",
":",
"return",
"stdout",
"=",
"stderr",
"=",
"None",
"if",
"verbose",
"else",
"subprocess",
".",
"DEVNULL",
"with",
"tempfile",
".",
"Tem... | Install all packages in dependency list via pip. | [
"Install",
"all",
"packages",
"in",
"dependency",
"list",
"via",
"pip",
"."
] | 42c1f0c36baa6a24f69742d74551a9ea7a5ceb33 | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/__main__.py#L108-L132 |
234,596 | cs50/check50 | check50/__main__.py | install_translations | def install_translations(config):
"""Add check translations according to ``config`` as a fallback to existing translations"""
if not config:
return
from . import _translation
checks_translation = gettext.translation(domain=config["domain"],
localedi... | python | def install_translations(config):
"""Add check translations according to ``config`` as a fallback to existing translations"""
if not config:
return
from . import _translation
checks_translation = gettext.translation(domain=config["domain"],
localedi... | [
"def",
"install_translations",
"(",
"config",
")",
":",
"if",
"not",
"config",
":",
"return",
"from",
".",
"import",
"_translation",
"checks_translation",
"=",
"gettext",
".",
"translation",
"(",
"domain",
"=",
"config",
"[",
"\"domain\"",
"]",
",",
"localedir... | Add check translations according to ``config`` as a fallback to existing translations | [
"Add",
"check",
"translations",
"according",
"to",
"config",
"as",
"a",
"fallback",
"to",
"existing",
"translations"
] | 42c1f0c36baa6a24f69742d74551a9ea7a5ceb33 | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/__main__.py#L134-L144 |
234,597 | cs50/check50 | check50/api.py | hash | def hash(file):
"""
Hashes file using SHA-256.
:param file: name of file to be hashed
:type file: str
:rtype: str
:raises check50.Failure: if ``file`` does not exist
"""
exists(file)
log(_("hashing {}...").format(file))
# https://stackoverflow.com/a/22058673
with open(fil... | python | def hash(file):
"""
Hashes file using SHA-256.
:param file: name of file to be hashed
:type file: str
:rtype: str
:raises check50.Failure: if ``file`` does not exist
"""
exists(file)
log(_("hashing {}...").format(file))
# https://stackoverflow.com/a/22058673
with open(fil... | [
"def",
"hash",
"(",
"file",
")",
":",
"exists",
"(",
"file",
")",
"log",
"(",
"_",
"(",
"\"hashing {}...\"",
")",
".",
"format",
"(",
"file",
")",
")",
"# https://stackoverflow.com/a/22058673",
"with",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"as",
"f",
... | Hashes file using SHA-256.
:param file: name of file to be hashed
:type file: str
:rtype: str
:raises check50.Failure: if ``file`` does not exist | [
"Hashes",
"file",
"using",
"SHA",
"-",
"256",
"."
] | 42c1f0c36baa6a24f69742d74551a9ea7a5ceb33 | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/api.py#L67-L86 |
234,598 | cs50/check50 | check50/api.py | exists | def exists(*paths):
"""
Assert that all given paths exist.
:params paths: files/directories to be checked for existence
:raises check50.Failure: if any ``path in paths`` does not exist
Example usage::
check50.exists("foo.c", "foo.h")
"""
for path in paths:
log(_("checking... | python | def exists(*paths):
"""
Assert that all given paths exist.
:params paths: files/directories to be checked for existence
:raises check50.Failure: if any ``path in paths`` does not exist
Example usage::
check50.exists("foo.c", "foo.h")
"""
for path in paths:
log(_("checking... | [
"def",
"exists",
"(",
"*",
"paths",
")",
":",
"for",
"path",
"in",
"paths",
":",
"log",
"(",
"_",
"(",
"\"checking that {} exists...\"",
")",
".",
"format",
"(",
"path",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":"... | Assert that all given paths exist.
:params paths: files/directories to be checked for existence
:raises check50.Failure: if any ``path in paths`` does not exist
Example usage::
check50.exists("foo.c", "foo.h") | [
"Assert",
"that",
"all",
"given",
"paths",
"exist",
"."
] | 42c1f0c36baa6a24f69742d74551a9ea7a5ceb33 | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/api.py#L89-L104 |
234,599 | cs50/check50 | check50/api.py | import_checks | def import_checks(path):
"""
Import checks module given relative path.
:param path: relative path from which to import checks module
:type path: str
:returns: the imported module
:raises FileNotFoundError: if ``path / .check50.yaml`` does not exist
:raises yaml.YAMLError: if ``path / .check... | python | def import_checks(path):
"""
Import checks module given relative path.
:param path: relative path from which to import checks module
:type path: str
:returns: the imported module
:raises FileNotFoundError: if ``path / .check50.yaml`` does not exist
:raises yaml.YAMLError: if ``path / .check... | [
"def",
"import_checks",
"(",
"path",
")",
":",
"dir",
"=",
"internal",
".",
"check_dir",
"/",
"path",
"file",
"=",
"internal",
".",
"load_config",
"(",
"dir",
")",
"[",
"\"checks\"",
"]",
"mod",
"=",
"internal",
".",
"import_file",
"(",
"dir",
".",
"na... | Import checks module given relative path.
:param path: relative path from which to import checks module
:type path: str
:returns: the imported module
:raises FileNotFoundError: if ``path / .check50.yaml`` does not exist
:raises yaml.YAMLError: if ``path / .check50.yaml`` is not a valid YAML file
... | [
"Import",
"checks",
"module",
"given",
"relative",
"path",
"."
] | 42c1f0c36baa6a24f69742d74551a9ea7a5ceb33 | https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/api.py#L107-L134 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.