repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
aws/aws-dynamodb-encryption-python
src/dynamodb_encryption_sdk/internal/utils.py
decrypt_get_item
def decrypt_get_item(decrypt_method, crypto_config_method, read_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently decrypt an item after getting it from the table. :param callable decrypt_method: Method to use to decrypt item :param ca...
python
def decrypt_get_item(decrypt_method, crypto_config_method, read_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently decrypt an item after getting it from the table. :param callable decrypt_method: Method to use to decrypt item :param ca...
[ "def", "decrypt_get_item", "(", "decrypt_method", ",", "crypto_config_method", ",", "read_method", ",", "**", "kwargs", ")", ":", "validate_get_arguments", "(", "kwargs", ")", "crypto_config", ",", "ddb_kwargs", "=", "crypto_config_method", "(", "**", "kwargs", ")",...
Transparently decrypt an item after getting it from the table. :param callable decrypt_method: Method to use to decrypt item :param callable crypto_config_method: Method that accepts ``kwargs`` and provides a :class:`CryptoConfig` :param callable read_method: Method that reads from the table :param **k...
[ "Transparently", "decrypt", "an", "item", "after", "getting", "it", "from", "the", "table", "." ]
8de3bbe13df39c59b21bf431010f7acfcf629a2f
https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/utils.py#L197-L217
train
aws/aws-dynamodb-encryption-python
src/dynamodb_encryption_sdk/internal/utils.py
decrypt_batch_get_item
def decrypt_batch_get_item(decrypt_method, crypto_config_method, read_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently decrypt multiple items after getting them in a batch request. :param callable decrypt_method: Method to use to decrypt...
python
def decrypt_batch_get_item(decrypt_method, crypto_config_method, read_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently decrypt multiple items after getting them in a batch request. :param callable decrypt_method: Method to use to decrypt...
[ "def", "decrypt_batch_get_item", "(", "decrypt_method", ",", "crypto_config_method", ",", "read_method", ",", "**", "kwargs", ")", ":", "request_crypto_config", "=", "kwargs", ".", "pop", "(", "\"crypto_config\"", ",", "None", ")", "for", "_table_name", ",", "tabl...
Transparently decrypt multiple items after getting them in a batch request. :param callable decrypt_method: Method to use to decrypt items :param callable crypto_config_method: Method that accepts ``kwargs`` and provides a :class:`CryptoConfig` :param callable read_method: Method that reads from the table ...
[ "Transparently", "decrypt", "multiple", "items", "after", "getting", "them", "in", "a", "batch", "request", "." ]
8de3bbe13df39c59b21bf431010f7acfcf629a2f
https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/utils.py#L220-L248
train
aws/aws-dynamodb-encryption-python
src/dynamodb_encryption_sdk/internal/utils.py
encrypt_put_item
def encrypt_put_item(encrypt_method, crypto_config_method, write_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently encrypt an item before putting it to the table. :param callable encrypt_method: Method to use to encrypt items :param c...
python
def encrypt_put_item(encrypt_method, crypto_config_method, write_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently encrypt an item before putting it to the table. :param callable encrypt_method: Method to use to encrypt items :param c...
[ "def", "encrypt_put_item", "(", "encrypt_method", ",", "crypto_config_method", ",", "write_method", ",", "**", "kwargs", ")", ":", "crypto_config", ",", "ddb_kwargs", "=", "crypto_config_method", "(", "**", "kwargs", ")", "ddb_kwargs", "[", "\"Item\"", "]", "=", ...
Transparently encrypt an item before putting it to the table. :param callable encrypt_method: Method to use to encrypt items :param callable crypto_config_method: Method that accepts ``kwargs`` and provides a :class:`CryptoConfig` :param callable write_method: Method that writes to the table :param **k...
[ "Transparently", "encrypt", "an", "item", "before", "putting", "it", "to", "the", "table", "." ]
8de3bbe13df39c59b21bf431010f7acfcf629a2f
https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/utils.py#L251-L268
train
aws/aws-dynamodb-encryption-python
src/dynamodb_encryption_sdk/internal/utils.py
encrypt_batch_write_item
def encrypt_batch_write_item(encrypt_method, crypto_config_method, write_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently encrypt multiple items before putting them in a batch request. :param callable encrypt_method: Method to use to enc...
python
def encrypt_batch_write_item(encrypt_method, crypto_config_method, write_method, **kwargs): # type: (Callable, Callable, Callable, **Any) -> Dict # TODO: narrow this down """Transparently encrypt multiple items before putting them in a batch request. :param callable encrypt_method: Method to use to enc...
[ "def", "encrypt_batch_write_item", "(", "encrypt_method", ",", "crypto_config_method", ",", "write_method", ",", "**", "kwargs", ")", ":", "request_crypto_config", "=", "kwargs", ".", "pop", "(", "\"crypto_config\"", ",", "None", ")", "table_crypto_configs", "=", "{...
Transparently encrypt multiple items before putting them in a batch request. :param callable encrypt_method: Method to use to encrypt items :param callable crypto_config_method: Method that accepts a table name string and provides a :class:`CryptoConfig` :param callable write_method: Method that writes to ...
[ "Transparently", "encrypt", "multiple", "items", "before", "putting", "them", "in", "a", "batch", "request", "." ]
8de3bbe13df39c59b21bf431010f7acfcf629a2f
https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/utils.py#L271-L304
train
aws/aws-dynamodb-encryption-python
src/dynamodb_encryption_sdk/internal/utils.py
_process_batch_write_response
def _process_batch_write_response(request, response, table_crypto_config): # type: (Dict, Dict, Dict[Text, CryptoConfig]) -> Dict """Handle unprocessed items in the response from a transparently encrypted write. :param dict request: The DynamoDB plaintext request dictionary :param dict response: The Dy...
python
def _process_batch_write_response(request, response, table_crypto_config): # type: (Dict, Dict, Dict[Text, CryptoConfig]) -> Dict """Handle unprocessed items in the response from a transparently encrypted write. :param dict request: The DynamoDB plaintext request dictionary :param dict response: The Dy...
[ "def", "_process_batch_write_response", "(", "request", ",", "response", ",", "table_crypto_config", ")", ":", "try", ":", "unprocessed_items", "=", "response", "[", "\"UnprocessedItems\"", "]", "except", "KeyError", ":", "return", "response", "for", "table_name", "...
Handle unprocessed items in the response from a transparently encrypted write. :param dict request: The DynamoDB plaintext request dictionary :param dict response: The DynamoDB response from the batch operation :param Dict[Text, CryptoConfig] table_crypto_config: table level CryptoConfig used in encrypting...
[ "Handle", "unprocessed", "items", "in", "the", "response", "from", "a", "transparently", "encrypted", "write", "." ]
8de3bbe13df39c59b21bf431010f7acfcf629a2f
https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/utils.py#L307-L344
train
aws/aws-dynamodb-encryption-python
src/dynamodb_encryption_sdk/internal/utils.py
_item_attributes_match
def _item_attributes_match(crypto_config, plaintext_item, encrypted_item): # type: (CryptoConfig, Dict, Dict) -> Bool """Determines whether the unencrypted values in the plaintext items attributes are the same as those in the encrypted item. Essentially this uses brute force to cover when we don't know the ...
python
def _item_attributes_match(crypto_config, plaintext_item, encrypted_item): # type: (CryptoConfig, Dict, Dict) -> Bool """Determines whether the unencrypted values in the plaintext items attributes are the same as those in the encrypted item. Essentially this uses brute force to cover when we don't know the ...
[ "def", "_item_attributes_match", "(", "crypto_config", ",", "plaintext_item", ",", "encrypted_item", ")", ":", "for", "name", ",", "value", "in", "plaintext_item", ".", "items", "(", ")", ":", "if", "crypto_config", ".", "attribute_actions", ".", "action", "(", ...
Determines whether the unencrypted values in the plaintext items attributes are the same as those in the encrypted item. Essentially this uses brute force to cover when we don't know the primary and sort index attribute names, since they can't be encrypted. :param CryptoConfig crypto_config: CryptoConfig u...
[ "Determines", "whether", "the", "unencrypted", "values", "in", "the", "plaintext", "items", "attributes", "are", "the", "same", "as", "those", "in", "the", "encrypted", "item", ".", "Essentially", "this", "uses", "brute", "force", "to", "cover", "when", "we", ...
8de3bbe13df39c59b21bf431010f7acfcf629a2f
https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/utils.py#L368-L389
train
Mic92/python-mpd2
mpd/asyncio.py
CommandResult._feed_line
def _feed_line(self, line): """Put the given line into the callback machinery, and set the result on a None line.""" if line is None: self.set_result(self._callback(self.__spooled_lines)) else: self.__spooled_lines.append(line)
python
def _feed_line(self, line): """Put the given line into the callback machinery, and set the result on a None line.""" if line is None: self.set_result(self._callback(self.__spooled_lines)) else: self.__spooled_lines.append(line)
[ "def", "_feed_line", "(", "self", ",", "line", ")", ":", "if", "line", "is", "None", ":", "self", ".", "set_result", "(", "self", ".", "_callback", "(", "self", ".", "__spooled_lines", ")", ")", "else", ":", "self", ".", "__spooled_lines", ".", "append...
Put the given line into the callback machinery, and set the result on a None line.
[ "Put", "the", "given", "line", "into", "the", "callback", "machinery", "and", "set", "the", "result", "on", "a", "None", "line", "." ]
fc2782009915d9b642ceef6e4d3b52fa6168998b
https://github.com/Mic92/python-mpd2/blob/fc2782009915d9b642ceef6e4d3b52fa6168998b/mpd/asyncio.py#L45-L50
train
Mic92/python-mpd2
mpd/base.py
mpd_command_provider
def mpd_command_provider(cls): """Decorator hooking up registered MPD commands to concrete client implementation. A class using this decorator must inherit from ``MPDClientBase`` and implement it's ``add_command`` function. """ def collect(cls, callbacks=dict()): """Collect MPD command ...
python
def mpd_command_provider(cls): """Decorator hooking up registered MPD commands to concrete client implementation. A class using this decorator must inherit from ``MPDClientBase`` and implement it's ``add_command`` function. """ def collect(cls, callbacks=dict()): """Collect MPD command ...
[ "def", "mpd_command_provider", "(", "cls", ")", ":", "def", "collect", "(", "cls", ",", "callbacks", "=", "dict", "(", ")", ")", ":", "for", "name", ",", "ob", "in", "cls", ".", "__dict__", ".", "items", "(", ")", ":", "if", "hasattr", "(", "ob", ...
Decorator hooking up registered MPD commands to concrete client implementation. A class using this decorator must inherit from ``MPDClientBase`` and implement it's ``add_command`` function.
[ "Decorator", "hooking", "up", "registered", "MPD", "commands", "to", "concrete", "client", "implementation", "." ]
fc2782009915d9b642ceef6e4d3b52fa6168998b
https://github.com/Mic92/python-mpd2/blob/fc2782009915d9b642ceef6e4d3b52fa6168998b/mpd/base.py#L133-L159
train
Mic92/python-mpd2
mpd/base.py
_create_callback
def _create_callback(self, function, wrap_result): """Create MPD command related response callback. """ if not isinstance(function, Callable): return None def command_callback(): # command result callback expects response from MPD as iterable lines, # thus read available lines fr...
python
def _create_callback(self, function, wrap_result): """Create MPD command related response callback. """ if not isinstance(function, Callable): return None def command_callback(): # command result callback expects response from MPD as iterable lines, # thus read available lines fr...
[ "def", "_create_callback", "(", "self", ",", "function", ",", "wrap_result", ")", ":", "if", "not", "isinstance", "(", "function", ",", "Callable", ")", ":", "return", "None", "def", "command_callback", "(", ")", ":", "res", "=", "function", "(", "self", ...
Create MPD command related response callback.
[ "Create", "MPD", "command", "related", "response", "callback", "." ]
fc2782009915d9b642ceef6e4d3b52fa6168998b
https://github.com/Mic92/python-mpd2/blob/fc2782009915d9b642ceef6e4d3b52fa6168998b/mpd/base.py#L360-L373
train
Mic92/python-mpd2
mpd/base.py
_create_command
def _create_command(wrapper, name, return_value, wrap_result): """Create MPD command related function. """ def mpd_command(self, *args): callback = _create_callback(self, return_value, wrap_result) return wrapper(self, name, args, callback) return mpd_command
python
def _create_command(wrapper, name, return_value, wrap_result): """Create MPD command related function. """ def mpd_command(self, *args): callback = _create_callback(self, return_value, wrap_result) return wrapper(self, name, args, callback) return mpd_command
[ "def", "_create_command", "(", "wrapper", ",", "name", ",", "return_value", ",", "wrap_result", ")", ":", "def", "mpd_command", "(", "self", ",", "*", "args", ")", ":", "callback", "=", "_create_callback", "(", "self", ",", "return_value", ",", "wrap_result"...
Create MPD command related function.
[ "Create", "MPD", "command", "related", "function", "." ]
fc2782009915d9b642ceef6e4d3b52fa6168998b
https://github.com/Mic92/python-mpd2/blob/fc2782009915d9b642ceef6e4d3b52fa6168998b/mpd/base.py#L376-L382
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
i4_bit_hi1
def i4_bit_hi1(n): """ i4_bit_hi1 returns the position of the high 1 bit base 2 in an integer. Example: +------+-------------+----- | N | Binary | BIT +------|-------------+----- | 0 | 0 | 0 | 1 | 1 | 1 | 2 | 10 | 2 ...
python
def i4_bit_hi1(n): """ i4_bit_hi1 returns the position of the high 1 bit base 2 in an integer. Example: +------+-------------+----- | N | Binary | BIT +------|-------------+----- | 0 | 0 | 0 | 1 | 1 | 1 | 2 | 10 | 2 ...
[ "def", "i4_bit_hi1", "(", "n", ")", ":", "i", "=", "np", ".", "floor", "(", "n", ")", "bit", "=", "0", "while", "i", ">", "0", ":", "bit", "+=", "1", "i", "//=", "2", "return", "bit" ]
i4_bit_hi1 returns the position of the high 1 bit base 2 in an integer. Example: +------+-------------+----- | N | Binary | BIT +------|-------------+----- | 0 | 0 | 0 | 1 | 1 | 1 | 2 | 10 | 2 | 3 | 11 | 2 ...
[ "i4_bit_hi1", "returns", "the", "position", "of", "the", "high", "1", "bit", "base", "2", "in", "an", "integer", "." ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L26-L67
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
i4_bit_lo0
def i4_bit_lo0(n): """ I4_BIT_LO0 returns the position of the low 0 bit base 2 in an integer. Example: +------+------------+---- | N | Binary | BIT +------+------------+---- | 0 | 0 | 1 | 1 | 1 | 2 | 2 | 10 | 1 | 3...
python
def i4_bit_lo0(n): """ I4_BIT_LO0 returns the position of the low 0 bit base 2 in an integer. Example: +------+------------+---- | N | Binary | BIT +------+------------+---- | 0 | 0 | 1 | 1 | 1 | 2 | 2 | 10 | 1 | 3...
[ "def", "i4_bit_lo0", "(", "n", ")", ":", "bit", "=", "1", "i", "=", "np", ".", "floor", "(", "n", ")", "while", "i", "!=", "2", "*", "(", "i", "//", "2", ")", ":", "bit", "+=", "1", "i", "//=", "2", "return", "bit" ]
I4_BIT_LO0 returns the position of the low 0 bit base 2 in an integer. Example: +------+------------+---- | N | Binary | BIT +------+------------+---- | 0 | 0 | 1 | 1 | 1 | 2 | 2 | 10 | 1 | 3 | 11 | 3 | ...
[ "I4_BIT_LO0", "returns", "the", "position", "of", "the", "low", "0", "bit", "base", "2", "in", "an", "integer", "." ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L70-L111
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
i4_sobol_generate
def i4_sobol_generate(dim_num, n, skip=1): """ i4_sobol_generate generates a Sobol dataset. Parameters: Input, integer dim_num, the spatial dimension. Input, integer N, the number of points to generate. Input, integer SKIP, the number of initial points to skip. Output, real R(M,N),...
python
def i4_sobol_generate(dim_num, n, skip=1): """ i4_sobol_generate generates a Sobol dataset. Parameters: Input, integer dim_num, the spatial dimension. Input, integer N, the number of points to generate. Input, integer SKIP, the number of initial points to skip. Output, real R(M,N),...
[ "def", "i4_sobol_generate", "(", "dim_num", ",", "n", ",", "skip", "=", "1", ")", ":", "r", "=", "np", ".", "full", "(", "(", "n", ",", "dim_num", ")", ",", "np", ".", "nan", ")", "for", "j", "in", "range", "(", "n", ")", ":", "seed", "=", ...
i4_sobol_generate generates a Sobol dataset. Parameters: Input, integer dim_num, the spatial dimension. Input, integer N, the number of points to generate. Input, integer SKIP, the number of initial points to skip. Output, real R(M,N), the points.
[ "i4_sobol_generate", "generates", "a", "Sobol", "dataset", "." ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L114-L130
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
i4_sobol_generate_std_normal
def i4_sobol_generate_std_normal(dim_num, n, skip=1): """ Generates multivariate standard normal quasi-random variables. Parameters: Input, integer dim_num, the spatial dimension. Input, integer n, the number of points to generate. Input, integer SKIP, the number of initial points to skip...
python
def i4_sobol_generate_std_normal(dim_num, n, skip=1): """ Generates multivariate standard normal quasi-random variables. Parameters: Input, integer dim_num, the spatial dimension. Input, integer n, the number of points to generate. Input, integer SKIP, the number of initial points to skip...
[ "def", "i4_sobol_generate_std_normal", "(", "dim_num", ",", "n", ",", "skip", "=", "1", ")", ":", "sobols", "=", "i4_sobol_generate", "(", "dim_num", ",", "n", ",", "skip", ")", "normals", "=", "norm", ".", "ppf", "(", "sobols", ")", "return", "normals" ...
Generates multivariate standard normal quasi-random variables. Parameters: Input, integer dim_num, the spatial dimension. Input, integer n, the number of points to generate. Input, integer SKIP, the number of initial points to skip. Output, real np array of shape (n, dim_num).
[ "Generates", "multivariate", "standard", "normal", "quasi", "-", "random", "variables", "." ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L133-L149
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
i4_uniform
def i4_uniform(a, b, seed): """ i4_uniform returns a scaled pseudorandom I4. Discussion: The pseudorandom number will be scaled to be uniformly distributed between A and B. Reference: Paul Bratley, Bennett Fox, Linus Schrage, A Guide to Simulation, Springer Verlag, pages ...
python
def i4_uniform(a, b, seed): """ i4_uniform returns a scaled pseudorandom I4. Discussion: The pseudorandom number will be scaled to be uniformly distributed between A and B. Reference: Paul Bratley, Bennett Fox, Linus Schrage, A Guide to Simulation, Springer Verlag, pages ...
[ "def", "i4_uniform", "(", "a", ",", "b", ",", "seed", ")", ":", "if", "seed", "==", "0", ":", "print", "(", "'I4_UNIFORM - Fatal error!'", ")", "print", "(", "' Input SEED = 0!'", ")", "seed", "=", "np", ".", "floor", "(", "seed", ")", "a", "=", "ro...
i4_uniform returns a scaled pseudorandom I4. Discussion: The pseudorandom number will be scaled to be uniformly distributed between A and B. Reference: Paul Bratley, Bennett Fox, Linus Schrage, A Guide to Simulation, Springer Verlag, pages 201-202, 1983. Pierre L'Ecuyer, ...
[ "i4_uniform", "returns", "a", "scaled", "pseudorandom", "I4", "." ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L397-L468
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
prime_ge
def prime_ge(n): """ PRIME_GE returns the smallest prime greater than or equal to N. Example: +-----+--------- | N | PRIME_GE +-----+--------- | -10 | 2 | 1 | 2 | 2 | 2 | 3 | 3 | 4 | 5 | 5 | 5 ...
python
def prime_ge(n): """ PRIME_GE returns the smallest prime greater than or equal to N. Example: +-----+--------- | N | PRIME_GE +-----+--------- | -10 | 2 | 1 | 2 | 2 | 2 | 3 | 3 | 4 | 5 | 5 | 5 ...
[ "def", "prime_ge", "(", "n", ")", ":", "p", "=", "max", "(", "np", ".", "ceil", "(", "n", ")", ",", "2", ")", "while", "not", "is_prime", "(", "p", ")", ":", "p", "+=", "1", "return", "p" ]
PRIME_GE returns the smallest prime greater than or equal to N. Example: +-----+--------- | N | PRIME_GE +-----+--------- | -10 | 2 | 1 | 2 | 2 | 2 | 3 | 3 | 4 | 5 | 5 | 5 | 6 | 7 | 7 ...
[ "PRIME_GE", "returns", "the", "smallest", "prime", "greater", "than", "or", "equal", "to", "N", "." ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L471-L501
train
naught101/sobol_seq
sobol_seq/sobol_seq.py
is_prime
def is_prime(n): """ is_prime returns True if N is a prime number, False otherwise Parameters: Input, integer N, the number to be checked. Output, boolean value, True or False """ if n != int(n) or n < 2: return False if n == 2 or n == 3: return True if n % 2 ...
python
def is_prime(n): """ is_prime returns True if N is a prime number, False otherwise Parameters: Input, integer N, the number to be checked. Output, boolean value, True or False """ if n != int(n) or n < 2: return False if n == 2 or n == 3: return True if n % 2 ...
[ "def", "is_prime", "(", "n", ")", ":", "if", "n", "!=", "int", "(", "n", ")", "or", "n", "<", "2", ":", "return", "False", "if", "n", "==", "2", "or", "n", "==", "3", ":", "return", "True", "if", "n", "%", "2", "==", "0", "or", "n", "%", ...
is_prime returns True if N is a prime number, False otherwise Parameters: Input, integer N, the number to be checked. Output, boolean value, True or False
[ "is_prime", "returns", "True", "if", "N", "is", "a", "prime", "number", "False", "otherwise" ]
6ac1799818a1b9a359a5fc86517173584fe34613
https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L504-L526
train
davedoesdev/python-jwt
python_jwt/__init__.py
generate_jwt
def generate_jwt(claims, priv_key=None, algorithm='PS512', lifetime=None, expires=None, not_before=None, jti_size=16, other_headers=None): """ Generate a JSON Web Token. :param claims: The claims you want included in the signature. :type claims: dict ...
python
def generate_jwt(claims, priv_key=None, algorithm='PS512', lifetime=None, expires=None, not_before=None, jti_size=16, other_headers=None): """ Generate a JSON Web Token. :param claims: The claims you want included in the signature. :type claims: dict ...
[ "def", "generate_jwt", "(", "claims", ",", "priv_key", "=", "None", ",", "algorithm", "=", "'PS512'", ",", "lifetime", "=", "None", ",", "expires", "=", "None", ",", "not_before", "=", "None", ",", "jti_size", "=", "16", ",", "other_headers", "=", "None"...
Generate a JSON Web Token. :param claims: The claims you want included in the signature. :type claims: dict :param priv_key: The private key to be used to sign the token. Note: if you pass ``None`` then the token will be returned with an empty cryptographic signature and :obj:`algorithm` will be forced to...
[ "Generate", "a", "JSON", "Web", "Token", "." ]
5c753a26955cc666f00f6ff8e601406d95071368
https://github.com/davedoesdev/python-jwt/blob/5c753a26955cc666f00f6ff8e601406d95071368/python_jwt/__init__.py#L17-L96
train
davedoesdev/python-jwt
python_jwt/__init__.py
verify_jwt
def verify_jwt(jwt, pub_key=None, allowed_algs=None, iat_skew=timedelta(), checks_optional=False, ignore_not_implemented=False): """ Verify a JSON Web Token. :param jwt: The JSON Web Token to verify. :type jwt: str or unicode ...
python
def verify_jwt(jwt, pub_key=None, allowed_algs=None, iat_skew=timedelta(), checks_optional=False, ignore_not_implemented=False): """ Verify a JSON Web Token. :param jwt: The JSON Web Token to verify. :type jwt: str or unicode ...
[ "def", "verify_jwt", "(", "jwt", ",", "pub_key", "=", "None", ",", "allowed_algs", "=", "None", ",", "iat_skew", "=", "timedelta", "(", ")", ",", "checks_optional", "=", "False", ",", "ignore_not_implemented", "=", "False", ")", ":", "if", "allowed_algs", ...
Verify a JSON Web Token. :param jwt: The JSON Web Token to verify. :type jwt: str or unicode :param pub_key: The public key to be used to verify the token. Note: if you pass ``None`` and **allowed_algs** contains ``none`` then the token's signature will not be verified. :type pub_key: `jwcrypto.jwk.JW...
[ "Verify", "a", "JSON", "Web", "Token", "." ]
5c753a26955cc666f00f6ff8e601406d95071368
https://github.com/davedoesdev/python-jwt/blob/5c753a26955cc666f00f6ff8e601406d95071368/python_jwt/__init__.py#L100-L205
train
davedoesdev/python-jwt
python_jwt/__init__.py
process_jwt
def process_jwt(jwt): """ Process a JSON Web Token without verifying it. Call this before :func:`verify_jwt` if you need access to the header or claims in the token before verifying it. For example, the claims might identify the issuer such that you can retrieve the appropriate public key. :param jwt:...
python
def process_jwt(jwt): """ Process a JSON Web Token without verifying it. Call this before :func:`verify_jwt` if you need access to the header or claims in the token before verifying it. For example, the claims might identify the issuer such that you can retrieve the appropriate public key. :param jwt:...
[ "def", "process_jwt", "(", "jwt", ")", ":", "header", ",", "claims", ",", "_", "=", "jwt", ".", "split", "(", "'.'", ")", "parsed_header", "=", "json_decode", "(", "base64url_decode", "(", "header", ")", ")", "parsed_claims", "=", "json_decode", "(", "ba...
Process a JSON Web Token without verifying it. Call this before :func:`verify_jwt` if you need access to the header or claims in the token before verifying it. For example, the claims might identify the issuer such that you can retrieve the appropriate public key. :param jwt: The JSON Web Token to verify. ...
[ "Process", "a", "JSON", "Web", "Token", "without", "verifying", "it", "." ]
5c753a26955cc666f00f6ff8e601406d95071368
https://github.com/davedoesdev/python-jwt/blob/5c753a26955cc666f00f6ff8e601406d95071368/python_jwt/__init__.py#L209-L224
train
davedoesdev/python-jwt
bench/unitbench.py
Benchmark.run
def run(self, reporter=None): """This should generally not be overloaded. Runs the benchmark functions that are found in the child class. """ if not reporter: reporter = ConsoleReporter() benchmarks = sorted(self._find_benchmarks()) reporter.write_titles(map(self._...
python
def run(self, reporter=None): """This should generally not be overloaded. Runs the benchmark functions that are found in the child class. """ if not reporter: reporter = ConsoleReporter() benchmarks = sorted(self._find_benchmarks()) reporter.write_titles(map(self._...
[ "def", "run", "(", "self", ",", "reporter", "=", "None", ")", ":", "if", "not", "reporter", ":", "reporter", "=", "ConsoleReporter", "(", ")", "benchmarks", "=", "sorted", "(", "self", ".", "_find_benchmarks", "(", ")", ")", "reporter", ".", "write_title...
This should generally not be overloaded. Runs the benchmark functions that are found in the child class.
[ "This", "should", "generally", "not", "be", "overloaded", ".", "Runs", "the", "benchmark", "functions", "that", "are", "found", "in", "the", "child", "class", "." ]
5c753a26955cc666f00f6ff8e601406d95071368
https://github.com/davedoesdev/python-jwt/blob/5c753a26955cc666f00f6ff8e601406d95071368/bench/unitbench.py#L165-L185
train
davedoesdev/python-jwt
bench/unitbench.py
Benchmark._find_benchmarks
def _find_benchmarks(self): """Return a suite of all tests cases contained in testCaseClass""" def is_bench_method(attrname, prefix="bench"): return attrname.startswith(prefix) and hasattr(getattr(self.__class__, attrname), '__call__') return list(filter(is_bench_method, dir(self...
python
def _find_benchmarks(self): """Return a suite of all tests cases contained in testCaseClass""" def is_bench_method(attrname, prefix="bench"): return attrname.startswith(prefix) and hasattr(getattr(self.__class__, attrname), '__call__') return list(filter(is_bench_method, dir(self...
[ "def", "_find_benchmarks", "(", "self", ")", ":", "def", "is_bench_method", "(", "attrname", ",", "prefix", "=", "\"bench\"", ")", ":", "return", "attrname", ".", "startswith", "(", "prefix", ")", "and", "hasattr", "(", "getattr", "(", "self", ".", "__clas...
Return a suite of all tests cases contained in testCaseClass
[ "Return", "a", "suite", "of", "all", "tests", "cases", "contained", "in", "testCaseClass" ]
5c753a26955cc666f00f6ff8e601406d95071368
https://github.com/davedoesdev/python-jwt/blob/5c753a26955cc666f00f6ff8e601406d95071368/bench/unitbench.py#L228-L232
train
ansible/tacacs_plus
tacacs_plus/client.py
TACACSClient.send
def send(self, body, req_type, seq_no=1): """ Send a TACACS+ message body :param body: packed bytes, i.e., `struct.pack(...)` :param req_type: TAC_PLUS_AUTHEN, TAC_PLUS_AUTHOR, TAC_PLUS_ACCT :param seq_no: The sequence numb...
python
def send(self, body, req_type, seq_no=1): """ Send a TACACS+ message body :param body: packed bytes, i.e., `struct.pack(...)` :param req_type: TAC_PLUS_AUTHEN, TAC_PLUS_AUTHOR, TAC_PLUS_ACCT :param seq_no: The sequence numb...
[ "def", "send", "(", "self", ",", "body", ",", "req_type", ",", "seq_no", "=", "1", ")", ":", "header", "=", "TACACSHeader", "(", "self", ".", "version", ",", "req_type", ",", "self", ".", "session_id", ",", "len", "(", "body", ".", "packed", ")", "...
Send a TACACS+ message body :param body: packed bytes, i.e., `struct.pack(...)` :param req_type: TAC_PLUS_AUTHEN, TAC_PLUS_AUTHOR, TAC_PLUS_ACCT :param seq_no: The sequence number of the current packet. The first ...
[ "Send", "a", "TACACS", "+", "message", "body" ]
de0d01372169c8849fa284d75097e57367c8930f
https://github.com/ansible/tacacs_plus/blob/de0d01372169c8849fa284d75097e57367c8930f/tacacs_plus/client.py#L88-L153
train
ansible/tacacs_plus
tacacs_plus/client.py
TACACSClient.authenticate
def authenticate(self, username, password, priv_lvl=TAC_PLUS_PRIV_LVL_MIN, authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII, chap_ppp_id=None, chap_challenge=None, rem_addr=TAC_PLUS_VIRTUAL_REM_ADDR, port=TAC_PLUS_VIRTUAL_PORT): """ Authenticate to a ...
python
def authenticate(self, username, password, priv_lvl=TAC_PLUS_PRIV_LVL_MIN, authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII, chap_ppp_id=None, chap_challenge=None, rem_addr=TAC_PLUS_VIRTUAL_REM_ADDR, port=TAC_PLUS_VIRTUAL_PORT): """ Authenticate to a ...
[ "def", "authenticate", "(", "self", ",", "username", ",", "password", ",", "priv_lvl", "=", "TAC_PLUS_PRIV_LVL_MIN", ",", "authen_type", "=", "TAC_PLUS_AUTHEN_TYPE_ASCII", ",", "chap_ppp_id", "=", "None", ",", "chap_challenge", "=", "None", ",", "rem_addr", "=", ...
Authenticate to a TACACS+ server with a username and password. :param username: :param password: :param priv_lvl: :param authen_type: TAC_PLUS_AUTHEN_TYPE_ASCII, TAC_PLUS_AUTHEN_TYPE_PAP, TAC_PLUS_AUTHEN_TYPE_CHAP ...
[ "Authenticate", "to", "a", "TACACS", "+", "server", "with", "a", "username", "and", "password", "." ]
de0d01372169c8849fa284d75097e57367c8930f
https://github.com/ansible/tacacs_plus/blob/de0d01372169c8849fa284d75097e57367c8930f/tacacs_plus/client.py#L155-L224
train
ansible/tacacs_plus
tacacs_plus/client.py
TACACSClient.authorize
def authorize(self, username, arguments=[], authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII, priv_lvl=TAC_PLUS_PRIV_LVL_MIN, rem_addr=TAC_PLUS_VIRTUAL_REM_ADDR, port=TAC_PLUS_VIRTUAL_PORT): """ Authorize with a TACACS+ server. :param username: :param arguments...
python
def authorize(self, username, arguments=[], authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII, priv_lvl=TAC_PLUS_PRIV_LVL_MIN, rem_addr=TAC_PLUS_VIRTUAL_REM_ADDR, port=TAC_PLUS_VIRTUAL_PORT): """ Authorize with a TACACS+ server. :param username: :param arguments...
[ "def", "authorize", "(", "self", ",", "username", ",", "arguments", "=", "[", "]", ",", "authen_type", "=", "TAC_PLUS_AUTHEN_TYPE_ASCII", ",", "priv_lvl", "=", "TAC_PLUS_PRIV_LVL_MIN", ",", "rem_addr", "=", "TAC_PLUS_VIRTUAL_REM_ADDR", ",", "port", "=", "TAC_PLUS_...
Authorize with a TACACS+ server. :param username: :param arguments: The authorization arguments :param authen_type: TAC_PLUS_AUTHEN_TYPE_ASCII, TAC_PLUS_AUTHEN_TYPE_PAP, TAC_PLUS_AUTHEN_TYPE_CHAP :param priv_lvl: ...
[ "Authorize", "with", "a", "TACACS", "+", "server", "." ]
de0d01372169c8849fa284d75097e57367c8930f
https://github.com/ansible/tacacs_plus/blob/de0d01372169c8849fa284d75097e57367c8930f/tacacs_plus/client.py#L226-L266
train
ansible/tacacs_plus
tacacs_plus/client.py
TACACSClient.account
def account(self, username, flags, arguments=[], authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII, priv_lvl=TAC_PLUS_PRIV_LVL_MIN, rem_addr=TAC_PLUS_VIRTUAL_REM_ADDR, port=TAC_PLUS_VIRTUAL_PORT): """ Account with a TACACS+ server. :param username: :param flags: ...
python
def account(self, username, flags, arguments=[], authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII, priv_lvl=TAC_PLUS_PRIV_LVL_MIN, rem_addr=TAC_PLUS_VIRTUAL_REM_ADDR, port=TAC_PLUS_VIRTUAL_PORT): """ Account with a TACACS+ server. :param username: :param flags: ...
[ "def", "account", "(", "self", ",", "username", ",", "flags", ",", "arguments", "=", "[", "]", ",", "authen_type", "=", "TAC_PLUS_AUTHEN_TYPE_ASCII", ",", "priv_lvl", "=", "TAC_PLUS_PRIV_LVL_MIN", ",", "rem_addr", "=", "TAC_PLUS_VIRTUAL_REM_ADDR", ",", "port", "...
Account with a TACACS+ server. :param username: :param flags: TAC_PLUS_ACCT_FLAG_START, TAC_PLUS_ACCT_FLAG_WATCHDOG, TAC_PLUS_ACCT_FLAG_STOP :param arguments: The authorization arguments :param authen_type: T...
[ "Account", "with", "a", "TACACS", "+", "server", "." ]
de0d01372169c8849fa284d75097e57367c8930f
https://github.com/ansible/tacacs_plus/blob/de0d01372169c8849fa284d75097e57367c8930f/tacacs_plus/client.py#L268-L302
train
IBM-Cloud/gp-python-client
gpclient/gpserviceaccount.py
GPServiceAccount.__get_user_env_vars
def __get_user_env_vars(self): """Return the user defined environment variables""" return (os.environ.get(self.GP_URL_ENV_VAR), os.environ.get(self.GP_INSTANCE_ID_ENV_VAR), os.environ.get(self.GP_USER_ID_ENV_VAR), os.environ.get(self.GP_PASSWORD_ENV_VAR), ...
python
def __get_user_env_vars(self): """Return the user defined environment variables""" return (os.environ.get(self.GP_URL_ENV_VAR), os.environ.get(self.GP_INSTANCE_ID_ENV_VAR), os.environ.get(self.GP_USER_ID_ENV_VAR), os.environ.get(self.GP_PASSWORD_ENV_VAR), ...
[ "def", "__get_user_env_vars", "(", "self", ")", ":", "return", "(", "os", ".", "environ", ".", "get", "(", "self", ".", "GP_URL_ENV_VAR", ")", ",", "os", ".", "environ", ".", "get", "(", "self", ".", "GP_INSTANCE_ID_ENV_VAR", ")", ",", "os", ".", "envi...
Return the user defined environment variables
[ "Return", "the", "user", "defined", "environment", "variables" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpserviceaccount.py#L203-L209
train
IBM-Cloud/gp-python-client
gpclient/gpserviceaccount.py
GPServiceAccount.__parse_vcap_services_env_var
def __parse_vcap_services_env_var(self, serviceInstanceName=None): """Parse the ``VCAP_SERVICES`` env var and search for the necessary values """ vcapServices = os.environ.get(self.__VCAP_SERVICES_ENV_VAR) if not vcapServices: return (None, None, None, None, N...
python
def __parse_vcap_services_env_var(self, serviceInstanceName=None): """Parse the ``VCAP_SERVICES`` env var and search for the necessary values """ vcapServices = os.environ.get(self.__VCAP_SERVICES_ENV_VAR) if not vcapServices: return (None, None, None, None, N...
[ "def", "__parse_vcap_services_env_var", "(", "self", ",", "serviceInstanceName", "=", "None", ")", ":", "vcapServices", "=", "os", ".", "environ", ".", "get", "(", "self", ".", "__VCAP_SERVICES_ENV_VAR", ")", "if", "not", "vcapServices", ":", "return", "(", "N...
Parse the ``VCAP_SERVICES`` env var and search for the necessary values
[ "Parse", "the", "VCAP_SERVICES", "env", "var", "and", "search", "for", "the", "necessary", "values" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpserviceaccount.py#L211-L258
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.__prepare_gprest_call
def __prepare_gprest_call(self, requestURL, params=None, headers=None, restType='GET', body=None): """Returns Authorization type and GP headers """ if self.__serviceAccount.is_iam_enabled(): auth = None iam_api_key_header = { self.__AUTHORIZATION_HEA...
python
def __prepare_gprest_call(self, requestURL, params=None, headers=None, restType='GET', body=None): """Returns Authorization type and GP headers """ if self.__serviceAccount.is_iam_enabled(): auth = None iam_api_key_header = { self.__AUTHORIZATION_HEA...
[ "def", "__prepare_gprest_call", "(", "self", ",", "requestURL", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "restType", "=", "'GET'", ",", "body", "=", "None", ")", ":", "if", "self", ".", "__serviceAccount", ".", "is_iam_enabled", "(", ...
Returns Authorization type and GP headers
[ "Returns", "Authorization", "type", "and", "GP", "headers" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L226-L256
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.__process_gprest_response
def __process_gprest_response(self, r=None, restType='GET'): """Returns the processed response for rest calls """ if r is None: logging.info('No response for REST '+restType+' request') return None httpStatus = r.status_code logging.info('HTTP sta...
python
def __process_gprest_response(self, r=None, restType='GET'): """Returns the processed response for rest calls """ if r is None: logging.info('No response for REST '+restType+' request') return None httpStatus = r.status_code logging.info('HTTP sta...
[ "def", "__process_gprest_response", "(", "self", ",", "r", "=", "None", ",", "restType", "=", "'GET'", ")", ":", "if", "r", "is", "None", ":", "logging", ".", "info", "(", "'No response for REST '", "+", "restType", "+", "' request'", ")", "return", "None"...
Returns the processed response for rest calls
[ "Returns", "the", "processed", "response", "for", "rest", "calls" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L258-L285
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.__perform_rest_call
def __perform_rest_call(self, requestURL, params=None, headers=None, restType='GET', body=None): """Returns the JSON representation of the response if the response status was ok, returns ``None`` otherwise. """ auth, headers = self.__prepare_gprest_call(requestURL, params=params, hea...
python
def __perform_rest_call(self, requestURL, params=None, headers=None, restType='GET', body=None): """Returns the JSON representation of the response if the response status was ok, returns ``None`` otherwise. """ auth, headers = self.__prepare_gprest_call(requestURL, params=params, hea...
[ "def", "__perform_rest_call", "(", "self", ",", "requestURL", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "restType", "=", "'GET'", ",", "body", "=", "None", ")", ":", "auth", ",", "headers", "=", "self", ".", "__prepare_gprest_call", "...
Returns the JSON representation of the response if the response status was ok, returns ``None`` otherwise.
[ "Returns", "the", "JSON", "representation", "of", "the", "response", "if", "the", "response", "status", "was", "ok", "returns", "None", "otherwise", "." ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L287-L301
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.createReaderUser
def createReaderUser(self,accessibleBundles=None): """Creates a new reader user with access to the specified bundle Ids""" url = self.__serviceAccount.get_url() + '/' + \ self.__serviceAccount.get_instance_id()+ '/v2/users/new' headers = {'content-type': 'application/json'}...
python
def createReaderUser(self,accessibleBundles=None): """Creates a new reader user with access to the specified bundle Ids""" url = self.__serviceAccount.get_url() + '/' + \ self.__serviceAccount.get_instance_id()+ '/v2/users/new' headers = {'content-type': 'application/json'}...
[ "def", "createReaderUser", "(", "self", ",", "accessibleBundles", "=", "None", ")", ":", "url", "=", "self", ".", "__serviceAccount", ".", "get_url", "(", ")", "+", "'/'", "+", "self", ".", "__serviceAccount", ".", "get_instance_id", "(", ")", "+", "'/v2/u...
Creates a new reader user with access to the specified bundle Ids
[ "Creates", "a", "new", "reader", "user", "with", "access", "to", "the", "specified", "bundle", "Ids" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L304-L317
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.__has_language
def __has_language(self, bundleId, languageId): """Returns ``True`` if the bundle has the language, ``False`` otherwise """ return True if self.__get_language_data(bundleId=bundleId, languageId=languageId) \ else False
python
def __has_language(self, bundleId, languageId): """Returns ``True`` if the bundle has the language, ``False`` otherwise """ return True if self.__get_language_data(bundleId=bundleId, languageId=languageId) \ else False
[ "def", "__has_language", "(", "self", ",", "bundleId", ",", "languageId", ")", ":", "return", "True", "if", "self", ".", "__get_language_data", "(", "bundleId", "=", "bundleId", ",", "languageId", "=", "languageId", ")", "else", "False" ]
Returns ``True`` if the bundle has the language, ``False`` otherwise
[ "Returns", "True", "if", "the", "bundle", "has", "the", "language", "False", "otherwise" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L387-L392
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.__get_keys_map
def __get_keys_map(self, bundleId, languageId, fallback=False): """Returns key-value pairs for the specified language. If fallback is ``True``, source language value is used if translated value is not available. """ return self.__get_language_data(bundleId=bundleId, ...
python
def __get_keys_map(self, bundleId, languageId, fallback=False): """Returns key-value pairs for the specified language. If fallback is ``True``, source language value is used if translated value is not available. """ return self.__get_language_data(bundleId=bundleId, ...
[ "def", "__get_keys_map", "(", "self", ",", "bundleId", ",", "languageId", ",", "fallback", "=", "False", ")", ":", "return", "self", ".", "__get_language_data", "(", "bundleId", "=", "bundleId", ",", "languageId", "=", "languageId", ",", "fallback", "=", "fa...
Returns key-value pairs for the specified language. If fallback is ``True``, source language value is used if translated value is not available.
[ "Returns", "key", "-", "value", "pairs", "for", "the", "specified", "language", ".", "If", "fallback", "is", "True", "source", "language", "value", "is", "used", "if", "translated", "value", "is", "not", "available", "." ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L394-L400
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.__get_value
def __get_value(self, bundleId, languageId, resourceKey, fallback=False): """Returns the value for the key. If fallback is ``True``, source language value is used if translated value is not available. If the key is not found, returns ``None``. """ resourceEntryData = self.__...
python
def __get_value(self, bundleId, languageId, resourceKey, fallback=False): """Returns the value for the key. If fallback is ``True``, source language value is used if translated value is not available. If the key is not found, returns ``None``. """ resourceEntryData = self.__...
[ "def", "__get_value", "(", "self", ",", "bundleId", ",", "languageId", ",", "resourceKey", ",", "fallback", "=", "False", ")", ":", "resourceEntryData", "=", "self", ".", "__get_resource_entry_data", "(", "bundleId", "=", "bundleId", ",", "languageId", "=", "l...
Returns the value for the key. If fallback is ``True``, source language value is used if translated value is not available. If the key is not found, returns ``None``.
[ "Returns", "the", "value", "for", "the", "key", ".", "If", "fallback", "is", "True", "source", "language", "value", "is", "used", "if", "translated", "value", "is", "not", "available", ".", "If", "the", "key", "is", "not", "found", "returns", "None", "."...
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L402-L415
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.get_avaliable_languages
def get_avaliable_languages(self, bundleId): """Returns a list of avaliable languages in the bundle""" bundleData = self.__get_bundle_data(bundleId) if not bundleData: return [] sourceLanguage = bundleData.get(self.__RESPONSE_SRC_LANGUAGE_KEY) languages = bu...
python
def get_avaliable_languages(self, bundleId): """Returns a list of avaliable languages in the bundle""" bundleData = self.__get_bundle_data(bundleId) if not bundleData: return [] sourceLanguage = bundleData.get(self.__RESPONSE_SRC_LANGUAGE_KEY) languages = bu...
[ "def", "get_avaliable_languages", "(", "self", ",", "bundleId", ")", ":", "bundleData", "=", "self", ".", "__get_bundle_data", "(", "bundleId", ")", "if", "not", "bundleData", ":", "return", "[", "]", "sourceLanguage", "=", "bundleData", ".", "get", "(", "se...
Returns a list of avaliable languages in the bundle
[ "Returns", "a", "list", "of", "avaliable", "languages", "in", "the", "bundle" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L423-L434
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.create_bundle
def create_bundle(self, bundleId, data=None): """Creates a bundle using Globalization Pipeline service""" headers={'content-type':'application/json'} url = self.__get_base_bundle_url() + "/" + bundleId if data is None: data = {} data['sourceLanguage'] = 'en'...
python
def create_bundle(self, bundleId, data=None): """Creates a bundle using Globalization Pipeline service""" headers={'content-type':'application/json'} url = self.__get_base_bundle_url() + "/" + bundleId if data is None: data = {} data['sourceLanguage'] = 'en'...
[ "def", "create_bundle", "(", "self", ",", "bundleId", ",", "data", "=", "None", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/json'", "}", "url", "=", "self", ".", "__get_base_bundle_url", "(", ")", "+", "\"/\"", "+", "bundleId", "if"...
Creates a bundle using Globalization Pipeline service
[ "Creates", "a", "bundle", "using", "Globalization", "Pipeline", "service" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L436-L451
train
IBM-Cloud/gp-python-client
gpclient/gpclient.py
GPClient.update_resource_entry
def update_resource_entry(self, bundleId, languageId, resourceKey, data=None): """Updates the resource entry for a particular key in a target language for a specific bundle in the globalization pipeline""" headers={'content-type':'application/json'} url = self.__get_base_bundle_ur...
python
def update_resource_entry(self, bundleId, languageId, resourceKey, data=None): """Updates the resource entry for a particular key in a target language for a specific bundle in the globalization pipeline""" headers={'content-type':'application/json'} url = self.__get_base_bundle_ur...
[ "def", "update_resource_entry", "(", "self", ",", "bundleId", ",", "languageId", ",", "resourceKey", ",", "data", "=", "None", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/json'", "}", "url", "=", "self", ".", "__get_base_bundle_url", "(...
Updates the resource entry for a particular key in a target language for a specific bundle in the globalization pipeline
[ "Updates", "the", "resource", "entry", "for", "a", "particular", "key", "in", "a", "target", "language", "for", "a", "specific", "bundle", "in", "the", "globalization", "pipeline" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gpclient.py#L480-L489
train
IBM-Cloud/gp-python-client
gpclient/gptranslations.py
GPTranslations.__get_return_value
def __get_return_value(self, messageKey, value): """Determines the return value; used to prevent code duplication """ # if value is not None, return it # otherwise, either use the Translations fallback if there is one, # or return the message key back if value: ...
python
def __get_return_value(self, messageKey, value): """Determines the return value; used to prevent code duplication """ # if value is not None, return it # otherwise, either use the Translations fallback if there is one, # or return the message key back if value: ...
[ "def", "__get_return_value", "(", "self", ",", "messageKey", ",", "value", ")", ":", "if", "value", ":", "return", "value", "else", ":", "if", "self", ".", "_fallback", ":", "return", "self", ".", "_fallback", ".", "gettext", "(", "messageKey", ")", "els...
Determines the return value; used to prevent code duplication
[ "Determines", "the", "return", "value", ";", "used", "to", "prevent", "code", "duplication" ]
082c6cdc250fb61bea99cba8ac3ee855ee77a410
https://github.com/IBM-Cloud/gp-python-client/blob/082c6cdc250fb61bea99cba8ac3ee855ee77a410/gpclient/gptranslations.py#L107-L118
train
FlorianRhiem/pyGLFW
glfw/library.py
_find_library_candidates
def _find_library_candidates(library_names, library_file_extensions, library_search_paths): """ Finds and returns filenames which might be the library you are looking for. """ candidates = set() for library_name in library_names: for ...
python
def _find_library_candidates(library_names, library_file_extensions, library_search_paths): """ Finds and returns filenames which might be the library you are looking for. """ candidates = set() for library_name in library_names: for ...
[ "def", "_find_library_candidates", "(", "library_names", ",", "library_file_extensions", ",", "library_search_paths", ")", ":", "candidates", "=", "set", "(", ")", "for", "library_name", "in", "library_names", ":", "for", "search_path", "in", "library_search_paths", "...
Finds and returns filenames which might be the library you are looking for.
[ "Finds", "and", "returns", "filenames", "which", "might", "be", "the", "library", "you", "are", "looking", "for", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/library.py#L17-L46
train
FlorianRhiem/pyGLFW
glfw/library.py
_load_library
def _load_library(library_names, library_file_extensions, library_search_paths, version_check_callback): """ Finds, loads and returns the most recent version of the library. """ candidates = _find_library_candidates(library_names, library_file_...
python
def _load_library(library_names, library_file_extensions, library_search_paths, version_check_callback): """ Finds, loads and returns the most recent version of the library. """ candidates = _find_library_candidates(library_names, library_file_...
[ "def", "_load_library", "(", "library_names", ",", "library_file_extensions", ",", "library_search_paths", ",", "version_check_callback", ")", ":", "candidates", "=", "_find_library_candidates", "(", "library_names", ",", "library_file_extensions", ",", "library_search_paths"...
Finds, loads and returns the most recent version of the library.
[ "Finds", "loads", "and", "returns", "the", "most", "recent", "version", "of", "the", "library", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/library.py#L49-L66
train
FlorianRhiem/pyGLFW
glfw/library.py
_get_library_search_paths
def _get_library_search_paths(): """ Returns a list of library search paths, considering of the current working directory, default paths and paths from environment variables. """ search_paths = [ '', '/usr/lib64', '/usr/local/lib64', '/usr/lib', '/usr/local/lib', ...
python
def _get_library_search_paths(): """ Returns a list of library search paths, considering of the current working directory, default paths and paths from environment variables. """ search_paths = [ '', '/usr/lib64', '/usr/local/lib64', '/usr/lib', '/usr/local/lib', ...
[ "def", "_get_library_search_paths", "(", ")", ":", "search_paths", "=", "[", "''", ",", "'/usr/lib64'", ",", "'/usr/local/lib64'", ",", "'/usr/lib'", ",", "'/usr/local/lib'", ",", "'/run/current-system/sw/lib'", ",", "'/usr/lib/x86_64-linux-gnu/'", ",", "os", ".", "pa...
Returns a list of library search paths, considering of the current working directory, default paths and paths from environment variables.
[ "Returns", "a", "list", "of", "library", "search", "paths", "considering", "of", "the", "current", "working", "directory", "default", "paths", "and", "paths", "from", "environment", "variables", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/library.py#L123-L144
train
FlorianRhiem/pyGLFW
glfw/__init__.py
_prepare_errcheck
def _prepare_errcheck(): """ This function sets the errcheck attribute of all ctypes wrapped functions to evaluate the _exc_info_from_callback global variable and re-raise any exceptions that might have been raised in callbacks. It also modifies all callback types to automatically wrap the function ...
python
def _prepare_errcheck(): """ This function sets the errcheck attribute of all ctypes wrapped functions to evaluate the _exc_info_from_callback global variable and re-raise any exceptions that might have been raised in callbacks. It also modifies all callback types to automatically wrap the function ...
[ "def", "_prepare_errcheck", "(", ")", ":", "def", "errcheck", "(", "result", ",", "*", "args", ")", ":", "global", "_exc_info_from_callback", "if", "_exc_info_from_callback", "is", "not", "None", ":", "exc", "=", "_exc_info_from_callback", "_exc_info_from_callback",...
This function sets the errcheck attribute of all ctypes wrapped functions to evaluate the _exc_info_from_callback global variable and re-raise any exceptions that might have been raised in callbacks. It also modifies all callback types to automatically wrap the function using the _callback_exception_dec...
[ "This", "function", "sets", "the", "errcheck", "attribute", "of", "all", "ctypes", "wrapped", "functions", "to", "evaluate", "the", "_exc_info_from_callback", "global", "variable", "and", "re", "-", "raise", "any", "exceptions", "that", "might", "have", "been", ...
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L503-L528
train
FlorianRhiem/pyGLFW
glfw/__init__.py
init
def init(): """ Initializes the GLFW library. Wrapper for: int glfwInit(void); """ cwd = _getcwd() res = _glfw.glfwInit() os.chdir(cwd) return res
python
def init(): """ Initializes the GLFW library. Wrapper for: int glfwInit(void); """ cwd = _getcwd() res = _glfw.glfwInit() os.chdir(cwd) return res
[ "def", "init", "(", ")", ":", "cwd", "=", "_getcwd", "(", ")", "res", "=", "_glfw", ".", "glfwInit", "(", ")", "os", ".", "chdir", "(", "cwd", ")", "return", "res" ]
Initializes the GLFW library. Wrapper for: int glfwInit(void);
[ "Initializes", "the", "GLFW", "library", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L599-L609
train
FlorianRhiem/pyGLFW
glfw/__init__.py
terminate
def terminate(): """ Terminates the GLFW library. Wrapper for: void glfwTerminate(void); """ for callback_repository in _callback_repositories: for window_addr in list(callback_repository.keys()): del callback_repository[window_addr] for window_addr in list(_window_...
python
def terminate(): """ Terminates the GLFW library. Wrapper for: void glfwTerminate(void); """ for callback_repository in _callback_repositories: for window_addr in list(callback_repository.keys()): del callback_repository[window_addr] for window_addr in list(_window_...
[ "def", "terminate", "(", ")", ":", "for", "callback_repository", "in", "_callback_repositories", ":", "for", "window_addr", "in", "list", "(", "callback_repository", ".", "keys", "(", ")", ")", ":", "del", "callback_repository", "[", "window_addr", "]", "for", ...
Terminates the GLFW library. Wrapper for: void glfwTerminate(void);
[ "Terminates", "the", "GLFW", "library", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L613-L626
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_version
def get_version(): """ Retrieves the version of the GLFW library. Wrapper for: void glfwGetVersion(int* major, int* minor, int* rev); """ major_value = ctypes.c_int(0) major = ctypes.pointer(major_value) minor_value = ctypes.c_int(0) minor = ctypes.pointer(minor_value) rev_v...
python
def get_version(): """ Retrieves the version of the GLFW library. Wrapper for: void glfwGetVersion(int* major, int* minor, int* rev); """ major_value = ctypes.c_int(0) major = ctypes.pointer(major_value) minor_value = ctypes.c_int(0) minor = ctypes.pointer(minor_value) rev_v...
[ "def", "get_version", "(", ")", ":", "major_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "major", "=", "ctypes", ".", "pointer", "(", "major_value", ")", "minor_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "minor", "=", "ctypes", ".", "...
Retrieves the version of the GLFW library. Wrapper for: void glfwGetVersion(int* major, int* minor, int* rev);
[ "Retrieves", "the", "version", "of", "the", "GLFW", "library", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L632-L646
train
FlorianRhiem/pyGLFW
glfw/__init__.py
_raise_glfw_errors_as_exceptions
def _raise_glfw_errors_as_exceptions(error_code, description): """ Default error callback that raises GLFWError exceptions for glfw errors. Set an alternative error callback or set glfw.ERROR_REPORTING to False to disable this behavior. """ global ERROR_REPORTING if ERROR_REPORTING: ...
python
def _raise_glfw_errors_as_exceptions(error_code, description): """ Default error callback that raises GLFWError exceptions for glfw errors. Set an alternative error callback or set glfw.ERROR_REPORTING to False to disable this behavior. """ global ERROR_REPORTING if ERROR_REPORTING: ...
[ "def", "_raise_glfw_errors_as_exceptions", "(", "error_code", ",", "description", ")", ":", "global", "ERROR_REPORTING", "if", "ERROR_REPORTING", ":", "message", "=", "\"(%d) %s\"", "%", "(", "error_code", ",", "description", ")", "raise", "GLFWError", "(", "message...
Default error callback that raises GLFWError exceptions for glfw errors. Set an alternative error callback or set glfw.ERROR_REPORTING to False to disable this behavior.
[ "Default", "error", "callback", "that", "raises", "GLFWError", "exceptions", "for", "glfw", "errors", ".", "Set", "an", "alternative", "error", "callback", "or", "set", "glfw", ".", "ERROR_REPORTING", "to", "False", "to", "disable", "this", "behavior", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L660-L669
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_monitors
def get_monitors(): """ Returns the currently connected monitors. Wrapper for: GLFWmonitor** glfwGetMonitors(int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetMonitors(count) monitors = [result[i] for i in range(count_value....
python
def get_monitors(): """ Returns the currently connected monitors. Wrapper for: GLFWmonitor** glfwGetMonitors(int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetMonitors(count) monitors = [result[i] for i in range(count_value....
[ "def", "get_monitors", "(", ")", ":", "count_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "count", "=", "ctypes", ".", "pointer", "(", "count_value", ")", "result", "=", "_glfw", ".", "glfwGetMonitors", "(", "count", ")", "monitors", "=", "[", "...
Returns the currently connected monitors. Wrapper for: GLFWmonitor** glfwGetMonitors(int* count);
[ "Returns", "the", "currently", "connected", "monitors", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L698-L709
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_monitor_pos
def get_monitor_pos(monitor): """ Returns the position of the monitor's viewport on the virtual screen. Wrapper for: void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); """ xpos_value = ctypes.c_int(0) xpos = ctypes.pointer(xpos_value) ypos_value = ctypes.c_int(0) ...
python
def get_monitor_pos(monitor): """ Returns the position of the monitor's viewport on the virtual screen. Wrapper for: void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); """ xpos_value = ctypes.c_int(0) xpos = ctypes.pointer(xpos_value) ypos_value = ctypes.c_int(0) ...
[ "def", "get_monitor_pos", "(", "monitor", ")", ":", "xpos_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "xpos", "=", "ctypes", ".", "pointer", "(", "xpos_value", ")", "ypos_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "ypos", "=", "ctypes"...
Returns the position of the monitor's viewport on the virtual screen. Wrapper for: void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
[ "Returns", "the", "position", "of", "the", "monitor", "s", "viewport", "on", "the", "virtual", "screen", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L726-L738
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_monitor_physical_size
def get_monitor_physical_size(monitor): """ Returns the physical size of the monitor. Wrapper for: void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); """ width_value = ctypes.c_int(0) width = ctypes.pointer(width_value) height_value = ctypes.c_int(0) ...
python
def get_monitor_physical_size(monitor): """ Returns the physical size of the monitor. Wrapper for: void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); """ width_value = ctypes.c_int(0) width = ctypes.pointer(width_value) height_value = ctypes.c_int(0) ...
[ "def", "get_monitor_physical_size", "(", "monitor", ")", ":", "width_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "width", "=", "ctypes", ".", "pointer", "(", "width_value", ")", "height_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "height", ...
Returns the physical size of the monitor. Wrapper for: void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
[ "Returns", "the", "physical", "size", "of", "the", "monitor", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L744-L756
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_monitor_callback
def set_monitor_callback(cbfun): """ Sets the monitor configuration callback. Wrapper for: GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); """ global _monitor_callback previous_callback = _monitor_callback if cbfun is None: cbfun = 0 c_cbfun = _GLFWmonitorfu...
python
def set_monitor_callback(cbfun): """ Sets the monitor configuration callback. Wrapper for: GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); """ global _monitor_callback previous_callback = _monitor_callback if cbfun is None: cbfun = 0 c_cbfun = _GLFWmonitorfu...
[ "def", "set_monitor_callback", "(", "cbfun", ")", ":", "global", "_monitor_callback", "previous_callback", "=", "_monitor_callback", "if", "cbfun", "is", "None", ":", "cbfun", "=", "0", "c_cbfun", "=", "_GLFWmonitorfun", "(", "cbfun", ")", "_monitor_callback", "="...
Sets the monitor configuration callback. Wrapper for: GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
[ "Sets", "the", "monitor", "configuration", "callback", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L772-L788
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_video_modes
def get_video_modes(monitor): """ Returns the available video modes for the specified monitor. Wrapper for: const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetVideoModes(...
python
def get_video_modes(monitor): """ Returns the available video modes for the specified monitor. Wrapper for: const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetVideoModes(...
[ "def", "get_video_modes", "(", "monitor", ")", ":", "count_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "count", "=", "ctypes", ".", "pointer", "(", "count_value", ")", "result", "=", "_glfw", ".", "glfwGetVideoModes", "(", "monitor", ",", "count", ...
Returns the available video modes for the specified monitor. Wrapper for: const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
[ "Returns", "the", "available", "video", "modes", "for", "the", "specified", "monitor", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L793-L804
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_gamma_ramp
def set_gamma_ramp(monitor, ramp): """ Sets the current gamma ramp for the specified monitor. Wrapper for: void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); """ gammaramp = _GLFWgammaramp() gammaramp.wrap(ramp) _glfw.glfwSetGammaRamp(monitor, ctypes.pointer(gam...
python
def set_gamma_ramp(monitor, ramp): """ Sets the current gamma ramp for the specified monitor. Wrapper for: void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); """ gammaramp = _GLFWgammaramp() gammaramp.wrap(ramp) _glfw.glfwSetGammaRamp(monitor, ctypes.pointer(gam...
[ "def", "set_gamma_ramp", "(", "monitor", ",", "ramp", ")", ":", "gammaramp", "=", "_GLFWgammaramp", "(", ")", "gammaramp", ".", "wrap", "(", "ramp", ")", "_glfw", ".", "glfwSetGammaRamp", "(", "monitor", ",", "ctypes", ".", "pointer", "(", "gammaramp", ")"...
Sets the current gamma ramp for the specified monitor. Wrapper for: void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
[ "Sets", "the", "current", "gamma", "ramp", "for", "the", "specified", "monitor", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L845-L854
train
FlorianRhiem/pyGLFW
glfw/__init__.py
create_window
def create_window(width, height, title, monitor, share): """ Creates a window and its associated context. Wrapper for: GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); """ return _glfw.glfwCreateWindow(width, height, _to_char_p...
python
def create_window(width, height, title, monitor, share): """ Creates a window and its associated context. Wrapper for: GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); """ return _glfw.glfwCreateWindow(width, height, _to_char_p...
[ "def", "create_window", "(", "width", ",", "height", ",", "title", ",", "monitor", ",", "share", ")", ":", "return", "_glfw", ".", "glfwCreateWindow", "(", "width", ",", "height", ",", "_to_char_p", "(", "title", ")", ",", "monitor", ",", "share", ")" ]
Creates a window and its associated context. Wrapper for: GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
[ "Creates", "a", "window", "and", "its", "associated", "context", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L885-L893
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_window_pos
def get_window_pos(window): """ Retrieves the position of the client area of the specified window. Wrapper for: void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); """ xpos_value = ctypes.c_int(0) xpos = ctypes.pointer(xpos_value) ypos_value = ctypes.c_int(0) ypos =...
python
def get_window_pos(window): """ Retrieves the position of the client area of the specified window. Wrapper for: void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); """ xpos_value = ctypes.c_int(0) xpos = ctypes.pointer(xpos_value) ypos_value = ctypes.c_int(0) ypos =...
[ "def", "get_window_pos", "(", "window", ")", ":", "xpos_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "xpos", "=", "ctypes", ".", "pointer", "(", "xpos_value", ")", "ypos_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "ypos", "=", "ctypes", ...
Retrieves the position of the client area of the specified window. Wrapper for: void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
[ "Retrieves", "the", "position", "of", "the", "client", "area", "of", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L952-L964
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_window_size
def get_window_size(window): """ Retrieves the size of the client area of the specified window. Wrapper for: void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); """ width_value = ctypes.c_int(0) width = ctypes.pointer(width_value) height_value = ctypes.c_int(0) ...
python
def get_window_size(window): """ Retrieves the size of the client area of the specified window. Wrapper for: void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); """ width_value = ctypes.c_int(0) width = ctypes.pointer(width_value) height_value = ctypes.c_int(0) ...
[ "def", "get_window_size", "(", "window", ")", ":", "width_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "width", "=", "ctypes", ".", "pointer", "(", "width_value", ")", "height_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "height", "=", "c...
Retrieves the size of the client area of the specified window. Wrapper for: void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
[ "Retrieves", "the", "size", "of", "the", "client", "area", "of", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L983-L995
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_framebuffer_size
def get_framebuffer_size(window): """ Retrieves the size of the framebuffer of the specified window. Wrapper for: void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); """ width_value = ctypes.c_int(0) width = ctypes.pointer(width_value) height_value = ctypes.c_i...
python
def get_framebuffer_size(window): """ Retrieves the size of the framebuffer of the specified window. Wrapper for: void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); """ width_value = ctypes.c_int(0) width = ctypes.pointer(width_value) height_value = ctypes.c_i...
[ "def", "get_framebuffer_size", "(", "window", ")", ":", "width_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "width", "=", "ctypes", ".", "pointer", "(", "width_value", ")", "height_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "height", "=",...
Retrieves the size of the framebuffer of the specified window. Wrapper for: void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
[ "Retrieves", "the", "size", "of", "the", "framebuffer", "of", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1014-L1026
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_user_pointer
def set_window_user_pointer(window, pointer): """ Sets the user pointer of the specified window. You may pass a normal python object into this function and it will be wrapped automatically. The object will be kept in existence until the pointer is set to something else or until the window is destroyed. ...
python
def set_window_user_pointer(window, pointer): """ Sets the user pointer of the specified window. You may pass a normal python object into this function and it will be wrapped automatically. The object will be kept in existence until the pointer is set to something else or until the window is destroyed. ...
[ "def", "set_window_user_pointer", "(", "window", ",", "pointer", ")", ":", "data", "=", "(", "False", ",", "pointer", ")", "if", "not", "isinstance", "(", "pointer", ",", "ctypes", ".", "c_void_p", ")", ":", "data", "=", "(", "True", ",", "pointer", ")...
Sets the user pointer of the specified window. You may pass a normal python object into this function and it will be wrapped automatically. The object will be kept in existence until the pointer is set to something else or until the window is destroyed. Wrapper for: void glfwSetWindowUserPointer(GL...
[ "Sets", "the", "user", "pointer", "of", "the", "specified", "window", ".", "You", "may", "pass", "a", "normal", "python", "object", "into", "this", "function", "and", "it", "will", "be", "wrapped", "automatically", ".", "The", "object", "will", "be", "kept...
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1099-L1118
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_window_user_pointer
def get_window_user_pointer(window): """ Returns the user pointer of the specified window. Wrapper for: void* glfwGetWindowUserPointer(GLFWwindow* window); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.value ...
python
def get_window_user_pointer(window): """ Returns the user pointer of the specified window. Wrapper for: void* glfwGetWindowUserPointer(GLFWwindow* window); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.value ...
[ "def", "get_window_user_pointer", "(", "window", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents", ".", "value",...
Returns the user pointer of the specified window. Wrapper for: void* glfwGetWindowUserPointer(GLFWwindow* window);
[ "Returns", "the", "user", "pointer", "of", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1122-L1138
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_pos_callback
def set_window_pos_callback(window, cbfun): """ Sets the position callback for the specified window. Wrapper for: GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes...
python
def set_window_pos_callback(window, cbfun): """ Sets the position callback for the specified window. Wrapper for: GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes...
[ "def", "set_window_pos_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents",...
Sets the position callback for the specified window. Wrapper for: GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
[ "Sets", "the", "position", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1145-L1165
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_size_callback
def set_window_size_callback(window, cbfun): """ Sets the size callback for the specified window. Wrapper for: GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes...
python
def set_window_size_callback(window, cbfun): """ Sets the size callback for the specified window. Wrapper for: GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes...
[ "def", "set_window_size_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents"...
Sets the size callback for the specified window. Wrapper for: GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
[ "Sets", "the", "size", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1172-L1192
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_close_callback
def set_window_close_callback(window, cbfun): """ Sets the close callback for the specified window. Wrapper for: GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), c...
python
def set_window_close_callback(window, cbfun): """ Sets the close callback for the specified window. Wrapper for: GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), c...
[ "def", "set_window_close_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents...
Sets the close callback for the specified window. Wrapper for: GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
[ "Sets", "the", "close", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1199-L1219
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_refresh_callback
def set_window_refresh_callback(window, cbfun): """ Sets the refresh callback for the specified window. Wrapper for: GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ...
python
def set_window_refresh_callback(window, cbfun): """ Sets the refresh callback for the specified window. Wrapper for: GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ...
[ "def", "set_window_refresh_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "conten...
Sets the refresh callback for the specified window. Wrapper for: GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
[ "Sets", "the", "refresh", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1226-L1246
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_focus_callback
def set_window_focus_callback(window, cbfun): """ Sets the focus callback for the specified window. Wrapper for: GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), c...
python
def set_window_focus_callback(window, cbfun): """ Sets the focus callback for the specified window. Wrapper for: GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), c...
[ "def", "set_window_focus_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents...
Sets the focus callback for the specified window. Wrapper for: GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
[ "Sets", "the", "focus", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1253-L1273
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_window_iconify_callback
def set_window_iconify_callback(window, cbfun): """ Sets the iconify callback for the specified window. Wrapper for: GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ...
python
def set_window_iconify_callback(window, cbfun): """ Sets the iconify callback for the specified window. Wrapper for: GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ...
[ "def", "set_window_iconify_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "conten...
Sets the iconify callback for the specified window. Wrapper for: GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
[ "Sets", "the", "iconify", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1280-L1300
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_framebuffer_size_callback
def set_framebuffer_size_callback(window, cbfun): """ Sets the framebuffer resize callback for the specified window. Wrapper for: GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ...
python
def set_framebuffer_size_callback(window, cbfun): """ Sets the framebuffer resize callback for the specified window. Wrapper for: GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ...
[ "def", "set_framebuffer_size_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "cont...
Sets the framebuffer resize callback for the specified window. Wrapper for: GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
[ "Sets", "the", "framebuffer", "resize", "callback", "for", "the", "specified", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1307-L1327
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_cursor_pos
def get_cursor_pos(window): """ Retrieves the last reported cursor position, relative to the client area of the window. Wrapper for: void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); """ xpos_value = ctypes.c_double(0.0) xpos = ctypes.pointer(xpos_value) ypo...
python
def get_cursor_pos(window): """ Retrieves the last reported cursor position, relative to the client area of the window. Wrapper for: void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); """ xpos_value = ctypes.c_double(0.0) xpos = ctypes.pointer(xpos_value) ypo...
[ "def", "get_cursor_pos", "(", "window", ")", ":", "xpos_value", "=", "ctypes", ".", "c_double", "(", "0.0", ")", "xpos", "=", "ctypes", ".", "pointer", "(", "xpos_value", ")", "ypos_value", "=", "ctypes", ".", "c_double", "(", "0.0", ")", "ypos", "=", ...
Retrieves the last reported cursor position, relative to the client area of the window. Wrapper for: void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
[ "Retrieves", "the", "last", "reported", "cursor", "position", "relative", "to", "the", "client", "area", "of", "the", "window", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1410-L1423
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_key_callback
def set_key_callback(window, cbfun): """ Sets the key callback. Wrapper for: GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.value if window_a...
python
def set_key_callback(window, cbfun): """ Sets the key callback. Wrapper for: GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.value if window_a...
[ "def", "set_key_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents", ".",...
Sets the key callback. Wrapper for: GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
[ "Sets", "the", "key", "callback", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1443-L1463
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_char_callback
def set_char_callback(window, cbfun): """ Sets the Unicode character callback. Wrapper for: GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.val...
python
def set_char_callback(window, cbfun): """ Sets the Unicode character callback. Wrapper for: GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.val...
[ "def", "set_char_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents", "."...
Sets the Unicode character callback. Wrapper for: GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
[ "Sets", "the", "Unicode", "character", "callback", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1470-L1490
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_mouse_button_callback
def set_mouse_button_callback(window, cbfun): """ Sets the mouse button callback. Wrapper for: GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctyp...
python
def set_mouse_button_callback(window, cbfun): """ Sets the mouse button callback. Wrapper for: GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctyp...
[ "def", "set_mouse_button_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents...
Sets the mouse button callback. Wrapper for: GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
[ "Sets", "the", "mouse", "button", "callback", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1497-L1517
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_cursor_pos_callback
def set_cursor_pos_callback(window, cbfun): """ Sets the cursor position callback. Wrapper for: GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_...
python
def set_cursor_pos_callback(window, cbfun): """ Sets the cursor position callback. Wrapper for: GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_...
[ "def", "set_cursor_pos_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents",...
Sets the cursor position callback. Wrapper for: GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
[ "Sets", "the", "cursor", "position", "callback", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1524-L1544
train
FlorianRhiem/pyGLFW
glfw/__init__.py
set_scroll_callback
def set_scroll_callback(window, cbfun): """ Sets the scroll callback. Wrapper for: GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.value ...
python
def set_scroll_callback(window, cbfun): """ Sets the scroll callback. Wrapper for: GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); """ window_addr = ctypes.cast(ctypes.pointer(window), ctypes.POINTER(ctypes.c_long)).contents.value ...
[ "def", "set_scroll_callback", "(", "window", ",", "cbfun", ")", ":", "window_addr", "=", "ctypes", ".", "cast", "(", "ctypes", ".", "pointer", "(", "window", ")", ",", "ctypes", ".", "POINTER", "(", "ctypes", ".", "c_long", ")", ")", ".", "contents", "...
Sets the scroll callback. Wrapper for: GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
[ "Sets", "the", "scroll", "callback", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1578-L1598
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_joystick_axes
def get_joystick_axes(joy): """ Returns the values of all axes of the specified joystick. Wrapper for: const float* glfwGetJoystickAxes(int joy, int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetJoystickAxes(joy, count) retu...
python
def get_joystick_axes(joy): """ Returns the values of all axes of the specified joystick. Wrapper for: const float* glfwGetJoystickAxes(int joy, int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetJoystickAxes(joy, count) retu...
[ "def", "get_joystick_axes", "(", "joy", ")", ":", "count_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "count", "=", "ctypes", ".", "pointer", "(", "count_value", ")", "result", "=", "_glfw", ".", "glfwGetJoystickAxes", "(", "joy", ",", "count", ")...
Returns the values of all axes of the specified joystick. Wrapper for: const float* glfwGetJoystickAxes(int joy, int* count);
[ "Returns", "the", "values", "of", "all", "axes", "of", "the", "specified", "joystick", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1614-L1624
train
FlorianRhiem/pyGLFW
glfw/__init__.py
get_joystick_buttons
def get_joystick_buttons(joy): """ Returns the state of all buttons of the specified joystick. Wrapper for: const unsigned char* glfwGetJoystickButtons(int joy, int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetJoystickButtons(j...
python
def get_joystick_buttons(joy): """ Returns the state of all buttons of the specified joystick. Wrapper for: const unsigned char* glfwGetJoystickButtons(int joy, int* count); """ count_value = ctypes.c_int(0) count = ctypes.pointer(count_value) result = _glfw.glfwGetJoystickButtons(j...
[ "def", "get_joystick_buttons", "(", "joy", ")", ":", "count_value", "=", "ctypes", ".", "c_int", "(", "0", ")", "count", "=", "ctypes", ".", "pointer", "(", "count_value", ")", "result", "=", "_glfw", ".", "glfwGetJoystickButtons", "(", "joy", ",", "count"...
Returns the state of all buttons of the specified joystick. Wrapper for: const unsigned char* glfwGetJoystickButtons(int joy, int* count);
[ "Returns", "the", "state", "of", "all", "buttons", "of", "the", "specified", "joystick", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1629-L1639
train
FlorianRhiem/pyGLFW
glfw/__init__.py
_GLFWvidmode.unwrap
def unwrap(self): """ Returns a GLFWvidmode object. """ size = self.Size(self.width, self.height) bits = self.Bits(self.red_bits, self.green_bits, self.blue_bits) return self.GLFWvidmode(size, bits, self.refresh_rate)
python
def unwrap(self): """ Returns a GLFWvidmode object. """ size = self.Size(self.width, self.height) bits = self.Bits(self.red_bits, self.green_bits, self.blue_bits) return self.GLFWvidmode(size, bits, self.refresh_rate)
[ "def", "unwrap", "(", "self", ")", ":", "size", "=", "self", ".", "Size", "(", "self", ".", "width", ",", "self", ".", "height", ")", "bits", "=", "self", ".", "Bits", "(", "self", ".", "red_bits", ",", "self", ".", "green_bits", ",", "self", "."...
Returns a GLFWvidmode object.
[ "Returns", "a", "GLFWvidmode", "object", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L118-L124
train
FlorianRhiem/pyGLFW
glfw/__init__.py
_GLFWgammaramp.unwrap
def unwrap(self): """ Returns a GLFWgammaramp object. """ red = [self.red[i] for i in range(self.size)] green = [self.green[i] for i in range(self.size)] blue = [self.blue[i] for i in range(self.size)] if NORMALIZE_GAMMA_RAMPS: red = [value / 65535.0 f...
python
def unwrap(self): """ Returns a GLFWgammaramp object. """ red = [self.red[i] for i in range(self.size)] green = [self.green[i] for i in range(self.size)] blue = [self.blue[i] for i in range(self.size)] if NORMALIZE_GAMMA_RAMPS: red = [value / 65535.0 f...
[ "def", "unwrap", "(", "self", ")", ":", "red", "=", "[", "self", ".", "red", "[", "i", "]", "for", "i", "in", "range", "(", "self", ".", "size", ")", "]", "green", "=", "[", "self", ".", "green", "[", "i", "]", "for", "i", "in", "range", "(...
Returns a GLFWgammaramp object.
[ "Returns", "a", "GLFWgammaramp", "object", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L175-L186
train
FlorianRhiem/pyGLFW
glfw/__init__.py
_GLFWimage.unwrap
def unwrap(self): """ Returns a GLFWimage object. """ pixels = [[[int(c) for c in p] for p in l] for l in self.pixels_array] return self.GLFWimage(self.width, self.height, pixels)
python
def unwrap(self): """ Returns a GLFWimage object. """ pixels = [[[int(c) for c in p] for p in l] for l in self.pixels_array] return self.GLFWimage(self.width, self.height, pixels)
[ "def", "unwrap", "(", "self", ")", ":", "pixels", "=", "[", "[", "[", "int", "(", "c", ")", "for", "c", "in", "p", "]", "for", "p", "in", "l", "]", "for", "l", "in", "self", ".", "pixels_array", "]", "return", "self", ".", "GLFWimage", "(", "...
Returns a GLFWimage object.
[ "Returns", "a", "GLFWimage", "object", "." ]
87767dfbe15ba15d2a8338cdfddf6afc6a25dff5
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L240-L245
train
wadda/gps3
gps3/gps3threaded.py
GPS3mechanism.stream_data
def stream_data(self, host=HOST, port=GPSD_PORT, enable=True, gpsd_protocol=PROTOCOL, devicepath=None): """ Connect and command, point and shoot, flail and bail """ self.socket.connect(host, port) self.socket.watch(enable, gpsd_protocol, devicepath)
python
def stream_data(self, host=HOST, port=GPSD_PORT, enable=True, gpsd_protocol=PROTOCOL, devicepath=None): """ Connect and command, point and shoot, flail and bail """ self.socket.connect(host, port) self.socket.watch(enable, gpsd_protocol, devicepath)
[ "def", "stream_data", "(", "self", ",", "host", "=", "HOST", ",", "port", "=", "GPSD_PORT", ",", "enable", "=", "True", ",", "gpsd_protocol", "=", "PROTOCOL", ",", "devicepath", "=", "None", ")", ":", "self", ".", "socket", ".", "connect", "(", "host",...
Connect and command, point and shoot, flail and bail
[ "Connect", "and", "command", "point", "and", "shoot", "flail", "and", "bail" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/gps3threaded.py#L32-L36
train
wadda/gps3
gps3/gps3threaded.py
GPS3mechanism.unpack_data
def unpack_data(self, usnap=.2): # 2/10th second sleep between empty requests """ Iterates over socket response and unpacks values of object attributes. Sleeping here has the greatest response to cpu cycles short of blocking sockets """ for new_data in self.socket: if new_da...
python
def unpack_data(self, usnap=.2): # 2/10th second sleep between empty requests """ Iterates over socket response and unpacks values of object attributes. Sleeping here has the greatest response to cpu cycles short of blocking sockets """ for new_data in self.socket: if new_da...
[ "def", "unpack_data", "(", "self", ",", "usnap", "=", ".2", ")", ":", "for", "new_data", "in", "self", ".", "socket", ":", "if", "new_data", ":", "self", ".", "data_stream", ".", "unpack", "(", "new_data", ")", "else", ":", "sleep", "(", "usnap", ")"...
Iterates over socket response and unpacks values of object attributes. Sleeping here has the greatest response to cpu cycles short of blocking sockets
[ "Iterates", "over", "socket", "response", "and", "unpacks", "values", "of", "object", "attributes", ".", "Sleeping", "here", "has", "the", "greatest", "response", "to", "cpu", "cycles", "short", "of", "blocking", "sockets" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/gps3threaded.py#L38-L46
train
wadda/gps3
gps3/gps3threaded.py
GPS3mechanism.run_thread
def run_thread(self, usnap=.2, daemon=True): """run thread with data """ # self.stream_data() # Unless other changes are made this would limit to localhost only. try: gps3_data_thread = Thread(target=self.unpack_data, args={usnap: usnap}, daemon=daemon) except TypeErr...
python
def run_thread(self, usnap=.2, daemon=True): """run thread with data """ # self.stream_data() # Unless other changes are made this would limit to localhost only. try: gps3_data_thread = Thread(target=self.unpack_data, args={usnap: usnap}, daemon=daemon) except TypeErr...
[ "def", "run_thread", "(", "self", ",", "usnap", "=", ".2", ",", "daemon", "=", "True", ")", ":", "try", ":", "gps3_data_thread", "=", "Thread", "(", "target", "=", "self", ".", "unpack_data", ",", "args", "=", "{", "usnap", ":", "usnap", "}", ",", ...
run thread with data
[ "run", "thread", "with", "data" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/gps3threaded.py#L48-L58
train
wadda/gps3
examples/human.py
add_args
def add_args(): """Adds commandline arguments and formatted Help""" parser = argparse.ArgumentParser() parser.add_argument('-host', action='store', dest='host', default='127.0.0.1', help='DEFAULT "127.0.0.1"') parser.add_argument('-port', action='store', dest='port', default='2947', help='DEFAULT 2947'...
python
def add_args(): """Adds commandline arguments and formatted Help""" parser = argparse.ArgumentParser() parser.add_argument('-host', action='store', dest='host', default='127.0.0.1', help='DEFAULT "127.0.0.1"') parser.add_argument('-port', action='store', dest='port', default='2947', help='DEFAULT 2947'...
[ "def", "add_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-host'", ",", "action", "=", "'store'", ",", "dest", "=", "'host'", ",", "default", "=", "'127.0.0.1'", ",", "help", "=", ...
Adds commandline arguments and formatted Help
[ "Adds", "commandline", "arguments", "and", "formatted", "Help" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/human.py#L39-L57
train
wadda/gps3
examples/human.py
make_time
def make_time(gps_datetime_str): """Makes datetime object from string object""" if not 'n/a' == gps_datetime_str: datetime_string = gps_datetime_str datetime_object = datetime.strptime(datetime_string, "%Y-%m-%dT%H:%M:%S") return datetime_object
python
def make_time(gps_datetime_str): """Makes datetime object from string object""" if not 'n/a' == gps_datetime_str: datetime_string = gps_datetime_str datetime_object = datetime.strptime(datetime_string, "%Y-%m-%dT%H:%M:%S") return datetime_object
[ "def", "make_time", "(", "gps_datetime_str", ")", ":", "if", "not", "'n/a'", "==", "gps_datetime_str", ":", "datetime_string", "=", "gps_datetime_str", "datetime_object", "=", "datetime", ".", "strptime", "(", "datetime_string", ",", "\"%Y-%m-%dT%H:%M:%S\"", ")", "r...
Makes datetime object from string object
[ "Makes", "datetime", "object", "from", "string", "object" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/human.py#L81-L86
train
wadda/gps3
examples/human.py
elapsed_time_from
def elapsed_time_from(start_time): """calculate time delta from latched time and current time""" time_then = make_time(start_time) time_now = datetime.utcnow().replace(microsecond=0) if time_then is None: return delta_t = time_now - time_then return delta_t
python
def elapsed_time_from(start_time): """calculate time delta from latched time and current time""" time_then = make_time(start_time) time_now = datetime.utcnow().replace(microsecond=0) if time_then is None: return delta_t = time_now - time_then return delta_t
[ "def", "elapsed_time_from", "(", "start_time", ")", ":", "time_then", "=", "make_time", "(", "start_time", ")", "time_now", "=", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "microsecond", "=", "0", ")", "if", "time_then", "is", "None", ":", ...
calculate time delta from latched time and current time
[ "calculate", "time", "delta", "from", "latched", "time", "and", "current", "time" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/human.py#L89-L96
train
wadda/gps3
examples/human.py
unit_conversion
def unit_conversion(thing, units, length=False): """converts base data between metric, imperial, or nautical units""" if 'n/a' == thing: return 'n/a' try: thing = round(thing * CONVERSION[units][0 + length], 2) except TypeError: thing = 'fubar' return thing, CONVERSION[units]...
python
def unit_conversion(thing, units, length=False): """converts base data between metric, imperial, or nautical units""" if 'n/a' == thing: return 'n/a' try: thing = round(thing * CONVERSION[units][0 + length], 2) except TypeError: thing = 'fubar' return thing, CONVERSION[units]...
[ "def", "unit_conversion", "(", "thing", ",", "units", ",", "length", "=", "False", ")", ":", "if", "'n/a'", "==", "thing", ":", "return", "'n/a'", "try", ":", "thing", "=", "round", "(", "thing", "*", "CONVERSION", "[", "units", "]", "[", "0", "+", ...
converts base data between metric, imperial, or nautical units
[ "converts", "base", "data", "between", "metric", "imperial", "or", "nautical", "units" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/human.py#L99-L107
train
wadda/gps3
examples/human.py
shut_down
def shut_down(): """Closes connection and restores terminal""" curses.nocbreak() curses.echo() curses.endwin() gpsd_socket.close() print('Keyboard interrupt received\nTerminated by user\nGood Bye.\n') sys.exit(1)
python
def shut_down(): """Closes connection and restores terminal""" curses.nocbreak() curses.echo() curses.endwin() gpsd_socket.close() print('Keyboard interrupt received\nTerminated by user\nGood Bye.\n') sys.exit(1)
[ "def", "shut_down", "(", ")", ":", "curses", ".", "nocbreak", "(", ")", "curses", ".", "echo", "(", ")", "curses", ".", "endwin", "(", ")", "gpsd_socket", ".", "close", "(", ")", "print", "(", "'Keyboard interrupt received\\nTerminated by user\\nGood Bye.\\n'", ...
Closes connection and restores terminal
[ "Closes", "connection", "and", "restores", "terminal" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/human.py#L292-L299
train
wadda/gps3
gps3/gps3.py
GPSDSocket.close
def close(self): """turn off stream and close socket""" if self.streamSock: self.watch(enable=False) self.streamSock.close() self.streamSock = None
python
def close(self): """turn off stream and close socket""" if self.streamSock: self.watch(enable=False) self.streamSock.close() self.streamSock = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "streamSock", ":", "self", ".", "watch", "(", "enable", "=", "False", ")", "self", ".", "streamSock", ".", "close", "(", ")", "self", ".", "streamSock", "=", "None" ]
turn off stream and close socket
[ "turn", "off", "stream", "and", "close", "socket" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/gps3.py#L128-L133
train
wadda/gps3
examples/ahuman.py
show_nmea
def show_nmea(): """NMEA output in curses terminal""" data_window = curses.newwin(24, 79, 0, 0) for new_data in gpsd_socket: if new_data: screen.nodelay(1) key_press = screen.getch() if key_press == ord('q'): shut_down() elif key_press...
python
def show_nmea(): """NMEA output in curses terminal""" data_window = curses.newwin(24, 79, 0, 0) for new_data in gpsd_socket: if new_data: screen.nodelay(1) key_press = screen.getch() if key_press == ord('q'): shut_down() elif key_press...
[ "def", "show_nmea", "(", ")", ":", "data_window", "=", "curses", ".", "newwin", "(", "24", ",", "79", ",", "0", ",", "0", ")", "for", "new_data", "in", "gpsd_socket", ":", "if", "new_data", ":", "screen", ".", "nodelay", "(", "1", ")", "key_press", ...
NMEA output in curses terminal
[ "NMEA", "output", "in", "curses", "terminal" ]
91adcd7073b891b135b2a46d039ce2125cf09a09
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/ahuman.py#L270-L290
train
batiste/django-page-cms
pages/widgets_registry.py
register_widget
def register_widget(widget): """ Register the given widget as a candidate to use in placeholder. """ if widget in registry: raise WidgetAlreadyRegistered( _('The widget %s has already been registered.') % widget.__name__) registry.append(widget)
python
def register_widget(widget): """ Register the given widget as a candidate to use in placeholder. """ if widget in registry: raise WidgetAlreadyRegistered( _('The widget %s has already been registered.') % widget.__name__) registry.append(widget)
[ "def", "register_widget", "(", "widget", ")", ":", "if", "widget", "in", "registry", ":", "raise", "WidgetAlreadyRegistered", "(", "_", "(", "'The widget %s has already been registered.'", ")", "%", "widget", ".", "__name__", ")", "registry", ".", "append", "(", ...
Register the given widget as a candidate to use in placeholder.
[ "Register", "the", "given", "widget", "as", "a", "candidate", "to", "use", "in", "placeholder", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/widgets_registry.py#L24-L31
train
batiste/django-page-cms
pages/widgets_registry.py
get_widget
def get_widget(name): """ Give back a widget class according to his name. """ for widget in registry: if widget.__name__ == name: return widget raise WidgetNotFound( _('The widget %s has not been registered.') % name)
python
def get_widget(name): """ Give back a widget class according to his name. """ for widget in registry: if widget.__name__ == name: return widget raise WidgetNotFound( _('The widget %s has not been registered.') % name)
[ "def", "get_widget", "(", "name", ")", ":", "for", "widget", "in", "registry", ":", "if", "widget", ".", "__name__", "==", "name", ":", "return", "widget", "raise", "WidgetNotFound", "(", "_", "(", "'The widget %s has not been registered.'", ")", "%", "name", ...
Give back a widget class according to his name.
[ "Give", "back", "a", "widget", "class", "according", "to", "his", "name", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/widgets_registry.py#L34-L42
train
batiste/django-page-cms
pages/settings.py
get_setting
def get_setting(*args, **kwargs): """Get a setting and raise an appropriate user friendly error if the setting is not found.""" for name in args: if hasattr(settings, name): return getattr(settings, name) if kwargs.get('raise_error', False): setting_url = url % args[0].lower(...
python
def get_setting(*args, **kwargs): """Get a setting and raise an appropriate user friendly error if the setting is not found.""" for name in args: if hasattr(settings, name): return getattr(settings, name) if kwargs.get('raise_error', False): setting_url = url % args[0].lower(...
[ "def", "get_setting", "(", "*", "args", ",", "**", "kwargs", ")", ":", "for", "name", "in", "args", ":", "if", "hasattr", "(", "settings", ",", "name", ")", ":", "return", "getattr", "(", "settings", ",", "name", ")", "if", "kwargs", ".", "get", "(...
Get a setting and raise an appropriate user friendly error if the setting is not found.
[ "Get", "a", "setting", "and", "raise", "an", "appropriate", "user", "friendly", "error", "if", "the", "setting", "is", "not", "found", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/settings.py#L12-L23
train
batiste/django-page-cms
pages/settings.py
get_page_templates
def get_page_templates(): """The callable that is used by the CMS.""" PAGE_TEMPLATES = get_setting('PAGE_TEMPLATES', default_value=()) if isinstance(PAGE_TEMPLATES, collections.Callable): return PAGE_TEMPLATES() else: return PAGE_TEMPLATES
python
def get_page_templates(): """The callable that is used by the CMS.""" PAGE_TEMPLATES = get_setting('PAGE_TEMPLATES', default_value=()) if isinstance(PAGE_TEMPLATES, collections.Callable): return PAGE_TEMPLATES() else: return PAGE_TEMPLATES
[ "def", "get_page_templates", "(", ")", ":", "PAGE_TEMPLATES", "=", "get_setting", "(", "'PAGE_TEMPLATES'", ",", "default_value", "=", "(", ")", ")", "if", "isinstance", "(", "PAGE_TEMPLATES", ",", "collections", ".", "Callable", ")", ":", "return", "PAGE_TEMPLAT...
The callable that is used by the CMS.
[ "The", "callable", "that", "is", "used", "by", "the", "CMS", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/settings.py#L51-L58
train
batiste/django-page-cms
pages/admin/views.py
change_status
def change_status(request, page_id): """ Switch the status of a page. """ perm = request.user.has_perm('pages.change_page') if perm and request.method == 'POST': page = Page.objects.get(pk=page_id) page.status = int(request.POST['status']) page.invalidate() page.save(...
python
def change_status(request, page_id): """ Switch the status of a page. """ perm = request.user.has_perm('pages.change_page') if perm and request.method == 'POST': page = Page.objects.get(pk=page_id) page.status = int(request.POST['status']) page.invalidate() page.save(...
[ "def", "change_status", "(", "request", ",", "page_id", ")", ":", "perm", "=", "request", ".", "user", ".", "has_perm", "(", "'pages.change_page'", ")", "if", "perm", "and", "request", ".", "method", "==", "'POST'", ":", "page", "=", "Page", ".", "object...
Switch the status of a page.
[ "Switch", "the", "status", "of", "a", "page", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/views.py#L21-L32
train
batiste/django-page-cms
pages/admin/views.py
get_last_content
def get_last_content(request, page_id): """Get the latest content for a particular type""" content_type = request.GET.get('content_type') language_id = request.GET.get('language_id') page = get_object_or_404(Page, pk=page_id) placeholders = get_placeholders(page.get_template()) _template = templ...
python
def get_last_content(request, page_id): """Get the latest content for a particular type""" content_type = request.GET.get('content_type') language_id = request.GET.get('language_id') page = get_object_or_404(Page, pk=page_id) placeholders = get_placeholders(page.get_template()) _template = templ...
[ "def", "get_last_content", "(", "request", ",", "page_id", ")", ":", "content_type", "=", "request", ".", "GET", ".", "get", "(", "'content_type'", ")", "language_id", "=", "request", ".", "GET", ".", "get", "(", "'language_id'", ")", "page", "=", "get_obj...
Get the latest content for a particular type
[ "Get", "the", "latest", "content", "for", "a", "particular", "type" ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/views.py#L122-L138
train
batiste/django-page-cms
pages/admin/views.py
traduction
def traduction(request, page_id, language_id): """Traduction helper.""" page = Page.objects.get(pk=page_id) lang = language_id placeholders = get_placeholders(page.get_template()) language_error = ( Content.objects.get_content(page, language_id, "title") is None ) return rend...
python
def traduction(request, page_id, language_id): """Traduction helper.""" page = Page.objects.get(pk=page_id) lang = language_id placeholders = get_placeholders(page.get_template()) language_error = ( Content.objects.get_content(page, language_id, "title") is None ) return rend...
[ "def", "traduction", "(", "request", ",", "page_id", ",", "language_id", ")", ":", "page", "=", "Page", ".", "objects", ".", "get", "(", "pk", "=", "page_id", ")", "lang", "=", "language_id", "placeholders", "=", "get_placeholders", "(", "page", ".", "ge...
Traduction helper.
[ "Traduction", "helper", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/views.py#L163-L177
train
batiste/django-page-cms
pages/admin/views.py
get_content
def get_content(request, page_id, content_id): """Get the content for a particular page""" content = Content.objects.get(pk=content_id) return HttpResponse(content.body)
python
def get_content(request, page_id, content_id): """Get the content for a particular page""" content = Content.objects.get(pk=content_id) return HttpResponse(content.body)
[ "def", "get_content", "(", "request", ",", "page_id", ",", "content_id", ")", ":", "content", "=", "Content", ".", "objects", ".", "get", "(", "pk", "=", "content_id", ")", "return", "HttpResponse", "(", "content", ".", "body", ")" ]
Get the content for a particular page
[ "Get", "the", "content", "for", "a", "particular", "page" ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/views.py#L181-L184
train
batiste/django-page-cms
pages/admin/views.py
get_media_url
def get_media_url(request, media_id): """Get media URL.""" media = Media.objects.get(id=media_id) return HttpResponse(media.url.name)
python
def get_media_url(request, media_id): """Get media URL.""" media = Media.objects.get(id=media_id) return HttpResponse(media.url.name)
[ "def", "get_media_url", "(", "request", ",", "media_id", ")", ":", "media", "=", "Media", ".", "objects", ".", "get", "(", "id", "=", "media_id", ")", "return", "HttpResponse", "(", "media", ".", "url", ".", "name", ")" ]
Get media URL.
[ "Get", "media", "URL", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/views.py#L232-L235
train
batiste/django-page-cms
pages/context_processors.py
media
def media(request): """Adds media-related variables to the `context`.""" return { 'PAGES_MEDIA_URL': settings.PAGES_MEDIA_URL, 'PAGES_STATIC_URL': settings.PAGES_STATIC_URL, 'PAGE_USE_SITE_ID': settings.PAGE_USE_SITE_ID, 'PAGE_HIDE_SITES': settings.PAGE_HIDE_SITES, 'PAGE_...
python
def media(request): """Adds media-related variables to the `context`.""" return { 'PAGES_MEDIA_URL': settings.PAGES_MEDIA_URL, 'PAGES_STATIC_URL': settings.PAGES_STATIC_URL, 'PAGE_USE_SITE_ID': settings.PAGE_USE_SITE_ID, 'PAGE_HIDE_SITES': settings.PAGE_HIDE_SITES, 'PAGE_...
[ "def", "media", "(", "request", ")", ":", "return", "{", "'PAGES_MEDIA_URL'", ":", "settings", ".", "PAGES_MEDIA_URL", ",", "'PAGES_STATIC_URL'", ":", "settings", ".", "PAGES_STATIC_URL", ",", "'PAGE_USE_SITE_ID'", ":", "settings", ".", "PAGE_USE_SITE_ID", ",", "'...
Adds media-related variables to the `context`.
[ "Adds", "media", "-", "related", "variables", "to", "the", "context", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/context_processors.py#L5-L13
train
batiste/django-page-cms
pages/utils.py
normalize_url
def normalize_url(url): """Return a normalized url with trailing and without leading slash. >>> normalize_url(None) '/' >>> normalize_url('/') '/' >>> normalize_url('/foo/bar') '/foo/bar' >>> normalize_url('foo/bar') '/foo/bar' >>> normalize_url('/foo/bar/') '/foo/...
python
def normalize_url(url): """Return a normalized url with trailing and without leading slash. >>> normalize_url(None) '/' >>> normalize_url('/') '/' >>> normalize_url('/foo/bar') '/foo/bar' >>> normalize_url('foo/bar') '/foo/bar' >>> normalize_url('/foo/bar/') '/foo/...
[ "def", "normalize_url", "(", "url", ")", ":", "if", "not", "url", "or", "len", "(", "url", ")", "==", "0", ":", "return", "'/'", "if", "not", "url", ".", "startswith", "(", "'/'", ")", ":", "url", "=", "'/'", "+", "url", "if", "len", "(", "url"...
Return a normalized url with trailing and without leading slash. >>> normalize_url(None) '/' >>> normalize_url('/') '/' >>> normalize_url('/foo/bar') '/foo/bar' >>> normalize_url('foo/bar') '/foo/bar' >>> normalize_url('/foo/bar/') '/foo/bar'
[ "Return", "a", "normalized", "url", "with", "trailing", "and", "without", "leading", "slash", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/utils.py#L116-L136
train
batiste/django-page-cms
pages/checks.py
page_templates_loading_check
def page_templates_loading_check(app_configs, **kwargs): """ Check if any page template can't be loaded. """ errors = [] for page_template in settings.get_page_templates(): try: loader.get_template(page_template[0]) except template.TemplateDoesNotExist: errors.append...
python
def page_templates_loading_check(app_configs, **kwargs): """ Check if any page template can't be loaded. """ errors = [] for page_template in settings.get_page_templates(): try: loader.get_template(page_template[0]) except template.TemplateDoesNotExist: errors.append...
[ "def", "page_templates_loading_check", "(", "app_configs", ",", "**", "kwargs", ")", ":", "errors", "=", "[", "]", "for", "page_template", "in", "settings", ".", "get_page_templates", "(", ")", ":", "try", ":", "loader", ".", "get_template", "(", "page_templat...
Check if any page template can't be loaded.
[ "Check", "if", "any", "page", "template", "can", "t", "be", "loaded", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/checks.py#L9-L21
train
batiste/django-page-cms
pages/templatetags/pages_tags.py
_get_content
def _get_content(context, page, content_type, lang, fallback=True): """Helper function used by ``PlaceholderNode``.""" if not page: return '' if not lang and 'lang' in context: lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE) page = get_page_from_string_or_id(page, lang...
python
def _get_content(context, page, content_type, lang, fallback=True): """Helper function used by ``PlaceholderNode``.""" if not page: return '' if not lang and 'lang' in context: lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE) page = get_page_from_string_or_id(page, lang...
[ "def", "_get_content", "(", "context", ",", "page", ",", "content_type", ",", "lang", ",", "fallback", "=", "True", ")", ":", "if", "not", "page", ":", "return", "''", "if", "not", "lang", "and", "'lang'", "in", "context", ":", "lang", "=", "context", ...
Helper function used by ``PlaceholderNode``.
[ "Helper", "function", "used", "by", "PlaceholderNode", "." ]
3c72111eb7c3997a63c462c1776ffd8ce8c50a5d
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/templatetags/pages_tags.py#L40-L54
train