repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
gmr/helper
helper/unix.py
Daemon.gid
def gid(self): """Return the group id that the daemon will run with :rtype: int """ if not self._gid: if self.controller.config.daemon.group: self._gid = grp.getgrnam(self.config.daemon.group).gr_gid else: self._gid = os.getgid() ...
python
def gid(self): """Return the group id that the daemon will run with :rtype: int """ if not self._gid: if self.controller.config.daemon.group: self._gid = grp.getgrnam(self.config.daemon.group).gr_gid else: self._gid = os.getgid() ...
[ "def", "gid", "(", "self", ")", ":", "if", "not", "self", ".", "_gid", ":", "if", "self", ".", "controller", ".", "config", ".", "daemon", ".", "group", ":", "self", ".", "_gid", "=", "grp", ".", "getgrnam", "(", "self", ".", "config", ".", "daem...
Return the group id that the daemon will run with :rtype: int
[ "Return", "the", "group", "id", "that", "the", "daemon", "will", "run", "with" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L117-L128
gmr/helper
helper/unix.py
Daemon.uid
def uid(self): """Return the user id that the process will run as :rtype: int """ if not self._uid: if self.config.daemon.user: self._uid = pwd.getpwnam(self.config.daemon.user).pw_uid else: self._uid = os.getuid() return ...
python
def uid(self): """Return the user id that the process will run as :rtype: int """ if not self._uid: if self.config.daemon.user: self._uid = pwd.getpwnam(self.config.daemon.user).pw_uid else: self._uid = os.getuid() return ...
[ "def", "uid", "(", "self", ")", ":", "if", "not", "self", ".", "_uid", ":", "if", "self", ".", "config", ".", "daemon", ".", "user", ":", "self", ".", "_uid", "=", "pwd", ".", "getpwnam", "(", "self", ".", "config", ".", "daemon", ".", "user", ...
Return the user id that the process will run as :rtype: int
[ "Return", "the", "user", "id", "that", "the", "process", "will", "run", "as" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L131-L142
gmr/helper
helper/unix.py
Daemon._daemonize
def _daemonize(self): """Fork into a background process and setup the process, copied in part from http://www.jejik.com/files/examples/daemon3x.py """ LOGGER.info('Forking %s into the background', sys.argv[0]) # Write the pidfile if current uid != final uid if os.getuid...
python
def _daemonize(self): """Fork into a background process and setup the process, copied in part from http://www.jejik.com/files/examples/daemon3x.py """ LOGGER.info('Forking %s into the background', sys.argv[0]) # Write the pidfile if current uid != final uid if os.getuid...
[ "def", "_daemonize", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'Forking %s into the background'", ",", "sys", ".", "argv", "[", "0", "]", ")", "# Write the pidfile if current uid != final uid", "if", "os", ".", "getuid", "(", ")", "!=", "self", ".", ...
Fork into a background process and setup the process, copied in part from http://www.jejik.com/files/examples/daemon3x.py
[ "Fork", "into", "a", "background", "process", "and", "setup", "the", "process", "copied", "in", "part", "from", "http", ":", "//", "www", ".", "jejik", ".", "com", "/", "files", "/", "examples", "/", "daemon3x", ".", "py" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L144-L201
gmr/helper
helper/unix.py
Daemon._get_exception_log_path
def _get_exception_log_path(): """Return the normalized path for the connection log, raising an exception if it can not written to. :return: str """ app = sys.argv[0].split('/')[-1] for exception_log in ['/var/log/%s.errors' % app, '/var/tm...
python
def _get_exception_log_path(): """Return the normalized path for the connection log, raising an exception if it can not written to. :return: str """ app = sys.argv[0].split('/')[-1] for exception_log in ['/var/log/%s.errors' % app, '/var/tm...
[ "def", "_get_exception_log_path", "(", ")", ":", "app", "=", "sys", ".", "argv", "[", "0", "]", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "for", "exception_log", "in", "[", "'/var/log/%s.errors'", "%", "app", ",", "'/var/tmp/%s.errors'", "%", ...
Return the normalized path for the connection log, raising an exception if it can not written to. :return: str
[ "Return", "the", "normalized", "path", "for", "the", "connection", "log", "raising", "an", "exception", "if", "it", "can", "not", "written", "to", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L204-L217
gmr/helper
helper/unix.py
Daemon._get_pidfile_path
def _get_pidfile_path(self): """Return the normalized path for the pidfile, raising an exception if it can not written to. :return: str :raises: ValueError :raises: OSError """ if self.config.daemon.pidfile: pidfile = path.abspath(self.config.daemon....
python
def _get_pidfile_path(self): """Return the normalized path for the pidfile, raising an exception if it can not written to. :return: str :raises: ValueError :raises: OSError """ if self.config.daemon.pidfile: pidfile = path.abspath(self.config.daemon....
[ "def", "_get_pidfile_path", "(", "self", ")", ":", "if", "self", ".", "config", ".", "daemon", ".", "pidfile", ":", "pidfile", "=", "path", ".", "abspath", "(", "self", ".", "config", ".", "daemon", ".", "pidfile", ")", "if", "not", "os", ".", "acces...
Return the normalized path for the pidfile, raising an exception if it can not written to. :return: str :raises: ValueError :raises: OSError
[ "Return", "the", "normalized", "path", "for", "the", "pidfile", "raising", "an", "exception", "if", "it", "can", "not", "written", "to", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L219-L243
gmr/helper
helper/unix.py
Daemon._is_already_running
def _is_already_running(self): """Check to see if the process is running, first looking for a pidfile, then shelling out in either case, removing a pidfile if it exists but the process is not running. """ # Look for the pidfile, if exists determine if the process is alive ...
python
def _is_already_running(self): """Check to see if the process is running, first looking for a pidfile, then shelling out in either case, removing a pidfile if it exists but the process is not running. """ # Look for the pidfile, if exists determine if the process is alive ...
[ "def", "_is_already_running", "(", "self", ")", ":", "# Look for the pidfile, if exists determine if the process is alive", "pidfile", "=", "self", ".", "_get_pidfile_path", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "pidfile", ")", ":", "pid", "=", "o...
Check to see if the process is running, first looking for a pidfile, then shelling out in either case, removing a pidfile if it exists but the process is not running.
[ "Check", "to", "see", "if", "the", "process", "is", "running", "first", "looking", "for", "a", "pidfile", "then", "shelling", "out", "in", "either", "case", "removing", "a", "pidfile", "if", "it", "exists", "but", "the", "process", "is", "not", "running", ...
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L245-L284
gmr/helper
helper/unix.py
Daemon._remove_pidfile
def _remove_pidfile(self): """Remove the pid file from the filesystem""" LOGGER.debug('Removing pidfile: %s', self.pidfile_path) try: os.unlink(self.pidfile_path) except OSError: pass
python
def _remove_pidfile(self): """Remove the pid file from the filesystem""" LOGGER.debug('Removing pidfile: %s', self.pidfile_path) try: os.unlink(self.pidfile_path) except OSError: pass
[ "def", "_remove_pidfile", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Removing pidfile: %s'", ",", "self", ".", "pidfile_path", ")", "try", ":", "os", ".", "unlink", "(", "self", ".", "pidfile_path", ")", "except", "OSError", ":", "pass" ]
Remove the pid file from the filesystem
[ "Remove", "the", "pid", "file", "from", "the", "filesystem" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L286-L292
gmr/helper
helper/unix.py
Daemon._write_pidfile
def _write_pidfile(self): """Write the pid file out with the process number in the pid file""" LOGGER.debug('Writing pidfile: %s', self.pidfile_path) with open(self.pidfile_path, "w") as handle: handle.write(str(os.getpid()))
python
def _write_pidfile(self): """Write the pid file out with the process number in the pid file""" LOGGER.debug('Writing pidfile: %s', self.pidfile_path) with open(self.pidfile_path, "w") as handle: handle.write(str(os.getpid()))
[ "def", "_write_pidfile", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Writing pidfile: %s'", ",", "self", ".", "pidfile_path", ")", "with", "open", "(", "self", ".", "pidfile_path", ",", "\"w\"", ")", "as", "handle", ":", "handle", ".", "write", ...
Write the pid file out with the process number in the pid file
[ "Write", "the", "pid", "file", "out", "with", "the", "process", "number", "in", "the", "pid", "file" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L294-L298
CitrineInformatics/pypif
pypif/util/case.py
to_camel_case
def to_camel_case(snake_case_string): """ Convert a string from snake case to camel case. For example, "some_var" would become "someVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string. """ parts = snake_case_string.lstr...
python
def to_camel_case(snake_case_string): """ Convert a string from snake case to camel case. For example, "some_var" would become "someVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string. """ parts = snake_case_string.lstr...
[ "def", "to_camel_case", "(", "snake_case_string", ")", ":", "parts", "=", "snake_case_string", ".", "lstrip", "(", "'_'", ")", ".", "split", "(", "'_'", ")", "return", "parts", "[", "0", "]", "+", "''", ".", "join", "(", "[", "i", ".", "title", "(", ...
Convert a string from snake case to camel case. For example, "some_var" would become "someVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string.
[ "Convert", "a", "string", "from", "snake", "case", "to", "camel", "case", ".", "For", "example", "some_var", "would", "become", "someVar", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L8-L16
CitrineInformatics/pypif
pypif/util/case.py
to_capitalized_camel_case
def to_capitalized_camel_case(snake_case_string): """ Convert a string from snake case to camel case with the first letter capitalized. For example, "some_var" would become "SomeVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_...
python
def to_capitalized_camel_case(snake_case_string): """ Convert a string from snake case to camel case with the first letter capitalized. For example, "some_var" would become "SomeVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_...
[ "def", "to_capitalized_camel_case", "(", "snake_case_string", ")", ":", "parts", "=", "snake_case_string", ".", "split", "(", "'_'", ")", "return", "''", ".", "join", "(", "[", "i", ".", "title", "(", ")", "for", "i", "in", "parts", "]", ")" ]
Convert a string from snake case to camel case with the first letter capitalized. For example, "some_var" would become "SomeVar". :param snake_case_string: Snake-cased string to convert to camel case. :returns: Camel-cased version of snake_case_string.
[ "Convert", "a", "string", "from", "snake", "case", "to", "camel", "case", "with", "the", "first", "letter", "capitalized", ".", "For", "example", "some_var", "would", "become", "SomeVar", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L19-L28
CitrineInformatics/pypif
pypif/util/case.py
to_snake_case
def to_snake_case(camel_case_string): """ Convert a string from camel case to snake case. From example, "someVar" would become "some_var". :param camel_case_string: Camel-cased string to convert to snake case. :return: Snake-cased version of camel_case_string. """ first_pass = _first_camel_case...
python
def to_snake_case(camel_case_string): """ Convert a string from camel case to snake case. From example, "someVar" would become "some_var". :param camel_case_string: Camel-cased string to convert to snake case. :return: Snake-cased version of camel_case_string. """ first_pass = _first_camel_case...
[ "def", "to_snake_case", "(", "camel_case_string", ")", ":", "first_pass", "=", "_first_camel_case_regex", ".", "sub", "(", "r'\\1_\\2'", ",", "camel_case_string", ")", "return", "_second_camel_case_regex", ".", "sub", "(", "r'\\1_\\2'", ",", "first_pass", ")", ".", ...
Convert a string from camel case to snake case. From example, "someVar" would become "some_var". :param camel_case_string: Camel-cased string to convert to snake case. :return: Snake-cased version of camel_case_string.
[ "Convert", "a", "string", "from", "camel", "case", "to", "snake", "case", ".", "From", "example", "someVar", "would", "become", "some_var", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L31-L39
CitrineInformatics/pypif
pypif/util/case.py
keys_to_snake_case
def keys_to_snake_case(camel_case_dict): """ Make a copy of a dictionary with all keys converted to snake case. This is just calls to_snake_case on each of the keys in the dictionary and returns a new dictionary. :param camel_case_dict: Dictionary with the keys to convert. :type camel_case_dict: Di...
python
def keys_to_snake_case(camel_case_dict): """ Make a copy of a dictionary with all keys converted to snake case. This is just calls to_snake_case on each of the keys in the dictionary and returns a new dictionary. :param camel_case_dict: Dictionary with the keys to convert. :type camel_case_dict: Di...
[ "def", "keys_to_snake_case", "(", "camel_case_dict", ")", ":", "return", "dict", "(", "(", "to_snake_case", "(", "key", ")", ",", "value", ")", "for", "(", "key", ",", "value", ")", "in", "camel_case_dict", ".", "items", "(", ")", ")" ]
Make a copy of a dictionary with all keys converted to snake case. This is just calls to_snake_case on each of the keys in the dictionary and returns a new dictionary. :param camel_case_dict: Dictionary with the keys to convert. :type camel_case_dict: Dictionary. :return: Dictionary with the keys conv...
[ "Make", "a", "copy", "of", "a", "dictionary", "with", "all", "keys", "converted", "to", "snake", "case", ".", "This", "is", "just", "calls", "to_snake_case", "on", "each", "of", "the", "keys", "in", "the", "dictionary", "and", "returns", "a", "new", "dic...
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/case.py#L42-L52
glomex/gcdt
gcdt/ramuda_core.py
list_functions
def list_functions(awsclient): """List the deployed lambda functions and print configuration. :return: exit_code """ client_lambda = awsclient.get_client('lambda') response = client_lambda.list_functions() for function in response['Functions']: log.info(function['FunctionName']) ...
python
def list_functions(awsclient): """List the deployed lambda functions and print configuration. :return: exit_code """ client_lambda = awsclient.get_client('lambda') response = client_lambda.list_functions() for function in response['Functions']: log.info(function['FunctionName']) ...
[ "def", "list_functions", "(", "awsclient", ")", ":", "client_lambda", "=", "awsclient", ".", "get_client", "(", "'lambda'", ")", "response", "=", "client_lambda", ".", "list_functions", "(", ")", "for", "function", "in", "response", "[", "'Functions'", "]", ":...
List the deployed lambda functions and print configuration. :return: exit_code
[ "List", "the", "deployed", "lambda", "functions", "and", "print", "configuration", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L125-L142
glomex/gcdt
gcdt/ramuda_core.py
deploy_lambda
def deploy_lambda(awsclient, function_name, role, handler_filename, handler_function, folders, description, timeout, memory, subnet_ids=None, security_groups=None, artifact_bucket=None, zipfile=None, fail_deployment_on_unsuccessfu...
python
def deploy_lambda(awsclient, function_name, role, handler_filename, handler_function, folders, description, timeout, memory, subnet_ids=None, security_groups=None, artifact_bucket=None, zipfile=None, fail_deployment_on_unsuccessfu...
[ "def", "deploy_lambda", "(", "awsclient", ",", "function_name", ",", "role", ",", "handler_filename", ",", "handler_function", ",", "folders", ",", "description", ",", "timeout", ",", "memory", ",", "subnet_ids", "=", "None", ",", "security_groups", "=", "None",...
Create or update a lambda function. :param awsclient: :param function_name: :param role: :param handler_filename: :param handler_function: :param folders: :param description: :param timeout: :param memory: :param subnet_ids: :param security_groups: :param artifact_bucket...
[ "Create", "or", "update", "a", "lambda", "function", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L145-L213
glomex/gcdt
gcdt/ramuda_core.py
bundle_lambda
def bundle_lambda(zipfile): """Write zipfile contents to file. :param zipfile: :return: exit_code """ # TODO have 'bundle.zip' as default config if not zipfile: return 1 with open('bundle.zip', 'wb') as zfile: zfile.write(zipfile) log.info('Finished - a bundle.zip is wai...
python
def bundle_lambda(zipfile): """Write zipfile contents to file. :param zipfile: :return: exit_code """ # TODO have 'bundle.zip' as default config if not zipfile: return 1 with open('bundle.zip', 'wb') as zfile: zfile.write(zipfile) log.info('Finished - a bundle.zip is wai...
[ "def", "bundle_lambda", "(", "zipfile", ")", ":", "# TODO have 'bundle.zip' as default config", "if", "not", "zipfile", ":", "return", "1", "with", "open", "(", "'bundle.zip'", ",", "'wb'", ")", "as", "zfile", ":", "zfile", ".", "write", "(", "zipfile", ")", ...
Write zipfile contents to file. :param zipfile: :return: exit_code
[ "Write", "zipfile", "contents", "to", "file", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L319-L331
glomex/gcdt
gcdt/ramuda_core.py
get_metrics
def get_metrics(awsclient, name): """Print out cloudformation metrics for a lambda function. :param awsclient :param name: name of the lambda function :return: exit_code """ metrics = ['Duration', 'Errors', 'Invocations', 'Throttles'] client_cw = awsclient.get_client('cloudwatch') for m...
python
def get_metrics(awsclient, name): """Print out cloudformation metrics for a lambda function. :param awsclient :param name: name of the lambda function :return: exit_code """ metrics = ['Duration', 'Errors', 'Invocations', 'Throttles'] client_cw = awsclient.get_client('cloudwatch') for m...
[ "def", "get_metrics", "(", "awsclient", ",", "name", ")", ":", "metrics", "=", "[", "'Duration'", ",", "'Errors'", ",", "'Invocations'", ",", "'Throttles'", "]", "client_cw", "=", "awsclient", ".", "get_client", "(", "'cloudwatch'", ")", "for", "metric", "in...
Print out cloudformation metrics for a lambda function. :param awsclient :param name: name of the lambda function :return: exit_code
[ "Print", "out", "cloudformation", "metrics", "for", "a", "lambda", "function", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L419-L450
glomex/gcdt
gcdt/ramuda_core.py
rollback
def rollback(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Rollback a lambda function to a given version. :param awsclient: :param function_name: :param alias_name: :param version: :return: exit_code """ if version: log.info('rolling back to version {}'.form...
python
def rollback(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Rollback a lambda function to a given version. :param awsclient: :param function_name: :param alias_name: :param version: :return: exit_code """ if version: log.info('rolling back to version {}'.form...
[ "def", "rollback", "(", "awsclient", ",", "function_name", ",", "alias_name", "=", "ALIAS_NAME", ",", "version", "=", "None", ")", ":", "if", "version", ":", "log", ".", "info", "(", "'rolling back to version {}'", ".", "format", "(", "version", ")", ")", ...
Rollback a lambda function to a given version. :param awsclient: :param function_name: :param alias_name: :param version: :return: exit_code
[ "Rollback", "a", "lambda", "function", "to", "a", "given", "version", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L453-L474
glomex/gcdt
gcdt/ramuda_core.py
delete_lambda
def delete_lambda(awsclient, function_name, events=None, delete_logs=False): """Delete a lambda function. :param awsclient: :param function_name: :param events: list of events :param delete_logs: :return: exit_code """ if events is not None: unwire(awsclient, events, function_na...
python
def delete_lambda(awsclient, function_name, events=None, delete_logs=False): """Delete a lambda function. :param awsclient: :param function_name: :param events: list of events :param delete_logs: :return: exit_code """ if events is not None: unwire(awsclient, events, function_na...
[ "def", "delete_lambda", "(", "awsclient", ",", "function_name", ",", "events", "=", "None", ",", "delete_logs", "=", "False", ")", ":", "if", "events", "is", "not", "None", ":", "unwire", "(", "awsclient", ",", "events", ",", "function_name", ",", "alias_n...
Delete a lambda function. :param awsclient: :param function_name: :param events: list of events :param delete_logs: :return: exit_code
[ "Delete", "a", "lambda", "function", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L477-L496
glomex/gcdt
gcdt/ramuda_core.py
delete_lambda_deprecated
def delete_lambda_deprecated(awsclient, function_name, s3_event_sources=[], time_event_sources=[], delete_logs=False): # FIXME: mutable default arguments! """Deprecated: please use delete_lambda! :param awsclient: :param function_name: :param s3_event_sources: :para...
python
def delete_lambda_deprecated(awsclient, function_name, s3_event_sources=[], time_event_sources=[], delete_logs=False): # FIXME: mutable default arguments! """Deprecated: please use delete_lambda! :param awsclient: :param function_name: :param s3_event_sources: :para...
[ "def", "delete_lambda_deprecated", "(", "awsclient", ",", "function_name", ",", "s3_event_sources", "=", "[", "]", ",", "time_event_sources", "=", "[", "]", ",", "delete_logs", "=", "False", ")", ":", "# FIXME: mutable default arguments!", "unwire_deprecated", "(", ...
Deprecated: please use delete_lambda! :param awsclient: :param function_name: :param s3_event_sources: :param time_event_sources: :param delete_logs: :return: exit_code
[ "Deprecated", ":", "please", "use", "delete_lambda!" ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L499-L522
glomex/gcdt
gcdt/ramuda_core.py
cleanup_bundle
def cleanup_bundle(): """Deletes files used for creating bundle. * vendored/* * bundle.zip """ paths = ['./vendored', './bundle.zip'] for path in paths: if os.path.exists(path): log.debug("Deleting %s..." % path) if os.path.isdir(path): shu...
python
def cleanup_bundle(): """Deletes files used for creating bundle. * vendored/* * bundle.zip """ paths = ['./vendored', './bundle.zip'] for path in paths: if os.path.exists(path): log.debug("Deleting %s..." % path) if os.path.isdir(path): shu...
[ "def", "cleanup_bundle", "(", ")", ":", "paths", "=", "[", "'./vendored'", ",", "'./bundle.zip'", "]", "for", "path", "in", "paths", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "log", ".", "debug", "(", "\"Deleting %s...\"", "%"...
Deletes files used for creating bundle. * vendored/* * bundle.zip
[ "Deletes", "files", "used", "for", "creating", "bundle", ".", "*", "vendored", "/", "*", "*", "bundle", ".", "zip" ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L623-L635
glomex/gcdt
gcdt/ramuda_core.py
ping
def ping(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param alias_name: :param version: :return: ping response payload """ log.debug('sending ping to lambda function: %s', function_n...
python
def ping(awsclient, function_name, alias_name=ALIAS_NAME, version=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param alias_name: :param version: :return: ping response payload """ log.debug('sending ping to lambda function: %s', function_n...
[ "def", "ping", "(", "awsclient", ",", "function_name", ",", "alias_name", "=", "ALIAS_NAME", ",", "version", "=", "None", ")", ":", "log", ".", "debug", "(", "'sending ping to lambda function: %s'", ",", "function_name", ")", "payload", "=", "'{\"ramuda_action\": ...
Send a ping request to a lambda function. :param awsclient: :param function_name: :param alias_name: :param version: :return: ping response payload
[ "Send", "a", "ping", "request", "to", "a", "lambda", "function", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L638-L651
glomex/gcdt
gcdt/ramuda_core.py
invoke
def invoke(awsclient, function_name, payload, invocation_type=None, alias_name=ALIAS_NAME, version=None, outfile=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param payload: :param invocation_type: :param alias_name: :param version: ...
python
def invoke(awsclient, function_name, payload, invocation_type=None, alias_name=ALIAS_NAME, version=None, outfile=None): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param payload: :param invocation_type: :param alias_name: :param version: ...
[ "def", "invoke", "(", "awsclient", ",", "function_name", ",", "payload", ",", "invocation_type", "=", "None", ",", "alias_name", "=", "ALIAS_NAME", ",", "version", "=", "None", ",", "outfile", "=", "None", ")", ":", "log", ".", "debug", "(", "'invoking lam...
Send a ping request to a lambda function. :param awsclient: :param function_name: :param payload: :param invocation_type: :param alias_name: :param version: :param outfile: write response to file :return: ping response payload
[ "Send", "a", "ping", "request", "to", "a", "lambda", "function", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L654-L700
glomex/gcdt
gcdt/ramuda_core.py
logs
def logs(awsclient, function_name, start_dt, end_dt=None, tail=False): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param start_dt: :param end_dt: :param tail: :return: """ log.debug('Getting cloudwatch logs for: %s', function_name) log_g...
python
def logs(awsclient, function_name, start_dt, end_dt=None, tail=False): """Send a ping request to a lambda function. :param awsclient: :param function_name: :param start_dt: :param end_dt: :param tail: :return: """ log.debug('Getting cloudwatch logs for: %s', function_name) log_g...
[ "def", "logs", "(", "awsclient", ",", "function_name", ",", "start_dt", ",", "end_dt", "=", "None", ",", "tail", "=", "False", ")", ":", "log", ".", "debug", "(", "'Getting cloudwatch logs for: %s'", ",", "function_name", ")", "log_group_name", "=", "'/aws/lam...
Send a ping request to a lambda function. :param awsclient: :param function_name: :param start_dt: :param end_dt: :param tail: :return:
[ "Send", "a", "ping", "request", "to", "a", "lambda", "function", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L703-L743
thombashi/typepy
typepy/converter/_datetime.py
DateTimeConverter.__validate_datetime_string
def __validate_datetime_string(self): """ This will require validating version string (such as "3.3.5"). A version string could be converted to a datetime value if this validation is not executed. """ try: try: StrictVersion(self._value) ...
python
def __validate_datetime_string(self): """ This will require validating version string (such as "3.3.5"). A version string could be converted to a datetime value if this validation is not executed. """ try: try: StrictVersion(self._value) ...
[ "def", "__validate_datetime_string", "(", "self", ")", ":", "try", ":", "try", ":", "StrictVersion", "(", "self", ".", "_value", ")", "raise", "TypeConversionError", "(", "\"invalid datetime string: version string found {}\"", ".", "format", "(", "self", ".", "_valu...
This will require validating version string (such as "3.3.5"). A version string could be converted to a datetime value if this validation is not executed.
[ "This", "will", "require", "validating", "version", "string", "(", "such", "as", "3", ".", "3", ".", "5", ")", ".", "A", "version", "string", "could", "be", "converted", "to", "a", "datetime", "value", "if", "this", "validation", "is", "not", "executed",...
train
https://github.com/thombashi/typepy/blob/8209d1df4f2a7f196a9fa4bfb0708c5ff648461f/typepy/converter/_datetime.py#L131-L147
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.ADR
def ADR(self, params): """ ADR Ra, [PC, #imm10_4] ADR Ra, label Load the address of label or the PC offset into Ra Ra must be a low register """ # TODO may need to rethink how I do PC, may need to be byte alligned # TODO This is wrong as each address is a...
python
def ADR(self, params): """ ADR Ra, [PC, #imm10_4] ADR Ra, label Load the address of label or the PC offset into Ra Ra must be a low register """ # TODO may need to rethink how I do PC, may need to be byte alligned # TODO This is wrong as each address is a...
[ "def", "ADR", "(", "self", ",", "params", ")", ":", "# TODO may need to rethink how I do PC, may need to be byte alligned", "# TODO This is wrong as each address is a word, not a byte. The filled value with its location (Do we want that, or the value at that location [Decompiled instruction])", ...
ADR Ra, [PC, #imm10_4] ADR Ra, label Load the address of label or the PC offset into Ra Ra must be a low register
[ "ADR", "Ra", "[", "PC", "#imm10_4", "]", "ADR", "Ra", "label" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L9-L39
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.LDR
def LDR(self, params): """ LDR Ra, [PC, #imm10_4] LDR Ra, label LDR Ra, =equate LDR Ra, [Rb, Rc] LDR Ra, [Rb, #imm7_4] LDR Ra, [SP, #imm10_4] Load a word from memory into Ra Ra, Rb, and Rc must be low registers """ # TODO definitio...
python
def LDR(self, params): """ LDR Ra, [PC, #imm10_4] LDR Ra, label LDR Ra, =equate LDR Ra, [Rb, Rc] LDR Ra, [Rb, #imm7_4] LDR Ra, [SP, #imm10_4] Load a word from memory into Ra Ra, Rb, and Rc must be low registers """ # TODO definitio...
[ "def", "LDR", "(", "self", ",", "params", ")", ":", "# TODO definition for PC is Ra <- M[PC + Imm10_4], Imm10_4 = PC - label, need to figure this one out", "try", ":", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMET...
LDR Ra, [PC, #imm10_4] LDR Ra, label LDR Ra, =equate LDR Ra, [Rb, Rc] LDR Ra, [Rb, #imm7_4] LDR Ra, [SP, #imm10_4] Load a word from memory into Ra Ra, Rb, and Rc must be low registers
[ "LDR", "Ra", "[", "PC", "#imm10_4", "]", "LDR", "Ra", "label", "LDR", "Ra", "=", "equate", "LDR", "Ra", "[", "Rb", "Rc", "]", "LDR", "Ra", "[", "Rb", "#imm7_4", "]", "LDR", "Ra", "[", "SP", "#imm10_4", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L64-L187
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.LDRB
def LDRB(self, params): """ LDRB Ra, [Rb, Rc] LDRB Ra, [Rb, #imm5] Load a byte from memory into Ra Ra, Rb, and Rc must be low registers """ try: Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) except iarm.exc...
python
def LDRB(self, params): """ LDRB Ra, [Rb, Rc] LDRB Ra, [Rb, #imm5] Load a byte from memory into Ra Ra, Rb, and Rc must be low registers """ try: Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) except iarm.exc...
[ "def", "LDRB", "(", "self", ",", "params", ")", ":", "try", ":", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "except", "iarm", ".", "exceptions", ".", "Parsi...
LDRB Ra, [Rb, Rc] LDRB Ra, [Rb, #imm5] Load a byte from memory into Ra Ra, Rb, and Rc must be low registers
[ "LDRB", "Ra", "[", "Rb", "Rc", "]", "LDRB", "Ra", "[", "Rb", "#imm5", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L189-L215
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.LDRH
def LDRH(self, params): """ LDRH Ra, [Rb, Rc] LDRH Ra, [Rb, #imm6_2] Load a half word from memory into Ra Ra, Rb, and Rc must be low registers """ try: Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) except i...
python
def LDRH(self, params): """ LDRH Ra, [Rb, Rc] LDRH Ra, [Rb, #imm6_2] Load a half word from memory into Ra Ra, Rb, and Rc must be low registers """ try: Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) except i...
[ "def", "LDRH", "(", "self", ",", "params", ")", ":", "try", ":", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "except", "iarm", ".", "exceptions", ".", "Parsi...
LDRH Ra, [Rb, Rc] LDRH Ra, [Rb, #imm6_2] Load a half word from memory into Ra Ra, Rb, and Rc must be low registers
[ "LDRH", "Ra", "[", "Rb", "Rc", "]", "LDRH", "Ra", "[", "Rb", "#imm6_2", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L217-L258
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.LDRSB
def LDRSB(self, params): """ LDRSB Ra, [Rb, Rc] Load a byte from memory, sign extend, and put into Ra Ra, Rb, and Rc must be low registers """ # TODO LDRSB cant use immediates Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) ...
python
def LDRSB(self, params): """ LDRSB Ra, [Rb, Rc] Load a byte from memory, sign extend, and put into Ra Ra, Rb, and Rc must be low registers """ # TODO LDRSB cant use immediates Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) ...
[ "def", "LDRSB", "(", "self", ",", "params", ")", ":", "# TODO LDRSB cant use immediates", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "self", ".", "check_arguments",...
LDRSB Ra, [Rb, Rc] Load a byte from memory, sign extend, and put into Ra Ra, Rb, and Rc must be low registers
[ "LDRSB", "Ra", "[", "Rb", "Rc", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L260-L279
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.LDRSH
def LDRSH(self, params): """ LDRSH Ra, [Rb, Rc] Load a half word from memory, sign extend, and put into Ra Ra, Rb, and Rc must be low registers """ # TODO LDRSH cant use immediates Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params)...
python
def LDRSH(self, params): """ LDRSH Ra, [Rb, Rc] Load a half word from memory, sign extend, and put into Ra Ra, Rb, and Rc must be low registers """ # TODO LDRSH cant use immediates Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params)...
[ "def", "LDRSH", "(", "self", ",", "params", ")", ":", "# TODO LDRSH cant use immediates", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "self", ".", "check_arguments",...
LDRSH Ra, [Rb, Rc] Load a half word from memory, sign extend, and put into Ra Ra, Rb, and Rc must be low registers
[ "LDRSH", "Ra", "[", "Rb", "Rc", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L281-L305
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.POP
def POP(self, params): """ POP {RPopList} Pop from the stack into the list of registers List must contain only low registers or PC """ # TODO verify pop order # TODO pop list is comma separate, right? # TODO what registeres are allowed to POP to? Low Regi...
python
def POP(self, params): """ POP {RPopList} Pop from the stack into the list of registers List must contain only low registers or PC """ # TODO verify pop order # TODO pop list is comma separate, right? # TODO what registeres are allowed to POP to? Low Regi...
[ "def", "POP", "(", "self", ",", "params", ")", ":", "# TODO verify pop order", "# TODO pop list is comma separate, right?", "# TODO what registeres are allowed to POP to? Low Registers and PC", "# TODO need to support ranges, ie {R2, R5-R7}", "# TODO PUSH should reverse the list, not POP", ...
POP {RPopList} Pop from the stack into the list of registers List must contain only low registers or PC
[ "POP", "{", "RPopList", "}" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L307-L334
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.PUSH
def PUSH(self, params): """ PUSH {RPushList} Push to the stack from a list of registers List must contain only low registers or LR """ # TODO what registers are allowed to PUSH to? Low registers and LR # TODO PUSH should reverse the list, not POP RPushLis...
python
def PUSH(self, params): """ PUSH {RPushList} Push to the stack from a list of registers List must contain only low registers or LR """ # TODO what registers are allowed to PUSH to? Low registers and LR # TODO PUSH should reverse the list, not POP RPushLis...
[ "def", "PUSH", "(", "self", ",", "params", ")", ":", "# TODO what registers are allowed to PUSH to? Low registers and LR", "# TODO PUSH should reverse the list, not POP", "RPushList", "=", "self", ".", "get_one_parameter", "(", "r'\\s*{(.*)}(.*)'", ",", "params", ")", ".", ...
PUSH {RPushList} Push to the stack from a list of registers List must contain only low registers or LR
[ "PUSH", "{", "RPushList", "}" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L336-L357
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.STM
def STM(self, params): """ STM Ra!, {RLoList} Store multiple registers into memory """ # TODO what registers can be stored? Ra, RLoList = self.get_two_parameters(r'\s*([^\s,]*)!,\s*{(.*)}(.*)', params).split(',') RLoList = RLoList.split(',') RLoList = [i....
python
def STM(self, params): """ STM Ra!, {RLoList} Store multiple registers into memory """ # TODO what registers can be stored? Ra, RLoList = self.get_two_parameters(r'\s*([^\s,]*)!,\s*{(.*)}(.*)', params).split(',') RLoList = RLoList.split(',') RLoList = [i....
[ "def", "STM", "(", "self", ",", "params", ")", ":", "# TODO what registers can be stored?", "Ra", ",", "RLoList", "=", "self", ".", "get_two_parameters", "(", "r'\\s*([^\\s,]*)!,\\s*{(.*)}(.*)'", ",", "params", ")", ".", "split", "(", "','", ")", "RLoList", "=",...
STM Ra!, {RLoList} Store multiple registers into memory
[ "STM", "Ra!", "{", "RLoList", "}" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L359-L378
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.STR
def STR(self, params): """ STR Ra, [Rb, Rc] STR Ra, [Rb, #imm7_4] STR Ra, [SP, #imm10_4] Store Ra into memory as a word Ra, Rb, and Rc must be low registers """ Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) if...
python
def STR(self, params): """ STR Ra, [Rb, Rc] STR Ra, [Rb, #imm7_4] STR Ra, [SP, #imm10_4] Store Ra into memory as a word Ra, Rb, and Rc must be low registers """ Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) if...
[ "def", "STR", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "if", "self", ".", "is_immediate", "(", "Rc", ")", ":", "if...
STR Ra, [Rb, Rc] STR Ra, [Rb, #imm7_4] STR Ra, [SP, #imm10_4] Store Ra into memory as a word Ra, Rb, and Rc must be low registers
[ "STR", "Ra", "[", "Rb", "Rc", "]", "STR", "Ra", "[", "Rb", "#imm7_4", "]", "STR", "Ra", "[", "SP", "#imm10_4", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L380-L407
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.STRB
def STRB(self, params): """ STRB Ra, [Rb, Rc] STRB Ra, [Rb, #imm5] Store Ra into memory as a byte Ra, Rb, and Rc must be low registers """ Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) if self.is_immediate(Rc): ...
python
def STRB(self, params): """ STRB Ra, [Rb, Rc] STRB Ra, [Rb, #imm5] Store Ra into memory as a byte Ra, Rb, and Rc must be low registers """ Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) if self.is_immediate(Rc): ...
[ "def", "STRB", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "if", "self", ".", "is_immediate", "(", "Rc", ")", ":", "s...
STRB Ra, [Rb, Rc] STRB Ra, [Rb, #imm5] Store Ra into memory as a byte Ra, Rb, and Rc must be low registers
[ "STRB", "Ra", "[", "Rb", "Rc", "]", "STRB", "Ra", "[", "Rb", "#imm5", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L409-L430
DeepHorizons/iarm
iarm/arm_instructions/memory.py
Memory.STRH
def STRH(self, params): """ STRH Ra, [Rb, Rc] STRH Ra, [Rb, #imm6_2] Store Ra into memory as a half word Ra, Rb, and Rc must be low registers """ Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) if self.is_immediate(Rc):...
python
def STRH(self, params): """ STRH Ra, [Rb, Rc] STRH Ra, [Rb, #imm6_2] Store Ra into memory as a half word Ra, Rb, and Rc must be low registers """ Ra, Rb, Rc = self.get_three_parameters(self.THREE_PARAMETER_WITH_BRACKETS, params) if self.is_immediate(Rc):...
[ "def", "STRH", "(", "self", ",", "params", ")", ":", "Ra", ",", "Rb", ",", "Rc", "=", "self", ".", "get_three_parameters", "(", "self", ".", "THREE_PARAMETER_WITH_BRACKETS", ",", "params", ")", "if", "self", ".", "is_immediate", "(", "Rc", ")", ":", "s...
STRH Ra, [Rb, Rc] STRH Ra, [Rb, #imm6_2] Store Ra into memory as a half word Ra, Rb, and Rc must be low registers
[ "STRH", "Ra", "[", "Rb", "Rc", "]", "STRH", "Ra", "[", "Rb", "#imm6_2", "]" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/memory.py#L432-L455
glomex/gcdt
gcdt/kumo_start_stop.py
_stop_ec2_instances
def _stop_ec2_instances(awsclient, ec2_instances, wait=True): """Helper to stop ec2 instances. By default it waits for instances to stop. :param awsclient: :param ec2_instances: :param wait: waits for instances to stop :return: """ if len(ec2_instances) == 0: return client_e...
python
def _stop_ec2_instances(awsclient, ec2_instances, wait=True): """Helper to stop ec2 instances. By default it waits for instances to stop. :param awsclient: :param ec2_instances: :param wait: waits for instances to stop :return: """ if len(ec2_instances) == 0: return client_e...
[ "def", "_stop_ec2_instances", "(", "awsclient", ",", "ec2_instances", ",", "wait", "=", "True", ")", ":", "if", "len", "(", "ec2_instances", ")", "==", "0", ":", "return", "client_ec2", "=", "awsclient", ".", "get_client", "(", "'ec2'", ")", "# get running i...
Helper to stop ec2 instances. By default it waits for instances to stop. :param awsclient: :param ec2_instances: :param wait: waits for instances to stop :return:
[ "Helper", "to", "stop", "ec2", "instances", ".", "By", "default", "it", "waits", "for", "instances", "to", "stop", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L11-L44
glomex/gcdt
gcdt/kumo_start_stop.py
_start_ec2_instances
def _start_ec2_instances(awsclient, ec2_instances, wait=True): """Helper to start ec2 instances :param awsclient: :param ec2_instances: :param wait: waits for instances to start :return: """ if len(ec2_instances) == 0: return client_ec2 = awsclient.get_client('ec2') # get s...
python
def _start_ec2_instances(awsclient, ec2_instances, wait=True): """Helper to start ec2 instances :param awsclient: :param ec2_instances: :param wait: waits for instances to start :return: """ if len(ec2_instances) == 0: return client_ec2 = awsclient.get_client('ec2') # get s...
[ "def", "_start_ec2_instances", "(", "awsclient", ",", "ec2_instances", ",", "wait", "=", "True", ")", ":", "if", "len", "(", "ec2_instances", ")", "==", "0", ":", "return", "client_ec2", "=", "awsclient", ".", "get_client", "(", "'ec2'", ")", "# get stopped ...
Helper to start ec2 instances :param awsclient: :param ec2_instances: :param wait: waits for instances to start :return:
[ "Helper", "to", "start", "ec2", "instances" ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L47-L85
glomex/gcdt
gcdt/kumo_start_stop.py
_filter_db_instances_by_status
def _filter_db_instances_by_status(awsclient, db_instances, status_list): """helper to select dbinstances. :param awsclient: :param db_instances: :param status_list: :return: list of db_instances that match the filter """ client_rds = awsclient.get_client('rds') db_instances_with_status...
python
def _filter_db_instances_by_status(awsclient, db_instances, status_list): """helper to select dbinstances. :param awsclient: :param db_instances: :param status_list: :return: list of db_instances that match the filter """ client_rds = awsclient.get_client('rds') db_instances_with_status...
[ "def", "_filter_db_instances_by_status", "(", "awsclient", ",", "db_instances", ",", "status_list", ")", ":", "client_rds", "=", "awsclient", ".", "get_client", "(", "'rds'", ")", "db_instances_with_status", "=", "[", "]", "for", "db", "in", "db_instances", ":", ...
helper to select dbinstances. :param awsclient: :param db_instances: :param status_list: :return: list of db_instances that match the filter
[ "helper", "to", "select", "dbinstances", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L88-L107
glomex/gcdt
gcdt/kumo_start_stop.py
_stop_ecs_services
def _stop_ecs_services(awsclient, services, template, parameters, wait=True): """Helper to change desiredCount of ECS services to zero. By default it waits for this to complete. Docs here: http://docs.aws.amazon.com/cli/latest/reference/ecs/update-service.html :param awsclient: :param services: ...
python
def _stop_ecs_services(awsclient, services, template, parameters, wait=True): """Helper to change desiredCount of ECS services to zero. By default it waits for this to complete. Docs here: http://docs.aws.amazon.com/cli/latest/reference/ecs/update-service.html :param awsclient: :param services: ...
[ "def", "_stop_ecs_services", "(", "awsclient", ",", "services", ",", "template", ",", "parameters", ",", "wait", "=", "True", ")", ":", "if", "len", "(", "services", ")", "==", "0", ":", "return", "client_ecs", "=", "awsclient", ".", "get_client", "(", "...
Helper to change desiredCount of ECS services to zero. By default it waits for this to complete. Docs here: http://docs.aws.amazon.com/cli/latest/reference/ecs/update-service.html :param awsclient: :param services: :param template: the cloudformation template :param parameters: the parameters u...
[ "Helper", "to", "change", "desiredCount", "of", "ECS", "services", "to", "zero", ".", "By", "default", "it", "waits", "for", "this", "to", "complete", ".", "Docs", "here", ":", "http", ":", "//", "docs", ".", "aws", ".", "amazon", ".", "com", "/", "c...
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L110-L136
glomex/gcdt
gcdt/kumo_start_stop.py
stop_stack
def stop_stack(awsclient, stack_name, use_suspend=False): """Stop an existing stack on AWS cloud. :param awsclient: :param stack_name: :param use_suspend: use suspend and resume on the autoscaling group :return: exit_code """ exit_code = 0 # check for DisableStop #disable_stop = co...
python
def stop_stack(awsclient, stack_name, use_suspend=False): """Stop an existing stack on AWS cloud. :param awsclient: :param stack_name: :param use_suspend: use suspend and resume on the autoscaling group :return: exit_code """ exit_code = 0 # check for DisableStop #disable_stop = co...
[ "def", "stop_stack", "(", "awsclient", ",", "stack_name", ",", "use_suspend", "=", "False", ")", ":", "exit_code", "=", "0", "# check for DisableStop", "#disable_stop = conf.get('deployment', {}).get('DisableStop', False)", "#if disable_stop:", "# log.warn('\\'DisableStop\\' i...
Stop an existing stack on AWS cloud. :param awsclient: :param stack_name: :param use_suspend: use suspend and resume on the autoscaling group :return: exit_code
[ "Stop", "an", "existing", "stack", "on", "AWS", "cloud", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L169-L284
glomex/gcdt
gcdt/kumo_start_stop.py
_get_autoscaling_min_max
def _get_autoscaling_min_max(template, parameters, asg_name): """Helper to extract the configured MinSize, MaxSize attributes from the template. :param template: cloudformation template (json) :param parameters: list of {'ParameterKey': 'x1', 'ParameterValue': 'y1'} :param asg_name: logical resourc...
python
def _get_autoscaling_min_max(template, parameters, asg_name): """Helper to extract the configured MinSize, MaxSize attributes from the template. :param template: cloudformation template (json) :param parameters: list of {'ParameterKey': 'x1', 'ParameterValue': 'y1'} :param asg_name: logical resourc...
[ "def", "_get_autoscaling_min_max", "(", "template", ",", "parameters", ",", "asg_name", ")", ":", "params", "=", "{", "e", "[", "'ParameterKey'", "]", ":", "e", "[", "'ParameterValue'", "]", "for", "e", "in", "parameters", "}", "asg", "=", "template", ".",...
Helper to extract the configured MinSize, MaxSize attributes from the template. :param template: cloudformation template (json) :param parameters: list of {'ParameterKey': 'x1', 'ParameterValue': 'y1'} :param asg_name: logical resource name of the autoscaling group :return: MinSize, MaxSize
[ "Helper", "to", "extract", "the", "configured", "MinSize", "MaxSize", "attributes", "from", "the", "template", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L287-L307
glomex/gcdt
gcdt/kumo_start_stop.py
_get_service_cluster_desired_count
def _get_service_cluster_desired_count(template, parameters, service_name): """Helper to extract the configured desiredCount attribute from the template. :param template: cloudformation template (json) :param parameters: list of {'ParameterKey': 'x1', 'ParameterValue': 'y1'} :param service_name: lo...
python
def _get_service_cluster_desired_count(template, parameters, service_name): """Helper to extract the configured desiredCount attribute from the template. :param template: cloudformation template (json) :param parameters: list of {'ParameterKey': 'x1', 'ParameterValue': 'y1'} :param service_name: lo...
[ "def", "_get_service_cluster_desired_count", "(", "template", ",", "parameters", ",", "service_name", ")", ":", "params", "=", "{", "e", "[", "'ParameterKey'", "]", ":", "e", "[", "'ParameterValue'", "]", "for", "e", "in", "parameters", "}", "service", "=", ...
Helper to extract the configured desiredCount attribute from the template. :param template: cloudformation template (json) :param parameters: list of {'ParameterKey': 'x1', 'ParameterValue': 'y1'} :param service_name: logical resource name of the ECS service :return: cluster, desiredCount
[ "Helper", "to", "extract", "the", "configured", "desiredCount", "attribute", "from", "the", "template", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L310-L329
glomex/gcdt
gcdt/kumo_start_stop.py
start_stack
def start_stack(awsclient, stack_name, use_suspend=False): """Start an existing stack on AWS cloud. :param awsclient: :param stack_name: :param use_suspend: use suspend and resume on the autoscaling group :return: exit_code """ exit_code = 0 # check for DisableStop #disable_stop = ...
python
def start_stack(awsclient, stack_name, use_suspend=False): """Start an existing stack on AWS cloud. :param awsclient: :param stack_name: :param use_suspend: use suspend and resume on the autoscaling group :return: exit_code """ exit_code = 0 # check for DisableStop #disable_stop = ...
[ "def", "start_stack", "(", "awsclient", ",", "stack_name", ",", "use_suspend", "=", "False", ")", ":", "exit_code", "=", "0", "# check for DisableStop", "#disable_stop = conf.get('deployment', {}).get('DisableStop', False)", "#if disable_stop:", "# log.warn('\\'DisableStop\\' ...
Start an existing stack on AWS cloud. :param awsclient: :param stack_name: :param use_suspend: use suspend and resume on the autoscaling group :return: exit_code
[ "Start", "an", "existing", "stack", "on", "AWS", "cloud", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_start_stop.py#L348-L455
gmr/helper
helper/controller.py
Controller.is_running
def is_running(self): """Property method that returns a bool specifying if the process is currently running. This will return true if the state is active, idle or initializing. :rtype: bool """ return self._state in [self.STATE_ACTIVE, sel...
python
def is_running(self): """Property method that returns a bool specifying if the process is currently running. This will return true if the state is active, idle or initializing. :rtype: bool """ return self._state in [self.STATE_ACTIVE, sel...
[ "def", "is_running", "(", "self", ")", ":", "return", "self", ".", "_state", "in", "[", "self", ".", "STATE_ACTIVE", ",", "self", ".", "STATE_IDLE", ",", "self", ".", "STATE_INITIALIZING", "]" ]
Property method that returns a bool specifying if the process is currently running. This will return true if the state is active, idle or initializing. :rtype: bool
[ "Property", "method", "that", "returns", "a", "bool", "specifying", "if", "the", "process", "is", "currently", "running", ".", "This", "will", "return", "true", "if", "the", "state", "is", "active", "idle", "or", "initializing", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/controller.py#L143-L153
gmr/helper
helper/controller.py
Controller.process_signal
def process_signal(self, signum): """Invoked whenever a signal is added to the stack. :param int signum: The signal that was added """ if signum == signal.SIGTERM: LOGGER.info('Received SIGTERM, initiating shutdown') self.stop() elif signum == signal.SIG...
python
def process_signal(self, signum): """Invoked whenever a signal is added to the stack. :param int signum: The signal that was added """ if signum == signal.SIGTERM: LOGGER.info('Received SIGTERM, initiating shutdown') self.stop() elif signum == signal.SIG...
[ "def", "process_signal", "(", "self", ",", "signum", ")", ":", "if", "signum", "==", "signal", ".", "SIGTERM", ":", "LOGGER", ".", "info", "(", "'Received SIGTERM, initiating shutdown'", ")", "self", ".", "stop", "(", ")", "elif", "signum", "==", "signal", ...
Invoked whenever a signal is added to the stack. :param int signum: The signal that was added
[ "Invoked", "whenever", "a", "signal", "is", "added", "to", "the", "stack", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/controller.py#L225-L243
gmr/helper
helper/controller.py
Controller.run
def run(self): """The core method for starting the application. Will setup logging, toggle the runtime state flag, block on loop, then call shutdown. Redefine this method if you intend to use an IO Loop or some other long running process. """ LOGGER.info('%s v%s started...
python
def run(self): """The core method for starting the application. Will setup logging, toggle the runtime state flag, block on loop, then call shutdown. Redefine this method if you intend to use an IO Loop or some other long running process. """ LOGGER.info('%s v%s started...
[ "def", "run", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'%s v%s started'", ",", "self", ".", "APPNAME", ",", "self", ".", "VERSION", ")", "self", ".", "setup", "(", ")", "while", "not", "any", "(", "[", "self", ".", "is_stopping", ",", "s...
The core method for starting the application. Will setup logging, toggle the runtime state flag, block on loop, then call shutdown. Redefine this method if you intend to use an IO Loop or some other long running process.
[ "The", "core", "method", "for", "starting", "the", "application", ".", "Will", "setup", "logging", "toggle", "the", "runtime", "state", "flag", "block", "on", "loop", "then", "call", "shutdown", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/controller.py#L245-L266
gmr/helper
helper/controller.py
Controller.start
def start(self): """Important: Do not extend this method, rather redefine Controller.run """ for signum in [signal.SIGHUP, signal.SIGTERM, signal.SIGUSR1, signal.SIGUSR2]: signal.signal(signum, self._on_signal) self.run()
python
def start(self): """Important: Do not extend this method, rather redefine Controller.run """ for signum in [signal.SIGHUP, signal.SIGTERM, signal.SIGUSR1, signal.SIGUSR2]: signal.signal(signum, self._on_signal) self.run()
[ "def", "start", "(", "self", ")", ":", "for", "signum", "in", "[", "signal", ".", "SIGHUP", ",", "signal", ".", "SIGTERM", ",", "signal", ".", "SIGUSR1", ",", "signal", ".", "SIGUSR2", "]", ":", "signal", ".", "signal", "(", "signum", ",", "self", ...
Important: Do not extend this method, rather redefine Controller.run
[ "Important", ":" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/controller.py#L268-L277
gmr/helper
helper/controller.py
Controller.set_state
def set_state(self, state): """Set the runtime state of the Controller. Use the internal constants to ensure proper state values: - :attr:`Controller.STATE_INITIALIZING` - :attr:`Controller.STATE_ACTIVE` - :attr:`Controller.STATE_IDLE` - :attr:`Controller.STATE_SLEEPING`...
python
def set_state(self, state): """Set the runtime state of the Controller. Use the internal constants to ensure proper state values: - :attr:`Controller.STATE_INITIALIZING` - :attr:`Controller.STATE_ACTIVE` - :attr:`Controller.STATE_IDLE` - :attr:`Controller.STATE_SLEEPING`...
[ "def", "set_state", "(", "self", ",", "state", ")", ":", "if", "state", "==", "self", ".", "_state", ":", "return", "elif", "state", "not", "in", "self", ".", "_STATES", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "'Invalid state {}'", ".",...
Set the runtime state of the Controller. Use the internal constants to ensure proper state values: - :attr:`Controller.STATE_INITIALIZING` - :attr:`Controller.STATE_ACTIVE` - :attr:`Controller.STATE_IDLE` - :attr:`Controller.STATE_SLEEPING` - :attr:`Controller.STATE_STOP...
[ "Set", "the", "runtime", "state", "of", "the", "Controller", ".", "Use", "the", "internal", "constants", "to", "ensure", "proper", "state", "values", ":" ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/controller.py#L279-L332
gmr/helper
helper/controller.py
Controller.stop
def stop(self): """Override to implement shutdown steps.""" LOGGER.info('Attempting to stop the process') self.set_state(self.STATE_STOP_REQUESTED) # Call shutdown for classes to add shutdown steps self.shutdown() # Wait for the current run to finish while self....
python
def stop(self): """Override to implement shutdown steps.""" LOGGER.info('Attempting to stop the process') self.set_state(self.STATE_STOP_REQUESTED) # Call shutdown for classes to add shutdown steps self.shutdown() # Wait for the current run to finish while self....
[ "def", "stop", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'Attempting to stop the process'", ")", "self", ".", "set_state", "(", "self", ".", "STATE_STOP_REQUESTED", ")", "# Call shutdown for classes to add shutdown steps", "self", ".", "shutdown", "(", ")"...
Override to implement shutdown steps.
[ "Override", "to", "implement", "shutdown", "steps", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/controller.py#L342-L363
glomex/gcdt
gcdt/servicediscovery.py
parse_ts
def parse_ts(ts): """ parse timestamp. :param ts: timestamp in ISO8601 format :return: tbd!!! """ # ISO8601 = '%Y-%m-%dT%H:%M:%SZ' # ISO8601_MS = '%Y-%m-%dT%H:%M:%S.%fZ' # RFC1123 = '%a, %d %b %Y %H:%M:%S %Z' dt = maya.parse(ts.strip()) return dt.datetime(naive=True)
python
def parse_ts(ts): """ parse timestamp. :param ts: timestamp in ISO8601 format :return: tbd!!! """ # ISO8601 = '%Y-%m-%dT%H:%M:%SZ' # ISO8601_MS = '%Y-%m-%dT%H:%M:%S.%fZ' # RFC1123 = '%a, %d %b %Y %H:%M:%S %Z' dt = maya.parse(ts.strip()) return dt.datetime(naive=True)
[ "def", "parse_ts", "(", "ts", ")", ":", "# ISO8601 = '%Y-%m-%dT%H:%M:%SZ'", "# ISO8601_MS = '%Y-%m-%dT%H:%M:%S.%fZ'", "# RFC1123 = '%a, %d %b %Y %H:%M:%S %Z'", "dt", "=", "maya", ".", "parse", "(", "ts", ".", "strip", "(", ")", ")", "return", "dt", ".", "datetime", ...
parse timestamp. :param ts: timestamp in ISO8601 format :return: tbd!!!
[ "parse", "timestamp", ".", ":", "param", "ts", ":", "timestamp", "in", "ISO8601", "format", ":", "return", ":", "tbd!!!" ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/servicediscovery.py#L18-L29
glomex/gcdt
gcdt/servicediscovery.py
get_outputs_for_stack
def get_outputs_for_stack(awsclient, stack_name): """ Read environment from ENV and mangle it to a (lower case) representation Note: gcdt.servicediscovery get_outputs_for_stack((awsclient, stack_name) is used in many cloudformation.py templates! :param awsclient: :param stack_name: :return:...
python
def get_outputs_for_stack(awsclient, stack_name): """ Read environment from ENV and mangle it to a (lower case) representation Note: gcdt.servicediscovery get_outputs_for_stack((awsclient, stack_name) is used in many cloudformation.py templates! :param awsclient: :param stack_name: :return:...
[ "def", "get_outputs_for_stack", "(", "awsclient", ",", "stack_name", ")", ":", "client_cf", "=", "awsclient", ".", "get_client", "(", "'cloudformation'", ")", "response", "=", "client_cf", ".", "describe_stacks", "(", "StackName", "=", "stack_name", ")", "if", "...
Read environment from ENV and mangle it to a (lower case) representation Note: gcdt.servicediscovery get_outputs_for_stack((awsclient, stack_name) is used in many cloudformation.py templates! :param awsclient: :param stack_name: :return: dictionary containing the stack outputs
[ "Read", "environment", "from", "ENV", "and", "mangle", "it", "to", "a", "(", "lower", "case", ")", "representation", "Note", ":", "gcdt", ".", "servicediscovery", "get_outputs_for_stack", "((", "awsclient", "stack_name", ")", "is", "used", "in", "many", "cloud...
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/servicediscovery.py#L33-L49
glomex/gcdt
gcdt/servicediscovery.py
get_base_ami
def get_base_ami(awsclient, owners): """ DEPRECATED!!! return the latest version of our base AMI we can't use tags for this, so we have only the name as resource note: this functionality is deprecated since this only works for "old" baseami. """ client_ec2 = awsclient.get_client('ec2') ...
python
def get_base_ami(awsclient, owners): """ DEPRECATED!!! return the latest version of our base AMI we can't use tags for this, so we have only the name as resource note: this functionality is deprecated since this only works for "old" baseami. """ client_ec2 = awsclient.get_client('ec2') ...
[ "def", "get_base_ami", "(", "awsclient", ",", "owners", ")", ":", "client_ec2", "=", "awsclient", ".", "get_client", "(", "'ec2'", ")", "image_filter", "=", "[", "{", "'Name'", ":", "'state'", ",", "'Values'", ":", "[", "'available'", ",", "]", "}", ",",...
DEPRECATED!!! return the latest version of our base AMI we can't use tags for this, so we have only the name as resource note: this functionality is deprecated since this only works for "old" baseami.
[ "DEPRECATED!!!", "return", "the", "latest", "version", "of", "our", "base", "AMI", "we", "can", "t", "use", "tags", "for", "this", "so", "we", "have", "only", "the", "name", "as", "resource", "note", ":", "this", "functionality", "is", "deprecated", "since...
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/servicediscovery.py#L71-L107
gmr/helper
helper/parser.py
_add_default_arguments
def _add_default_arguments(parser): """Add the default arguments to the parser. :param argparse.ArgumentParser parser: The argument parser """ parser.add_argument('-c', '--config', action='store', dest='config', help='Path to the configuration file') parser.add_argument('-f...
python
def _add_default_arguments(parser): """Add the default arguments to the parser. :param argparse.ArgumentParser parser: The argument parser """ parser.add_argument('-c', '--config', action='store', dest='config', help='Path to the configuration file') parser.add_argument('-f...
[ "def", "_add_default_arguments", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "'-c'", ",", "'--config'", ",", "action", "=", "'store'", ",", "dest", "=", "'config'", ",", "help", "=", "'Path to the configuration file'", ")", "parser", ".", "add...
Add the default arguments to the parser. :param argparse.ArgumentParser parser: The argument parser
[ "Add", "the", "default", "arguments", "to", "the", "parser", "." ]
train
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/parser.py#L62-L71
valhallasw/flask-mwoauth
flask_mwoauth/__init__.py
_str
def _str(val): """ Ensures that the val is the default str() type for python2 or 3 """ if str == bytes: if isinstance(val, str): return val else: return str(val) else: if isinstance(val, str): return val else: return str...
python
def _str(val): """ Ensures that the val is the default str() type for python2 or 3 """ if str == bytes: if isinstance(val, str): return val else: return str(val) else: if isinstance(val, str): return val else: return str...
[ "def", "_str", "(", "val", ")", ":", "if", "str", "==", "bytes", ":", "if", "isinstance", "(", "val", ",", "str", ")", ":", "return", "val", "else", ":", "return", "str", "(", "val", ")", "else", ":", "if", "isinstance", "(", "val", ",", "str", ...
Ensures that the val is the default str() type for python2 or 3
[ "Ensures", "that", "the", "val", "is", "the", "default", "str", "()", "type", "for", "python2", "or", "3" ]
train
https://github.com/valhallasw/flask-mwoauth/blob/216aa9c1ead07d99a9e11deb7642e33a70aa59d7/flask_mwoauth/__init__.py#L174-L187
valhallasw/flask-mwoauth
flask_mwoauth/__init__.py
MWOAuth._prepare_long_request
def _prepare_long_request(self, url, api_query): """ Use requests.Request and requests.PreparedRequest to produce the body (and boundary value) of a multipart/form-data; POST request as detailed in https://www.mediawiki.org/wiki/API:Edit#Large_texts """ partlist = [] ...
python
def _prepare_long_request(self, url, api_query): """ Use requests.Request and requests.PreparedRequest to produce the body (and boundary value) of a multipart/form-data; POST request as detailed in https://www.mediawiki.org/wiki/API:Edit#Large_texts """ partlist = [] ...
[ "def", "_prepare_long_request", "(", "self", ",", "url", ",", "api_query", ")", ":", "partlist", "=", "[", "]", "for", "k", ",", "v", "in", "iteritems", "(", "api_query", ")", ":", "if", "k", "in", "(", "'title'", ",", "'text'", ",", "'summary'", ")"...
Use requests.Request and requests.PreparedRequest to produce the body (and boundary value) of a multipart/form-data; POST request as detailed in https://www.mediawiki.org/wiki/API:Edit#Large_texts
[ "Use", "requests", ".", "Request", "and", "requests", ".", "PreparedRequest", "to", "produce", "the", "body", "(", "and", "boundary", "value", ")", "of", "a", "multipart", "/", "form", "-", "data", ";", "POST", "request", "as", "detailed", "in", "https", ...
train
https://github.com/valhallasw/flask-mwoauth/blob/216aa9c1ead07d99a9e11deb7642e33a70aa59d7/flask_mwoauth/__init__.py#L93-L122
valhallasw/flask-mwoauth
flask_mwoauth/__init__.py
MWOAuth.request
def request(self, api_query, url=None): """ e.g. {'action': 'query', 'meta': 'userinfo'}. format=json not required function returns a python dict that resembles the api's json response """ api_query['format'] = 'json' if url is not None: api_url = url + "/api....
python
def request(self, api_query, url=None): """ e.g. {'action': 'query', 'meta': 'userinfo'}. format=json not required function returns a python dict that resembles the api's json response """ api_query['format'] = 'json' if url is not None: api_url = url + "/api....
[ "def", "request", "(", "self", ",", "api_query", ",", "url", "=", "None", ")", ":", "api_query", "[", "'format'", "]", "=", "'json'", "if", "url", "is", "not", "None", ":", "api_url", "=", "url", "+", "\"/api.php\"", "else", ":", "api_url", "=", "sel...
e.g. {'action': 'query', 'meta': 'userinfo'}. format=json not required function returns a python dict that resembles the api's json response
[ "e", ".", "g", ".", "{", "action", ":", "query", "meta", ":", "userinfo", "}", ".", "format", "=", "json", "not", "required", "function", "returns", "a", "python", "dict", "that", "resembles", "the", "api", "s", "json", "response" ]
train
https://github.com/valhallasw/flask-mwoauth/blob/216aa9c1ead07d99a9e11deb7642e33a70aa59d7/flask_mwoauth/__init__.py#L124-L158
CitrineInformatics/pypif
pypif/pif.py
dump
def dump(pif, fp, **kwargs): """ Convert a single Physical Information Object, or a list of such objects, into a JSON-encoded text file. :param pif: Object or list of objects to serialize. :param fp: File-like object supporting .write() method to write the serialized object(s) to. :param kwargs: An...
python
def dump(pif, fp, **kwargs): """ Convert a single Physical Information Object, or a list of such objects, into a JSON-encoded text file. :param pif: Object or list of objects to serialize. :param fp: File-like object supporting .write() method to write the serialized object(s) to. :param kwargs: An...
[ "def", "dump", "(", "pif", ",", "fp", ",", "*", "*", "kwargs", ")", ":", "return", "json", ".", "dump", "(", "pif", ",", "fp", ",", "cls", "=", "PifEncoder", ",", "*", "*", "kwargs", ")" ]
Convert a single Physical Information Object, or a list of such objects, into a JSON-encoded text file. :param pif: Object or list of objects to serialize. :param fp: File-like object supporting .write() method to write the serialized object(s) to. :param kwargs: Any options available to json.dump().
[ "Convert", "a", "single", "Physical", "Information", "Object", "or", "a", "list", "of", "such", "objects", "into", "a", "JSON", "-", "encoded", "text", "file", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/pif.py#L8-L16
CitrineInformatics/pypif
pypif/pif.py
load
def load(fp, class_=None, **kwargs): """ Convert content in a JSON-encoded text file to a Physical Information Object or a list of such objects. :param fp: File-like object supporting .read() method to deserialize from. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :param ...
python
def load(fp, class_=None, **kwargs): """ Convert content in a JSON-encoded text file to a Physical Information Object or a list of such objects. :param fp: File-like object supporting .read() method to deserialize from. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :param ...
[ "def", "load", "(", "fp", ",", "class_", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "loado", "(", "json", ".", "load", "(", "fp", ",", "*", "*", "kwargs", ")", ",", "class_", "=", "class_", ")" ]
Convert content in a JSON-encoded text file to a Physical Information Object or a list of such objects. :param fp: File-like object supporting .read() method to deserialize from. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :param kwargs: Any options available to json.load(). ...
[ "Convert", "content", "in", "a", "JSON", "-", "encoded", "text", "file", "to", "a", "Physical", "Information", "Object", "or", "a", "list", "of", "such", "objects", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/pif.py#L29-L38
CitrineInformatics/pypif
pypif/pif.py
loads
def loads(s, class_=None, **kwargs): """ Convert content in a JSON-encoded string to a Physical Information Object or a list of such objects. :param s: String to deserialize. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :param kwargs: Any options available to json.loads()...
python
def loads(s, class_=None, **kwargs): """ Convert content in a JSON-encoded string to a Physical Information Object or a list of such objects. :param s: String to deserialize. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :param kwargs: Any options available to json.loads()...
[ "def", "loads", "(", "s", ",", "class_", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "loado", "(", "json", ".", "loads", "(", "s", ",", "*", "*", "kwargs", ")", ",", "class_", "=", "class_", ")" ]
Convert content in a JSON-encoded string to a Physical Information Object or a list of such objects. :param s: String to deserialize. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :param kwargs: Any options available to json.loads(). :return: Single object derived from :class:...
[ "Convert", "content", "in", "a", "JSON", "-", "encoded", "string", "to", "a", "Physical", "Information", "Object", "or", "a", "list", "of", "such", "objects", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/pif.py#L41-L50
CitrineInformatics/pypif
pypif/pif.py
loado
def loado(obj, class_=None): """ Convert a dictionary or a list of dictionaries into a single Physical Information Object or a list of such objects. :param obj: Dictionary or list to convert to Physical Information Objects. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :re...
python
def loado(obj, class_=None): """ Convert a dictionary or a list of dictionaries into a single Physical Information Object or a list of such objects. :param obj: Dictionary or list to convert to Physical Information Objects. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :re...
[ "def", "loado", "(", "obj", ",", "class_", "=", "None", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "[", "_dict_to_pio", "(", "i", ",", "class_", "=", "class_", ")", "for", "i", "in", "obj", "]", "elif", "isinstance",...
Convert a dictionary or a list of dictionaries into a single Physical Information Object or a list of such objects. :param obj: Dictionary or list to convert to Physical Information Objects. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :return: Single object derived from :class:`...
[ "Convert", "a", "dictionary", "or", "a", "list", "of", "dictionaries", "into", "a", "single", "Physical", "Information", "Object", "or", "a", "list", "of", "such", "objects", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/pif.py#L53-L66
CitrineInformatics/pypif
pypif/pif.py
_dict_to_pio
def _dict_to_pio(d, class_=None): """ Convert a single dictionary object to a Physical Information Object. :param d: Dictionary to convert. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :return: Single object derived from :class:`.Pio`. """ d = keys_to_snake_case(d...
python
def _dict_to_pio(d, class_=None): """ Convert a single dictionary object to a Physical Information Object. :param d: Dictionary to convert. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :return: Single object derived from :class:`.Pio`. """ d = keys_to_snake_case(d...
[ "def", "_dict_to_pio", "(", "d", ",", "class_", "=", "None", ")", ":", "d", "=", "keys_to_snake_case", "(", "d", ")", "if", "class_", ":", "return", "class_", "(", "*", "*", "d", ")", "if", "'category'", "not", "in", "d", ":", "raise", "ValueError", ...
Convert a single dictionary object to a Physical Information Object. :param d: Dictionary to convert. :param class_: Subclass of :class:`.Pio` to produce, if not unambiguous :return: Single object derived from :class:`.Pio`.
[ "Convert", "a", "single", "dictionary", "object", "to", "a", "Physical", "Information", "Object", "." ]
train
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/pif.py#L69-L90
glomex/gcdt
gcdt/gcdt_cmd_dispatcher.py
get_command
def get_command(arguments): """Utility function to extract command from docopt arguments. :param arguments: :return: command """ cmds = list(filter(lambda k: not (k.startswith('-') or k.startswith('<')) and arguments[k], arguments.keys())) if l...
python
def get_command(arguments): """Utility function to extract command from docopt arguments. :param arguments: :return: command """ cmds = list(filter(lambda k: not (k.startswith('-') or k.startswith('<')) and arguments[k], arguments.keys())) if l...
[ "def", "get_command", "(", "arguments", ")", ":", "cmds", "=", "list", "(", "filter", "(", "lambda", "k", ":", "not", "(", "k", ".", "startswith", "(", "'-'", ")", "or", "k", ".", "startswith", "(", "'<'", ")", ")", "and", "arguments", "[", "k", ...
Utility function to extract command from docopt arguments. :param arguments: :return: command
[ "Utility", "function", "to", "extract", "command", "from", "docopt", "arguments", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/gcdt_cmd_dispatcher.py#L101-L112
glomex/gcdt
gcdt/gcdt_cmd_dispatcher.py
cmd.dispatch
def dispatch(cls, arguments, **kwargs): """Dispatch arguments parsed by docopt to the cmd with matching spec. :param arguments: :param kwargs: :return: exit_code """ # first match wins # spec: all '-' elements must match, all others are False; # '<s...
python
def dispatch(cls, arguments, **kwargs): """Dispatch arguments parsed by docopt to the cmd with matching spec. :param arguments: :param kwargs: :return: exit_code """ # first match wins # spec: all '-' elements must match, all others are False; # '<s...
[ "def", "dispatch", "(", "cls", ",", "arguments", ",", "*", "*", "kwargs", ")", ":", "# first match wins", "# spec: all '-' elements must match, all others are False;", "# '<sth>' elements are converted to call args on order of", "# appearance", "#", "# kwargs are provid...
Dispatch arguments parsed by docopt to the cmd with matching spec. :param arguments: :param kwargs: :return: exit_code
[ "Dispatch", "arguments", "parsed", "by", "docopt", "to", "the", "cmd", "with", "matching", "spec", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/gcdt_cmd_dispatcher.py#L42-L98
glomex/gcdt
gcdt/kumo_util.py
StackLookup.get_att
def get_att(self, parameter, as_reference=True): """Retrieves an attribute from an existing stack :param parameter: The output parameter which should be retrieved :param as_reference: Is the parameter a reference (Default) or a string :return: Value of parameter to retrieve """ ...
python
def get_att(self, parameter, as_reference=True): """Retrieves an attribute from an existing stack :param parameter: The output parameter which should be retrieved :param as_reference: Is the parameter a reference (Default) or a string :return: Value of parameter to retrieve """ ...
[ "def", "get_att", "(", "self", ",", "parameter", ",", "as_reference", "=", "True", ")", ":", "if", "as_reference", ":", "return", "troposphere", ".", "GetAtt", "(", "self", ".", "__custom_stack_obj", ",", "troposphere", ".", "Ref", "(", "parameter", ")", "...
Retrieves an attribute from an existing stack :param parameter: The output parameter which should be retrieved :param as_reference: Is the parameter a reference (Default) or a string :return: Value of parameter to retrieve
[ "Retrieves", "an", "attribute", "from", "an", "existing", "stack", ":", "param", "parameter", ":", "The", "output", "parameter", "which", "should", "be", "retrieved", ":", "param", "as_reference", ":", "Is", "the", "parameter", "a", "reference", "(", "Default"...
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/kumo_util.py#L64-L79
glomex/gcdt
gcdt/event_source/s3.py
S3EventSource._get_notification_spec
def _get_notification_spec(self, lambda_arn): lambda_name = base.get_lambda_name(lambda_arn) notification_spec = { 'Id': self._make_notification_id(lambda_name), 'Events': [e for e in self._config['events']], 'LambdaFunctionArn': lambda_arn } # Add S3...
python
def _get_notification_spec(self, lambda_arn): lambda_name = base.get_lambda_name(lambda_arn) notification_spec = { 'Id': self._make_notification_id(lambda_name), 'Events': [e for e in self._config['events']], 'LambdaFunctionArn': lambda_arn } # Add S3...
[ "def", "_get_notification_spec", "(", "self", ",", "lambda_arn", ")", ":", "lambda_name", "=", "base", ".", "get_lambda_name", "(", "lambda_arn", ")", "notification_spec", "=", "{", "'Id'", ":", "self", ".", "_make_notification_id", "(", "lambda_name", ")", ",",...
if 'key_filters' in self._config: filters_spec = {'Key': {'FilterRules': [] } } # I do not think this is a useful structure: for filter in self._config['key_filters']: if 'type' in filter and 'value' in filter and filter['type'] in ('prefix', 'suffix'): ...
[ "if", "key_filters", "in", "self", ".", "_config", ":", "filters_spec", "=", "{", "Key", ":", "{", "FilterRules", ":", "[]", "}", "}", "#", "I", "do", "not", "think", "this", "is", "a", "useful", "structure", ":", "for", "filter", "in", "self", ".", ...
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/event_source/s3.py#L51-L80
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.convert_representation
def convert_representation(self, i): """ Return the proper representation for the given integer """ if self.number_representation == 'unsigned': return i elif self.number_representation == 'signed': if i & (1 << self.interpreter._bit_width - 1): ...
python
def convert_representation(self, i): """ Return the proper representation for the given integer """ if self.number_representation == 'unsigned': return i elif self.number_representation == 'signed': if i & (1 << self.interpreter._bit_width - 1): ...
[ "def", "convert_representation", "(", "self", ",", "i", ")", ":", "if", "self", ".", "number_representation", "==", "'unsigned'", ":", "return", "i", "elif", "self", ".", "number_representation", "==", "'signed'", ":", "if", "i", "&", "(", "1", "<<", "self...
Return the proper representation for the given integer
[ "Return", "the", "proper", "representation", "for", "the", "given", "integer" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L40-L52
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.magic_generate_random
def magic_generate_random(self, line): """ Set the generate random flag, unset registers and memory will return a random value. Usage: Call the magic by itself or with `true` to have registers and memory return a random value if they are unset and read from, much like how real h...
python
def magic_generate_random(self, line): """ Set the generate random flag, unset registers and memory will return a random value. Usage: Call the magic by itself or with `true` to have registers and memory return a random value if they are unset and read from, much like how real h...
[ "def", "magic_generate_random", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "not", "line", "or", "line", "==", "'true'", ":", "self", ".", "interpreter", ".", "generate_random", "=", ...
Set the generate random flag, unset registers and memory will return a random value. Usage: Call the magic by itself or with `true` to have registers and memory return a random value if they are unset and read from, much like how real hardware would work. Defaults to False, or to not ge...
[ "Set", "the", "generate", "random", "flag", "unset", "registers", "and", "memory", "will", "return", "a", "random", "value", "." ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L54-L81
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.magic_postpone_execution
def magic_postpone_execution(self, line): """ Postpone execution of instructions until explicitly run Usage: Call this magic with `true` or nothing to postpone execution, or call with `false` to execute each instruction when evaluated. This defaults to True. Not...
python
def magic_postpone_execution(self, line): """ Postpone execution of instructions until explicitly run Usage: Call this magic with `true` or nothing to postpone execution, or call with `false` to execute each instruction when evaluated. This defaults to True. Not...
[ "def", "magic_postpone_execution", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "not", "line", "or", "line", "==", "'true'", ":", "self", ".", "interpreter", ".", "postpone_execution", "...
Postpone execution of instructions until explicitly run Usage: Call this magic with `true` or nothing to postpone execution, or call with `false` to execute each instruction when evaluated. This defaults to True. Note that each cell is executed only executed after all lines in ...
[ "Postpone", "execution", "of", "instructions", "until", "explicitly", "run" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L83-L113
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.magic_register
def magic_register(self, line): """ Print out the current value of a register Usage: Pass in the register, or a list of registers separated by spaces A list of registeres can be entered by separating them by a hyphen `%reg R1` or `%reg R0 R5 R6` ...
python
def magic_register(self, line): """ Print out the current value of a register Usage: Pass in the register, or a list of registers separated by spaces A list of registeres can be entered by separating them by a hyphen `%reg R1` or `%reg R0 R5 R6` ...
[ "def", "magic_register", "(", "self", ",", "line", ")", ":", "message", "=", "\"\"", "for", "reg", "in", "[", "i", ".", "strip", "(", ")", "for", "i", "in", "line", ".", "replace", "(", "','", ",", "''", ")", ".", "split", "(", ")", "]", ":", ...
Print out the current value of a register Usage: Pass in the register, or a list of registers separated by spaces A list of registeres can be entered by separating them by a hyphen `%reg R1` or `%reg R0 R5 R6` or `%reg R8-R12`
[ "Print", "out", "the", "current", "value", "of", "a", "register" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L148-L181
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.magic_memory
def magic_memory(self, line): """ Print out the current value of memory Usage: Pass in the byte of memory to read, separated by spaced A list of memory contents can be entered by separating them by a hyphen `%mem 4 5` or `%mem 8-12` """ #...
python
def magic_memory(self, line): """ Print out the current value of memory Usage: Pass in the byte of memory to read, separated by spaced A list of memory contents can be entered by separating them by a hyphen `%mem 4 5` or `%mem 8-12` """ #...
[ "def", "magic_memory", "(", "self", ",", "line", ")", ":", "# TODO add support for directives", "message", "=", "\"\"", "for", "address", "in", "[", "i", ".", "strip", "(", ")", "for", "i", "in", "line", ".", "replace", "(", "','", ",", "''", ")", ".",...
Print out the current value of memory Usage: Pass in the byte of memory to read, separated by spaced A list of memory contents can be entered by separating them by a hyphen `%mem 4 5` or `%mem 8-12`
[ "Print", "out", "the", "current", "value", "of", "memory" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L183-L215
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.magic_run
def magic_run(self, line): """ Run the current program Usage: Call with a numbe rto run that many steps, or call with no arguments to run to the end of the current program `%run` or `%run 1` """ i = float('inf') if line.strip(): ...
python
def magic_run(self, line): """ Run the current program Usage: Call with a numbe rto run that many steps, or call with no arguments to run to the end of the current program `%run` or `%run 1` """ i = float('inf') if line.strip(): ...
[ "def", "magic_run", "(", "self", ",", "line", ")", ":", "i", "=", "float", "(", "'inf'", ")", "if", "line", ".", "strip", "(", ")", ":", "i", "=", "int", "(", "line", ")", "try", ":", "with", "warnings", ".", "catch_warnings", "(", "record", "=",...
Run the current program Usage: Call with a numbe rto run that many steps, or call with no arguments to run to the end of the current program `%run` or `%run 1`
[ "Run", "the", "current", "program" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L217-L254
DeepHorizons/iarm
iarm_kernel/iarmkernel.py
ArmKernel.magic_help
def magic_help(self, line): """ Print out the help for magics Usage: Call help with no arguments to list all magics, or call it with a magic to print out it's help info. `%help` or `%help run """ line = line.strip() if not line: ...
python
def magic_help(self, line): """ Print out the help for magics Usage: Call help with no arguments to list all magics, or call it with a magic to print out it's help info. `%help` or `%help run """ line = line.strip() if not line: ...
[ "def", "magic_help", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "not", "line", ":", "for", "magic", "in", "self", ".", "magics", ":", "stream_content", "=", "{", "'name'", ":", "'stdout'", ",", "'text'", ...
Print out the help for magics Usage: Call help with no arguments to list all magics, or call it with a magic to print out it's help info. `%help` or `%help run
[ "Print", "out", "the", "help", "for", "magics" ]
train
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm_kernel/iarmkernel.py#L256-L283
glomex/gcdt
gcdt/yugen_core.py
export_to_swagger
def export_to_swagger(awsclient, api_name, stage_name, api_description, lambdas, custom_hostname=False, custom_base_path=False): """Export the API design as swagger file. :param api_name: :param stage_name: :param api_description: :param lambdas: :param custom_hos...
python
def export_to_swagger(awsclient, api_name, stage_name, api_description, lambdas, custom_hostname=False, custom_base_path=False): """Export the API design as swagger file. :param api_name: :param stage_name: :param api_description: :param lambdas: :param custom_hos...
[ "def", "export_to_swagger", "(", "awsclient", ",", "api_name", ",", "stage_name", ",", "api_description", ",", "lambdas", ",", "custom_hostname", "=", "False", ",", "custom_base_path", "=", "False", ")", ":", "print", "(", "'Exporting to swagger...'", ")", "api", ...
Export the API design as swagger file. :param api_name: :param stage_name: :param api_description: :param lambdas: :param custom_hostname: :param custom_base_path:
[ "Export", "the", "API", "design", "as", "swagger", "file", ".", ":", "param", "api_name", ":", ":", "param", "stage_name", ":", ":", "param", "api_description", ":", ":", "param", "lambdas", ":", ":", "param", "custom_hostname", ":", ":", "param", "custom_...
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L21-L54
glomex/gcdt
gcdt/yugen_core.py
list_apis
def list_apis(awsclient): """List APIs in account.""" client_api = awsclient.get_client('apigateway') apis = client_api.get_rest_apis()['items'] for api in apis: print(json2table(api))
python
def list_apis(awsclient): """List APIs in account.""" client_api = awsclient.get_client('apigateway') apis = client_api.get_rest_apis()['items'] for api in apis: print(json2table(api))
[ "def", "list_apis", "(", "awsclient", ")", ":", "client_api", "=", "awsclient", ".", "get_client", "(", "'apigateway'", ")", "apis", "=", "client_api", ".", "get_rest_apis", "(", ")", "[", "'items'", "]", "for", "api", "in", "apis", ":", "print", "(", "j...
List APIs in account.
[ "List", "APIs", "in", "account", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L57-L64
glomex/gcdt
gcdt/yugen_core.py
deploy_api
def deploy_api(awsclient, api_name, api_description, stage_name, api_key, lambdas, cache_cluster_enabled, cache_cluster_size, method_settings=None): """Deploy API Gateway to AWS cloud. :param awsclient: :param api_name: :param api_description: :param stage_name: :param api_key: ...
python
def deploy_api(awsclient, api_name, api_description, stage_name, api_key, lambdas, cache_cluster_enabled, cache_cluster_size, method_settings=None): """Deploy API Gateway to AWS cloud. :param awsclient: :param api_name: :param api_description: :param stage_name: :param api_key: ...
[ "def", "deploy_api", "(", "awsclient", ",", "api_name", ",", "api_description", ",", "stage_name", ",", "api_key", ",", "lambdas", ",", "cache_cluster_enabled", ",", "cache_cluster_size", ",", "method_settings", "=", "None", ")", ":", "if", "not", "_api_exists", ...
Deploy API Gateway to AWS cloud. :param awsclient: :param api_name: :param api_description: :param stage_name: :param api_key: :param lambdas: :param cache_cluster_enabled: :param cache_cluster_size: :param method_settings:
[ "Deploy", "API", "Gateway", "to", "AWS", "cloud", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L67-L113
glomex/gcdt
gcdt/yugen_core.py
delete_api
def delete_api(awsclient, api_name): """Delete the API. :param api_name: """ _sleep() client_api = awsclient.get_client('apigateway') print('deleting api: %s' % api_name) api = _api_by_name(awsclient, api_name) if api is not None: print(json2table(api)) response = cli...
python
def delete_api(awsclient, api_name): """Delete the API. :param api_name: """ _sleep() client_api = awsclient.get_client('apigateway') print('deleting api: %s' % api_name) api = _api_by_name(awsclient, api_name) if api is not None: print(json2table(api)) response = cli...
[ "def", "delete_api", "(", "awsclient", ",", "api_name", ")", ":", "_sleep", "(", ")", "client_api", "=", "awsclient", ".", "get_client", "(", "'apigateway'", ")", "print", "(", "'deleting api: %s'", "%", "api_name", ")", "api", "=", "_api_by_name", "(", "aws...
Delete the API. :param api_name:
[ "Delete", "the", "API", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L116-L136
glomex/gcdt
gcdt/yugen_core.py
create_api_key
def create_api_key(awsclient, api_name, api_key_name): """Create a new API key as reference for api.conf. :param api_name: :param api_key_name: :return: api_key """ _sleep() client_api = awsclient.get_client('apigateway') print('create api key: %s' % api_key_name) response = client...
python
def create_api_key(awsclient, api_name, api_key_name): """Create a new API key as reference for api.conf. :param api_name: :param api_key_name: :return: api_key """ _sleep() client_api = awsclient.get_client('apigateway') print('create api key: %s' % api_key_name) response = client...
[ "def", "create_api_key", "(", "awsclient", ",", "api_name", ",", "api_key_name", ")", ":", "_sleep", "(", ")", "client_api", "=", "awsclient", ".", "get_client", "(", "'apigateway'", ")", "print", "(", "'create api key: %s'", "%", "api_key_name", ")", "response"...
Create a new API key as reference for api.conf. :param api_name: :param api_key_name: :return: api_key
[ "Create", "a", "new", "API", "key", "as", "reference", "for", "api", ".", "conf", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L139-L159
glomex/gcdt
gcdt/yugen_core.py
delete_api_key
def delete_api_key(awsclient, api_key): """Remove API key. :param api_key: """ _sleep() client_api = awsclient.get_client('apigateway') print('delete api key: %s' % api_key) response = client_api.delete_api_key( apiKey=api_key ) print(json2table(response))
python
def delete_api_key(awsclient, api_key): """Remove API key. :param api_key: """ _sleep() client_api = awsclient.get_client('apigateway') print('delete api key: %s' % api_key) response = client_api.delete_api_key( apiKey=api_key ) print(json2table(response))
[ "def", "delete_api_key", "(", "awsclient", ",", "api_key", ")", ":", "_sleep", "(", ")", "client_api", "=", "awsclient", ".", "get_client", "(", "'apigateway'", ")", "print", "(", "'delete api key: %s'", "%", "api_key", ")", "response", "=", "client_api", ".",...
Remove API key. :param api_key:
[ "Remove", "API", "key", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L162-L175
glomex/gcdt
gcdt/yugen_core.py
list_api_keys
def list_api_keys(awsclient): """Print the defined API keys. """ _sleep() client_api = awsclient.get_client('apigateway') print('listing api keys') response = client_api.get_api_keys()['items'] for item in response: print(json2table(item))
python
def list_api_keys(awsclient): """Print the defined API keys. """ _sleep() client_api = awsclient.get_client('apigateway') print('listing api keys') response = client_api.get_api_keys()['items'] for item in response: print(json2table(item))
[ "def", "list_api_keys", "(", "awsclient", ")", ":", "_sleep", "(", ")", "client_api", "=", "awsclient", ".", "get_client", "(", "'apigateway'", ")", "print", "(", "'listing api keys'", ")", "response", "=", "client_api", ".", "get_api_keys", "(", ")", "[", "...
Print the defined API keys.
[ "Print", "the", "defined", "API", "keys", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L178-L188
glomex/gcdt
gcdt/yugen_core.py
deploy_custom_domain
def deploy_custom_domain(awsclient, api_name, api_target_stage, api_base_path, domain_name, route_53_record, cert_name, cert_arn, hosted_zone_id, ensure_cname): """Add custom domain to your API. :param api_name: :param api_target_stage: :param api_base_...
python
def deploy_custom_domain(awsclient, api_name, api_target_stage, api_base_path, domain_name, route_53_record, cert_name, cert_arn, hosted_zone_id, ensure_cname): """Add custom domain to your API. :param api_name: :param api_target_stage: :param api_base_...
[ "def", "deploy_custom_domain", "(", "awsclient", ",", "api_name", ",", "api_target_stage", ",", "api_base_path", ",", "domain_name", ",", "route_53_record", ",", "cert_name", ",", "cert_arn", ",", "hosted_zone_id", ",", "ensure_cname", ")", ":", "api_base_path", "="...
Add custom domain to your API. :param api_name: :param api_target_stage: :param api_base_path: :param domain_name: :param route_53_record: :param ssl_cert: :param cert_name: :param cert_arn: :param hosted_zone_id: :return: exit_code
[ "Add", "custom", "domain", "to", "your", "API", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L191-L249
glomex/gcdt
gcdt/yugen_core.py
get_lambdas
def get_lambdas(awsclient, config, add_arn=False): """Get the list of lambda functions. :param config: :param add_arn: :return: list containing lambda entries """ if 'lambda' in config: client_lambda = awsclient.get_client('lambda') lambda_entries = config['lambda'].get('entries...
python
def get_lambdas(awsclient, config, add_arn=False): """Get the list of lambda functions. :param config: :param add_arn: :return: list containing lambda entries """ if 'lambda' in config: client_lambda = awsclient.get_client('lambda') lambda_entries = config['lambda'].get('entries...
[ "def", "get_lambdas", "(", "awsclient", ",", "config", ",", "add_arn", "=", "False", ")", ":", "if", "'lambda'", "in", "config", ":", "client_lambda", "=", "awsclient", ".", "get_client", "(", "'lambda'", ")", "lambda_entries", "=", "config", "[", "'lambda'"...
Get the list of lambda functions. :param config: :param add_arn: :return: list containing lambda entries
[ "Get", "the", "list", "of", "lambda", "functions", "." ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L252-L277
glomex/gcdt
gcdt/yugen_core.py
_update_stage
def _update_stage(awsclient, api_id, stage_name, method_settings): """Helper to apply method_settings to stage :param awsclient: :param api_id: :param stage_name: :param method_settings: :return: """ # settings docs in response: https://botocore.readthedocs.io/en/latest/reference/servic...
python
def _update_stage(awsclient, api_id, stage_name, method_settings): """Helper to apply method_settings to stage :param awsclient: :param api_id: :param stage_name: :param method_settings: :return: """ # settings docs in response: https://botocore.readthedocs.io/en/latest/reference/servic...
[ "def", "_update_stage", "(", "awsclient", ",", "api_id", ",", "stage_name", ",", "method_settings", ")", ":", "# settings docs in response: https://botocore.readthedocs.io/en/latest/reference/services/apigateway.html#APIGateway.Client.update_stage", "client_api", "=", "awsclient", "....
Helper to apply method_settings to stage :param awsclient: :param api_id: :param stage_name: :param method_settings: :return:
[ "Helper", "to", "apply", "method_settings", "to", "stage" ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L461-L479
glomex/gcdt
gcdt/yugen_core.py
_convert_method_settings_into_operations
def _convert_method_settings_into_operations(method_settings=None): """Helper to handle the conversion of method_settings to operations :param method_settings: :return: list of operations """ # operations docs here: https://tools.ietf.org/html/rfc6902#section-4 operations = [] if method_set...
python
def _convert_method_settings_into_operations(method_settings=None): """Helper to handle the conversion of method_settings to operations :param method_settings: :return: list of operations """ # operations docs here: https://tools.ietf.org/html/rfc6902#section-4 operations = [] if method_set...
[ "def", "_convert_method_settings_into_operations", "(", "method_settings", "=", "None", ")", ":", "# operations docs here: https://tools.ietf.org/html/rfc6902#section-4", "operations", "=", "[", "]", "if", "method_settings", ":", "for", "method", "in", "method_settings", ".",...
Helper to handle the conversion of method_settings to operations :param method_settings: :return: list of operations
[ "Helper", "to", "handle", "the", "conversion", "of", "method_settings", "to", "operations" ]
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/yugen_core.py#L503-L524
lincolnloop/salmon
salmon/core/runner.py
generate_settings
def generate_settings(): """ This command is run when ``default_path`` doesn't exist, or ``init`` is run and returns a string representing the default data to put into their settings file. """ conf_file = os.path.join(os.path.dirname(base_settings.__file__), 'example...
python
def generate_settings(): """ This command is run when ``default_path`` doesn't exist, or ``init`` is run and returns a string representing the default data to put into their settings file. """ conf_file = os.path.join(os.path.dirname(base_settings.__file__), 'example...
[ "def", "generate_settings", "(", ")", ":", "conf_file", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "base_settings", ".", "__file__", ")", ",", "'example'", ",", "'conf.py'", ")", "conf_template", "=", "open", "(", ...
This command is run when ``default_path`` doesn't exist, or ``init`` is run and returns a string representing the default data to put into their settings file.
[ "This", "command", "is", "run", "when", "default_path", "doesn", "t", "exist", "or", "init", "is", "run", "and", "returns", "a", "string", "representing", "the", "default", "data", "to", "put", "into", "their", "settings", "file", "." ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/core/runner.py#L11-L28
lincolnloop/salmon
salmon/core/runner.py
configure_app
def configure_app(**kwargs): """Builds up the settings using the same method as logan""" sys_args = sys.argv args, command, command_args = parse_args(sys_args[1:]) parser = OptionParser() parser.add_option('--config', metavar='CONFIG') (options, logan_args) = parser.parse_args(args) config_p...
python
def configure_app(**kwargs): """Builds up the settings using the same method as logan""" sys_args = sys.argv args, command, command_args = parse_args(sys_args[1:]) parser = OptionParser() parser.add_option('--config', metavar='CONFIG') (options, logan_args) = parser.parse_args(args) config_p...
[ "def", "configure_app", "(", "*", "*", "kwargs", ")", ":", "sys_args", "=", "sys", ".", "argv", "args", ",", "command", ",", "command_args", "=", "parse_args", "(", "sys_args", "[", "1", ":", "]", ")", "parser", "=", "OptionParser", "(", ")", "parser",...
Builds up the settings using the same method as logan
[ "Builds", "up", "the", "settings", "using", "the", "same", "method", "as", "logan" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/core/runner.py#L42-L50
lincolnloop/salmon
salmon/metrics/models.py
Metric._reset_changes
def _reset_changes(self): """Stores current values for comparison later""" self._original = {} if self.last_updated is not None: self._original['last_updated'] = self.last_updated
python
def _reset_changes(self): """Stores current values for comparison later""" self._original = {} if self.last_updated is not None: self._original['last_updated'] = self.last_updated
[ "def", "_reset_changes", "(", "self", ")", ":", "self", ".", "_original", "=", "{", "}", "if", "self", ".", "last_updated", "is", "not", "None", ":", "self", ".", "_original", "[", "'last_updated'", "]", "=", "self", ".", "last_updated" ]
Stores current values for comparison later
[ "Stores", "current", "values", "for", "comparison", "later" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/models.py#L62-L66
lincolnloop/salmon
salmon/metrics/models.py
Metric.whisper_filename
def whisper_filename(self): """Build a file path to the Whisper database""" source_name = self.source_id and self.source.name or '' return get_valid_filename("{0}__{1}.wsp".format(source_name, self.name))
python
def whisper_filename(self): """Build a file path to the Whisper database""" source_name = self.source_id and self.source.name or '' return get_valid_filename("{0}__{1}.wsp".format(source_name, self.name))
[ "def", "whisper_filename", "(", "self", ")", ":", "source_name", "=", "self", ".", "source_id", "and", "self", ".", "source", ".", "name", "or", "''", "return", "get_valid_filename", "(", "\"{0}__{1}.wsp\"", ".", "format", "(", "source_name", ",", "self", "....
Build a file path to the Whisper database
[ "Build", "a", "file", "path", "to", "the", "Whisper", "database" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/models.py#L69-L73
lincolnloop/salmon
salmon/metrics/models.py
Metric.get_value_display
def get_value_display(self): """Human friendly value output""" if self.display_as == 'percentage': return '{0}%'.format(self.latest_value) if self.display_as == 'boolean': return bool(self.latest_value) if self.display_as == 'byte': return defaultfilte...
python
def get_value_display(self): """Human friendly value output""" if self.display_as == 'percentage': return '{0}%'.format(self.latest_value) if self.display_as == 'boolean': return bool(self.latest_value) if self.display_as == 'byte': return defaultfilte...
[ "def", "get_value_display", "(", "self", ")", ":", "if", "self", ".", "display_as", "==", "'percentage'", ":", "return", "'{0}%'", ".", "format", "(", "self", ".", "latest_value", ")", "if", "self", ".", "display_as", "==", "'boolean'", ":", "return", "boo...
Human friendly value output
[ "Human", "friendly", "value", "output" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/models.py#L95-L105
lincolnloop/salmon
salmon/metrics/models.py
Metric.time_between_updates
def time_between_updates(self): """Time between current `last_updated` and previous `last_updated`""" if 'last_updated' not in self._original: return 0 last_update = self._original['last_updated'] this_update = self.last_updated return this_update - last_update
python
def time_between_updates(self): """Time between current `last_updated` and previous `last_updated`""" if 'last_updated' not in self._original: return 0 last_update = self._original['last_updated'] this_update = self.last_updated return this_update - last_update
[ "def", "time_between_updates", "(", "self", ")", ":", "if", "'last_updated'", "not", "in", "self", ".", "_original", ":", "return", "0", "last_update", "=", "self", ".", "_original", "[", "'last_updated'", "]", "this_update", "=", "self", ".", "last_updated", ...
Time between current `last_updated` and previous `last_updated`
[ "Time", "between", "current", "last_updated", "and", "previous", "last_updated" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/models.py#L107-L113
lincolnloop/salmon
salmon/metrics/models.py
Metric.do_transform
def do_transform(self): """Apply the transformation (if it exists) to the latest_value""" if not self.transform: return try: self.latest_value = utils.Transform( expr=self.transform, value=self.latest_value, timedelta=self.time_between_upda...
python
def do_transform(self): """Apply the transformation (if it exists) to the latest_value""" if not self.transform: return try: self.latest_value = utils.Transform( expr=self.transform, value=self.latest_value, timedelta=self.time_between_upda...
[ "def", "do_transform", "(", "self", ")", ":", "if", "not", "self", ".", "transform", ":", "return", "try", ":", "self", ".", "latest_value", "=", "utils", ".", "Transform", "(", "expr", "=", "self", ".", "transform", ",", "value", "=", "self", ".", "...
Apply the transformation (if it exists) to the latest_value
[ "Apply", "the", "transformation", "(", "if", "it", "exists", ")", "to", "the", "latest_value" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/models.py#L115-L126
lincolnloop/salmon
salmon/metrics/models.py
Metric.do_counter_conversion
def do_counter_conversion(self): """Update latest value to the diff between it and the previous value""" if self.is_counter: if self._previous_counter_value is None: prev_value = self.latest_value else: prev_value = self._previous_counter_value ...
python
def do_counter_conversion(self): """Update latest value to the diff between it and the previous value""" if self.is_counter: if self._previous_counter_value is None: prev_value = self.latest_value else: prev_value = self._previous_counter_value ...
[ "def", "do_counter_conversion", "(", "self", ")", ":", "if", "self", ".", "is_counter", ":", "if", "self", ".", "_previous_counter_value", "is", "None", ":", "prev_value", "=", "self", ".", "latest_value", "else", ":", "prev_value", "=", "self", ".", "_previ...
Update latest value to the diff between it and the previous value
[ "Update", "latest", "value", "to", "the", "diff", "between", "it", "and", "the", "previous", "value" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/models.py#L128-L136
ninapavlich/django-imagekit-cropper
imagekit_cropper/registry.py
InstanceSourceGroupRegistry.source_group_receiver
def source_group_receiver(self, sender, source, signal, **kwargs): """ Relay source group signals to the appropriate spec strategy. """ from imagekit.cachefiles import ImageCacheFile source_group = sender # Ignore signals from unregistered groups. if source_gro...
python
def source_group_receiver(self, sender, source, signal, **kwargs): """ Relay source group signals to the appropriate spec strategy. """ from imagekit.cachefiles import ImageCacheFile source_group = sender # Ignore signals from unregistered groups. if source_gro...
[ "def", "source_group_receiver", "(", "self", ",", "sender", ",", "source", ",", "signal", ",", "*", "*", "kwargs", ")", ":", "from", "imagekit", ".", "cachefiles", "import", "ImageCacheFile", "source_group", "=", "sender", "# Ignore signals from unregistered groups....
Relay source group signals to the appropriate spec strategy.
[ "Relay", "source", "group", "signals", "to", "the", "appropriate", "spec", "strategy", "." ]
train
https://github.com/ninapavlich/django-imagekit-cropper/blob/c1c2dc5c3c4724492052e5d244e9de1cc362dbcc/imagekit_cropper/registry.py#L46-L68
lincolnloop/salmon
salmon/metrics/utils.py
Transform.replace_variable
def replace_variable(self, variable): """Substitute variables with numeric values""" if variable == 'x': return self.value if variable == 't': return self.timedelta raise ValueError("Invalid variable %s", variable)
python
def replace_variable(self, variable): """Substitute variables with numeric values""" if variable == 'x': return self.value if variable == 't': return self.timedelta raise ValueError("Invalid variable %s", variable)
[ "def", "replace_variable", "(", "self", ",", "variable", ")", ":", "if", "variable", "==", "'x'", ":", "return", "self", ".", "value", "if", "variable", "==", "'t'", ":", "return", "self", ".", "timedelta", "raise", "ValueError", "(", "\"Invalid variable %s\...
Substitute variables with numeric values
[ "Substitute", "variables", "with", "numeric", "values" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/utils.py#L17-L23
lincolnloop/salmon
salmon/metrics/utils.py
Transform.result
def result(self): """Evaluate expression and return result""" # Module(body=[Expr(value=...)]) return self.eval_(ast.parse(self.expr).body[0].value)
python
def result(self): """Evaluate expression and return result""" # Module(body=[Expr(value=...)]) return self.eval_(ast.parse(self.expr).body[0].value)
[ "def", "result", "(", "self", ")", ":", "# Module(body=[Expr(value=...)])", "return", "self", ".", "eval_", "(", "ast", ".", "parse", "(", "self", ".", "expr", ")", ".", "body", "[", "0", "]", ".", "value", ")" ]
Evaluate expression and return result
[ "Evaluate", "expression", "and", "return", "result" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/utils.py#L25-L28
acrazing/dbapi
dbapi/People.py
People.get_people
def get_people(self, user_alias=None): """ 获取用户信息 :param user_alias: 用户ID :return: """ user_alias = user_alias or self.api.user_alias content = self.api.req(API_PEOPLE_HOME % user_alias).content xml = self.api.to_xml(re.sub(b'<br />', b'\n', cont...
python
def get_people(self, user_alias=None): """ 获取用户信息 :param user_alias: 用户ID :return: """ user_alias = user_alias or self.api.user_alias content = self.api.req(API_PEOPLE_HOME % user_alias).content xml = self.api.to_xml(re.sub(b'<br />', b'\n', cont...
[ "def", "get_people", "(", "self", ",", "user_alias", "=", "None", ")", ":", "user_alias", "=", "user_alias", "or", "self", ".", "api", ".", "user_alias", "content", "=", "self", ".", "api", ".", "req", "(", "API_PEOPLE_HOME", "%", "user_alias", ")", ".",...
获取用户信息 :param user_alias: 用户ID :return:
[ "获取用户信息", ":", "param", "user_alias", ":", "用户ID", ":", "return", ":" ]
train
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/People.py#L16-L59
matthiask/django-authlib
authlib/views.py
email_login
def email_login(request, *, email, **kwargs): """ Given a request, an email and optionally some additional data, ensure that a user with the email address exists, and authenticate & login them right away if the user is active. Returns a tuple consisting of ``(user, created)`` upon success or ``(Non...
python
def email_login(request, *, email, **kwargs): """ Given a request, an email and optionally some additional data, ensure that a user with the email address exists, and authenticate & login them right away if the user is active. Returns a tuple consisting of ``(user, created)`` upon success or ``(Non...
[ "def", "email_login", "(", "request", ",", "*", ",", "email", ",", "*", "*", "kwargs", ")", ":", "_u", ",", "created", "=", "auth", ".", "get_user_model", "(", ")", ".", "_default_manager", ".", "get_or_create", "(", "email", "=", "email", ")", "user",...
Given a request, an email and optionally some additional data, ensure that a user with the email address exists, and authenticate & login them right away if the user is active. Returns a tuple consisting of ``(user, created)`` upon success or ``(None, None)`` when authentication fails.
[ "Given", "a", "request", "an", "email", "and", "optionally", "some", "additional", "data", "ensure", "that", "a", "user", "with", "the", "email", "address", "exists", "and", "authenticate", "&", "login", "them", "right", "away", "if", "the", "user", "is", ...
train
https://github.com/matthiask/django-authlib/blob/a142da7e27fe9d30f34a84b12f24f686f9d2c8e1/authlib/views.py#L54-L68
lincolnloop/salmon
salmon/metrics/views.py
dashboard
def dashboard(request): """Shows the latest results for each source""" sources = (models.Source.objects.all().prefetch_related('metric_set') .order_by('name')) metrics = SortedDict([(src, src.metric_set.all()) for src in sources]) no_source_metrics = models.Metr...
python
def dashboard(request): """Shows the latest results for each source""" sources = (models.Source.objects.all().prefetch_related('metric_set') .order_by('name')) metrics = SortedDict([(src, src.metric_set.all()) for src in sources]) no_source_metrics = models.Metr...
[ "def", "dashboard", "(", "request", ")", ":", "sources", "=", "(", "models", ".", "Source", ".", "objects", ".", "all", "(", ")", ".", "prefetch_related", "(", "'metric_set'", ")", ".", "order_by", "(", "'name'", ")", ")", "metrics", "=", "SortedDict", ...
Shows the latest results for each source
[ "Shows", "the", "latest", "results", "for", "each", "source" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/metrics/views.py#L32-L48
lincolnloop/salmon
salmon/core/graph.py
WhisperDatabase._create
def _create(self): """Create the Whisper file on disk""" if not os.path.exists(settings.SALMON_WHISPER_DB_PATH): os.makedirs(settings.SALMON_WHISPER_DB_PATH) archives = [whisper.parseRetentionDef(retentionDef) for retentionDef in settings.ARCHIVES.split(",")] ...
python
def _create(self): """Create the Whisper file on disk""" if not os.path.exists(settings.SALMON_WHISPER_DB_PATH): os.makedirs(settings.SALMON_WHISPER_DB_PATH) archives = [whisper.parseRetentionDef(retentionDef) for retentionDef in settings.ARCHIVES.split(",")] ...
[ "def", "_create", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "settings", ".", "SALMON_WHISPER_DB_PATH", ")", ":", "os", ".", "makedirs", "(", "settings", ".", "SALMON_WHISPER_DB_PATH", ")", "archives", "=", "[", "whisper", ...
Create the Whisper file on disk
[ "Create", "the", "Whisper", "file", "on", "disk" ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/core/graph.py#L18-L26
lincolnloop/salmon
salmon/core/graph.py
WhisperDatabase._update
def _update(self, datapoints): """ This method store in the datapoints in the current database. :datapoints: is a list of tupple with the epoch timestamp and value [(1368977629,10)] """ if len(datapoints) == 1: timestamp, value = datapoints[0] ...
python
def _update(self, datapoints): """ This method store in the datapoints in the current database. :datapoints: is a list of tupple with the epoch timestamp and value [(1368977629,10)] """ if len(datapoints) == 1: timestamp, value = datapoints[0] ...
[ "def", "_update", "(", "self", ",", "datapoints", ")", ":", "if", "len", "(", "datapoints", ")", "==", "1", ":", "timestamp", ",", "value", "=", "datapoints", "[", "0", "]", "whisper", ".", "update", "(", "self", ".", "path", ",", "value", ",", "ti...
This method store in the datapoints in the current database. :datapoints: is a list of tupple with the epoch timestamp and value [(1368977629,10)]
[ "This", "method", "store", "in", "the", "datapoints", "in", "the", "current", "database", "." ]
train
https://github.com/lincolnloop/salmon/blob/62a965ad9716707ea1db4afb5d9646766f29b64b/salmon/core/graph.py#L31-L42