repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
DeepHorizons/iarm
iarm/arm_instructions/data_movement.py
DataMovement.REV16
def REV16(self, params): """ REV16 Ra, Rb Reverse the byte order of the half words in register Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params) self.check_arguments(low_registers=(Ra, Rb)) def REV16_...
python
def REV16(self, params): """ REV16 Ra, Rb Reverse the byte order of the half words in register Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params) self.check_arguments(low_registers=(Ra, Rb)) def REV16_...
[ "def", "REV16", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "self", ".", "TWO_PARAMETER_COMMA_SEPARATED", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ",",...
REV16 Ra, Rb Reverse the byte order of the half words in register Rb and store the result in Ra
[ "REV16", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/data_movement.py#L140-L154
train
DeepHorizons/iarm
iarm/arm_instructions/data_movement.py
DataMovement.REVSH
def REVSH(self, params): """ REVSH Reverse the byte order in the lower half word in Rb and store the result in Ra. If the result of the result is signed, then sign extend """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) ...
python
def REVSH(self, params): """ REVSH Reverse the byte order in the lower half word in Rb and store the result in Ra. If the result of the result is signed, then sign extend """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) ...
[ "def", "REVSH", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "r'\\s*([^\\s,]*),\\s*([^\\s,]*)(,\\s*[^\\s,]*)*\\s*'", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ...
REVSH Reverse the byte order in the lower half word in Rb and store the result in Ra. If the result of the result is signed, then sign extend
[ "REVSH" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/data_movement.py#L156-L173
train
DeepHorizons/iarm
iarm/arm_instructions/data_movement.py
DataMovement.SXTB
def SXTB(self, params): """ STXB Ra, Rb Sign extend the byte in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def SXTB_func(): i...
python
def SXTB(self, params): """ STXB Ra, Rb Sign extend the byte in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def SXTB_func(): i...
[ "def", "SXTB", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "r'\\s*([^\\s,]*),\\s*([^\\s,]*)(,\\s*[^\\s,]*)*\\s*'", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ...
STXB Ra, Rb Sign extend the byte in Rb and store the result in Ra
[ "STXB", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/data_movement.py#L175-L191
train
DeepHorizons/iarm
iarm/arm_instructions/data_movement.py
DataMovement.SXTH
def SXTH(self, params): """ STXH Ra, Rb Sign extend the half word in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def SXTH_func(): ...
python
def SXTH(self, params): """ STXH Ra, Rb Sign extend the half word in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def SXTH_func(): ...
[ "def", "SXTH", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "r'\\s*([^\\s,]*),\\s*([^\\s,]*)(,\\s*[^\\s,]*)*\\s*'", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ...
STXH Ra, Rb Sign extend the half word in Rb and store the result in Ra
[ "STXH", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/data_movement.py#L193-L209
train
DeepHorizons/iarm
iarm/arm_instructions/data_movement.py
DataMovement.UXTB
def UXTB(self, params): """ UTXB Ra, Rb Zero extend the byte in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def UXTB_func(): s...
python
def UXTB(self, params): """ UTXB Ra, Rb Zero extend the byte in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def UXTB_func(): s...
[ "def", "UXTB", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "r'\\s*([^\\s,]*),\\s*([^\\s,]*)(,\\s*[^\\s,]*)*\\s*'", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ...
UTXB Ra, Rb Zero extend the byte in Rb and store the result in Ra
[ "UTXB", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/data_movement.py#L211-L224
train
DeepHorizons/iarm
iarm/arm_instructions/data_movement.py
DataMovement.UXTH
def UXTH(self, params): """ UTXH Ra, Rb Zero extend the half word in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def UXTH_func(): ...
python
def UXTH(self, params): """ UTXH Ra, Rb Zero extend the half word in Rb and store the result in Ra """ Ra, Rb = self.get_two_parameters(r'\s*([^\s,]*),\s*([^\s,]*)(,\s*[^\s,]*)*\s*', params) self.check_arguments(low_registers=(Ra, Rb)) def UXTH_func(): ...
[ "def", "UXTH", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "r'\\s*([^\\s,]*),\\s*([^\\s,]*)(,\\s*[^\\s,]*)*\\s*'", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ...
UTXH Ra, Rb Zero extend the half word in Rb and store the result in Ra
[ "UTXH", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/data_movement.py#L226-L239
train
glomex/gcdt
gcdt/ramuda_wire.py
_get_event_type
def _get_event_type(evt_source): """Get type of event e.g. 's3', 'events', 'kinesis',... :param evt_source: :return: """ if 'schedule' in evt_source: return 'events' elif 'pattern' in evt_source: return 'events' elif 'log_group_name_prefix' in evt_source: return 'clo...
python
def _get_event_type(evt_source): """Get type of event e.g. 's3', 'events', 'kinesis',... :param evt_source: :return: """ if 'schedule' in evt_source: return 'events' elif 'pattern' in evt_source: return 'events' elif 'log_group_name_prefix' in evt_source: return 'clo...
[ "def", "_get_event_type", "(", "evt_source", ")", ":", "if", "'schedule'", "in", "evt_source", ":", "return", "'events'", "elif", "'pattern'", "in", "evt_source", ":", "return", "'events'", "elif", "'log_group_name_prefix'", "in", "evt_source", ":", "return", "'cl...
Get type of event e.g. 's3', 'events', 'kinesis',... :param evt_source: :return:
[ "Get", "type", "of", "event", "e", ".", "g", ".", "s3", "events", "kinesis", "..." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L28-L43
train
glomex/gcdt
gcdt/ramuda_wire.py
_get_event_source_obj
def _get_event_source_obj(awsclient, evt_source): """ Given awsclient, event_source dictionary item create an event_source object of the appropriate event type to schedule this event, and return the object. """ event_source_map = { 'dynamodb': event_source.dynamodb_stream.DynamoDBStreamE...
python
def _get_event_source_obj(awsclient, evt_source): """ Given awsclient, event_source dictionary item create an event_source object of the appropriate event type to schedule this event, and return the object. """ event_source_map = { 'dynamodb': event_source.dynamodb_stream.DynamoDBStreamE...
[ "def", "_get_event_source_obj", "(", "awsclient", ",", "evt_source", ")", ":", "event_source_map", "=", "{", "'dynamodb'", ":", "event_source", ".", "dynamodb_stream", ".", "DynamoDBStreamEventSource", ",", "'kinesis'", ":", "event_source", ".", "kinesis", ".", "Kin...
Given awsclient, event_source dictionary item create an event_source object of the appropriate event type to schedule this event, and return the object.
[ "Given", "awsclient", "event_source", "dictionary", "item", "create", "an", "event_source", "object", "of", "the", "appropriate", "event", "type", "to", "schedule", "this", "event", "and", "return", "the", "object", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L84-L106
train
glomex/gcdt
gcdt/ramuda_wire.py
_add_event_source
def _add_event_source(awsclient, evt_source, lambda_arn): """ Given an event_source dictionary, create the object and add the event source. """ event_source_obj = _get_event_source_obj(awsclient, evt_source) # (where zappa goes like remove, add) # we go with update and add like this: if eve...
python
def _add_event_source(awsclient, evt_source, lambda_arn): """ Given an event_source dictionary, create the object and add the event source. """ event_source_obj = _get_event_source_obj(awsclient, evt_source) # (where zappa goes like remove, add) # we go with update and add like this: if eve...
[ "def", "_add_event_source", "(", "awsclient", ",", "evt_source", ",", "lambda_arn", ")", ":", "event_source_obj", "=", "_get_event_source_obj", "(", "awsclient", ",", "evt_source", ")", "# (where zappa goes like remove, add)", "# we go with update and add like this:", "if", ...
Given an event_source dictionary, create the object and add the event source.
[ "Given", "an", "event_source", "dictionary", "create", "the", "object", "and", "add", "the", "event", "source", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L109-L120
train
glomex/gcdt
gcdt/ramuda_wire.py
_remove_event_source
def _remove_event_source(awsclient, evt_source, lambda_arn): """ Given an event_source dictionary, create the object and remove the event source. """ event_source_obj = _get_event_source_obj(awsclient, evt_source) if event_source_obj.exists(lambda_arn): event_source_obj.remove(lambda_arn)
python
def _remove_event_source(awsclient, evt_source, lambda_arn): """ Given an event_source dictionary, create the object and remove the event source. """ event_source_obj = _get_event_source_obj(awsclient, evt_source) if event_source_obj.exists(lambda_arn): event_source_obj.remove(lambda_arn)
[ "def", "_remove_event_source", "(", "awsclient", ",", "evt_source", ",", "lambda_arn", ")", ":", "event_source_obj", "=", "_get_event_source_obj", "(", "awsclient", ",", "evt_source", ")", "if", "event_source_obj", ".", "exists", "(", "lambda_arn", ")", ":", "even...
Given an event_source dictionary, create the object and remove the event source.
[ "Given", "an", "event_source", "dictionary", "create", "the", "object", "and", "remove", "the", "event", "source", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L123-L129
train
glomex/gcdt
gcdt/ramuda_wire.py
_get_event_source_status
def _get_event_source_status(awsclient, evt_source, lambda_arn): """ Given an event_source dictionary, create the object and get the event source status. """ event_source_obj = _get_event_source_obj(awsclient, evt_source) return event_source_obj.status(lambda_arn)
python
def _get_event_source_status(awsclient, evt_source, lambda_arn): """ Given an event_source dictionary, create the object and get the event source status. """ event_source_obj = _get_event_source_obj(awsclient, evt_source) return event_source_obj.status(lambda_arn)
[ "def", "_get_event_source_status", "(", "awsclient", ",", "evt_source", ",", "lambda_arn", ")", ":", "event_source_obj", "=", "_get_event_source_obj", "(", "awsclient", ",", "evt_source", ")", "return", "event_source_obj", ".", "status", "(", "lambda_arn", ")" ]
Given an event_source dictionary, create the object and get the event source status.
[ "Given", "an", "event_source", "dictionary", "create", "the", "object", "and", "get", "the", "event", "source", "status", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L132-L137
train
glomex/gcdt
gcdt/ramuda_wire.py
unwire
def unwire(awsclient, events, lambda_name, alias_name=ALIAS_NAME): """Unwire a list of event from an AWS Lambda function. 'events' is a list of dictionaries, where the dict must contains the 'schedule' of the event as string, and an optional 'name' and 'description'. :param awsclient: :param event...
python
def unwire(awsclient, events, lambda_name, alias_name=ALIAS_NAME): """Unwire a list of event from an AWS Lambda function. 'events' is a list of dictionaries, where the dict must contains the 'schedule' of the event as string, and an optional 'name' and 'description'. :param awsclient: :param event...
[ "def", "unwire", "(", "awsclient", ",", "events", ",", "lambda_name", ",", "alias_name", "=", "ALIAS_NAME", ")", ":", "if", "not", "lambda_exists", "(", "awsclient", ",", "lambda_name", ")", ":", "log", ".", "error", "(", "colored", ".", "red", "(", "'Th...
Unwire a list of event from an AWS Lambda function. 'events' is a list of dictionaries, where the dict must contains the 'schedule' of the event as string, and an optional 'name' and 'description'. :param awsclient: :param events: list of events :param lambda_name: :param alias_name: :retu...
[ "Unwire", "a", "list", "of", "event", "from", "an", "AWS", "Lambda", "function", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L140-L181
train
glomex/gcdt
gcdt/ramuda_wire.py
wire_deprecated
def wire_deprecated(awsclient, function_name, s3_event_sources=None, time_event_sources=None, alias_name=ALIAS_NAME): """Deprecated! Please use wire! :param awsclient: :param function_name: :param s3_event_sources: dictionary :param time_event_sources: :...
python
def wire_deprecated(awsclient, function_name, s3_event_sources=None, time_event_sources=None, alias_name=ALIAS_NAME): """Deprecated! Please use wire! :param awsclient: :param function_name: :param s3_event_sources: dictionary :param time_event_sources: :...
[ "def", "wire_deprecated", "(", "awsclient", ",", "function_name", ",", "s3_event_sources", "=", "None", ",", "time_event_sources", "=", "None", ",", "alias_name", "=", "ALIAS_NAME", ")", ":", "if", "not", "lambda_exists", "(", "awsclient", ",", "function_name", ...
Deprecated! Please use wire! :param awsclient: :param function_name: :param s3_event_sources: dictionary :param time_event_sources: :param alias_name: :return: exit_code
[ "Deprecated!", "Please", "use", "wire!" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L191-L235
train
glomex/gcdt
gcdt/ramuda_wire.py
unwire_deprecated
def unwire_deprecated(awsclient, function_name, s3_event_sources=None, time_event_sources=None, alias_name=ALIAS_NAME): """Deprecated! Please use unwire! :param awsclient: :param function_name: :param s3_event_sources: dictionary :param time_event_sources: :param alias_nam...
python
def unwire_deprecated(awsclient, function_name, s3_event_sources=None, time_event_sources=None, alias_name=ALIAS_NAME): """Deprecated! Please use unwire! :param awsclient: :param function_name: :param s3_event_sources: dictionary :param time_event_sources: :param alias_nam...
[ "def", "unwire_deprecated", "(", "awsclient", ",", "function_name", ",", "s3_event_sources", "=", "None", ",", "time_event_sources", "=", "None", ",", "alias_name", "=", "ALIAS_NAME", ")", ":", "if", "not", "lambda_exists", "(", "awsclient", ",", "function_name", ...
Deprecated! Please use unwire! :param awsclient: :param function_name: :param s3_event_sources: dictionary :param time_event_sources: :param alias_name: :return: exit_code
[ "Deprecated!", "Please", "use", "unwire!" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L238-L313
train
glomex/gcdt
gcdt/ramuda_wire.py
_lambda_add_s3_event_source
def _lambda_add_s3_event_source(awsclient, arn, event, bucket, prefix, suffix): """Use only prefix OR suffix :param arn: :param event: :param bucket: :param prefix: :param suffix: :return: """ json_data = { 'LambdaFunctionConfigurations': [{ ...
python
def _lambda_add_s3_event_source(awsclient, arn, event, bucket, prefix, suffix): """Use only prefix OR suffix :param arn: :param event: :param bucket: :param prefix: :param suffix: :return: """ json_data = { 'LambdaFunctionConfigurations': [{ ...
[ "def", "_lambda_add_s3_event_source", "(", "awsclient", ",", "arn", ",", "event", ",", "bucket", ",", "prefix", ",", "suffix", ")", ":", "json_data", "=", "{", "'LambdaFunctionConfigurations'", ":", "[", "{", "'LambdaFunctionArn'", ":", "arn", ",", "'Id'", ":"...
Use only prefix OR suffix :param arn: :param event: :param bucket: :param prefix: :param suffix: :return:
[ "Use", "only", "prefix", "OR", "suffix" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_wire.py#L616-L665
train
tdegeus/cppmat
cppmat/__init__.py
find_eigen
def find_eigen(hint=None): r''' Try to find the Eigen library. If successful the include directory is returned. ''' # search with pkgconfig # --------------------- try: import pkgconfig if pkgconfig.installed('eigen3','>3.0.0'): return pkgconfig.parse('eigen3')['include_dirs'][0] except: ...
python
def find_eigen(hint=None): r''' Try to find the Eigen library. If successful the include directory is returned. ''' # search with pkgconfig # --------------------- try: import pkgconfig if pkgconfig.installed('eigen3','>3.0.0'): return pkgconfig.parse('eigen3')['include_dirs'][0] except: ...
[ "def", "find_eigen", "(", "hint", "=", "None", ")", ":", "# search with pkgconfig", "# ---------------------", "try", ":", "import", "pkgconfig", "if", "pkgconfig", ".", "installed", "(", "'eigen3'", ",", "'>3.0.0'", ")", ":", "return", "pkgconfig", ".", "parse"...
r''' Try to find the Eigen library. If successful the include directory is returned.
[ "r", "Try", "to", "find", "the", "Eigen", "library", ".", "If", "successful", "the", "include", "directory", "is", "returned", "." ]
0d5031d08ce621a4d3e9c396779d99fd5203aa00
https://github.com/tdegeus/cppmat/blob/0d5031d08ce621a4d3e9c396779d99fd5203aa00/cppmat/__init__.py#L109-L157
train
glomex/gcdt
gcdt/ramuda_utils.py
check_and_format_logs_params
def check_and_format_logs_params(start, end, tail): """Helper to read the params for the logs command""" def _decode_duration_type(duration_type): durations = {'m': 'minutes', 'h': 'hours', 'd': 'days', 'w': 'weeks'} return durations[duration_type] if not start: if tail: ...
python
def check_and_format_logs_params(start, end, tail): """Helper to read the params for the logs command""" def _decode_duration_type(duration_type): durations = {'m': 'minutes', 'h': 'hours', 'd': 'days', 'w': 'weeks'} return durations[duration_type] if not start: if tail: ...
[ "def", "check_and_format_logs_params", "(", "start", ",", "end", ",", "tail", ")", ":", "def", "_decode_duration_type", "(", "duration_type", ")", ":", "durations", "=", "{", "'m'", ":", "'minutes'", ",", "'h'", ":", "'hours'", ",", "'d'", ":", "'days'", "...
Helper to read the params for the logs command
[ "Helper", "to", "read", "the", "params", "for", "the", "logs", "command" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_utils.py#L201-L227
train
glomex/gcdt
gcdt/s3.py
upload_file_to_s3
def upload_file_to_s3(awsclient, bucket, key, filename): """Upload a file to AWS S3 bucket. :param awsclient: :param bucket: :param key: :param filename: :return: """ client_s3 = awsclient.get_client('s3') transfer = S3Transfer(client_s3) # Upload /tmp/myfile to s3://bucket/key ...
python
def upload_file_to_s3(awsclient, bucket, key, filename): """Upload a file to AWS S3 bucket. :param awsclient: :param bucket: :param key: :param filename: :return: """ client_s3 = awsclient.get_client('s3') transfer = S3Transfer(client_s3) # Upload /tmp/myfile to s3://bucket/key ...
[ "def", "upload_file_to_s3", "(", "awsclient", ",", "bucket", ",", "key", ",", "filename", ")", ":", "client_s3", "=", "awsclient", ".", "get_client", "(", "'s3'", ")", "transfer", "=", "S3Transfer", "(", "client_s3", ")", "# Upload /tmp/myfile to s3://bucket/key a...
Upload a file to AWS S3 bucket. :param awsclient: :param bucket: :param key: :param filename: :return:
[ "Upload", "a", "file", "to", "AWS", "S3", "bucket", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/s3.py#L73-L89
train
glomex/gcdt
gcdt/s3.py
remove_file_from_s3
def remove_file_from_s3(awsclient, bucket, key): """Remove a file from an AWS S3 bucket. :param awsclient: :param bucket: :param key: :return: """ client_s3 = awsclient.get_client('s3') response = client_s3.delete_object(Bucket=bucket, Key=key)
python
def remove_file_from_s3(awsclient, bucket, key): """Remove a file from an AWS S3 bucket. :param awsclient: :param bucket: :param key: :return: """ client_s3 = awsclient.get_client('s3') response = client_s3.delete_object(Bucket=bucket, Key=key)
[ "def", "remove_file_from_s3", "(", "awsclient", ",", "bucket", ",", "key", ")", ":", "client_s3", "=", "awsclient", ".", "get_client", "(", "'s3'", ")", "response", "=", "client_s3", ".", "delete_object", "(", "Bucket", "=", "bucket", ",", "Key", "=", "key...
Remove a file from an AWS S3 bucket. :param awsclient: :param bucket: :param key: :return:
[ "Remove", "a", "file", "from", "an", "AWS", "S3", "bucket", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/s3.py#L92-L101
train
glomex/gcdt
gcdt/s3.py
ls
def ls(awsclient, bucket, prefix=None): """List bucket contents :param awsclient: :param bucket: :param prefix: :return: """ # this works until 1000 keys! params = {'Bucket': bucket} if prefix: params['Prefix'] = prefix client_s3 = awsclient.get_client('s3') objects ...
python
def ls(awsclient, bucket, prefix=None): """List bucket contents :param awsclient: :param bucket: :param prefix: :return: """ # this works until 1000 keys! params = {'Bucket': bucket} if prefix: params['Prefix'] = prefix client_s3 = awsclient.get_client('s3') objects ...
[ "def", "ls", "(", "awsclient", ",", "bucket", ",", "prefix", "=", "None", ")", ":", "# this works until 1000 keys!", "params", "=", "{", "'Bucket'", ":", "bucket", "}", "if", "prefix", ":", "params", "[", "'Prefix'", "]", "=", "prefix", "client_s3", "=", ...
List bucket contents :param awsclient: :param bucket: :param prefix: :return:
[ "List", "bucket", "contents" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/s3.py#L104-L120
train
DeepHorizons/iarm
iarm/arm_instructions/logic.py
Logic.ORRS
def ORRS(self, params): """ ORRS [Ra,] Ra, Rb OR Ra and Rb together and store the result in Ra The equivalent of `Ra = Ra | Rc` Updates NZ flags Ra and Rb must be low registers The first register is optional """ # This instruction allows for an op...
python
def ORRS(self, params): """ ORRS [Ra,] Ra, Rb OR Ra and Rb together and store the result in Ra The equivalent of `Ra = Ra | Rc` Updates NZ flags Ra and Rb must be low registers The first register is optional """ # This instruction allows for an op...
[ "def", "ORRS", "(", "self", ",", "params", ")", ":", "# This instruction allows for an optional destination register", "# If it is omitted, then it is assumed to be Rb", "# As defined in http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0662b/index.html", "try", ":", "Ra", "...
ORRS [Ra,] Ra, Rb OR Ra and Rb together and store the result in Ra The equivalent of `Ra = Ra | Rc` Updates NZ flags Ra and Rb must be low registers The first register is optional
[ "ORRS", "[", "Ra", "]", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/logic.py#L93-L120
train
DeepHorizons/iarm
iarm/arm_instructions/logic.py
Logic.TST
def TST(self, params): """ TST Ra, Rb AND Ra and Rb together and update the NZ flag. The result is not set The equivalent of `Ra & Rc` Ra and Rb must be low registers """ Ra, Rb = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params) self.c...
python
def TST(self, params): """ TST Ra, Rb AND Ra and Rb together and update the NZ flag. The result is not set The equivalent of `Ra & Rc` Ra and Rb must be low registers """ Ra, Rb = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params) self.c...
[ "def", "TST", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", "=", "self", ".", "get_two_parameters", "(", "self", ".", "TWO_PARAMETER_COMMA_SEPARATED", ",", "params", ")", "self", ".", "check_arguments", "(", "low_registers", "=", "(", "Ra", ",", ...
TST Ra, Rb AND Ra and Rb together and update the NZ flag. The result is not set The equivalent of `Ra & Rc` Ra and Rb must be low registers
[ "TST", "Ra", "Rb" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/logic.py#L122-L138
train
matthiask/django-authlib
authlib/email.py
render_to_mail
def render_to_mail(template, context, **kwargs): """ Renders a mail and returns the resulting ``EmailMultiAlternatives`` instance * ``template``: The base name of the text and HTML (optional) version of the mail. * ``context``: The context used to render the mail. This context instance ...
python
def render_to_mail(template, context, **kwargs): """ Renders a mail and returns the resulting ``EmailMultiAlternatives`` instance * ``template``: The base name of the text and HTML (optional) version of the mail. * ``context``: The context used to render the mail. This context instance ...
[ "def", "render_to_mail", "(", "template", ",", "context", ",", "*", "*", "kwargs", ")", ":", "lines", "=", "iter", "(", "line", ".", "rstrip", "(", ")", "for", "line", "in", "render_to_string", "(", "\"%s.txt\"", "%", "template", ",", "context", ")", "...
Renders a mail and returns the resulting ``EmailMultiAlternatives`` instance * ``template``: The base name of the text and HTML (optional) version of the mail. * ``context``: The context used to render the mail. This context instance should contain everything required. * Additional keyword ...
[ "Renders", "a", "mail", "and", "returns", "the", "resulting", "EmailMultiAlternatives", "instance" ]
a142da7e27fe9d30f34a84b12f24f686f9d2c8e1
https://github.com/matthiask/django-authlib/blob/a142da7e27fe9d30f34a84b12f24f686f9d2c8e1/authlib/email.py#L14-L61
train
matthiask/django-authlib
authlib/email.py
get_confirmation_url
def get_confirmation_url(email, request, name="email_registration_confirm", **kwargs): """ Returns the confirmation URL """ return request.build_absolute_uri( reverse(name, kwargs={"code": get_confirmation_code(email, request, **kwargs)}) )
python
def get_confirmation_url(email, request, name="email_registration_confirm", **kwargs): """ Returns the confirmation URL """ return request.build_absolute_uri( reverse(name, kwargs={"code": get_confirmation_code(email, request, **kwargs)}) )
[ "def", "get_confirmation_url", "(", "email", ",", "request", ",", "name", "=", "\"email_registration_confirm\"", ",", "*", "*", "kwargs", ")", ":", "return", "request", ".", "build_absolute_uri", "(", "reverse", "(", "name", ",", "kwargs", "=", "{", "\"code\""...
Returns the confirmation URL
[ "Returns", "the", "confirmation", "URL" ]
a142da7e27fe9d30f34a84b12f24f686f9d2c8e1
https://github.com/matthiask/django-authlib/blob/a142da7e27fe9d30f34a84b12f24f686f9d2c8e1/authlib/email.py#L81-L87
train
matthiask/django-authlib
authlib/email.py
send_registration_mail
def send_registration_mail(email, *, request, **kwargs): """send_registration_mail(email, *, request, **kwargs) Sends the registration mail * ``email``: The email address where the registration link should be sent to. * ``request``: A HTTP request instance, used to construct the complete UR...
python
def send_registration_mail(email, *, request, **kwargs): """send_registration_mail(email, *, request, **kwargs) Sends the registration mail * ``email``: The email address where the registration link should be sent to. * ``request``: A HTTP request instance, used to construct the complete UR...
[ "def", "send_registration_mail", "(", "email", ",", "*", ",", "request", ",", "*", "*", "kwargs", ")", ":", "render_to_mail", "(", "\"registration/email_registration_email\"", ",", "{", "\"url\"", ":", "get_confirmation_url", "(", "email", ",", "request", ",", "...
send_registration_mail(email, *, request, **kwargs) Sends the registration mail * ``email``: The email address where the registration link should be sent to. * ``request``: A HTTP request instance, used to construct the complete URL (including protocol and domain) for the registration link. ...
[ "send_registration_mail", "(", "email", "*", "request", "**", "kwargs", ")", "Sends", "the", "registration", "mail" ]
a142da7e27fe9d30f34a84b12f24f686f9d2c8e1
https://github.com/matthiask/django-authlib/blob/a142da7e27fe9d30f34a84b12f24f686f9d2c8e1/authlib/email.py#L90-L115
train
matthiask/django-authlib
authlib/email.py
decode
def decode(code, *, max_age): """decode(code, *, max_age) Decodes the code from the registration link and returns a tuple consisting of the verified email address and the payload which was passed through to ``get_confirmation_code``. The maximum age in seconds of the link has to be specified as ``m...
python
def decode(code, *, max_age): """decode(code, *, max_age) Decodes the code from the registration link and returns a tuple consisting of the verified email address and the payload which was passed through to ``get_confirmation_code``. The maximum age in seconds of the link has to be specified as ``m...
[ "def", "decode", "(", "code", ",", "*", ",", "max_age", ")", ":", "try", ":", "data", "=", "get_signer", "(", ")", ".", "unsign", "(", "code", ",", "max_age", "=", "max_age", ")", "except", "signing", ".", "SignatureExpired", ":", "raise", "ValidationE...
decode(code, *, max_age) Decodes the code from the registration link and returns a tuple consisting of the verified email address and the payload which was passed through to ``get_confirmation_code``. The maximum age in seconds of the link has to be specified as ``max_age``. This method raises ``V...
[ "decode", "(", "code", "*", "max_age", ")", "Decodes", "the", "code", "from", "the", "registration", "link", "and", "returns", "a", "tuple", "consisting", "of", "the", "verified", "email", "address", "and", "the", "payload", "which", "was", "passed", "throug...
a142da7e27fe9d30f34a84b12f24f686f9d2c8e1
https://github.com/matthiask/django-authlib/blob/a142da7e27fe9d30f34a84b12f24f686f9d2c8e1/authlib/email.py#L118-L146
train
jay-johnson/celery-loaders
celery_loaders/work_tasks/tasks.py
do_some_work
def do_some_work( self, work_dict): """do_some_work :param work_dict: dictionary for key/values """ label = "do_some_work" log.info(("task - {} - start " "work_dict={}") .format(label, work_dict)) ret_data = { "job_resul...
python
def do_some_work( self, work_dict): """do_some_work :param work_dict: dictionary for key/values """ label = "do_some_work" log.info(("task - {} - start " "work_dict={}") .format(label, work_dict)) ret_data = { "job_resul...
[ "def", "do_some_work", "(", "self", ",", "work_dict", ")", ":", "label", "=", "\"do_some_work\"", "log", ".", "info", "(", "(", "\"task - {} - start \"", "\"work_dict={}\"", ")", ".", "format", "(", "label", ",", "work_dict", ")", ")", "ret_data", "=", "{", ...
do_some_work :param work_dict: dictionary for key/values
[ "do_some_work" ]
aca8169c774582af42a377c27cb3980020080814
https://github.com/jay-johnson/celery-loaders/blob/aca8169c774582af42a377c27cb3980020080814/celery_loaders/work_tasks/tasks.py#L15-L40
train
glomex/gcdt
gcdt/route53.py
create_record
def create_record(awsclient, name_prefix, instance_reference, type="A", host_zone_name=None): """ Builds route53 record entries enabling DNS names for services Note: gcdt.route53 create_record(awsclient, ...) is used in dataplatform cloudformation.py templates! :param name_prefix: The sub domain pr...
python
def create_record(awsclient, name_prefix, instance_reference, type="A", host_zone_name=None): """ Builds route53 record entries enabling DNS names for services Note: gcdt.route53 create_record(awsclient, ...) is used in dataplatform cloudformation.py templates! :param name_prefix: The sub domain pr...
[ "def", "create_record", "(", "awsclient", ",", "name_prefix", ",", "instance_reference", ",", "type", "=", "\"A\"", ",", "host_zone_name", "=", "None", ")", ":", "# Only fetch the host zone from the COPS stack if nessary", "if", "host_zone_name", "is", "None", ":", "h...
Builds route53 record entries enabling DNS names for services Note: gcdt.route53 create_record(awsclient, ...) is used in dataplatform cloudformation.py templates! :param name_prefix: The sub domain prefix to use :param instance_reference: The EC2 troposphere reference which's private IP should be link...
[ "Builds", "route53", "record", "entries", "enabling", "DNS", "names", "for", "services", "Note", ":", "gcdt", ".", "route53", "create_record", "(", "awsclient", "...", ")", "is", "used", "in", "dataplatform", "cloudformation", ".", "py", "templates!" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/route53.py#L24-L70
train
glomex/gcdt
gcdt/route53.py
_retrieve_stack_host_zone_name
def _retrieve_stack_host_zone_name(awsclient, default_stack_name=None): """ Use service discovery to get the host zone name from the default stack :return: Host zone name as string """ global _host_zone_name if _host_zone_name is not None: return _host_zone_name env = get_env() ...
python
def _retrieve_stack_host_zone_name(awsclient, default_stack_name=None): """ Use service discovery to get the host zone name from the default stack :return: Host zone name as string """ global _host_zone_name if _host_zone_name is not None: return _host_zone_name env = get_env() ...
[ "def", "_retrieve_stack_host_zone_name", "(", "awsclient", ",", "default_stack_name", "=", "None", ")", ":", "global", "_host_zone_name", "if", "_host_zone_name", "is", "not", "None", ":", "return", "_host_zone_name", "env", "=", "get_env", "(", ")", "if", "env", ...
Use service discovery to get the host zone name from the default stack :return: Host zone name as string
[ "Use", "service", "discovery", "to", "get", "the", "host", "zone", "name", "from", "the", "default", "stack" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/route53.py#L73-L105
train
glomex/gcdt
gcdt/gcdt_plugins.py
load_plugins
def load_plugins(group='gcdt10'): """Load and register installed gcdt plugins. """ # on using entrypoints: # http://stackoverflow.com/questions/774824/explain-python-entry-points # TODO: make sure we do not have conflicting generators installed! for ep in pkg_resources.iter_entry_points(group, n...
python
def load_plugins(group='gcdt10'): """Load and register installed gcdt plugins. """ # on using entrypoints: # http://stackoverflow.com/questions/774824/explain-python-entry-points # TODO: make sure we do not have conflicting generators installed! for ep in pkg_resources.iter_entry_points(group, n...
[ "def", "load_plugins", "(", "group", "=", "'gcdt10'", ")", ":", "# on using entrypoints:", "# http://stackoverflow.com/questions/774824/explain-python-entry-points", "# TODO: make sure we do not have conflicting generators installed!", "for", "ep", "in", "pkg_resources", ".", "iter_e...
Load and register installed gcdt plugins.
[ "Load", "and", "register", "installed", "gcdt", "plugins", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/gcdt_plugins.py#L18-L30
train
glomex/gcdt
gcdt/gcdt_plugins.py
get_plugin_versions
def get_plugin_versions(group='gcdt10'): """Load and register installed gcdt plugins. """ versions = {} for ep in pkg_resources.iter_entry_points(group, name=None): versions[ep.dist.project_name] = ep.dist.version return versions
python
def get_plugin_versions(group='gcdt10'): """Load and register installed gcdt plugins. """ versions = {} for ep in pkg_resources.iter_entry_points(group, name=None): versions[ep.dist.project_name] = ep.dist.version return versions
[ "def", "get_plugin_versions", "(", "group", "=", "'gcdt10'", ")", ":", "versions", "=", "{", "}", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "group", ",", "name", "=", "None", ")", ":", "versions", "[", "ep", ".", "dist", ".", "...
Load and register installed gcdt plugins.
[ "Load", "and", "register", "installed", "gcdt", "plugins", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/gcdt_plugins.py#L33-L40
train
glomex/gcdt
gcdt/cloudwatch_logs.py
delete_log_group
def delete_log_group(awsclient, log_group_name): """Delete the specified log group :param log_group_name: log group name :return: """ client_logs = awsclient.get_client('logs') response = client_logs.delete_log_group( logGroupName=log_group_name )
python
def delete_log_group(awsclient, log_group_name): """Delete the specified log group :param log_group_name: log group name :return: """ client_logs = awsclient.get_client('logs') response = client_logs.delete_log_group( logGroupName=log_group_name )
[ "def", "delete_log_group", "(", "awsclient", ",", "log_group_name", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "response", "=", "client_logs", ".", "delete_log_group", "(", "logGroupName", "=", "log_group_name", ")" ]
Delete the specified log group :param log_group_name: log group name :return:
[ "Delete", "the", "specified", "log", "group" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L18-L28
train
glomex/gcdt
gcdt/cloudwatch_logs.py
put_retention_policy
def put_retention_policy(awsclient, log_group_name, retention_in_days): """Sets the retention of the specified log group if the log group does not yet exist than it will be created first. :param log_group_name: log group name :param retention_in_days: log group name :return: """ try: ...
python
def put_retention_policy(awsclient, log_group_name, retention_in_days): """Sets the retention of the specified log group if the log group does not yet exist than it will be created first. :param log_group_name: log group name :param retention_in_days: log group name :return: """ try: ...
[ "def", "put_retention_policy", "(", "awsclient", ",", "log_group_name", ",", "retention_in_days", ")", ":", "try", ":", "# Note: for AWS Lambda the log_group is created once the first", "# log event occurs. So if the log_group does not exist we create it", "create_log_group", "(", "a...
Sets the retention of the specified log group if the log group does not yet exist than it will be created first. :param log_group_name: log group name :param retention_in_days: log group name :return:
[ "Sets", "the", "retention", "of", "the", "specified", "log", "group", "if", "the", "log", "group", "does", "not", "yet", "exist", "than", "it", "will", "be", "created", "first", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L31-L53
train
glomex/gcdt
gcdt/cloudwatch_logs.py
filter_log_events
def filter_log_events(awsclient, log_group_name, start_ts, end_ts=None): """ Note: this is used to retrieve logs in ramuda. :param log_group_name: log group name :param start_ts: timestamp :param end_ts: timestamp :return: list of log entries """ client_logs = awsclient.get_client('logs...
python
def filter_log_events(awsclient, log_group_name, start_ts, end_ts=None): """ Note: this is used to retrieve logs in ramuda. :param log_group_name: log group name :param start_ts: timestamp :param end_ts: timestamp :return: list of log entries """ client_logs = awsclient.get_client('logs...
[ "def", "filter_log_events", "(", "awsclient", ",", "log_group_name", ",", "start_ts", ",", "end_ts", "=", "None", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "# TODO use all_pages instead!", "logs", "=", "[", "]", "next_toke...
Note: this is used to retrieve logs in ramuda. :param log_group_name: log group name :param start_ts: timestamp :param end_ts: timestamp :return: list of log entries
[ "Note", ":", "this", "is", "used", "to", "retrieve", "logs", "in", "ramuda", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L56-L86
train
glomex/gcdt
gcdt/cloudwatch_logs.py
describe_log_group
def describe_log_group(awsclient, log_group_name): """Get info on the specified log group :param log_group_name: log group name :return: """ client_logs = awsclient.get_client('logs') request = { 'logGroupNamePrefix': log_group_name, 'limit': 1 } response = client_logs....
python
def describe_log_group(awsclient, log_group_name): """Get info on the specified log group :param log_group_name: log group name :return: """ client_logs = awsclient.get_client('logs') request = { 'logGroupNamePrefix': log_group_name, 'limit': 1 } response = client_logs....
[ "def", "describe_log_group", "(", "awsclient", ",", "log_group_name", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "request", "=", "{", "'logGroupNamePrefix'", ":", "log_group_name", ",", "'limit'", ":", "1", "}", "response",...
Get info on the specified log group :param log_group_name: log group name :return:
[ "Get", "info", "on", "the", "specified", "log", "group" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L90-L106
train
glomex/gcdt
gcdt/cloudwatch_logs.py
describe_log_stream
def describe_log_stream(awsclient, log_group_name, log_stream_name): """Get info on the specified log stream :param log_group_name: log group name :param log_stream_name: log stream :return: """ client_logs = awsclient.get_client('logs') response = client_logs.describe_log_streams( ...
python
def describe_log_stream(awsclient, log_group_name, log_stream_name): """Get info on the specified log stream :param log_group_name: log group name :param log_stream_name: log stream :return: """ client_logs = awsclient.get_client('logs') response = client_logs.describe_log_streams( ...
[ "def", "describe_log_stream", "(", "awsclient", ",", "log_group_name", ",", "log_stream_name", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "response", "=", "client_logs", ".", "describe_log_streams", "(", "logGroupName", "=", ...
Get info on the specified log stream :param log_group_name: log group name :param log_stream_name: log stream :return:
[ "Get", "info", "on", "the", "specified", "log", "stream" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L109-L126
train
glomex/gcdt
gcdt/cloudwatch_logs.py
create_log_group
def create_log_group(awsclient, log_group_name): """Creates a log group with the specified name. :param log_group_name: log group name :return: """ client_logs = awsclient.get_client('logs') response = client_logs.create_log_group( logGroupName=log_group_name, )
python
def create_log_group(awsclient, log_group_name): """Creates a log group with the specified name. :param log_group_name: log group name :return: """ client_logs = awsclient.get_client('logs') response = client_logs.create_log_group( logGroupName=log_group_name, )
[ "def", "create_log_group", "(", "awsclient", ",", "log_group_name", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "response", "=", "client_logs", ".", "create_log_group", "(", "logGroupName", "=", "log_group_name", ",", ")" ]
Creates a log group with the specified name. :param log_group_name: log group name :return:
[ "Creates", "a", "log", "group", "with", "the", "specified", "name", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L140-L150
train
glomex/gcdt
gcdt/cloudwatch_logs.py
create_log_stream
def create_log_stream(awsclient, log_group_name, log_stream_name): """Creates a log stream for the specified log group. :param log_group_name: log group name :param log_stream_name: log stream name :return: """ client_logs = awsclient.get_client('logs') response = client_logs.create_log_st...
python
def create_log_stream(awsclient, log_group_name, log_stream_name): """Creates a log stream for the specified log group. :param log_group_name: log group name :param log_stream_name: log stream name :return: """ client_logs = awsclient.get_client('logs') response = client_logs.create_log_st...
[ "def", "create_log_stream", "(", "awsclient", ",", "log_group_name", ",", "log_stream_name", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "response", "=", "client_logs", ".", "create_log_stream", "(", "logGroupName", "=", "log_...
Creates a log stream for the specified log group. :param log_group_name: log group name :param log_stream_name: log stream name :return:
[ "Creates", "a", "log", "stream", "for", "the", "specified", "log", "group", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L153-L165
train
glomex/gcdt
gcdt/cloudwatch_logs.py
put_log_events
def put_log_events(awsclient, log_group_name, log_stream_name, log_events, sequence_token=None): """Put log events for the specified log group and stream. :param log_group_name: log group name :param log_stream_name: log stream name :param log_events: [{'timestamp': 123, 'message': '...
python
def put_log_events(awsclient, log_group_name, log_stream_name, log_events, sequence_token=None): """Put log events for the specified log group and stream. :param log_group_name: log group name :param log_stream_name: log stream name :param log_events: [{'timestamp': 123, 'message': '...
[ "def", "put_log_events", "(", "awsclient", ",", "log_group_name", ",", "log_stream_name", ",", "log_events", ",", "sequence_token", "=", "None", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "request", "=", "{", "'logGroupName...
Put log events for the specified log group and stream. :param log_group_name: log group name :param log_stream_name: log stream name :param log_events: [{'timestamp': 123, 'message': 'string'}, ...] :param sequence_token: the sequence token :return: next_token
[ "Put", "log", "events", "for", "the", "specified", "log", "group", "and", "stream", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L168-L191
train
glomex/gcdt
gcdt/cloudwatch_logs.py
get_log_events
def get_log_events(awsclient, log_group_name, log_stream_name, start_ts=None): """Get log events for the specified log group and stream. this is used in tenkai output instance diagnostics :param log_group_name: log group name :param log_stream_name: log stream name :param start_ts: timestamp :r...
python
def get_log_events(awsclient, log_group_name, log_stream_name, start_ts=None): """Get log events for the specified log group and stream. this is used in tenkai output instance diagnostics :param log_group_name: log group name :param log_stream_name: log stream name :param start_ts: timestamp :r...
[ "def", "get_log_events", "(", "awsclient", ",", "log_group_name", ",", "log_stream_name", ",", "start_ts", "=", "None", ")", ":", "client_logs", "=", "awsclient", ".", "get_client", "(", "'logs'", ")", "request", "=", "{", "'logGroupName'", ":", "log_group_name"...
Get log events for the specified log group and stream. this is used in tenkai output instance diagnostics :param log_group_name: log group name :param log_stream_name: log stream name :param start_ts: timestamp :return:
[ "Get", "log", "events", "for", "the", "specified", "log", "group", "and", "stream", ".", "this", "is", "used", "in", "tenkai", "output", "instance", "diagnostics" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L194-L218
train
glomex/gcdt
gcdt/cloudwatch_logs.py
check_log_stream_exists
def check_log_stream_exists(awsclient, log_group_name, log_stream_name): """Check :param log_group_name: log group name :param log_stream_name: log stream name :return: True / False """ lg = describe_log_group(awsclient, log_group_name) if lg and lg['logGroupName'] == log_group_name: ...
python
def check_log_stream_exists(awsclient, log_group_name, log_stream_name): """Check :param log_group_name: log group name :param log_stream_name: log stream name :return: True / False """ lg = describe_log_group(awsclient, log_group_name) if lg and lg['logGroupName'] == log_group_name: ...
[ "def", "check_log_stream_exists", "(", "awsclient", ",", "log_group_name", ",", "log_stream_name", ")", ":", "lg", "=", "describe_log_group", "(", "awsclient", ",", "log_group_name", ")", "if", "lg", "and", "lg", "[", "'logGroupName'", "]", "==", "log_group_name",...
Check :param log_group_name: log group name :param log_stream_name: log stream name :return: True / False
[ "Check" ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L221-L233
train
glomex/gcdt
gcdt/cloudwatch_logs.py
decode_format_timestamp
def decode_format_timestamp(timestamp): """Convert unix timestamp (millis) into date & time we use in logs output. :param timestamp: unix timestamp in millis :return: date, time in UTC """ dt = maya.MayaDT(timestamp / 1000).datetime(naive=True) return dt.strftime('%Y-%m-%d'), dt.strftime('%H:%M...
python
def decode_format_timestamp(timestamp): """Convert unix timestamp (millis) into date & time we use in logs output. :param timestamp: unix timestamp in millis :return: date, time in UTC """ dt = maya.MayaDT(timestamp / 1000).datetime(naive=True) return dt.strftime('%Y-%m-%d'), dt.strftime('%H:%M...
[ "def", "decode_format_timestamp", "(", "timestamp", ")", ":", "dt", "=", "maya", ".", "MayaDT", "(", "timestamp", "/", "1000", ")", ".", "datetime", "(", "naive", "=", "True", ")", "return", "dt", ".", "strftime", "(", "'%Y-%m-%d'", ")", ",", "dt", "."...
Convert unix timestamp (millis) into date & time we use in logs output. :param timestamp: unix timestamp in millis :return: date, time in UTC
[ "Convert", "unix", "timestamp", "(", "millis", ")", "into", "date", "&", "time", "we", "use", "in", "logs", "output", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L236-L243
train
gmr/helper
helper/config.py
Config.reload
def reload(self): """Reload the configuration from disk returning True if the configuration has changed from the previous values. """ config = self._default_configuration() if self._file_path: config.update(self._load_config_file()) if config != self._values:...
python
def reload(self): """Reload the configuration from disk returning True if the configuration has changed from the previous values. """ config = self._default_configuration() if self._file_path: config.update(self._load_config_file()) if config != self._values:...
[ "def", "reload", "(", "self", ")", ":", "config", "=", "self", ".", "_default_configuration", "(", ")", "if", "self", ".", "_file_path", ":", "config", ".", "update", "(", "self", ".", "_load_config_file", "(", ")", ")", "if", "config", "!=", "self", "...
Reload the configuration from disk returning True if the configuration has changed from the previous values.
[ "Reload", "the", "configuration", "from", "disk", "returning", "True", "if", "the", "configuration", "has", "changed", "from", "the", "previous", "values", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L102-L113
train
gmr/helper
helper/config.py
Config._load_config_file
def _load_config_file(self): """Load the configuration file into memory, returning the content. """ LOGGER.info('Loading configuration from %s', self._file_path) if self._file_path.endswith('json'): config = self._load_json_config() else: config = self._l...
python
def _load_config_file(self): """Load the configuration file into memory, returning the content. """ LOGGER.info('Loading configuration from %s', self._file_path) if self._file_path.endswith('json'): config = self._load_json_config() else: config = self._l...
[ "def", "_load_config_file", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'Loading configuration from %s'", ",", "self", ".", "_file_path", ")", "if", "self", ".", "_file_path", ".", "endswith", "(", "'json'", ")", ":", "config", "=", "self", ".", "_...
Load the configuration file into memory, returning the content.
[ "Load", "the", "configuration", "file", "into", "memory", "returning", "the", "content", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L128-L141
train
gmr/helper
helper/config.py
Config._load_json_config
def _load_json_config(self): """Load the configuration file in JSON format :rtype: dict """ try: return json.loads(self._read_config()) except ValueError as error: raise ValueError( 'Could not read configuration file: {}'.format(error))
python
def _load_json_config(self): """Load the configuration file in JSON format :rtype: dict """ try: return json.loads(self._read_config()) except ValueError as error: raise ValueError( 'Could not read configuration file: {}'.format(error))
[ "def", "_load_json_config", "(", "self", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "self", ".", "_read_config", "(", ")", ")", "except", "ValueError", "as", "error", ":", "raise", "ValueError", "(", "'Could not read configuration file: {}'", "...
Load the configuration file in JSON format :rtype: dict
[ "Load", "the", "configuration", "file", "in", "JSON", "format" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L143-L153
train
gmr/helper
helper/config.py
Config._load_yaml_config
def _load_yaml_config(self): """Loads the configuration file from a .yaml or .yml file :type: dict """ try: config = self._read_config() except OSError as error: raise ValueError('Could not read configuration file: %s' % error) try: r...
python
def _load_yaml_config(self): """Loads the configuration file from a .yaml or .yml file :type: dict """ try: config = self._read_config() except OSError as error: raise ValueError('Could not read configuration file: %s' % error) try: r...
[ "def", "_load_yaml_config", "(", "self", ")", ":", "try", ":", "config", "=", "self", ".", "_read_config", "(", ")", "except", "OSError", "as", "error", ":", "raise", "ValueError", "(", "'Could not read configuration file: %s'", "%", "error", ")", "try", ":", ...
Loads the configuration file from a .yaml or .yml file :type: dict
[ "Loads", "the", "configuration", "file", "from", "a", ".", "yaml", "or", ".", "yml", "file" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L155-L175
train
gmr/helper
helper/config.py
Config._normalize_file_path
def _normalize_file_path(file_path): """Normalize the file path value. :param str file_path: The file path as passed in :rtype: str """ if not file_path: return None elif file_path.startswith('s3://') or \ file_path.startswith('http://') or \...
python
def _normalize_file_path(file_path): """Normalize the file path value. :param str file_path: The file path as passed in :rtype: str """ if not file_path: return None elif file_path.startswith('s3://') or \ file_path.startswith('http://') or \...
[ "def", "_normalize_file_path", "(", "file_path", ")", ":", "if", "not", "file_path", ":", "return", "None", "elif", "file_path", ".", "startswith", "(", "'s3://'", ")", "or", "file_path", ".", "startswith", "(", "'http://'", ")", "or", "file_path", ".", "sta...
Normalize the file path value. :param str file_path: The file path as passed in :rtype: str
[ "Normalize", "the", "file", "path", "value", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L178-L191
train
gmr/helper
helper/config.py
Config._read_config
def _read_config(self): """Read the configuration from the various places it may be read from. :rtype: str :raises: ValueError """ if not self._file_path: return None elif self._file_path.startswith('s3://'): return self._read_s3_config() ...
python
def _read_config(self): """Read the configuration from the various places it may be read from. :rtype: str :raises: ValueError """ if not self._file_path: return None elif self._file_path.startswith('s3://'): return self._read_s3_config() ...
[ "def", "_read_config", "(", "self", ")", ":", "if", "not", "self", ".", "_file_path", ":", "return", "None", "elif", "self", ".", "_file_path", ".", "startswith", "(", "'s3://'", ")", ":", "return", "self", ".", "_read_s3_config", "(", ")", "elif", "self...
Read the configuration from the various places it may be read from. :rtype: str :raises: ValueError
[ "Read", "the", "configuration", "from", "the", "various", "places", "it", "may", "be", "read", "from", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L193-L212
train
gmr/helper
helper/config.py
Config._read_remote_config
def _read_remote_config(self): """Read a remote config via URL. :rtype: str :raises: ValueError """ try: import requests except ImportError: requests = None if not requests: raise ValueError( 'Remote config URL...
python
def _read_remote_config(self): """Read a remote config via URL. :rtype: str :raises: ValueError """ try: import requests except ImportError: requests = None if not requests: raise ValueError( 'Remote config URL...
[ "def", "_read_remote_config", "(", "self", ")", ":", "try", ":", "import", "requests", "except", "ImportError", ":", "requests", "=", "None", "if", "not", "requests", ":", "raise", "ValueError", "(", "'Remote config URL specified but requests not installed'", ")", "...
Read a remote config via URL. :rtype: str :raises: ValueError
[ "Read", "a", "remote", "config", "via", "URL", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L214-L233
train
gmr/helper
helper/config.py
Config._read_s3_config
def _read_s3_config(self): """Read in the value of the configuration file in Amazon S3. :rtype: str :raises: ValueError """ try: import boto3 import botocore.exceptions except ImportError: boto3, botocore = None, None if not ...
python
def _read_s3_config(self): """Read in the value of the configuration file in Amazon S3. :rtype: str :raises: ValueError """ try: import boto3 import botocore.exceptions except ImportError: boto3, botocore = None, None if not ...
[ "def", "_read_s3_config", "(", "self", ")", ":", "try", ":", "import", "boto3", "import", "botocore", ".", "exceptions", "except", "ImportError", ":", "boto3", ",", "botocore", "=", "None", ",", "None", "if", "not", "boto3", ":", "raise", "ValueError", "("...
Read in the value of the configuration file in Amazon S3. :rtype: str :raises: ValueError
[ "Read", "in", "the", "value", "of", "the", "configuration", "file", "in", "Amazon", "S3", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L235-L259
train
gmr/helper
helper/config.py
LoggingConfig.update
def update(self, configuration, debug=None): """Update the internal configuration values, removing debug_only handlers if debug is False. Returns True if the configuration has changed from previous configuration values. :param dict configuration: The logging configuration :param...
python
def update(self, configuration, debug=None): """Update the internal configuration values, removing debug_only handlers if debug is False. Returns True if the configuration has changed from previous configuration values. :param dict configuration: The logging configuration :param...
[ "def", "update", "(", "self", ",", "configuration", ",", "debug", "=", "None", ")", ":", "if", "self", ".", "config", "!=", "dict", "(", "configuration", ")", "and", "debug", "!=", "self", ".", "debug", ":", "self", ".", "config", "=", "dict", "(", ...
Update the internal configuration values, removing debug_only handlers if debug is False. Returns True if the configuration has changed from previous configuration values. :param dict configuration: The logging configuration :param bool debug: Toggles use of debug_only loggers :...
[ "Update", "the", "internal", "configuration", "values", "removing", "debug_only", "handlers", "if", "debug", "is", "False", ".", "Returns", "True", "if", "the", "configuration", "has", "changed", "from", "previous", "configuration", "values", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L288-L303
train
gmr/helper
helper/config.py
LoggingConfig.configure
def configure(self): """Configure the Python stdlib logger""" if self.debug is not None and not self.debug: self._remove_debug_handlers() self._remove_debug_only() logging.config.dictConfig(self.config) try: logging.captureWarnings(True) except Att...
python
def configure(self): """Configure the Python stdlib logger""" if self.debug is not None and not self.debug: self._remove_debug_handlers() self._remove_debug_only() logging.config.dictConfig(self.config) try: logging.captureWarnings(True) except Att...
[ "def", "configure", "(", "self", ")", ":", "if", "self", ".", "debug", "is", "not", "None", "and", "not", "self", ".", "debug", ":", "self", ".", "_remove_debug_handlers", "(", ")", "self", ".", "_remove_debug_only", "(", ")", "logging", ".", "config", ...
Configure the Python stdlib logger
[ "Configure", "the", "Python", "stdlib", "logger" ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L305-L314
train
gmr/helper
helper/config.py
LoggingConfig._remove_debug_handlers
def _remove_debug_handlers(self): """Remove any handlers with an attribute of debug_only that is True and remove the references to said handlers from any loggers that are referencing them. """ remove = list() for handler in self.config[self.HANDLERS]: if self...
python
def _remove_debug_handlers(self): """Remove any handlers with an attribute of debug_only that is True and remove the references to said handlers from any loggers that are referencing them. """ remove = list() for handler in self.config[self.HANDLERS]: if self...
[ "def", "_remove_debug_handlers", "(", "self", ")", ":", "remove", "=", "list", "(", ")", "for", "handler", "in", "self", ".", "config", "[", "self", ".", "HANDLERS", "]", ":", "if", "self", ".", "config", "[", "self", ".", "HANDLERS", "]", "[", "hand...
Remove any handlers with an attribute of debug_only that is True and remove the references to said handlers from any loggers that are referencing them.
[ "Remove", "any", "handlers", "with", "an", "attribute", "of", "debug_only", "that", "is", "True", "and", "remove", "the", "references", "to", "said", "handlers", "from", "any", "loggers", "that", "are", "referencing", "them", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L316-L332
train
gmr/helper
helper/config.py
LoggingConfig._remove_debug_only
def _remove_debug_only(self): """Iterate through each handler removing the invalid dictConfig key of debug_only. """ LOGGER.debug('Removing debug only from handlers') for handler in self.config[self.HANDLERS]: if self.DEBUG_ONLY in self.config[self.HANDLERS][handler]...
python
def _remove_debug_only(self): """Iterate through each handler removing the invalid dictConfig key of debug_only. """ LOGGER.debug('Removing debug only from handlers') for handler in self.config[self.HANDLERS]: if self.DEBUG_ONLY in self.config[self.HANDLERS][handler]...
[ "def", "_remove_debug_only", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Removing debug only from handlers'", ")", "for", "handler", "in", "self", ".", "config", "[", "self", ".", "HANDLERS", "]", ":", "if", "self", ".", "DEBUG_ONLY", "in", "self",...
Iterate through each handler removing the invalid dictConfig key of debug_only.
[ "Iterate", "through", "each", "handler", "removing", "the", "invalid", "dictConfig", "key", "of", "debug_only", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/config.py#L334-L342
train
CitrineInformatics/pypif
pypif/util/serializable.py
Serializable.as_dictionary
def as_dictionary(self): """ Convert this object to a dictionary with formatting appropriate for a PIF. :returns: Dictionary with the content of this object formatted for a PIF. """ return {to_camel_case(i): Serializable._convert_to_dictionary(self.__dict__[i]) f...
python
def as_dictionary(self): """ Convert this object to a dictionary with formatting appropriate for a PIF. :returns: Dictionary with the content of this object formatted for a PIF. """ return {to_camel_case(i): Serializable._convert_to_dictionary(self.__dict__[i]) f...
[ "def", "as_dictionary", "(", "self", ")", ":", "return", "{", "to_camel_case", "(", "i", ")", ":", "Serializable", ".", "_convert_to_dictionary", "(", "self", ".", "__dict__", "[", "i", "]", ")", "for", "i", "in", "self", ".", "__dict__", "if", "self", ...
Convert this object to a dictionary with formatting appropriate for a PIF. :returns: Dictionary with the content of this object formatted for a PIF.
[ "Convert", "this", "object", "to", "a", "dictionary", "with", "formatting", "appropriate", "for", "a", "PIF", "." ]
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/serializable.py#L10-L17
train
CitrineInformatics/pypif
pypif/util/serializable.py
Serializable._convert_to_dictionary
def _convert_to_dictionary(obj): """ Convert obj to a dictionary with formatting appropriate for a PIF. This function attempts to treat obj as a Pio object and otherwise returns obj. :param obj: Object to convert to a dictionary. :returns: Input object as a dictionary or the ori...
python
def _convert_to_dictionary(obj): """ Convert obj to a dictionary with formatting appropriate for a PIF. This function attempts to treat obj as a Pio object and otherwise returns obj. :param obj: Object to convert to a dictionary. :returns: Input object as a dictionary or the ori...
[ "def", "_convert_to_dictionary", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "[", "Serializable", ".", "_convert_to_dictionary", "(", "i", ")", "for", "i", "in", "obj", "]", "elif", "hasattr", "(", "obj", ",", ...
Convert obj to a dictionary with formatting appropriate for a PIF. This function attempts to treat obj as a Pio object and otherwise returns obj. :param obj: Object to convert to a dictionary. :returns: Input object as a dictionary or the original object.
[ "Convert", "obj", "to", "a", "dictionary", "with", "formatting", "appropriate", "for", "a", "PIF", ".", "This", "function", "attempts", "to", "treat", "obj", "as", "a", "Pio", "object", "and", "otherwise", "returns", "obj", "." ]
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/serializable.py#L20-L33
train
CitrineInformatics/pypif
pypif/util/serializable.py
Serializable._get_object
def _get_object(class_, obj): """ Helper function that returns an object, or if it is a dictionary, initializes it from class_. :param class_: Class to use to instantiate object. :param obj: Object to process. :return: One or more objects. """ if isinstance(obj, ...
python
def _get_object(class_, obj): """ Helper function that returns an object, or if it is a dictionary, initializes it from class_. :param class_: Class to use to instantiate object. :param obj: Object to process. :return: One or more objects. """ if isinstance(obj, ...
[ "def", "_get_object", "(", "class_", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "[", "Serializable", ".", "_get_object", "(", "class_", ",", "i", ")", "for", "i", "in", "obj", "]", "elif", "isinstance", "("...
Helper function that returns an object, or if it is a dictionary, initializes it from class_. :param class_: Class to use to instantiate object. :param obj: Object to process. :return: One or more objects.
[ "Helper", "function", "that", "returns", "an", "object", "or", "if", "it", "is", "a", "dictionary", "initializes", "it", "from", "class_", "." ]
938348a8ff7b10b330770cccaaeb2109922f681b
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/serializable.py#L36-L49
train
marians/audiocalc
audiocalc/py_audiocalc.py
damping
def damping(temp, relhum, freq, pres=101325): """ Calculates the damping factor for sound in dB/m depending on temperature, humidity and sound frequency. Source: http://www.sengpielaudio.com/LuftdaempfungFormel.htm temp: Temperature in degrees celsius relhum: Relative humidity as percentage, e....
python
def damping(temp, relhum, freq, pres=101325): """ Calculates the damping factor for sound in dB/m depending on temperature, humidity and sound frequency. Source: http://www.sengpielaudio.com/LuftdaempfungFormel.htm temp: Temperature in degrees celsius relhum: Relative humidity as percentage, e....
[ "def", "damping", "(", "temp", ",", "relhum", ",", "freq", ",", "pres", "=", "101325", ")", ":", "temp", "+=", "273.15", "# convert to kelvin", "pres", "=", "pres", "/", "101325.0", "# convert to relative pressure", "c_humid", "=", "4.6151", "-", "6.8346", "...
Calculates the damping factor for sound in dB/m depending on temperature, humidity and sound frequency. Source: http://www.sengpielaudio.com/LuftdaempfungFormel.htm temp: Temperature in degrees celsius relhum: Relative humidity as percentage, e.g. 50 freq: Sound frequency in herz pres: Atmosphe...
[ "Calculates", "the", "damping", "factor", "for", "sound", "in", "dB", "/", "m", "depending", "on", "temperature", "humidity", "and", "sound", "frequency", ".", "Source", ":", "http", ":", "//", "www", ".", "sengpielaudio", ".", "com", "/", "LuftdaempfungForm...
ef917b05d9dddc5a3a44165112835669ef4808d3
https://github.com/marians/audiocalc/blob/ef917b05d9dddc5a3a44165112835669ef4808d3/audiocalc/py_audiocalc.py#L19-L51
train
marians/audiocalc
audiocalc/py_audiocalc.py
total_level
def total_level(source_levels): """ Calculates the total sound pressure level based on multiple source levels """ sums = 0.0 for l in source_levels: if l is None: continue if l == 0: continue sums += pow(10.0, float(l) / 10.0) level = 10.0 * math.l...
python
def total_level(source_levels): """ Calculates the total sound pressure level based on multiple source levels """ sums = 0.0 for l in source_levels: if l is None: continue if l == 0: continue sums += pow(10.0, float(l) / 10.0) level = 10.0 * math.l...
[ "def", "total_level", "(", "source_levels", ")", ":", "sums", "=", "0.0", "for", "l", "in", "source_levels", ":", "if", "l", "is", "None", ":", "continue", "if", "l", "==", "0", ":", "continue", "sums", "+=", "pow", "(", "10.0", ",", "float", "(", ...
Calculates the total sound pressure level based on multiple source levels
[ "Calculates", "the", "total", "sound", "pressure", "level", "based", "on", "multiple", "source", "levels" ]
ef917b05d9dddc5a3a44165112835669ef4808d3
https://github.com/marians/audiocalc/blob/ef917b05d9dddc5a3a44165112835669ef4808d3/audiocalc/py_audiocalc.py#L54-L66
train
marians/audiocalc
audiocalc/py_audiocalc.py
total_rated_level
def total_rated_level(octave_frequencies): """ Calculates the A-rated total sound pressure level based on octave band frequencies """ sums = 0.0 for band in OCTAVE_BANDS.keys(): if band not in octave_frequencies: continue if octave_frequencies[band] is None: ...
python
def total_rated_level(octave_frequencies): """ Calculates the A-rated total sound pressure level based on octave band frequencies """ sums = 0.0 for band in OCTAVE_BANDS.keys(): if band not in octave_frequencies: continue if octave_frequencies[band] is None: ...
[ "def", "total_rated_level", "(", "octave_frequencies", ")", ":", "sums", "=", "0.0", "for", "band", "in", "OCTAVE_BANDS", ".", "keys", "(", ")", ":", "if", "band", "not", "in", "octave_frequencies", ":", "continue", "if", "octave_frequencies", "[", "band", "...
Calculates the A-rated total sound pressure level based on octave band frequencies
[ "Calculates", "the", "A", "-", "rated", "total", "sound", "pressure", "level", "based", "on", "octave", "band", "frequencies" ]
ef917b05d9dddc5a3a44165112835669ef4808d3
https://github.com/marians/audiocalc/blob/ef917b05d9dddc5a3a44165112835669ef4808d3/audiocalc/py_audiocalc.py#L69-L84
train
marians/audiocalc
audiocalc/py_audiocalc.py
leq3
def leq3(levels): """ Calculates the energy-equivalent (Leq3) value given a regular measurement interval. """ n = float(len(levels)) sums = 0.0 if sum(levels) == 0.0: return 0.0 for l in levels: if l == 0: continue sums += pow(10.0, float(l) / 10.0) ...
python
def leq3(levels): """ Calculates the energy-equivalent (Leq3) value given a regular measurement interval. """ n = float(len(levels)) sums = 0.0 if sum(levels) == 0.0: return 0.0 for l in levels: if l == 0: continue sums += pow(10.0, float(l) / 10.0) ...
[ "def", "leq3", "(", "levels", ")", ":", "n", "=", "float", "(", "len", "(", "levels", ")", ")", "sums", "=", "0.0", "if", "sum", "(", "levels", ")", "==", "0.0", ":", "return", "0.0", "for", "l", "in", "levels", ":", "if", "l", "==", "0", ":"...
Calculates the energy-equivalent (Leq3) value given a regular measurement interval.
[ "Calculates", "the", "energy", "-", "equivalent", "(", "Leq3", ")", "value", "given", "a", "regular", "measurement", "interval", "." ]
ef917b05d9dddc5a3a44165112835669ef4808d3
https://github.com/marians/audiocalc/blob/ef917b05d9dddc5a3a44165112835669ef4808d3/audiocalc/py_audiocalc.py#L87-L102
train
marians/audiocalc
audiocalc/py_audiocalc.py
distant_level
def distant_level(reference_level, distance, reference_distance=1.0): """ Calculates the sound pressure level in dependence of a distance where a perfect ball-shaped source and spread is assumed. reference_level: Sound pressure level in reference distance in dB distance: Distance to calculate s...
python
def distant_level(reference_level, distance, reference_distance=1.0): """ Calculates the sound pressure level in dependence of a distance where a perfect ball-shaped source and spread is assumed. reference_level: Sound pressure level in reference distance in dB distance: Distance to calculate s...
[ "def", "distant_level", "(", "reference_level", ",", "distance", ",", "reference_distance", "=", "1.0", ")", ":", "rel_dist", "=", "float", "(", "reference_distance", ")", "/", "float", "(", "distance", ")", "level", "=", "float", "(", "reference_level", ")", ...
Calculates the sound pressure level in dependence of a distance where a perfect ball-shaped source and spread is assumed. reference_level: Sound pressure level in reference distance in dB distance: Distance to calculate sound pressure level for, in meters reference_distance: reference distance in m...
[ "Calculates", "the", "sound", "pressure", "level", "in", "dependence", "of", "a", "distance", "where", "a", "perfect", "ball", "-", "shaped", "source", "and", "spread", "is", "assumed", "." ]
ef917b05d9dddc5a3a44165112835669ef4808d3
https://github.com/marians/audiocalc/blob/ef917b05d9dddc5a3a44165112835669ef4808d3/audiocalc/py_audiocalc.py#L105-L117
train
marians/audiocalc
audiocalc/py_audiocalc.py
distant_total_damped_rated_level
def distant_total_damped_rated_level( octave_frequencies, distance, temp, relhum, reference_distance=1.0): """ Calculates the damped, A-rated total sound pressure level in a given distance, temperature and relative humidity from octave frequenc...
python
def distant_total_damped_rated_level( octave_frequencies, distance, temp, relhum, reference_distance=1.0): """ Calculates the damped, A-rated total sound pressure level in a given distance, temperature and relative humidity from octave frequenc...
[ "def", "distant_total_damped_rated_level", "(", "octave_frequencies", ",", "distance", ",", "temp", ",", "relhum", ",", "reference_distance", "=", "1.0", ")", ":", "damping_distance", "=", "distance", "-", "reference_distance", "sums", "=", "0.0", "for", "band", "...
Calculates the damped, A-rated total sound pressure level in a given distance, temperature and relative humidity from octave frequency sound pressure levels in a reference distance
[ "Calculates", "the", "damped", "A", "-", "rated", "total", "sound", "pressure", "level", "in", "a", "given", "distance", "temperature", "and", "relative", "humidity", "from", "octave", "frequency", "sound", "pressure", "levels", "in", "a", "reference", "distance...
ef917b05d9dddc5a3a44165112835669ef4808d3
https://github.com/marians/audiocalc/blob/ef917b05d9dddc5a3a44165112835669ef4808d3/audiocalc/py_audiocalc.py#L120-L154
train
DeepHorizons/iarm
iarm/arm_instructions/shift.py
Shift.ASRS
def ASRS(self, params): """ ASRS [Ra,] Ra, Rc ASRS [Ra,] Rb, #imm5_counting Arithmetic shift right Rb by Rc or imm5_counting and store the result in Ra imm5 counting is [1, 32] In the register shift, the first two operands must be the same register Ra, Rb, and Rc...
python
def ASRS(self, params): """ ASRS [Ra,] Ra, Rc ASRS [Ra,] Rb, #imm5_counting Arithmetic shift right Rb by Rc or imm5_counting and store the result in Ra imm5 counting is [1, 32] In the register shift, the first two operands must be the same register Ra, Rb, and Rc...
[ "def", "ASRS", "(", "self", ",", "params", ")", ":", "# This instruction allows for an optional destination register", "# If it is omitted, then it is assumed to be Rb", "# As defined in http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0662b/index.html", "try", ":", "Ra", "...
ASRS [Ra,] Ra, Rc ASRS [Ra,] Rb, #imm5_counting Arithmetic shift right Rb by Rc or imm5_counting and store the result in Ra imm5 counting is [1, 32] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low registers If Ra is omit...
[ "ASRS", "[", "Ra", "]", "Ra", "Rc", "ASRS", "[", "Ra", "]", "Rb", "#imm5_counting" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/shift.py#L6-L63
train
DeepHorizons/iarm
iarm/arm_instructions/shift.py
Shift.LSLS
def LSLS(self, params): """ LSLS [Ra,] Ra, Rc LSLS [Ra,] Rb, #imm5 Logical shift left Rb by Rc or imm5 and store the result in Ra imm5 is [0, 31] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low registers ...
python
def LSLS(self, params): """ LSLS [Ra,] Ra, Rc LSLS [Ra,] Rb, #imm5 Logical shift left Rb by Rc or imm5 and store the result in Ra imm5 is [0, 31] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low registers ...
[ "def", "LSLS", "(", "self", ",", "params", ")", ":", "# This instruction allows for an optional destination register", "# If it is omitted, then it is assumed to be Rb", "# As defined in http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0662b/index.html", "try", ":", "Ra", "...
LSLS [Ra,] Ra, Rc LSLS [Ra,] Rb, #imm5 Logical shift left Rb by Rc or imm5 and store the result in Ra imm5 is [0, 31] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low registers If Ra is omitted, then it is assumed to be R...
[ "LSLS", "[", "Ra", "]", "Ra", "Rc", "LSLS", "[", "Ra", "]", "Rb", "#imm5" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/shift.py#L65-L114
train
DeepHorizons/iarm
iarm/arm_instructions/shift.py
Shift.LSRS
def LSRS(self, params): """ LSRS [Ra,] Ra, Rc LSRS [Ra,] Rb, #imm5_counting Logical shift right Rb by Rc or imm5 and store the result in Ra imm5 counting is [1, 32] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low...
python
def LSRS(self, params): """ LSRS [Ra,] Ra, Rc LSRS [Ra,] Rb, #imm5_counting Logical shift right Rb by Rc or imm5 and store the result in Ra imm5 counting is [1, 32] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low...
[ "def", "LSRS", "(", "self", ",", "params", ")", ":", "# This instruction allows for an optional destination register", "# If it is omitted, then it is assumed to be Rb", "# As defined in http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0662b/index.html", "try", ":", "Ra", "...
LSRS [Ra,] Ra, Rc LSRS [Ra,] Rb, #imm5_counting Logical shift right Rb by Rc or imm5 and store the result in Ra imm5 counting is [1, 32] In the register shift, the first two operands must be the same register Ra, Rb, and Rc must be low registers If Ra is omitted, then it...
[ "LSRS", "[", "Ra", "]", "Ra", "Rc", "LSRS", "[", "Ra", "]", "Rb", "#imm5_counting" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/shift.py#L116-L165
train
DeepHorizons/iarm
iarm/arm_instructions/shift.py
Shift.RORS
def RORS(self, params): """ RORS [Ra,] Ra, Rc Rotate shift right Rb by Rc or imm5 and store the result in Ra The first two operands must be the same register Ra and Rc must be low registers The first register is optional """ # This instruction allows for ...
python
def RORS(self, params): """ RORS [Ra,] Ra, Rc Rotate shift right Rb by Rc or imm5 and store the result in Ra The first two operands must be the same register Ra and Rc must be low registers The first register is optional """ # This instruction allows for ...
[ "def", "RORS", "(", "self", ",", "params", ")", ":", "# This instruction allows for an optional destination register", "# If it is omitted, then it is assumed to be Rb", "# As defined in http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0662b/index.html", "try", ":", "Ra", "...
RORS [Ra,] Ra, Rc Rotate shift right Rb by Rc or imm5 and store the result in Ra The first two operands must be the same register Ra and Rc must be low registers The first register is optional
[ "RORS", "[", "Ra", "]", "Ra", "Rc" ]
b913c9fd577b793a6bbced78b78a5d8d7cd88de4
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/shift.py#L167-L197
train
acrazing/dbapi
dbapi/Group.py
Group._parse_topic_table
def _parse_topic_table(self, xml, tds='title,created,comment,group', selector='//table[@class="olt"]//tr'): """ 解析话题列表 :internal :param xml: 页面XML :param tds: 每列的含义,可以是title, created, comment, group, updated, author, time, rec :param selector: 表在页面中的位置 :...
python
def _parse_topic_table(self, xml, tds='title,created,comment,group', selector='//table[@class="olt"]//tr'): """ 解析话题列表 :internal :param xml: 页面XML :param tds: 每列的含义,可以是title, created, comment, group, updated, author, time, rec :param selector: 表在页面中的位置 :...
[ "def", "_parse_topic_table", "(", "self", ",", "xml", ",", "tds", "=", "'title,created,comment,group'", ",", "selector", "=", "'//table[@class=\"olt\"]//tr'", ")", ":", "xml_results", "=", "xml", ".", "xpath", "(", "selector", ")", "results", "=", "[", "]", "t...
解析话题列表 :internal :param xml: 页面XML :param tds: 每列的含义,可以是title, created, comment, group, updated, author, time, rec :param selector: 表在页面中的位置 :return:
[ "解析话题列表", ":", "internal", ":", "param", "xml", ":", "页面XML", ":", "param", "tds", ":", "每列的含义,可以是title", "created", "comment", "group", "updated", "author", "time", "rec", ":", "param", "selector", ":", "表在页面中的位置", ":", "return", ":" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L29-L90
train
acrazing/dbapi
dbapi/Group.py
Group.search_groups
def search_groups(self, keyword, start=0): """ 搜索小组 :param keyword: 搜索的关键字 :param start: 翻页 :return: 含总数的列表 """ xml = self.api.xml(API_GROUP_SEARCH_GROUPS % (start, keyword)) xml_results = xml.xpath('//div[@class="groups"]/div[@class="result"]') ...
python
def search_groups(self, keyword, start=0): """ 搜索小组 :param keyword: 搜索的关键字 :param start: 翻页 :return: 含总数的列表 """ xml = self.api.xml(API_GROUP_SEARCH_GROUPS % (start, keyword)) xml_results = xml.xpath('//div[@class="groups"]/div[@class="result"]') ...
[ "def", "search_groups", "(", "self", ",", "keyword", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_SEARCH_GROUPS", "%", "(", "start", ",", "keyword", ")", ")", "xml_results", "=", "xml", ".", "xpath", "...
搜索小组 :param keyword: 搜索的关键字 :param start: 翻页 :return: 含总数的列表
[ "搜索小组", ":", "param", "keyword", ":", "搜索的关键字", ":", "param", "start", ":", "翻页", ":", "return", ":", "含总数的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L101-L129
train
acrazing/dbapi
dbapi/Group.py
Group.list_joined_groups
def list_joined_groups(self, user_alias=None): """ 已加入的小组列表 :param user_alias: 用户名,默认为当前用户名 :return: 单页列表 """ xml = self.api.xml(API_GROUP_LIST_JOINED_GROUPS % (user_alias or self.api.user_alias)) xml_results = xml.xpath('//div[@class="group-list group-ca...
python
def list_joined_groups(self, user_alias=None): """ 已加入的小组列表 :param user_alias: 用户名,默认为当前用户名 :return: 单页列表 """ xml = self.api.xml(API_GROUP_LIST_JOINED_GROUPS % (user_alias or self.api.user_alias)) xml_results = xml.xpath('//div[@class="group-list group-ca...
[ "def", "list_joined_groups", "(", "self", ",", "user_alias", "=", "None", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_LIST_JOINED_GROUPS", "%", "(", "user_alias", "or", "self", ".", "api", ".", "user_alias", ")", ")", "xml_results...
已加入的小组列表 :param user_alias: 用户名,默认为当前用户名 :return: 单页列表
[ "已加入的小组列表", ":", "param", "user_alias", ":", "用户名,默认为当前用户名", ":", "return", ":", "单页列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L131-L158
train
acrazing/dbapi
dbapi/Group.py
Group.join_group
def join_group(self, group_alias, message=None): """ 加入小组 :param group_alias: 小组ID :param message: 如果要验证,留言信息 :return: 枚举 - joined: 加入成功 - waiting: 等待审核 - initial: 加入失败 """ xml = self.api.xml(API_GROUP_GROUP...
python
def join_group(self, group_alias, message=None): """ 加入小组 :param group_alias: 小组ID :param message: 如果要验证,留言信息 :return: 枚举 - joined: 加入成功 - waiting: 等待审核 - initial: 加入失败 """ xml = self.api.xml(API_GROUP_GROUP...
[ "def", "join_group", "(", "self", ",", "group_alias", ",", "message", "=", "None", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_GROUP_HOME", "%", "group_alias", ",", "params", "=", "{", "'action'", ":", "'join'", ",", "'ck'", "...
加入小组 :param group_alias: 小组ID :param message: 如果要验证,留言信息 :return: 枚举 - joined: 加入成功 - waiting: 等待审核 - initial: 加入失败
[ "加入小组", ":", "param", "group_alias", ":", "小组ID", ":", "param", "message", ":", "如果要验证,留言信息", ":", "return", ":", "枚举", "-", "joined", ":", "加入成功", "-", "waiting", ":", "等待审核", "-", "initial", ":", "加入失败" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L169-L204
train
acrazing/dbapi
dbapi/Group.py
Group.leave_group
def leave_group(self, group_alias): """ 退出小组 :param group_alias: 小组ID :return: """ return self.api.req(API_GROUP_GROUP_HOME % group_alias, params={ 'action': 'quit', 'ck': self.api.ck(), })
python
def leave_group(self, group_alias): """ 退出小组 :param group_alias: 小组ID :return: """ return self.api.req(API_GROUP_GROUP_HOME % group_alias, params={ 'action': 'quit', 'ck': self.api.ck(), })
[ "def", "leave_group", "(", "self", ",", "group_alias", ")", ":", "return", "self", ".", "api", ".", "req", "(", "API_GROUP_GROUP_HOME", "%", "group_alias", ",", "params", "=", "{", "'action'", ":", "'quit'", ",", "'ck'", ":", "self", ".", "api", ".", "...
退出小组 :param group_alias: 小组ID :return:
[ "退出小组", ":", "param", "group_alias", ":", "小组ID", ":", "return", ":" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L206-L216
train
acrazing/dbapi
dbapi/Group.py
Group.search_topics
def search_topics(self, keyword, sort='relevance', start=0): """ 搜索话题 :param keyword: 关键字 :param sort: 排序方式 relevance/newest :param start: 翻页 :return: 带总数的列表 """ xml = self.api.xml(API_GROUP_SEARCH_TOPICS % (start, sort, keyword)) return b...
python
def search_topics(self, keyword, sort='relevance', start=0): """ 搜索话题 :param keyword: 关键字 :param sort: 排序方式 relevance/newest :param start: 翻页 :return: 带总数的列表 """ xml = self.api.xml(API_GROUP_SEARCH_TOPICS % (start, sort, keyword)) return b...
[ "def", "search_topics", "(", "self", ",", "keyword", ",", "sort", "=", "'relevance'", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_SEARCH_TOPICS", "%", "(", "start", ",", "sort", ",", "keyword", ")", "...
搜索话题 :param keyword: 关键字 :param sort: 排序方式 relevance/newest :param start: 翻页 :return: 带总数的列表
[ "搜索话题", ":", "param", "keyword", ":", "关键字", ":", "param", "sort", ":", "排序方式", "relevance", "/", "newest", ":", "param", "start", ":", "翻页", ":", "return", ":", "带总数的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L218-L228
train
acrazing/dbapi
dbapi/Group.py
Group.list_topics
def list_topics(self, group_alias, _type='', start=0): """ 小组内话题列表 :param group_alias: 小组ID :param _type: 类型 默认最新,hot:最热 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_LIST_GROUP_TOPICS % group_alias, params={ 'star...
python
def list_topics(self, group_alias, _type='', start=0): """ 小组内话题列表 :param group_alias: 小组ID :param _type: 类型 默认最新,hot:最热 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_LIST_GROUP_TOPICS % group_alias, params={ 'star...
[ "def", "list_topics", "(", "self", ",", "group_alias", ",", "_type", "=", "''", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_LIST_GROUP_TOPICS", "%", "group_alias", ",", "params", "=", "{", "'start'", ":...
小组内话题列表 :param group_alias: 小组ID :param _type: 类型 默认最新,hot:最热 :param start: 翻页 :return: 带下一页的列表
[ "小组内话题列表", ":", "param", "group_alias", ":", "小组ID", ":", "param", "_type", ":", "类型", "默认最新,hot", ":", "最热", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L230-L243
train
acrazing/dbapi
dbapi/Group.py
Group.list_joined_topics
def list_joined_topics(self, start=0): """ 已加入的所有小组的话题列表 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_HOME, params={'start': start}) return build_list_result(self._parse_topic_table(xml, 'title,comment,created,group'), xml)
python
def list_joined_topics(self, start=0): """ 已加入的所有小组的话题列表 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_HOME, params={'start': start}) return build_list_result(self._parse_topic_table(xml, 'title,comment,created,group'), xml)
[ "def", "list_joined_topics", "(", "self", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_HOME", ",", "params", "=", "{", "'start'", ":", "start", "}", ")", "return", "build_list_result", "(", "self", ".", ...
已加入的所有小组的话题列表 :param start: 翻页 :return: 带下一页的列表
[ "已加入的所有小组的话题列表", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L245-L253
train
acrazing/dbapi
dbapi/Group.py
Group.list_user_topics
def list_user_topics(self, start=0): """ 发表的话题 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_LIST_USER_PUBLISHED_TOPICS % self.api.user_alias, params={'start': start}) return build_list_result(self._parse_topic_table(xml, 'title,comme...
python
def list_user_topics(self, start=0): """ 发表的话题 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_LIST_USER_PUBLISHED_TOPICS % self.api.user_alias, params={'start': start}) return build_list_result(self._parse_topic_table(xml, 'title,comme...
[ "def", "list_user_topics", "(", "self", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_LIST_USER_PUBLISHED_TOPICS", "%", "self", ".", "api", ".", "user_alias", ",", "params", "=", "{", "'start'", ":", "start...
发表的话题 :param start: 翻页 :return: 带下一页的列表
[ "发表的话题", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L255-L263
train
acrazing/dbapi
dbapi/Group.py
Group.list_commented_topics
def list_commented_topics(self, start=0): """ 回复过的话题列表 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_LIST_USER_COMMENTED_TOPICS % self.api.user_alias, params={'start': start}) return build_list_result(self._parse_topic_table(xml, 'tit...
python
def list_commented_topics(self, start=0): """ 回复过的话题列表 :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_LIST_USER_COMMENTED_TOPICS % self.api.user_alias, params={'start': start}) return build_list_result(self._parse_topic_table(xml, 'tit...
[ "def", "list_commented_topics", "(", "self", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_LIST_USER_COMMENTED_TOPICS", "%", "self", ".", "api", ".", "user_alias", ",", "params", "=", "{", "'start'", ":", "...
回复过的话题列表 :param start: 翻页 :return: 带下一页的列表
[ "回复过的话题列表", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L265-L273
train
acrazing/dbapi
dbapi/Group.py
Group.list_liked_topics
def list_liked_topics(self, user_alias=None, start=0): """ 喜欢过的话题 :param user_alias: 指定用户,默认当前 :param start: 翻页 :return: 带下一页的列表 """ user_alias = user_alias or self.api.user_alias xml = self.api.xml(API_GROUP_LIST_USER_LIKED_TOPICS % user_alias, p...
python
def list_liked_topics(self, user_alias=None, start=0): """ 喜欢过的话题 :param user_alias: 指定用户,默认当前 :param start: 翻页 :return: 带下一页的列表 """ user_alias = user_alias or self.api.user_alias xml = self.api.xml(API_GROUP_LIST_USER_LIKED_TOPICS % user_alias, p...
[ "def", "list_liked_topics", "(", "self", ",", "user_alias", "=", "None", ",", "start", "=", "0", ")", ":", "user_alias", "=", "user_alias", "or", "self", ".", "api", ".", "user_alias", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_LIST_USER...
喜欢过的话题 :param user_alias: 指定用户,默认当前 :param start: 翻页 :return: 带下一页的列表
[ "喜欢过的话题", ":", "param", "user_alias", ":", "指定用户,默认当前", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L275-L285
train
acrazing/dbapi
dbapi/Group.py
Group.list_reced_topics
def list_reced_topics(self, user_alias=None, start=0): """ 推荐的话题列表 :param user_alias: 指定用户,默认当前 :param start: 翻页 :return: 带下一页的列表 """ user_alias = user_alias or self.api.user_alias xml = self.api.xml(API_GROUP_LIST_USER_RECED_TOPICS % user_alias, ...
python
def list_reced_topics(self, user_alias=None, start=0): """ 推荐的话题列表 :param user_alias: 指定用户,默认当前 :param start: 翻页 :return: 带下一页的列表 """ user_alias = user_alias or self.api.user_alias xml = self.api.xml(API_GROUP_LIST_USER_RECED_TOPICS % user_alias, ...
[ "def", "list_reced_topics", "(", "self", ",", "user_alias", "=", "None", ",", "start", "=", "0", ")", ":", "user_alias", "=", "user_alias", "or", "self", ".", "api", ".", "user_alias", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_LIST_USER...
推荐的话题列表 :param user_alias: 指定用户,默认当前 :param start: 翻页 :return: 带下一页的列表
[ "推荐的话题列表", ":", "param", "user_alias", ":", "指定用户,默认当前", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L287-L297
train
acrazing/dbapi
dbapi/Group.py
Group.add_topic
def add_topic(self, group_alias, title, content): """ 创建话题(小心验证码~) :param group_alias: 小组ID :param title: 标题 :param content: 内容 :return: bool """ xml = self.api.req(API_GROUP_ADD_TOPIC % group_alias, 'post', data={ 'ck': self.api.ck(),...
python
def add_topic(self, group_alias, title, content): """ 创建话题(小心验证码~) :param group_alias: 小组ID :param title: 标题 :param content: 内容 :return: bool """ xml = self.api.req(API_GROUP_ADD_TOPIC % group_alias, 'post', data={ 'ck': self.api.ck(),...
[ "def", "add_topic", "(", "self", ",", "group_alias", ",", "title", ",", "content", ")", ":", "xml", "=", "self", ".", "api", ".", "req", "(", "API_GROUP_ADD_TOPIC", "%", "group_alias", ",", "'post'", ",", "data", "=", "{", "'ck'", ":", "self", ".", "...
创建话题(小心验证码~) :param group_alias: 小组ID :param title: 标题 :param content: 内容 :return: bool
[ "创建话题(小心验证码~)", ":", "param", "group_alias", ":", "小组ID", ":", "param", "title", ":", "标题", ":", "param", "content", ":", "内容", ":", "return", ":", "bool" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L299-L314
train
acrazing/dbapi
dbapi/Group.py
Group.remove_topic
def remove_topic(self, topic_id): """ 删除话题(需要先删除所有评论,使用默认参数) :param topic_id: 话题ID :return: None """ comment_start = 0 while comment_start is not None: comments = self.list_comments(topic_id, comment_start) for comment in comments[...
python
def remove_topic(self, topic_id): """ 删除话题(需要先删除所有评论,使用默认参数) :param topic_id: 话题ID :return: None """ comment_start = 0 while comment_start is not None: comments = self.list_comments(topic_id, comment_start) for comment in comments[...
[ "def", "remove_topic", "(", "self", ",", "topic_id", ")", ":", "comment_start", "=", "0", "while", "comment_start", "is", "not", "None", ":", "comments", "=", "self", ".", "list_comments", "(", "topic_id", ",", "comment_start", ")", "for", "comment", "in", ...
删除话题(需要先删除所有评论,使用默认参数) :param topic_id: 话题ID :return: None
[ "删除话题(需要先删除所有评论,使用默认参数)", ":", "param", "topic_id", ":", "话题ID", ":", "return", ":", "None" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L343-L356
train
acrazing/dbapi
dbapi/Group.py
Group.update_topic
def update_topic(self, topic_id, title, content): """ 更新话题 :param topic_id: 话题ID :param title: 标题 :param content: 内容 :return: bool """ xml = self.api.req(API_GROUP_UPDATE_TOPIC % topic_id, 'post', data={ 'ck': self.api.ck(), ...
python
def update_topic(self, topic_id, title, content): """ 更新话题 :param topic_id: 话题ID :param title: 标题 :param content: 内容 :return: bool """ xml = self.api.req(API_GROUP_UPDATE_TOPIC % topic_id, 'post', data={ 'ck': self.api.ck(), ...
[ "def", "update_topic", "(", "self", ",", "topic_id", ",", "title", ",", "content", ")", ":", "xml", "=", "self", ".", "api", ".", "req", "(", "API_GROUP_UPDATE_TOPIC", "%", "topic_id", ",", "'post'", ",", "data", "=", "{", "'ck'", ":", "self", ".", "...
更新话题 :param topic_id: 话题ID :param title: 标题 :param content: 内容 :return: bool
[ "更新话题", ":", "param", "topic_id", ":", "话题ID", ":", "param", "title", ":", "标题", ":", "param", "content", ":", "内容", ":", "return", ":", "bool" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L358-L373
train
acrazing/dbapi
dbapi/Group.py
Group.list_comments
def list_comments(self, topic_id, start=0): """ 回复列表 :param topic_id: 话题ID :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_GET_TOPIC % topic_id, params={'start': start}) xml_results = xml.xpath('//ul[@id="comments"]/li') ...
python
def list_comments(self, topic_id, start=0): """ 回复列表 :param topic_id: 话题ID :param start: 翻页 :return: 带下一页的列表 """ xml = self.api.xml(API_GROUP_GET_TOPIC % topic_id, params={'start': start}) xml_results = xml.xpath('//ul[@id="comments"]/li') ...
[ "def", "list_comments", "(", "self", ",", "topic_id", ",", "start", "=", "0", ")", ":", "xml", "=", "self", ".", "api", ".", "xml", "(", "API_GROUP_GET_TOPIC", "%", "topic_id", ",", "params", "=", "{", "'start'", ":", "start", "}", ")", "xml_results", ...
回复列表 :param topic_id: 话题ID :param start: 翻页 :return: 带下一页的列表
[ "回复列表", ":", "param", "topic_id", ":", "话题ID", ":", "param", "start", ":", "翻页", ":", "return", ":", "带下一页的列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L411-L444
train
acrazing/dbapi
dbapi/Group.py
Group.add_comment
def add_comment(self, topic_id, content, reply_id=None): """ 添加评论 :param topic_id: 话题ID :param content: 内容 :param reply_id: 回复ID :return: None """ return self.api.req(API_GROUP_ADD_COMMENT % topic_id, 'post', data={ 'ck': self.api.ck()...
python
def add_comment(self, topic_id, content, reply_id=None): """ 添加评论 :param topic_id: 话题ID :param content: 内容 :param reply_id: 回复ID :return: None """ return self.api.req(API_GROUP_ADD_COMMENT % topic_id, 'post', data={ 'ck': self.api.ck()...
[ "def", "add_comment", "(", "self", ",", "topic_id", ",", "content", ",", "reply_id", "=", "None", ")", ":", "return", "self", ".", "api", ".", "req", "(", "API_GROUP_ADD_COMMENT", "%", "topic_id", ",", "'post'", ",", "data", "=", "{", "'ck'", ":", "sel...
添加评论 :param topic_id: 话题ID :param content: 内容 :param reply_id: 回复ID :return: None
[ "添加评论", ":", "param", "topic_id", ":", "话题ID", ":", "param", "content", ":", "内容", ":", "param", "reply_id", ":", "回复ID", ":", "return", ":", "None" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L446-L461
train
acrazing/dbapi
dbapi/Group.py
Group.remove_comment
def remove_comment(self, topic_id, comment_id, reason='0', other=None): """ 删除评论(自己发的话题所有的都可以删除,否则只能删自己发的) :param topic_id: 话题ID :param comment_id: 评论ID :param reason: 原因 0/1/2 (内容不符/反动/其它) :param other: 其它原因的具体(2) :return: None """ params...
python
def remove_comment(self, topic_id, comment_id, reason='0', other=None): """ 删除评论(自己发的话题所有的都可以删除,否则只能删自己发的) :param topic_id: 话题ID :param comment_id: 评论ID :param reason: 原因 0/1/2 (内容不符/反动/其它) :param other: 其它原因的具体(2) :return: None """ params...
[ "def", "remove_comment", "(", "self", ",", "topic_id", ",", "comment_id", ",", "reason", "=", "'0'", ",", "other", "=", "None", ")", ":", "params", "=", "{", "'cid'", ":", "comment_id", "}", "data", "=", "{", "'cid'", ":", "comment_id", ",", "'ck'", ...
删除评论(自己发的话题所有的都可以删除,否则只能删自己发的) :param topic_id: 话题ID :param comment_id: 评论ID :param reason: 原因 0/1/2 (内容不符/反动/其它) :param other: 其它原因的具体(2) :return: None
[ "删除评论(自己发的话题所有的都可以删除,否则只能删自己发的)", ":", "param", "topic_id", ":", "话题ID", ":", "param", "comment_id", ":", "评论ID", ":", "param", "reason", ":", "原因", "0", "/", "1", "/", "2", "(内容不符", "/", "反动", "/", "其它)", ":", "param", "other", ":", "其它原因的具体", "(", "2...
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L463-L479
train
acrazing/dbapi
dbapi/Group.py
Group.list_user_comments
def list_user_comments(self, topic_id, user_alias=None): """ 列出用户在话题下的所有回复 :param topic_id: 话题ID :param user_alias: 用户ID,默认当前 :return: 纯列表 """ user_alias = user_alias or self.api.user_alias comment_start = 0 results = [] while comm...
python
def list_user_comments(self, topic_id, user_alias=None): """ 列出用户在话题下的所有回复 :param topic_id: 话题ID :param user_alias: 用户ID,默认当前 :return: 纯列表 """ user_alias = user_alias or self.api.user_alias comment_start = 0 results = [] while comm...
[ "def", "list_user_comments", "(", "self", ",", "topic_id", ",", "user_alias", "=", "None", ")", ":", "user_alias", "=", "user_alias", "or", "self", ".", "api", ".", "user_alias", "comment_start", "=", "0", "results", "=", "[", "]", "while", "comment_start", ...
列出用户在话题下的所有回复 :param topic_id: 话题ID :param user_alias: 用户ID,默认当前 :return: 纯列表
[ "列出用户在话题下的所有回复", ":", "param", "topic_id", ":", "话题ID", ":", "param", "user_alias", ":", "用户ID,默认当前", ":", "return", ":", "纯列表" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L481-L496
train
acrazing/dbapi
dbapi/Group.py
Group.remove_commented_topic
def remove_commented_topic(self, topic_id): """ 删除回复的话题(删除所有自己发布的评论) :param topic_id: 话题ID :return: None """ return [self.remove_comment(topic_id, item['id']) for item in self.list_user_comments(topic_id)]
python
def remove_commented_topic(self, topic_id): """ 删除回复的话题(删除所有自己发布的评论) :param topic_id: 话题ID :return: None """ return [self.remove_comment(topic_id, item['id']) for item in self.list_user_comments(topic_id)]
[ "def", "remove_commented_topic", "(", "self", ",", "topic_id", ")", ":", "return", "[", "self", ".", "remove_comment", "(", "topic_id", ",", "item", "[", "'id'", "]", ")", "for", "item", "in", "self", ".", "list_user_comments", "(", "topic_id", ")", "]" ]
删除回复的话题(删除所有自己发布的评论) :param topic_id: 话题ID :return: None
[ "删除回复的话题(删除所有自己发布的评论)", ":", "param", "topic_id", ":", "话题ID", ":", "return", ":", "None" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L498-L505
train
clarkperkins/click-shell
click_shell/decorators.py
shell
def shell(name=None, **attrs): """Creates a new :class:`Shell` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Shell`. """ attrs.setdefault('cls', Shell) return click.command(name, **attrs)
python
def shell(name=None, **attrs): """Creates a new :class:`Shell` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Shell`. """ attrs.setdefault('cls', Shell) return click.command(name, **attrs)
[ "def", "shell", "(", "name", "=", "None", ",", "*", "*", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "'cls'", ",", "Shell", ")", "return", "click", ".", "command", "(", "name", ",", "*", "*", "attrs", ")" ]
Creates a new :class:`Shell` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Shell`.
[ "Creates", "a", "new", ":", "class", ":", "Shell", "with", "a", "function", "as", "callback", ".", "This", "works", "otherwise", "the", "same", "as", ":", "func", ":", "command", "just", "that", "the", "cls", "parameter", "is", "set", "to", ":", "class...
8d6e1a492176bc79e029d714f19d3156409656ea
https://github.com/clarkperkins/click-shell/blob/8d6e1a492176bc79e029d714f19d3156409656ea/click_shell/decorators.py#L12-L18
train
glomex/gcdt
gcdt/gcdt_logging.py
getLogger
def getLogger(name): """This is used by gcdt plugins to get a logger with the right level.""" logger = logging.getLogger(name) # note: the level might be adjusted via '-v' option logger.setLevel(logging_config['loggers']['gcdt']['level']) return logger
python
def getLogger(name): """This is used by gcdt plugins to get a logger with the right level.""" logger = logging.getLogger(name) # note: the level might be adjusted via '-v' option logger.setLevel(logging_config['loggers']['gcdt']['level']) return logger
[ "def", "getLogger", "(", "name", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "# note: the level might be adjusted via '-v' option", "logger", ".", "setLevel", "(", "logging_config", "[", "'loggers'", "]", "[", "'gcdt'", "]", "[", "'le...
This is used by gcdt plugins to get a logger with the right level.
[ "This", "is", "used", "by", "gcdt", "plugins", "to", "get", "a", "logger", "with", "the", "right", "level", "." ]
cd67cf416371337b83cb9ca3f696277125703339
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/gcdt_logging.py#L70-L75
train
bernieke/python-magento
magento/magento_api.py
MagentoAPI._discover
def _discover(self): """Discovers methods in the XML-RPC API and creates attributes for them on this object. Enables stuff like "magento.cart.create(...)" to work without having to define Python methods for each XML-RPC equivalent. """ self._resources = {} resources = se...
python
def _discover(self): """Discovers methods in the XML-RPC API and creates attributes for them on this object. Enables stuff like "magento.cart.create(...)" to work without having to define Python methods for each XML-RPC equivalent. """ self._resources = {} resources = se...
[ "def", "_discover", "(", "self", ")", ":", "self", ".", "_resources", "=", "{", "}", "resources", "=", "self", ".", "_client", ".", "resources", "(", "self", ".", "_session_id", ")", "for", "resource", "in", "resources", ":", "self", ".", "_resources", ...
Discovers methods in the XML-RPC API and creates attributes for them on this object. Enables stuff like "magento.cart.create(...)" to work without having to define Python methods for each XML-RPC equivalent.
[ "Discovers", "methods", "in", "the", "XML", "-", "RPC", "API", "and", "creates", "attributes", "for", "them", "on", "this", "object", ".", "Enables", "stuff", "like", "magento", ".", "cart", ".", "create", "(", "...", ")", "to", "work", "without", "havin...
bfd23e233905b1b1491a7c07b9d833dfebd70456
https://github.com/bernieke/python-magento/blob/bfd23e233905b1b1491a7c07b9d833dfebd70456/magento/magento_api.py#L73-L84
train
bernieke/python-magento
magento/magento_api.py
MagentoAPI.keep_session_alive
def keep_session_alive(self): """If the session expired, logs back in.""" try: self.resources() except xmlrpclib.Fault as fault: if fault.faultCode == 5: self.login() else: raise
python
def keep_session_alive(self): """If the session expired, logs back in.""" try: self.resources() except xmlrpclib.Fault as fault: if fault.faultCode == 5: self.login() else: raise
[ "def", "keep_session_alive", "(", "self", ")", ":", "try", ":", "self", ".", "resources", "(", ")", "except", "xmlrpclib", ".", "Fault", "as", "fault", ":", "if", "fault", ".", "faultCode", "==", "5", ":", "self", ".", "login", "(", ")", "else", ":",...
If the session expired, logs back in.
[ "If", "the", "session", "expired", "logs", "back", "in", "." ]
bfd23e233905b1b1491a7c07b9d833dfebd70456
https://github.com/bernieke/python-magento/blob/bfd23e233905b1b1491a7c07b9d833dfebd70456/magento/magento_api.py#L118-L127
train
bernieke/python-magento
magento/magento_api.py
MagentoAPI.help
def help(self): """Prints discovered resources and their associated methods. Nice when noodling in the terminal to wrap your head around Magento's insanity. """ print('Resources:') print('') for name in sorted(self._resources.keys()): methods = sorted(self._r...
python
def help(self): """Prints discovered resources and their associated methods. Nice when noodling in the terminal to wrap your head around Magento's insanity. """ print('Resources:') print('') for name in sorted(self._resources.keys()): methods = sorted(self._r...
[ "def", "help", "(", "self", ")", ":", "print", "(", "'Resources:'", ")", "print", "(", "''", ")", "for", "name", "in", "sorted", "(", "self", ".", "_resources", ".", "keys", "(", ")", ")", ":", "methods", "=", "sorted", "(", "self", ".", "_resource...
Prints discovered resources and their associated methods. Nice when noodling in the terminal to wrap your head around Magento's insanity.
[ "Prints", "discovered", "resources", "and", "their", "associated", "methods", ".", "Nice", "when", "noodling", "in", "the", "terminal", "to", "wrap", "your", "head", "around", "Magento", "s", "insanity", "." ]
bfd23e233905b1b1491a7c07b9d833dfebd70456
https://github.com/bernieke/python-magento/blob/bfd23e233905b1b1491a7c07b9d833dfebd70456/magento/magento_api.py#L156-L165
train
gmr/helper
helper/setupext.py
RunCommand.run
def run(self): """Import the controller and run it. This mimics the processing done by :func:`helper.start` when a controller is run in the foreground. A new instance of ``self.controller`` is created and run until a keyboard interrupt occurs or the controller stops on its own ...
python
def run(self): """Import the controller and run it. This mimics the processing done by :func:`helper.start` when a controller is run in the foreground. A new instance of ``self.controller`` is created and run until a keyboard interrupt occurs or the controller stops on its own ...
[ "def", "run", "(", "self", ")", ":", "segments", "=", "self", ".", "controller", ".", "split", "(", "'.'", ")", "controller_class", "=", "reduce", "(", "getattr", ",", "segments", "[", "1", ":", "]", ",", "__import__", "(", "'.'", ".", "join", "(", ...
Import the controller and run it. This mimics the processing done by :func:`helper.start` when a controller is run in the foreground. A new instance of ``self.controller`` is created and run until a keyboard interrupt occurs or the controller stops on its own accord.
[ "Import", "the", "controller", "and", "run", "it", "." ]
fe8e45fc8eabf619429b2940c682c252ee33c082
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/setupext.py#L50-L70
train
kz26/dottorrent
dottorrent/__init__.py
Torrent.get_info
def get_info(self): """ Scans the input path and automatically determines the optimal piece size based on ~1500 pieces (up to MAX_PIECE_SIZE) along with other basic info, including total size (in bytes), the total number of files, piece size (in bytes), and resulting numb...
python
def get_info(self): """ Scans the input path and automatically determines the optimal piece size based on ~1500 pieces (up to MAX_PIECE_SIZE) along with other basic info, including total size (in bytes), the total number of files, piece size (in bytes), and resulting numb...
[ "def", "get_info", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "path", ")", ":", "total_size", "=", "os", ".", "path", ".", "getsize", "(", "self", ".", "path", ")", "total_files", "=", "1", "elif", "os", ".",...
Scans the input path and automatically determines the optimal piece size based on ~1500 pieces (up to MAX_PIECE_SIZE) along with other basic info, including total size (in bytes), the total number of files, piece size (in bytes), and resulting number of pieces. If ``piece_size`` has alre...
[ "Scans", "the", "input", "path", "and", "automatically", "determines", "the", "optimal", "piece", "size", "based", "on", "~1500", "pieces", "(", "up", "to", "MAX_PIECE_SIZE", ")", "along", "with", "other", "basic", "info", "including", "total", "size", "(", ...
fea5714efe0cde2a55eabfb387295781a78d84bb
https://github.com/kz26/dottorrent/blob/fea5714efe0cde2a55eabfb387295781a78d84bb/dottorrent/__init__.py#L154-L192
train
kz26/dottorrent
dottorrent/__init__.py
Torrent.generate
def generate(self, callback=None): """ Computes and stores piece data. Returns ``True`` on success, ``False`` otherwise. :param callback: progress/cancellation callable with method signature ``(filename, pieces_completed, pieces_total)``. Useful for reporting pro...
python
def generate(self, callback=None): """ Computes and stores piece data. Returns ``True`` on success, ``False`` otherwise. :param callback: progress/cancellation callable with method signature ``(filename, pieces_completed, pieces_total)``. Useful for reporting pro...
[ "def", "generate", "(", "self", ",", "callback", "=", "None", ")", ":", "files", "=", "[", "]", "single_file", "=", "os", ".", "path", ".", "isfile", "(", "self", ".", "path", ")", "if", "single_file", ":", "files", ".", "append", "(", "(", "self",...
Computes and stores piece data. Returns ``True`` on success, ``False`` otherwise. :param callback: progress/cancellation callable with method signature ``(filename, pieces_completed, pieces_total)``. Useful for reporting progress if dottorrent is used in a GUI/thread...
[ "Computes", "and", "stores", "piece", "data", ".", "Returns", "True", "on", "success", "False", "otherwise", "." ]
fea5714efe0cde2a55eabfb387295781a78d84bb
https://github.com/kz26/dottorrent/blob/fea5714efe0cde2a55eabfb387295781a78d84bb/dottorrent/__init__.py#L194-L311
train
kz26/dottorrent
dottorrent/__init__.py
Torrent.info_hash_base32
def info_hash_base32(self): """ Returns the base32 info hash of the torrent. Useful for generating magnet links. .. note:: ``generate()`` must be called first. """ if getattr(self, '_data', None): return b32encode(sha1(bencode(self._data['info'])).digest()) ...
python
def info_hash_base32(self): """ Returns the base32 info hash of the torrent. Useful for generating magnet links. .. note:: ``generate()`` must be called first. """ if getattr(self, '_data', None): return b32encode(sha1(bencode(self._data['info'])).digest()) ...
[ "def", "info_hash_base32", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'_data'", ",", "None", ")", ":", "return", "b32encode", "(", "sha1", "(", "bencode", "(", "self", ".", "_data", "[", "'info'", "]", ")", ")", ".", "digest", "(", ...
Returns the base32 info hash of the torrent. Useful for generating magnet links. .. note:: ``generate()`` must be called first.
[ "Returns", "the", "base32", "info", "hash", "of", "the", "torrent", ".", "Useful", "for", "generating", "magnet", "links", "." ]
fea5714efe0cde2a55eabfb387295781a78d84bb
https://github.com/kz26/dottorrent/blob/fea5714efe0cde2a55eabfb387295781a78d84bb/dottorrent/__init__.py#L327-L337
train
kz26/dottorrent
dottorrent/__init__.py
Torrent.info_hash
def info_hash(self): """ :return: The SHA-1 info hash of the torrent. Useful for generating magnet links. .. note:: ``generate()`` must be called first. """ if getattr(self, '_data', None): return sha1(bencode(self._data['info'])).hexdigest() else...
python
def info_hash(self): """ :return: The SHA-1 info hash of the torrent. Useful for generating magnet links. .. note:: ``generate()`` must be called first. """ if getattr(self, '_data', None): return sha1(bencode(self._data['info'])).hexdigest() else...
[ "def", "info_hash", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'_data'", ",", "None", ")", ":", "return", "sha1", "(", "bencode", "(", "self", ".", "_data", "[", "'info'", "]", ")", ")", ".", "hexdigest", "(", ")", "else", ":", "r...
:return: The SHA-1 info hash of the torrent. Useful for generating magnet links. .. note:: ``generate()`` must be called first.
[ ":", "return", ":", "The", "SHA", "-", "1", "info", "hash", "of", "the", "torrent", ".", "Useful", "for", "generating", "magnet", "links", "." ]
fea5714efe0cde2a55eabfb387295781a78d84bb
https://github.com/kz26/dottorrent/blob/fea5714efe0cde2a55eabfb387295781a78d84bb/dottorrent/__init__.py#L340-L350
train
acrazing/dbapi
dbapi/base.py
BaseAPI.req
def req(self, url, method='get', params=None, data=None, auth=False): """ 请求API :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict ...
python
def req(self, url, method='get', params=None, data=None, auth=False): """ 请求API :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict ...
[ "def", "req", "(", "self", ",", "url", ",", "method", "=", "'get'", ",", "params", "=", "None", ",", "data", "=", "None", ",", "auth", "=", "False", ")", ":", "self", ".", "logger", ".", "debug", "(", "'fetch api<%s:%s>'", "%", "(", "method", ",", ...
请求API :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict :param data: body :type auth: bool :param auth: if True and sess...
[ "请求API" ]
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/base.py#L71-L104
train
acrazing/dbapi
dbapi/base.py
BaseAPI.json
def json(self, url, method='get', params=None, data=None): """ 请求并返回json :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: di...
python
def json(self, url, method='get', params=None, data=None): """ 请求并返回json :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: di...
[ "def", "json", "(", "self", ",", "url", ",", "method", "=", "'get'", ",", "params", "=", "None", ",", "data", "=", "None", ")", ":", "r", "=", "self", ".", "req", "(", "url", ",", "method", ",", "params", ",", "data", ")", "return", "r", ".", ...
请求并返回json :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict :param data: body :rtype: dict :return:
[ "请求并返回json", ":", "type", "url", ":", "str", ":", "param", "url", ":", "API", ":", "type", "method", ":", "str", ":", "param", "method", ":", "HTTP", "METHOD", ":", "type", "params", ":", "dict", ":", "param", "params", ":", "query", ":", "type", "...
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/base.py#L106-L127
train
acrazing/dbapi
dbapi/base.py
BaseAPI.xml
def xml(self, url, method='get', params=None, data=None): """ 请求并返回xml :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict ...
python
def xml(self, url, method='get', params=None, data=None): """ 请求并返回xml :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict ...
[ "def", "xml", "(", "self", ",", "url", ",", "method", "=", "'get'", ",", "params", "=", "None", ",", "data", "=", "None", ")", ":", "r", "=", "self", ".", "req", "(", "url", ",", "method", ",", "params", ",", "data", ")", "# this is required for av...
请求并返回xml :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict :param data: body :rtype: html.HtmlElement :return:
[ "请求并返回xml", ":", "type", "url", ":", "str", ":", "param", "url", ":", "API", ":", "type", "method", ":", "str", ":", "param", "method", ":", "HTTP", "METHOD", ":", "type", "params", ":", "dict", ":", "param", "params", ":", "query", ":", "type", "d...
8c1f85cb1a051daf7be1fc97a62c4499983e9898
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/base.py#L133-L154
train