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
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.follow
def follow(self, author): ''' Follows the given account ''' try: self.steem_instance().commit.follow(author, ['blog'], self.mainaccount) except Exception as e: self.msg.error_message(e) return False else: return Tru...
python
def follow(self, author): ''' Follows the given account ''' try: self.steem_instance().commit.follow(author, ['blog'], self.mainaccount) except Exception as e: self.msg.error_message(e) return False else: return Tru...
[ "def", "follow", "(", "self", ",", "author", ")", ":", "try", ":", "self", ".", "steem_instance", "(", ")", ".", "commit", ".", "follow", "(", "author", ",", "[", "'blog'", "]", ",", "self", ".", "mainaccount", ")", "except", "Exception", "as", "e", ...
Follows the given account
[ "Follows", "the", "given", "account" ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L402-L412
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.following
def following(self, account=None, limit=100): ''' Gets a list of all the followers of a given account. If no account is given the followers of the mainaccount are returned. ''' if not account: account = self.mainaccount followingnames = [] try:...
python
def following(self, account=None, limit=100): ''' Gets a list of all the followers of a given account. If no account is given the followers of the mainaccount are returned. ''' if not account: account = self.mainaccount followingnames = [] try:...
[ "def", "following", "(", "self", ",", "account", "=", "None", ",", "limit", "=", "100", ")", ":", "if", "not", "account", ":", "account", "=", "self", ".", "mainaccount", "followingnames", "=", "[", "]", "try", ":", "self", ".", "followed", "=", "sel...
Gets a list of all the followers of a given account. If no account is given the followers of the mainaccount are returned.
[ "Gets", "a", "list", "of", "all", "the", "followers", "of", "a", "given", "account", ".", "If", "no", "account", "is", "given", "the", "followers", "of", "the", "mainaccount", "are", "returned", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L428-L446
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.recent_post
def recent_post(self, author=None, daysback=0, flag=0): ''' Returns the most recent post from the account given. If the days back is greater than zero then the most recent post is returned for that day. For instance if daysback is set to 2 then it will be the most recent post fro...
python
def recent_post(self, author=None, daysback=0, flag=0): ''' Returns the most recent post from the account given. If the days back is greater than zero then the most recent post is returned for that day. For instance if daysback is set to 2 then it will be the most recent post fro...
[ "def", "recent_post", "(", "self", ",", "author", "=", "None", ",", "daysback", "=", "0", ",", "flag", "=", "0", ")", ":", "if", "not", "author", ":", "author", "=", "self", ".", "mainaccount", "for", "num_of_retries", "in", "range", "(", "default", ...
Returns the most recent post from the account given. If the days back is greater than zero then the most recent post is returned for that day. For instance if daysback is set to 2 then it will be the most recent post from 2 days ago (48 hours).
[ "Returns", "the", "most", "recent", "post", "from", "the", "account", "given", ".", "If", "the", "days", "back", "is", "greater", "than", "zero", "then", "the", "most", "recent", "post", "is", "returned", "for", "that", "day", ".", "For", "instance", "if...
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L449-L484
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.vote_history
def vote_history(self, permlink, author=None): ''' Returns the raw vote history of a given post from a given account ''' if author is None: author = self.mainaccount return self.steem_instance().get_active_votes(author, permlink)
python
def vote_history(self, permlink, author=None): ''' Returns the raw vote history of a given post from a given account ''' if author is None: author = self.mainaccount return self.steem_instance().get_active_votes(author, permlink)
[ "def", "vote_history", "(", "self", ",", "permlink", ",", "author", "=", "None", ")", ":", "if", "author", "is", "None", ":", "author", "=", "self", ".", "mainaccount", "return", "self", ".", "steem_instance", "(", ")", ".", "get_active_votes", "(", "aut...
Returns the raw vote history of a given post from a given account
[ "Returns", "the", "raw", "vote", "history", "of", "a", "given", "post", "from", "a", "given", "account" ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L487-L493
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.vote
def vote(self, identifier, weight=100.0): ''' Waits 5 seconds as that is the required amount of time between votes. ''' for num_of_retries in range(default.max_retry): try: self.steem_instance().vote(identifier, weight, self.mainaccount) ...
python
def vote(self, identifier, weight=100.0): ''' Waits 5 seconds as that is the required amount of time between votes. ''' for num_of_retries in range(default.max_retry): try: self.steem_instance().vote(identifier, weight, self.mainaccount) ...
[ "def", "vote", "(", "self", ",", "identifier", ",", "weight", "=", "100.0", ")", ":", "for", "num_of_retries", "in", "range", "(", "default", ".", "max_retry", ")", ":", "try", ":", "self", ".", "steem_instance", "(", ")", ".", "vote", "(", "identifier...
Waits 5 seconds as that is the required amount of time between votes.
[ "Waits", "5", "seconds", "as", "that", "is", "the", "required", "amount", "of", "time", "between", "votes", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L496-L517
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.resteem
def resteem(self, identifier): ''' Waits 20 seconds as that is the required amount of time between resteems ''' for num_of_retries in range(default.max_retry): try: self.steem_instance().resteem( identifier, self.mainaccount) ...
python
def resteem(self, identifier): ''' Waits 20 seconds as that is the required amount of time between resteems ''' for num_of_retries in range(default.max_retry): try: self.steem_instance().resteem( identifier, self.mainaccount) ...
[ "def", "resteem", "(", "self", ",", "identifier", ")", ":", "for", "num_of_retries", "in", "range", "(", "default", ".", "max_retry", ")", ":", "try", ":", "self", ".", "steem_instance", "(", ")", ".", "resteem", "(", "identifier", ",", "self", ".", "m...
Waits 20 seconds as that is the required amount of time between resteems
[ "Waits", "20", "seconds", "as", "that", "is", "the", "required", "amount", "of", "time", "between", "resteems" ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L520-L536
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.dex_ticker
def dex_ticker(self): ''' Simply grabs the ticker using the steem_instance method and adds it to a class variable. ''' self.dex = Dex(self.steem_instance()) self.ticker = self.dex.get_ticker(); return self.ticker
python
def dex_ticker(self): ''' Simply grabs the ticker using the steem_instance method and adds it to a class variable. ''' self.dex = Dex(self.steem_instance()) self.ticker = self.dex.get_ticker(); return self.ticker
[ "def", "dex_ticker", "(", "self", ")", ":", "self", ".", "dex", "=", "Dex", "(", "self", ".", "steem_instance", "(", ")", ")", "self", ".", "ticker", "=", "self", ".", "dex", ".", "get_ticker", "(", ")", "return", "self", ".", "ticker" ]
Simply grabs the ticker using the steem_instance method and adds it to a class variable.
[ "Simply", "grabs", "the", "ticker", "using", "the", "steem_instance", "method", "and", "adds", "it", "to", "a", "class", "variable", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L539-L546
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.steem_to_sbd
def steem_to_sbd(self, steemamt=0, price=0, account=None): ''' Uses the ticker to get the highest bid and moves the steem at that price. ''' if not account: account = self.mainaccount if self.check_balances(account): if steemamt == 0: steem...
python
def steem_to_sbd(self, steemamt=0, price=0, account=None): ''' Uses the ticker to get the highest bid and moves the steem at that price. ''' if not account: account = self.mainaccount if self.check_balances(account): if steemamt == 0: steem...
[ "def", "steem_to_sbd", "(", "self", ",", "steemamt", "=", "0", ",", "price", "=", "0", ",", "account", "=", "None", ")", ":", "if", "not", "account", ":", "account", "=", "self", ".", "mainaccount", "if", "self", ".", "check_balances", "(", "account", ...
Uses the ticker to get the highest bid and moves the steem at that price.
[ "Uses", "the", "ticker", "to", "get", "the", "highest", "bid", "and", "moves", "the", "steem", "at", "that", "price", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L549-L576
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.sbd_to_steem
def sbd_to_steem(self, sbd=0, price=0, account=None): ''' Uses the ticker to get the lowest ask and moves the sbd at that price. ''' if not account: account = self.mainaccount if self.check_balances(account): if sbd == 0: sbd = self.sbdbal ...
python
def sbd_to_steem(self, sbd=0, price=0, account=None): ''' Uses the ticker to get the lowest ask and moves the sbd at that price. ''' if not account: account = self.mainaccount if self.check_balances(account): if sbd == 0: sbd = self.sbdbal ...
[ "def", "sbd_to_steem", "(", "self", ",", "sbd", "=", "0", ",", "price", "=", "0", ",", "account", "=", "None", ")", ":", "if", "not", "account", ":", "account", "=", "self", ".", "mainaccount", "if", "self", ".", "check_balances", "(", "account", ")"...
Uses the ticker to get the lowest ask and moves the sbd at that price.
[ "Uses", "the", "ticker", "to", "get", "the", "lowest", "ask", "and", "moves", "the", "sbd", "at", "that", "price", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L579-L606
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.vote_witness
def vote_witness(self, witness, account=None): ''' Uses the steem_instance method to vote on a witness. ''' if not account: account = self.mainaccount try: self.steem_instance().approve_witness(witness, account=account) except Exception as e: ...
python
def vote_witness(self, witness, account=None): ''' Uses the steem_instance method to vote on a witness. ''' if not account: account = self.mainaccount try: self.steem_instance().approve_witness(witness, account=account) except Exception as e: ...
[ "def", "vote_witness", "(", "self", ",", "witness", ",", "account", "=", "None", ")", ":", "if", "not", "account", ":", "account", "=", "self", ".", "mainaccount", "try", ":", "self", ".", "steem_instance", "(", ")", ".", "approve_witness", "(", "witness...
Uses the steem_instance method to vote on a witness.
[ "Uses", "the", "steem_instance", "method", "to", "vote", "on", "a", "witness", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L609-L622
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.unvote_witness
def unvote_witness(self, witness, account=None): ''' Uses the steem_instance method to unvote a witness. ''' if not account: account = self.mainaccount try: self.steem_instance().disapprove_witness(witness, account=account) except Exception as e: ...
python
def unvote_witness(self, witness, account=None): ''' Uses the steem_instance method to unvote a witness. ''' if not account: account = self.mainaccount try: self.steem_instance().disapprove_witness(witness, account=account) except Exception as e: ...
[ "def", "unvote_witness", "(", "self", ",", "witness", ",", "account", "=", "None", ")", ":", "if", "not", "account", ":", "account", "=", "self", ".", "mainaccount", "try", ":", "self", ".", "steem_instance", "(", ")", ".", "disapprove_witness", "(", "wi...
Uses the steem_instance method to unvote a witness.
[ "Uses", "the", "steem_instance", "method", "to", "unvote", "a", "witness", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L625-L638
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.voted_me_witness
def voted_me_witness(self, account=None, limit=100): ''' Fetches all those a given account is following and sees if they have voted that account as witness. ''' if not account: account = self.mainaccount self.has_voted = [] self.has_not_voted = [] ...
python
def voted_me_witness(self, account=None, limit=100): ''' Fetches all those a given account is following and sees if they have voted that account as witness. ''' if not account: account = self.mainaccount self.has_voted = [] self.has_not_voted = [] ...
[ "def", "voted_me_witness", "(", "self", ",", "account", "=", "None", ",", "limit", "=", "100", ")", ":", "if", "not", "account", ":", "account", "=", "self", ".", "mainaccount", "self", ".", "has_voted", "=", "[", "]", "self", ".", "has_not_voted", "="...
Fetches all those a given account is following and sees if they have voted that account as witness.
[ "Fetches", "all", "those", "a", "given", "account", "is", "following", "and", "sees", "if", "they", "have", "voted", "that", "account", "as", "witness", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L641-L660
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.muted_me
def muted_me(self, account=None, limit=100): ''' Fetches all those a given account is following and sees if they have muted that account. ''' self.has_muted = [] if account is None: account = self.mainaccount following = self.following(account, limit) ...
python
def muted_me(self, account=None, limit=100): ''' Fetches all those a given account is following and sees if they have muted that account. ''' self.has_muted = [] if account is None: account = self.mainaccount following = self.following(account, limit) ...
[ "def", "muted_me", "(", "self", ",", "account", "=", "None", ",", "limit", "=", "100", ")", ":", "self", ".", "has_muted", "=", "[", "]", "if", "account", "is", "None", ":", "account", "=", "self", ".", "mainaccount", "following", "=", "self", ".", ...
Fetches all those a given account is following and sees if they have muted that account.
[ "Fetches", "all", "those", "a", "given", "account", "is", "following", "and", "sees", "if", "they", "have", "muted", "that", "account", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L663-L693
ArtoLabs/SimpleSteem
simplesteem/simplesteem.py
SimpleSteem.delegate
def delegate(self, to, steempower): ''' Delegates based on Steem Power rather than by vests. ''' self.global_props() vests = self.util.sp_to_vests(steempower) strvests = str(vests) strvests = strvests + " VESTS" try: self.steem_instance().commi...
python
def delegate(self, to, steempower): ''' Delegates based on Steem Power rather than by vests. ''' self.global_props() vests = self.util.sp_to_vests(steempower) strvests = str(vests) strvests = strvests + " VESTS" try: self.steem_instance().commi...
[ "def", "delegate", "(", "self", ",", "to", ",", "steempower", ")", ":", "self", ".", "global_props", "(", ")", "vests", "=", "self", ".", "util", ".", "sp_to_vests", "(", "steempower", ")", "strvests", "=", "str", "(", "vests", ")", "strvests", "=", ...
Delegates based on Steem Power rather than by vests.
[ "Delegates", "based", "on", "Steem", "Power", "rather", "than", "by", "vests", "." ]
train
https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/simplesteem.py#L696-L715
diffeo/rejester
rejester/run_multi_worker.py
start_logging
def start_logging(gconfig, logpath): '''Turn on logging and set up the global config. This expects the :mod:`yakonfig` global configuration to be unset, and establishes it. It starts the log system via the :mod:`dblogger` setup. In addition to :mod:`dblogger`'s defaults, if `logpath` is provided,...
python
def start_logging(gconfig, logpath): '''Turn on logging and set up the global config. This expects the :mod:`yakonfig` global configuration to be unset, and establishes it. It starts the log system via the :mod:`dblogger` setup. In addition to :mod:`dblogger`'s defaults, if `logpath` is provided,...
[ "def", "start_logging", "(", "gconfig", ",", "logpath", ")", ":", "yakonfig", ".", "set_default_config", "(", "[", "rejester", ",", "dblogger", "]", ",", "config", "=", "gconfig", ")", "if", "logpath", ":", "formatter", "=", "dblogger", ".", "FixedWidthForma...
Turn on logging and set up the global config. This expects the :mod:`yakonfig` global configuration to be unset, and establishes it. It starts the log system via the :mod:`dblogger` setup. In addition to :mod:`dblogger`'s defaults, if `logpath` is provided, a :class:`logging.handlers.RotatingFileHand...
[ "Turn", "on", "logging", "and", "set", "up", "the", "global", "config", "." ]
train
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/run_multi_worker.py#L53-L77
diffeo/rejester
rejester/run_multi_worker.py
start_worker
def start_worker(which_worker, config={}): '''Start some worker class. :param str which_worker: name of the worker :param dict config: ``rejester`` config block ''' if which_worker == 'multi_worker': cls = MultiWorker elif which_worker == 'fork_worker': cls = ForkWorker els...
python
def start_worker(which_worker, config={}): '''Start some worker class. :param str which_worker: name of the worker :param dict config: ``rejester`` config block ''' if which_worker == 'multi_worker': cls = MultiWorker elif which_worker == 'fork_worker': cls = ForkWorker els...
[ "def", "start_worker", "(", "which_worker", ",", "config", "=", "{", "}", ")", ":", "if", "which_worker", "==", "'multi_worker'", ":", "cls", "=", "MultiWorker", "elif", "which_worker", "==", "'fork_worker'", ":", "cls", "=", "ForkWorker", "else", ":", "# Do...
Start some worker class. :param str which_worker: name of the worker :param dict config: ``rejester`` config block
[ "Start", "some", "worker", "class", "." ]
train
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/run_multi_worker.py#L79-L93
diffeo/rejester
rejester/run_multi_worker.py
go
def go(gconfig, args): '''Actually run the worker. This does some required housekeeping, like setting up logging for :class:`~rejester.workers.MultiWorker` and establishing the global :mod:`yakonfig` configuration. This expects to be called with the :mod:`yakonfig` configuration unset. :param...
python
def go(gconfig, args): '''Actually run the worker. This does some required housekeeping, like setting up logging for :class:`~rejester.workers.MultiWorker` and establishing the global :mod:`yakonfig` configuration. This expects to be called with the :mod:`yakonfig` configuration unset. :param...
[ "def", "go", "(", "gconfig", ",", "args", ")", ":", "rconfig", "=", "gconfig", "[", "'rejester'", "]", "which_worker", "=", "rconfig", ".", "get", "(", "'worker'", ",", "'fork_worker'", ")", "if", "which_worker", "==", "'fork_worker'", ":", "yakonfig", "."...
Actually run the worker. This does some required housekeeping, like setting up logging for :class:`~rejester.workers.MultiWorker` and establishing the global :mod:`yakonfig` configuration. This expects to be called with the :mod:`yakonfig` configuration unset. :param dict gconfig: the :mod:`yakon...
[ "Actually", "run", "the", "worker", "." ]
train
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/run_multi_worker.py#L95-L113
diffeo/rejester
rejester/run_multi_worker.py
fork_worker
def fork_worker(gconfig, args): '''Run the worker as a daemon process. This uses :mod:`daemon` to run the standard double-fork, so it can return immediately and successfully in the parent process having forked. :param dict gconfig: the :mod:`yakonfig` global configuration :param args: command-line...
python
def fork_worker(gconfig, args): '''Run the worker as a daemon process. This uses :mod:`daemon` to run the standard double-fork, so it can return immediately and successfully in the parent process having forked. :param dict gconfig: the :mod:`yakonfig` global configuration :param args: command-line...
[ "def", "fork_worker", "(", "gconfig", ",", "args", ")", ":", "if", "args", ".", "pidfile", ":", "pidfile_lock", "=", "lockfile", ".", "FileLock", "(", "args", ".", "pidfile", ")", "else", ":", "pidfile_lock", "=", "None", "with", "daemon", ".", "DaemonCo...
Run the worker as a daemon process. This uses :mod:`daemon` to run the standard double-fork, so it can return immediately and successfully in the parent process having forked. :param dict gconfig: the :mod:`yakonfig` global configuration :param args: command-line arguments
[ "Run", "the", "worker", "as", "a", "daemon", "process", "." ]
train
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/run_multi_worker.py#L115-L138
pyros-dev/pyros-common
pyros_interfaces_common/transient_if_pool.py
TransientIfPool.update_transients
def update_transients(self, add_names, remove_names, *class_build_args, **class_build_kwargs): """ Adds transients (service, topic, etc) named in add_names if they are not exposed in resolved_dict and removes transients named in remove_names if they are exposed in resolved_dict This met...
python
def update_transients(self, add_names, remove_names, *class_build_args, **class_build_kwargs): """ Adds transients (service, topic, etc) named in add_names if they are not exposed in resolved_dict and removes transients named in remove_names if they are exposed in resolved_dict This met...
[ "def", "update_transients", "(", "self", ",", "add_names", ",", "remove_names", ",", "*", "class_build_args", ",", "*", "*", "class_build_kwargs", ")", ":", "# Important : no effect if names is empty list. only return empty. functional style.", "added", "=", "[", "]", "re...
Adds transients (service, topic, etc) named in add_names if they are not exposed in resolved_dict and removes transients named in remove_names if they are exposed in resolved_dict This method can be used to force exposing/withholding any transient, bypassing other mechanisms. No extra check is ...
[ "Adds", "transients", "(", "service", "topic", "etc", ")", "named", "in", "add_names", "if", "they", "are", "not", "exposed", "in", "resolved_dict", "and", "removes", "transients", "named", "in", "remove_names", "if", "they", "are", "exposed", "in", "resolved_...
train
https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/transient_if_pool.py#L51-L93
pyros-dev/pyros-common
pyros_interfaces_common/transient_if_pool.py
TransientIfPool.expose_transients_regex
def expose_transients_regex(self, regexes, *class_build_args, **class_build_kwargs): """ Exposes a list of transients regexes. resolved transients not matching the regexes will be removed. _expose_transients_regex -> _transient_change_detect -> _transient_change_diff -> _update_transients ...
python
def expose_transients_regex(self, regexes, *class_build_args, **class_build_kwargs): """ Exposes a list of transients regexes. resolved transients not matching the regexes will be removed. _expose_transients_regex -> _transient_change_detect -> _transient_change_diff -> _update_transients ...
[ "def", "expose_transients_regex", "(", "self", ",", "regexes", ",", "*", "class_build_args", ",", "*", "*", "class_build_kwargs", ")", ":", "# Important : no effect if names is empty list. only return empty diff. functional style.", "# look through the new service names received by r...
Exposes a list of transients regexes. resolved transients not matching the regexes will be removed. _expose_transients_regex -> _transient_change_detect -> _transient_change_diff -> _update_transients :param regexes: the list of regex to filter the transient to add. Note: regexes = [] rem...
[ "Exposes", "a", "list", "of", "transients", "regexes", ".", "resolved", "transients", "not", "matching", "the", "regexes", "will", "be", "removed", ".", "_expose_transients_regex", "-", ">", "_transient_change_detect", "-", ">", "_transient_change_diff", "-", ">", ...
train
https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/transient_if_pool.py#L95-L123
pyros-dev/pyros-common
pyros_interfaces_common/transient_if_pool.py
TransientIfPool.transient_change_detect
def transient_change_detect(self, *class_build_args, **class_build_kwargs): """ This should be called when we want to detect a change in the status of the system regarding the transient list This function also applies changes due to regex_set updates if needed _transient_change_detect ->...
python
def transient_change_detect(self, *class_build_args, **class_build_kwargs): """ This should be called when we want to detect a change in the status of the system regarding the transient list This function also applies changes due to regex_set updates if needed _transient_change_detect ->...
[ "def", "transient_change_detect", "(", "self", ",", "*", "class_build_args", ",", "*", "*", "class_build_kwargs", ")", ":", "transient_detected", "=", "set", "(", "self", ".", "get_transients_available", "(", ")", ")", "#TODO : unify that last_got_set with the *_availab...
This should be called when we want to detect a change in the status of the system regarding the transient list This function also applies changes due to regex_set updates if needed _transient_change_detect -> _transient_change_diff -> _update_transients
[ "This", "should", "be", "called", "when", "we", "want", "to", "detect", "a", "change", "in", "the", "status", "of", "the", "system", "regarding", "the", "transient", "list", "This", "function", "also", "applies", "changes", "due", "to", "regex_set", "updates...
train
https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/transient_if_pool.py#L126-L153
pyros-dev/pyros-common
pyros_interfaces_common/transient_if_pool.py
TransientIfPool.transient_change_diff
def transient_change_diff(self, transient_appeared, transient_gone, *class_build_args, **class_build_kwargs): """ This should be called when we want to process a change in the status of the system (if we already have the diff) This function also applies changes due to regex_set updates if needed...
python
def transient_change_diff(self, transient_appeared, transient_gone, *class_build_args, **class_build_kwargs): """ This should be called when we want to process a change in the status of the system (if we already have the diff) This function also applies changes due to regex_set updates if needed...
[ "def", "transient_change_diff", "(", "self", ",", "transient_appeared", ",", "transient_gone", ",", "*", "class_build_args", ",", "*", "*", "class_build_kwargs", ")", ":", "to_add", "=", "set", "(", "regexes_match_sublist", "(", "self", ".", "transients_args", ","...
This should be called when we want to process a change in the status of the system (if we already have the diff) This function also applies changes due to regex_set updates if needed _transient_change_diff -> _update_transients
[ "This", "should", "be", "called", "when", "we", "want", "to", "process", "a", "change", "in", "the", "status", "of", "the", "system", "(", "if", "we", "already", "have", "the", "diff", ")", "This", "function", "also", "applies", "changes", "due", "to", ...
train
https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/transient_if_pool.py#L155-L171
pyros-dev/pyros-common
pyros_interfaces_common/transient_if_pool.py
TransientIfPool.mock
def mock(self, tst_name, tst_type): """ Mock appearance/disappearance to force changes in interface , via setting local cache. :param tst_name: :param tst_type: :return: """ print(" -> Mock {tst_name} appear".format(**locals())) # Service appears s...
python
def mock(self, tst_name, tst_type): """ Mock appearance/disappearance to force changes in interface , via setting local cache. :param tst_name: :param tst_type: :return: """ print(" -> Mock {tst_name} appear".format(**locals())) # Service appears s...
[ "def", "mock", "(", "self", ",", "tst_name", ",", "tst_type", ")", ":", "print", "(", "\" -> Mock {tst_name} appear\"", ".", "format", "(", "*", "*", "locals", "(", ")", ")", ")", "# Service appears", "self", ".", "available", "[", "tst_name", "]", "=", ...
Mock appearance/disappearance to force changes in interface , via setting local cache. :param tst_name: :param tst_type: :return:
[ "Mock", "appearance", "/", "disappearance", "to", "force", "changes", "in", "interface", "via", "setting", "local", "cache", ".", ":", "param", "tst_name", ":", ":", "param", "tst_type", ":", ":", "return", ":" ]
train
https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/transient_if_pool.py#L274-L287
Tathorack/searchcolor
searchcolor/web_image.py
GoogleImageSearch.search
def search(self, search_term, num_results, **kwargs): """Gets x number of Google image result urls for a given search term. Arguments search_term: str tearm to search for num_results: int number of url results to return return ['url','url'] ...
python
def search(self, search_term, num_results, **kwargs): """Gets x number of Google image result urls for a given search term. Arguments search_term: str tearm to search for num_results: int number of url results to return return ['url','url'] ...
[ "def", "search", "(", "self", ",", "search_term", ",", "num_results", ",", "*", "*", "kwargs", ")", ":", "results", "=", "[", "]", "count", "=", "1", "try", ":", "while", "len", "(", "results", ")", "<=", "num_results", ":", "search_results", "=", "s...
Gets x number of Google image result urls for a given search term. Arguments search_term: str tearm to search for num_results: int number of url results to return return ['url','url']
[ "Gets", "x", "number", "of", "Google", "image", "result", "urls", "for", "a", "given", "search", "term", ".", "Arguments", "search_term", ":", "str", "tearm", "to", "search", "for", "num_results", ":", "int", "number", "of", "url", "results", "to", "return...
train
https://github.com/Tathorack/searchcolor/blob/f50b0a40e9da59fd994440f20e106730b9deb6bf/searchcolor/web_image.py#L48-L77
pawamoy/python-getdoc
src/getdoc/__init__.py
_doc_object
def _doc_object(obj, obj_type, nest=None, config=default_config): """Return a dict with type, name, doc and nested doc (if any).""" doc = inspect.getdoc(obj) if not doc and not nest: return None result = { 'type': obj_type, 'name': obj.__name__, 'doc': doc } if...
python
def _doc_object(obj, obj_type, nest=None, config=default_config): """Return a dict with type, name, doc and nested doc (if any).""" doc = inspect.getdoc(obj) if not doc and not nest: return None result = { 'type': obj_type, 'name': obj.__name__, 'doc': doc } if...
[ "def", "_doc_object", "(", "obj", ",", "obj_type", ",", "nest", "=", "None", ",", "config", "=", "default_config", ")", ":", "doc", "=", "inspect", ".", "getdoc", "(", "obj", ")", "if", "not", "doc", "and", "not", "nest", ":", "return", "None", "resu...
Return a dict with type, name, doc and nested doc (if any).
[ "Return", "a", "dict", "with", "type", "name", "doc", "and", "nested", "doc", "(", "if", "any", ")", "." ]
train
https://github.com/pawamoy/python-getdoc/blob/7589605be746ecde54f3fb68a46c88242d9b6405/src/getdoc/__init__.py#L125-L141
pawamoy/python-getdoc
src/getdoc/__init__.py
get_function_doc
def get_function_doc(function, config=default_config): """Return doc for a function.""" if config.exclude_function: for ex in config.exclude_function: if ex.match(function.__name__): return None return _doc_object(function, 'function', config=config)
python
def get_function_doc(function, config=default_config): """Return doc for a function.""" if config.exclude_function: for ex in config.exclude_function: if ex.match(function.__name__): return None return _doc_object(function, 'function', config=config)
[ "def", "get_function_doc", "(", "function", ",", "config", "=", "default_config", ")", ":", "if", "config", ".", "exclude_function", ":", "for", "ex", "in", "config", ".", "exclude_function", ":", "if", "ex", ".", "match", "(", "function", ".", "__name__", ...
Return doc for a function.
[ "Return", "doc", "for", "a", "function", "." ]
train
https://github.com/pawamoy/python-getdoc/blob/7589605be746ecde54f3fb68a46c88242d9b6405/src/getdoc/__init__.py#L144-L151
pawamoy/python-getdoc
src/getdoc/__init__.py
get_class_doc
def get_class_doc(klass, config=default_config): """Return doc for a class.""" if config.exclude_class: for ex in config.exclude_class: if ex.match(klass.__name__): return None nested_doc = [] class_dict = klass.__dict__ for item in dir(klass): if item i...
python
def get_class_doc(klass, config=default_config): """Return doc for a class.""" if config.exclude_class: for ex in config.exclude_class: if ex.match(klass.__name__): return None nested_doc = [] class_dict = klass.__dict__ for item in dir(klass): if item i...
[ "def", "get_class_doc", "(", "klass", ",", "config", "=", "default_config", ")", ":", "if", "config", ".", "exclude_class", ":", "for", "ex", "in", "config", ".", "exclude_class", ":", "if", "ex", ".", "match", "(", "klass", ".", "__name__", ")", ":", ...
Return doc for a class.
[ "Return", "doc", "for", "a", "class", "." ]
train
https://github.com/pawamoy/python-getdoc/blob/7589605be746ecde54f3fb68a46c88242d9b6405/src/getdoc/__init__.py#L154-L174
pawamoy/python-getdoc
src/getdoc/__init__.py
get_module_doc
def get_module_doc(module, config=default_config, already_met=None): """Return doc for a module.""" # Avoid recursion loops (init) if already_met is None: already_met = set() if config.exclude_module: for ex in config.exclude_module: if ex.match(module.__name__): ...
python
def get_module_doc(module, config=default_config, already_met=None): """Return doc for a module.""" # Avoid recursion loops (init) if already_met is None: already_met = set() if config.exclude_module: for ex in config.exclude_module: if ex.match(module.__name__): ...
[ "def", "get_module_doc", "(", "module", ",", "config", "=", "default_config", ",", "already_met", "=", "None", ")", ":", "# Avoid recursion loops (init)", "if", "already_met", "is", "None", ":", "already_met", "=", "set", "(", ")", "if", "config", ".", "exclud...
Return doc for a module.
[ "Return", "doc", "for", "a", "module", "." ]
train
https://github.com/pawamoy/python-getdoc/blob/7589605be746ecde54f3fb68a46c88242d9b6405/src/getdoc/__init__.py#L177-L240
pawamoy/python-getdoc
src/getdoc/__init__.py
Ex.match
def match(self, name): """ Check if given name matches. Args: name (str): name to check. Returns: bool: matches name. """ if self.method == Ex.Method.PREFIX: return name.startswith(self.value) elif self.method == Ex.Method.SUF...
python
def match(self, name): """ Check if given name matches. Args: name (str): name to check. Returns: bool: matches name. """ if self.method == Ex.Method.PREFIX: return name.startswith(self.value) elif self.method == Ex.Method.SUF...
[ "def", "match", "(", "self", ",", "name", ")", ":", "if", "self", ".", "method", "==", "Ex", ".", "Method", ".", "PREFIX", ":", "return", "name", ".", "startswith", "(", "self", ".", "value", ")", "elif", "self", ".", "method", "==", "Ex", ".", "...
Check if given name matches. Args: name (str): name to check. Returns: bool: matches name.
[ "Check", "if", "given", "name", "matches", "." ]
train
https://github.com/pawamoy/python-getdoc/blob/7589605be746ecde54f3fb68a46c88242d9b6405/src/getdoc/__init__.py#L57-L77
jashort/SmartFileSorter
smartfilesorter/actionplugins/printfileinfo.py
PrintFileInfo.do_action
def do_action(self, target, dry_run=False): """ :param target: Full path and filename :param dry_run: True - don't actually perform action. False: perform action. No effect for this rule. :return: filename: Full path and filename after action completes """ if dry_run is F...
python
def do_action(self, target, dry_run=False): """ :param target: Full path and filename :param dry_run: True - don't actually perform action. False: perform action. No effect for this rule. :return: filename: Full path and filename after action completes """ if dry_run is F...
[ "def", "do_action", "(", "self", ",", "target", ",", "dry_run", "=", "False", ")", ":", "if", "dry_run", "is", "False", ":", "try", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "target", ")", "size", "=", "os", ".", "path", ".", ...
:param target: Full path and filename :param dry_run: True - don't actually perform action. False: perform action. No effect for this rule. :return: filename: Full path and filename after action completes
[ ":", "param", "target", ":", "Full", "path", "and", "filename", ":", "param", "dry_run", ":", "True", "-", "don", "t", "actually", "perform", "action", ".", "False", ":", "perform", "action", ".", "No", "effect", "for", "this", "rule", ".", ":", "retur...
train
https://github.com/jashort/SmartFileSorter/blob/77faf09e5a737da93e16e71a64707366b8307910/smartfilesorter/actionplugins/printfileinfo.py#L15-L29
jpscaletti/moar
moar/utils.py
parse_geometry
def parse_geometry(geometry): """Parse a geometry string and returns a (width, height) tuple Eg: '100x200' ==> (100, 200) '50' ==> (50, None) '50x' ==> (50, None) 'x100' ==> (None, 100) None ==> None A callable `geometry` parameter is also supported. """ if n...
python
def parse_geometry(geometry): """Parse a geometry string and returns a (width, height) tuple Eg: '100x200' ==> (100, 200) '50' ==> (50, None) '50x' ==> (50, None) 'x100' ==> (None, 100) None ==> None A callable `geometry` parameter is also supported. """ if n...
[ "def", "parse_geometry", "(", "geometry", ")", ":", "if", "not", "geometry", ":", "return", "None", ",", "None", "if", "callable", "(", "geometry", ")", ":", "geometry", "=", "geometry", "(", ")", "geometry", "=", "str", "(", "geometry", ")", ".", "spl...
Parse a geometry string and returns a (width, height) tuple Eg: '100x200' ==> (100, 200) '50' ==> (50, None) '50x' ==> (50, None) 'x100' ==> (None, 100) None ==> None A callable `geometry` parameter is also supported.
[ "Parse", "a", "geometry", "string", "and", "returns", "a", "(", "width", "height", ")", "tuple", "Eg", ":", "100x200", "==", ">", "(", "100", "200", ")", "50", "==", ">", "(", "50", "None", ")", "50x", "==", ">", "(", "50", "None", ")", "x100", ...
train
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/utils.py#L5-L28
lukaszb/porunga
porunga/__init__.py
get_version
def get_version(): """ Returns shorter version (digit parts only) as string. """ version = '.'.join((str(each) for each in VERSION[:3])) if len(VERSION) > 3: version += VERSION[3] return version
python
def get_version(): """ Returns shorter version (digit parts only) as string. """ version = '.'.join((str(each) for each in VERSION[:3])) if len(VERSION) > 3: version += VERSION[3] return version
[ "def", "get_version", "(", ")", ":", "version", "=", "'.'", ".", "join", "(", "(", "str", "(", "each", ")", "for", "each", "in", "VERSION", "[", ":", "3", "]", ")", ")", "if", "len", "(", "VERSION", ")", ">", "3", ":", "version", "+=", "VERSION...
Returns shorter version (digit parts only) as string.
[ "Returns", "shorter", "version", "(", "digit", "parts", "only", ")", "as", "string", "." ]
train
https://github.com/lukaszb/porunga/blob/13177ff9bc654ac25cf09def6b526eb38e40e483/porunga/__init__.py#L12-L19
oleg-golovanov/unilog
unilog/unilog.py
as_unicode
def as_unicode(obj, encoding=convert.LOCALE, pretty=False): """ Representing any object to <unicode> string (python2.7) or <str> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by ...
python
def as_unicode(obj, encoding=convert.LOCALE, pretty=False): """ Representing any object to <unicode> string (python2.7) or <str> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by ...
[ "def", "as_unicode", "(", "obj", ",", "encoding", "=", "convert", ".", "LOCALE", ",", "pretty", "=", "False", ")", ":", "return", "convert", ".", "convert", "(", "obj", ",", "encoding", ",", "0", "if", "pretty", "else", "None", ")" ]
Representing any object to <unicode> string (python2.7) or <str> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by default) :type pretty: bool :param pretty: pretty print :rt...
[ "Representing", "any", "object", "to", "<unicode", ">", "string", "(", "python2", ".", "7", ")", "or", "<str", ">", "string", "(", "python3", ".", "0", ")", "." ]
train
https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/unilog.py#L7-L22
oleg-golovanov/unilog
unilog/unilog.py
as_str
def as_str(obj, encoding=convert.LOCALE, pretty=False): """ Representing any object to <str> string (python2.7) or <bytes> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by defaul...
python
def as_str(obj, encoding=convert.LOCALE, pretty=False): """ Representing any object to <str> string (python2.7) or <bytes> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by defaul...
[ "def", "as_str", "(", "obj", ",", "encoding", "=", "convert", ".", "LOCALE", ",", "pretty", "=", "False", ")", ":", "return", "as_unicode", "(", "obj", ",", "encoding", ",", "pretty", ")", ".", "encode", "(", "encoding", ")" ]
Representing any object to <str> string (python2.7) or <bytes> string (python3.0). :param obj: any object :type encoding: str :param encoding: codec for encoding unicode strings (locale.getpreferredencoding() by default) :type pretty: bool :param pretty: pretty print :rtyp...
[ "Representing", "any", "object", "to", "<str", ">", "string", "(", "python2", ".", "7", ")", "or", "<bytes", ">", "string", "(", "python3", ".", "0", ")", "." ]
train
https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/unilog.py#L25-L40
mayfield/shellish
shellish/command/autocommand.py
autocommand
def autocommand(func): """ A simplified decorator for making a single function a Command instance. In the future this will leverage PEP0484 to do really smart function parsing and conversion to argparse actions. """ name = func.__name__ title, desc = command.parse_docstring(func) if not title: ...
python
def autocommand(func): """ A simplified decorator for making a single function a Command instance. In the future this will leverage PEP0484 to do really smart function parsing and conversion to argparse actions. """ name = func.__name__ title, desc = command.parse_docstring(func) if not title: ...
[ "def", "autocommand", "(", "func", ")", ":", "name", "=", "func", ".", "__name__", "title", ",", "desc", "=", "command", ".", "parse_docstring", "(", "func", ")", "if", "not", "title", ":", "title", "=", "'Auto command for: %s'", "%", "name", "if", "not"...
A simplified decorator for making a single function a Command instance. In the future this will leverage PEP0484 to do really smart function parsing and conversion to argparse actions.
[ "A", "simplified", "decorator", "for", "making", "a", "single", "function", "a", "Command", "instance", ".", "In", "the", "future", "this", "will", "leverage", "PEP0484", "to", "do", "really", "smart", "function", "parsing", "and", "conversion", "to", "argpars...
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/autocommand.py#L114-L125
mayfield/shellish
shellish/command/autocommand.py
AutoCommand.run
def run(self, args): """ Convert the unordered args into function arguments. """ args = vars(args) positionals = [] keywords = {} for action in self.argparser._actions: if not hasattr(action, 'label'): continue if action.label == 'positiona...
python
def run(self, args): """ Convert the unordered args into function arguments. """ args = vars(args) positionals = [] keywords = {} for action in self.argparser._actions: if not hasattr(action, 'label'): continue if action.label == 'positiona...
[ "def", "run", "(", "self", ",", "args", ")", ":", "args", "=", "vars", "(", "args", ")", "positionals", "=", "[", "]", "keywords", "=", "{", "}", "for", "action", "in", "self", ".", "argparser", ".", "_actions", ":", "if", "not", "hasattr", "(", ...
Convert the unordered args into function arguments.
[ "Convert", "the", "unordered", "args", "into", "function", "arguments", "." ]
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/command/autocommand.py#L29-L52
rwmeta/starter-py-client
starter_api/private_api.py
PrivateApi.submit
def submit(self, task): """ :type task: Task """ if self.api_url == 'http://STUB_URL': logging.info(u'STARTER CLIENT DEV MODE Задача условно поставлена') return url = self.api_url + '/services/' + task.serviceId + '/tasks' last_e = None fo...
python
def submit(self, task): """ :type task: Task """ if self.api_url == 'http://STUB_URL': logging.info(u'STARTER CLIENT DEV MODE Задача условно поставлена') return url = self.api_url + '/services/' + task.serviceId + '/tasks' last_e = None fo...
[ "def", "submit", "(", "self", ",", "task", ")", ":", "if", "self", ".", "api_url", "==", "'http://STUB_URL'", ":", "logging", ".", "info", "(", "u'STARTER CLIENT DEV MODE Задача условно поставлена')", "", "return", "url", "=", "self", ".", "api_url", "+", "'/s...
:type task: Task
[ ":", "type", "task", ":", "Task" ]
train
https://github.com/rwmeta/starter-py-client/blob/e60e2373925f75ec930cfb45a4b4a8dad6d26225/starter_api/private_api.py#L16-L42
jpscaletti/moar
moar/engines/wand_engine.py
WandEngine._save_to
def _save_to(self, im, path, format=None): """Save the image for testing. """ format = format or im.format if not format: _, format = splitext(path) format = format[1:] im.format = format.lower() im.save(filename=path)
python
def _save_to(self, im, path, format=None): """Save the image for testing. """ format = format or im.format if not format: _, format = splitext(path) format = format[1:] im.format = format.lower() im.save(filename=path)
[ "def", "_save_to", "(", "self", ",", "im", ",", "path", ",", "format", "=", "None", ")", ":", "format", "=", "format", "or", "im", ".", "format", "if", "not", "format", ":", "_", ",", "format", "=", "splitext", "(", "path", ")", "format", "=", "f...
Save the image for testing.
[ "Save", "the", "image", "for", "testing", "." ]
train
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/engines/wand_engine.py#L33-L41
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger._log
def _log(self, priority, message, *args, **kwargs): """Generic log functions """ for arg in args: message = message + "\n" + self.pretty_printer.pformat(arg) self.logger.log(priority, message)
python
def _log(self, priority, message, *args, **kwargs): """Generic log functions """ for arg in args: message = message + "\n" + self.pretty_printer.pformat(arg) self.logger.log(priority, message)
[ "def", "_log", "(", "self", ",", "priority", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "message", "=", "message", "+", "\"\\n\"", "+", "self", ".", "pretty_printer", ".", "pformat", "(", "...
Generic log functions
[ "Generic", "log", "functions" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L70-L76
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.debug
def debug(self, message, *args, **kwargs): """Debug level to use and abuse when coding """ self._log(logging.DEBUG, message, *args, **kwargs)
python
def debug(self, message, *args, **kwargs): """Debug level to use and abuse when coding """ self._log(logging.DEBUG, message, *args, **kwargs)
[ "def", "debug", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_log", "(", "logging", ".", "DEBUG", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Debug level to use and abuse when coding
[ "Debug", "level", "to", "use", "and", "abuse", "when", "coding" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L78-L81
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.info
def info(self, message, *args, **kwargs): """More important level : default for print and save """ self._log(logging.INFO, message, *args, **kwargs)
python
def info(self, message, *args, **kwargs): """More important level : default for print and save """ self._log(logging.INFO, message, *args, **kwargs)
[ "def", "info", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_log", "(", "logging", ".", "INFO", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
More important level : default for print and save
[ "More", "important", "level", ":", "default", "for", "print", "and", "save" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L83-L86
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.warn
def warn(self, message, *args, **kwargs): """Send email and syslog by default ... """ self._log(logging.WARNING, message, *args, **kwargs)
python
def warn(self, message, *args, **kwargs): """Send email and syslog by default ... """ self._log(logging.WARNING, message, *args, **kwargs)
[ "def", "warn", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_log", "(", "logging", ".", "WARNING", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Send email and syslog by default ...
[ "Send", "email", "and", "syslog", "by", "default", "..." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L88-L91
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.warning
def warning(self, message, *args, **kwargs): """Alias to warn """ self._log(logging.WARNING, message, *args, **kwargs)
python
def warning(self, message, *args, **kwargs): """Alias to warn """ self._log(logging.WARNING, message, *args, **kwargs)
[ "def", "warning", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_log", "(", "logging", ".", "WARNING", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Alias to warn
[ "Alias", "to", "warn" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L93-L96
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.error
def error(self, message, *args, **kwargs): """Should not happen ... """ self._log(logging.ERROR, message, *args, **kwargs)
python
def error(self, message, *args, **kwargs): """Should not happen ... """ self._log(logging.ERROR, message, *args, **kwargs)
[ "def", "error", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_log", "(", "logging", ".", "ERROR", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Should not happen ...
[ "Should", "not", "happen", "..." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L98-L101
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.critical
def critical(self, message, *args, **kwargs): """Highest level """ self._log(logging.CRITICAL, message, *args, **kwargs)
python
def critical(self, message, *args, **kwargs): """Highest level """ self._log(logging.CRITICAL, message, *args, **kwargs)
[ "def", "critical", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_log", "(", "logging", ".", "CRITICAL", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Highest level
[ "Highest", "level" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L103-L106
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.exception
def exception(self, message, *args, **kwargs): """Handle exception """ self.logger.exception(message, *args, **kwargs)
python
def exception(self, message, *args, **kwargs): """Handle exception """ self.logger.exception(message, *args, **kwargs)
[ "def", "exception", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", ".", "exception", "(", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Handle exception
[ "Handle", "exception" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L108-L111
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.init_logger
def init_logger(self): """Create configuration for the root logger.""" # All logs are comming to this logger self.logger.setLevel(logging.DEBUG) self.logger.propagate = False # Logging to console if self.min_log_level_to_print: level = self.min_log_level_to_p...
python
def init_logger(self): """Create configuration for the root logger.""" # All logs are comming to this logger self.logger.setLevel(logging.DEBUG) self.logger.propagate = False # Logging to console if self.min_log_level_to_print: level = self.min_log_level_to_p...
[ "def", "init_logger", "(", "self", ")", ":", "# All logs are comming to this logger", "self", ".", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "self", ".", "logger", ".", "propagate", "=", "False", "# Logging to console", "if", "self", ".", "...
Create configuration for the root logger.
[ "Create", "configuration", "for", "the", "root", "logger", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L113-L143
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.new_iteration
def new_iteration(self, prefix): """When inside a loop logger, created a new iteration """ # Flush data for the current iteration self.flush() # Fix prefix self.prefix[-1] = prefix self.reset_formatter()
python
def new_iteration(self, prefix): """When inside a loop logger, created a new iteration """ # Flush data for the current iteration self.flush() # Fix prefix self.prefix[-1] = prefix self.reset_formatter()
[ "def", "new_iteration", "(", "self", ",", "prefix", ")", ":", "# Flush data for the current iteration", "self", ".", "flush", "(", ")", "# Fix prefix", "self", ".", "prefix", "[", "-", "1", "]", "=", "prefix", "self", ".", "reset_formatter", "(", ")" ]
When inside a loop logger, created a new iteration
[ "When", "inside", "a", "loop", "logger", "created", "a", "new", "iteration" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L168-L176
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.reset_formatter
def reset_formatter(self): """Rebuild formatter for all handlers.""" for handler in self.handlers: formatter = self.get_formatter(handler) handler.setFormatter(formatter)
python
def reset_formatter(self): """Rebuild formatter for all handlers.""" for handler in self.handlers: formatter = self.get_formatter(handler) handler.setFormatter(formatter)
[ "def", "reset_formatter", "(", "self", ")", ":", "for", "handler", "in", "self", ".", "handlers", ":", "formatter", "=", "self", ".", "get_formatter", "(", "handler", ")", "handler", ".", "setFormatter", "(", "formatter", ")" ]
Rebuild formatter for all handlers.
[ "Rebuild", "formatter", "for", "all", "handlers", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L178-L182
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger._set_min_level
def _set_min_level(self, handler_class, level): """Generic method to setLevel for handlers.""" if self._exist_handler(handler_class): if not level: self._delete_handler(handler_class) else: self._update_handler(handler_class, level=level) e...
python
def _set_min_level(self, handler_class, level): """Generic method to setLevel for handlers.""" if self._exist_handler(handler_class): if not level: self._delete_handler(handler_class) else: self._update_handler(handler_class, level=level) e...
[ "def", "_set_min_level", "(", "self", ",", "handler_class", ",", "level", ")", ":", "if", "self", ".", "_exist_handler", "(", "handler_class", ")", ":", "if", "not", "level", ":", "self", ".", "_delete_handler", "(", "handler_class", ")", "else", ":", "sel...
Generic method to setLevel for handlers.
[ "Generic", "method", "to", "setLevel", "for", "handlers", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L189-L197
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.set_min_level_to_print
def set_min_level_to_print(self, level): """Allow to change print level after creation """ self.min_log_level_to_print = level handler_class = logging.StreamHandler self._set_min_level(handler_class, level)
python
def set_min_level_to_print(self, level): """Allow to change print level after creation """ self.min_log_level_to_print = level handler_class = logging.StreamHandler self._set_min_level(handler_class, level)
[ "def", "set_min_level_to_print", "(", "self", ",", "level", ")", ":", "self", ".", "min_log_level_to_print", "=", "level", "handler_class", "=", "logging", ".", "StreamHandler", "self", ".", "_set_min_level", "(", "handler_class", ",", "level", ")" ]
Allow to change print level after creation
[ "Allow", "to", "change", "print", "level", "after", "creation" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L199-L204
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.set_min_level_to_save
def set_min_level_to_save(self, level): """Allow to change save level after creation """ self.min_log_level_to_save = level handler_class = logging.handlers.TimedRotatingFileHandler self._set_min_level(handler_class, level)
python
def set_min_level_to_save(self, level): """Allow to change save level after creation """ self.min_log_level_to_save = level handler_class = logging.handlers.TimedRotatingFileHandler self._set_min_level(handler_class, level)
[ "def", "set_min_level_to_save", "(", "self", ",", "level", ")", ":", "self", ".", "min_log_level_to_save", "=", "level", "handler_class", "=", "logging", ".", "handlers", ".", "TimedRotatingFileHandler", "self", ".", "_set_min_level", "(", "handler_class", ",", "l...
Allow to change save level after creation
[ "Allow", "to", "change", "save", "level", "after", "creation" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L206-L211
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.set_min_level_to_mail
def set_min_level_to_mail(self, level): """Allow to change mail level after creation """ self.min_log_level_to_mail = level handler_class = AlkiviEmailHandler self._set_min_level(handler_class, level)
python
def set_min_level_to_mail(self, level): """Allow to change mail level after creation """ self.min_log_level_to_mail = level handler_class = AlkiviEmailHandler self._set_min_level(handler_class, level)
[ "def", "set_min_level_to_mail", "(", "self", ",", "level", ")", ":", "self", ".", "min_log_level_to_mail", "=", "level", "handler_class", "=", "AlkiviEmailHandler", "self", ".", "_set_min_level", "(", "handler_class", ",", "level", ")" ]
Allow to change mail level after creation
[ "Allow", "to", "change", "mail", "level", "after", "creation" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L213-L218
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.set_min_level_to_syslog
def set_min_level_to_syslog(self, level): """Allow to change syslog level after creation """ self.min_log_level_to_syslog = level handler_class = logging.handlers.SysLogHandler self._set_min_level(handler_class, level)
python
def set_min_level_to_syslog(self, level): """Allow to change syslog level after creation """ self.min_log_level_to_syslog = level handler_class = logging.handlers.SysLogHandler self._set_min_level(handler_class, level)
[ "def", "set_min_level_to_syslog", "(", "self", ",", "level", ")", ":", "self", ".", "min_log_level_to_syslog", "=", "level", "handler_class", "=", "logging", ".", "handlers", ".", "SysLogHandler", "self", ".", "_set_min_level", "(", "handler_class", ",", "level", ...
Allow to change syslog level after creation
[ "Allow", "to", "change", "syslog", "level", "after", "creation" ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L220-L225
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger._get_handler
def _get_handler(self, handler_class): """Return an existing class of handler.""" element = None for handler in self.handlers: if isinstance(handler, handler_class): element = handler break return element
python
def _get_handler(self, handler_class): """Return an existing class of handler.""" element = None for handler in self.handlers: if isinstance(handler, handler_class): element = handler break return element
[ "def", "_get_handler", "(", "self", ",", "handler_class", ")", ":", "element", "=", "None", "for", "handler", "in", "self", ".", "handlers", ":", "if", "isinstance", "(", "handler", ",", "handler_class", ")", ":", "element", "=", "handler", "break", "retur...
Return an existing class of handler.
[ "Return", "an", "existing", "class", "of", "handler", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L227-L234
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger._delete_handler
def _delete_handler(self, handler_class): """Delete a specific handler from our logger.""" to_remove = self._get_handler(handler_class) if not to_remove: logging.warning('Error we should have an element to remove') else: self.handlers.remove(to_remove) ...
python
def _delete_handler(self, handler_class): """Delete a specific handler from our logger.""" to_remove = self._get_handler(handler_class) if not to_remove: logging.warning('Error we should have an element to remove') else: self.handlers.remove(to_remove) ...
[ "def", "_delete_handler", "(", "self", ",", "handler_class", ")", ":", "to_remove", "=", "self", ".", "_get_handler", "(", "handler_class", ")", "if", "not", "to_remove", ":", "logging", ".", "warning", "(", "'Error we should have an element to remove'", ")", "els...
Delete a specific handler from our logger.
[ "Delete", "a", "specific", "handler", "from", "our", "logger", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L240-L247
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger._update_handler
def _update_handler(self, handler_class, level): """Update the level of an handler.""" handler = self._get_handler(handler_class) handler.setLevel(level)
python
def _update_handler(self, handler_class, level): """Update the level of an handler.""" handler = self._get_handler(handler_class) handler.setLevel(level)
[ "def", "_update_handler", "(", "self", ",", "handler_class", ",", "level", ")", ":", "handler", "=", "self", ".", "_get_handler", "(", "handler_class", ")", "handler", ".", "setLevel", "(", "level", ")" ]
Update the level of an handler.
[ "Update", "the", "level", "of", "an", "handler", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L249-L252
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger._create_handler
def _create_handler(self, handler_class, level): """Create an handler for at specific level.""" if handler_class == logging.StreamHandler: handler = handler_class() handler.setLevel(level) elif handler_class == logging.handlers.SysLogHandler: handler = handler...
python
def _create_handler(self, handler_class, level): """Create an handler for at specific level.""" if handler_class == logging.StreamHandler: handler = handler_class() handler.setLevel(level) elif handler_class == logging.handlers.SysLogHandler: handler = handler...
[ "def", "_create_handler", "(", "self", ",", "handler_class", ",", "level", ")", ":", "if", "handler_class", "==", "logging", ".", "StreamHandler", ":", "handler", "=", "handler_class", "(", ")", "handler", ".", "setLevel", "(", "level", ")", "elif", "handler...
Create an handler for at specific level.
[ "Create", "an", "handler", "for", "at", "specific", "level", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L254-L276
alkivi-sas/python-alkivi-logger
alkivi/logger/logger.py
Logger.get_formatter
def get_formatter(self, handler): """ Return formatters according to handler. All handlers are the same format, except syslog. We omit time when syslogging. """ if isinstance(handler, logging.handlers.SysLogHandler): formatter = '[%(levelname)-9s]' el...
python
def get_formatter(self, handler): """ Return formatters according to handler. All handlers are the same format, except syslog. We omit time when syslogging. """ if isinstance(handler, logging.handlers.SysLogHandler): formatter = '[%(levelname)-9s]' el...
[ "def", "get_formatter", "(", "self", ",", "handler", ")", ":", "if", "isinstance", "(", "handler", ",", "logging", ".", "handlers", ".", "SysLogHandler", ")", ":", "formatter", "=", "'[%(levelname)-9s]'", "else", ":", "formatter", "=", "'[%(asctime)s] [%(levelna...
Return formatters according to handler. All handlers are the same format, except syslog. We omit time when syslogging.
[ "Return", "formatters", "according", "to", "handler", "." ]
train
https://github.com/alkivi-sas/python-alkivi-logger/blob/e96d5a987a5c8789c51d4fa7541709e05b1f51e1/alkivi/logger/logger.py#L278-L293
jlesquembre/jlle
jlle/releaser/release.py
version_control
def version_control(): """Return an object that provides the version control interface based on the detected version control system.""" curdir_contents = os.listdir('.') if '.hg' in curdir_contents: return hg.Hg() elif '.git' in curdir_contents: return git.Git() else: log...
python
def version_control(): """Return an object that provides the version control interface based on the detected version control system.""" curdir_contents = os.listdir('.') if '.hg' in curdir_contents: return hg.Hg() elif '.git' in curdir_contents: return git.Git() else: log...
[ "def", "version_control", "(", ")", ":", "curdir_contents", "=", "os", ".", "listdir", "(", "'.'", ")", "if", "'.hg'", "in", "curdir_contents", ":", "return", "hg", ".", "Hg", "(", ")", "elif", "'.git'", "in", "curdir_contents", ":", "return", "git", "."...
Return an object that provides the version control interface based on the detected version control system.
[ "Return", "an", "object", "that", "provides", "the", "version", "control", "interface", "based", "on", "the", "detected", "version", "control", "system", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L24-L34
jlesquembre/jlle
jlle/releaser/release.py
package_in_pypi
def package_in_pypi(package): """Check whether the package is registered on pypi""" url = 'http://pypi.python.org/simple/%s' % package try: urllib.request.urlopen(url) return True except urllib.error.HTTPError as e: logger.debug("Package not found on pypi: %s", e) return ...
python
def package_in_pypi(package): """Check whether the package is registered on pypi""" url = 'http://pypi.python.org/simple/%s' % package try: urllib.request.urlopen(url) return True except urllib.error.HTTPError as e: logger.debug("Package not found on pypi: %s", e) return ...
[ "def", "package_in_pypi", "(", "package", ")", ":", "url", "=", "'http://pypi.python.org/simple/%s'", "%", "package", "try", ":", "urllib", ".", "request", ".", "urlopen", "(", "url", ")", "return", "True", "except", "urllib", ".", "error", ".", "HTTPError", ...
Check whether the package is registered on pypi
[ "Check", "whether", "the", "package", "is", "registered", "on", "pypi" ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L37-L45
jlesquembre/jlle
jlle/releaser/release.py
Releaser._grab_version
def _grab_version(self): """Set the version to a non-development version.""" original_version = self.vcs.version logger.debug("Extracted version: %s", original_version) if original_version is None: logger.critical('No version found.') sys.exit(1) suggestio...
python
def _grab_version(self): """Set the version to a non-development version.""" original_version = self.vcs.version logger.debug("Extracted version: %s", original_version) if original_version is None: logger.critical('No version found.') sys.exit(1) suggestio...
[ "def", "_grab_version", "(", "self", ")", ":", "original_version", "=", "self", ".", "vcs", ".", "version", "logger", ".", "debug", "(", "\"Extracted version: %s\"", ",", "original_version", ")", "if", "original_version", "is", "None", ":", "logger", ".", "cri...
Set the version to a non-development version.
[ "Set", "the", "version", "to", "a", "non", "-", "development", "version", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L65-L77
jlesquembre/jlle
jlle/releaser/release.py
Releaser._grab_history
def _grab_history(self): """Calculate the needed history/changelog changes Every history heading looks like '1.0 b4 (1972-12-25)'. Extract them, check if the first one matches the version and whether it has a the current date. """ default_location = None config =...
python
def _grab_history(self): """Calculate the needed history/changelog changes Every history heading looks like '1.0 b4 (1972-12-25)'. Extract them, check if the first one matches the version and whether it has a the current date. """ default_location = None config =...
[ "def", "_grab_history", "(", "self", ")", ":", "default_location", "=", "None", "config", "=", "self", ".", "setup_cfg", ".", "config", "if", "config", "and", "config", ".", "has_option", "(", "'zest.releaser'", ",", "'history_file'", ")", ":", "default_locati...
Calculate the needed history/changelog changes Every history heading looks like '1.0 b4 (1972-12-25)'. Extract them, check if the first one matches the version and whether it has a the current date.
[ "Calculate", "the", "needed", "history", "/", "changelog", "changes" ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L87-L124
jlesquembre/jlle
jlle/releaser/release.py
Releaser._write_history
def _write_history(self): """Write previously-calculated history lines back to the file""" if self.data['history_file'] is None: return contents = '\n'.join(self.data['history_lines']) history = self.data['history_file'] open(history, 'w').write(contents) logg...
python
def _write_history(self): """Write previously-calculated history lines back to the file""" if self.data['history_file'] is None: return contents = '\n'.join(self.data['history_lines']) history = self.data['history_file'] open(history, 'w').write(contents) logg...
[ "def", "_write_history", "(", "self", ")", ":", "if", "self", ".", "data", "[", "'history_file'", "]", "is", "None", ":", "return", "contents", "=", "'\\n'", ".", "join", "(", "self", ".", "data", "[", "'history_lines'", "]", ")", "history", "=", "self...
Write previously-calculated history lines back to the file
[ "Write", "previously", "-", "calculated", "history", "lines", "back", "to", "the", "file" ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L128-L135
jlesquembre/jlle
jlle/releaser/release.py
Releaser._check_if_tag_already_exists
def _check_if_tag_already_exists(self): """Check if tag already exists and show the difference if so""" version = self.data['new_version'] if self.vcs.tag_exists(version): return True else: return False
python
def _check_if_tag_already_exists(self): """Check if tag already exists and show the difference if so""" version = self.data['new_version'] if self.vcs.tag_exists(version): return True else: return False
[ "def", "_check_if_tag_already_exists", "(", "self", ")", ":", "version", "=", "self", ".", "data", "[", "'new_version'", "]", "if", "self", ".", "vcs", ".", "tag_exists", "(", "version", ")", ":", "return", "True", "else", ":", "return", "False" ]
Check if tag already exists and show the difference if so
[ "Check", "if", "tag", "already", "exists", "and", "show", "the", "difference", "if", "so" ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L147-L153
jlesquembre/jlle
jlle/releaser/release.py
Releaser._release
def _release(self): """Upload the release, when desired""" pypiconfig = pypi.PypiConfig() # Does the user normally want a real release? We are # interested in getting a sane default answer here, so you can # override it in the exceptional case but just hit Enter in # t...
python
def _release(self): """Upload the release, when desired""" pypiconfig = pypi.PypiConfig() # Does the user normally want a real release? We are # interested in getting a sane default answer here, so you can # override it in the exceptional case but just hit Enter in # t...
[ "def", "_release", "(", "self", ")", ":", "pypiconfig", "=", "pypi", ".", "PypiConfig", "(", ")", "# Does the user normally want a real release? We are", "# interested in getting a sane default answer here, so you can", "# override it in the exceptional case but just hit Enter in", ...
Upload the release, when desired
[ "Upload", "the", "release", "when", "desired" ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L250-L294
jlesquembre/jlle
jlle/releaser/release.py
Releaser._update_version
def _update_version(self): """Ask for and store a new dev version string.""" #current = self.vcs.version current = self.data['new_version'] # Clean it up to a non-development version. current = utils.cleanup_version(current) # Try to make sure that the suggestion for nex...
python
def _update_version(self): """Ask for and store a new dev version string.""" #current = self.vcs.version current = self.data['new_version'] # Clean it up to a non-development version. current = utils.cleanup_version(current) # Try to make sure that the suggestion for nex...
[ "def", "_update_version", "(", "self", ")", ":", "#current = self.vcs.version", "current", "=", "self", ".", "data", "[", "'new_version'", "]", "# Clean it up to a non-development version.", "current", "=", "utils", ".", "cleanup_version", "(", "current", ")", "# Try ...
Ask for and store a new dev version string.
[ "Ask", "for", "and", "store", "a", "new", "dev", "version", "string", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L296-L336
jlesquembre/jlle
jlle/releaser/release.py
Releaser._update_history
def _update_history(self): """Update the history file""" version = self.data['new_version'] history = self.vcs.history_file() if not history: logger.warn("No history file found") return history_lines = open(history).read().split('\n') headings = ut...
python
def _update_history(self): """Update the history file""" version = self.data['new_version'] history = self.vcs.history_file() if not history: logger.warn("No history file found") return history_lines = open(history).read().split('\n') headings = ut...
[ "def", "_update_history", "(", "self", ")", ":", "version", "=", "self", ".", "data", "[", "'new_version'", "]", "history", "=", "self", ".", "vcs", ".", "history_file", "(", ")", "if", "not", "history", ":", "logger", ".", "warn", "(", "\"No history fil...
Update the history file
[ "Update", "the", "history", "file" ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L338-L371
jlesquembre/jlle
jlle/releaser/release.py
Releaser._push
def _push(self): """Offer to push changes, if needed.""" push_cmds = self.vcs.push_commands() if not push_cmds: return if utils.ask("OK to push commits to the server?"): for push_cmd in push_cmds: output = utils.system(push_cmd) lo...
python
def _push(self): """Offer to push changes, if needed.""" push_cmds = self.vcs.push_commands() if not push_cmds: return if utils.ask("OK to push commits to the server?"): for push_cmd in push_cmds: output = utils.system(push_cmd) lo...
[ "def", "_push", "(", "self", ")", ":", "push_cmds", "=", "self", ".", "vcs", ".", "push_commands", "(", ")", "if", "not", "push_cmds", ":", "return", "if", "utils", ".", "ask", "(", "\"OK to push commits to the server?\"", ")", ":", "for", "push_cmd", "in"...
Offer to push changes, if needed.
[ "Offer", "to", "push", "changes", "if", "needed", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/release.py#L373-L382
Apitax/Apitax
apitax/api/controllers/apitax_controller.py
delete_user
def delete_user(user, driver, user_delete=None): # noqa: E501 """Delete a user Delete a user # noqa: E501 :param user: Delete user with this name :type user: str :param driver: The driver to use for the request. ie. github :type driver: str :param user_delete: The data needed to delete th...
python
def delete_user(user, driver, user_delete=None): # noqa: E501 """Delete a user Delete a user # noqa: E501 :param user: Delete user with this name :type user: str :param driver: The driver to use for the request. ie. github :type driver: str :param user_delete: The data needed to delete th...
[ "def", "delete_user", "(", "user", ",", "driver", ",", "user_delete", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "user_delete", "=", "UserDelete", ".", "from_dict", "(", "connexion", ".", "request", ".", ...
Delete a user Delete a user # noqa: E501 :param user: Delete user with this name :type user: str :param driver: The driver to use for the request. ie. github :type driver: str :param user_delete: The data needed to delete this user :type user_delete: dict | bytes :rtype: Response
[ "Delete", "a", "user" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/apitax_controller.py#L86-L114
Apitax/Apitax
apitax/api/controllers/apitax_controller.py
get_user
def get_user(user, driver): # noqa: E501 """Retrieve a user Retrieve a user # noqa: E501 :param user: Get user with this name :type user: str :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = ApitaxResponse() driv...
python
def get_user(user, driver): # noqa: E501 """Retrieve a user Retrieve a user # noqa: E501 :param user: Get user with this name :type user: str :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = ApitaxResponse() driv...
[ "def", "get_user", "(", "user", ",", "driver", ")", ":", "# noqa: E501", "response", "=", "ApitaxResponse", "(", ")", "driver", ":", "Driver", "=", "LoadedDrivers", ".", "getDriver", "(", "driver", ")", "user", ":", "User", "=", "driver", ".", "getApitaxUs...
Retrieve a user Retrieve a user # noqa: E501 :param user: Get user with this name :type user: str :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response
[ "Retrieve", "a", "user" ]
train
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/apitax_controller.py#L146-L165
joaopcanario/imports
imports/cli.py
main
def main(path_dir, requirements_name): """Console script for imports.""" click.echo("\nWARNING: Uninstall libs it's at your own risk!") click.echo('\nREMINDER: After uninstall libs, update your requirements ' 'file.\nUse the `pip freeze > requirements.txt` command.') click.echo('\n\nList...
python
def main(path_dir, requirements_name): """Console script for imports.""" click.echo("\nWARNING: Uninstall libs it's at your own risk!") click.echo('\nREMINDER: After uninstall libs, update your requirements ' 'file.\nUse the `pip freeze > requirements.txt` command.') click.echo('\n\nList...
[ "def", "main", "(", "path_dir", ",", "requirements_name", ")", ":", "click", ".", "echo", "(", "\"\\nWARNING: Uninstall libs it's at your own risk!\"", ")", "click", ".", "echo", "(", "'\\nREMINDER: After uninstall libs, update your requirements '", "'file.\\nUse the `pip freez...
Console script for imports.
[ "Console", "script", "for", "imports", "." ]
train
https://github.com/joaopcanario/imports/blob/46db0d3d2aa55427027bf0e91d61a24d52730337/imports/cli.py#L13-L22
smartmob-project/strawboss
strawboss/__init__.py
now
def now(utc=False): """Returns the current time. :param utc: If ``True``, returns a timezone-aware ``datetime`` object in UTC. When ``False`` (the default), returns a naive ``datetime`` object in local time. :return: A ``datetime`` object representing the current time at the time of t...
python
def now(utc=False): """Returns the current time. :param utc: If ``True``, returns a timezone-aware ``datetime`` object in UTC. When ``False`` (the default), returns a naive ``datetime`` object in local time. :return: A ``datetime`` object representing the current time at the time of t...
[ "def", "now", "(", "utc", "=", "False", ")", ":", "if", "utc", ":", "return", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", "=", "dateutil", ".", "tz", ".", "tzutc", "(", ")", ")", "else", ":", "return", "da...
Returns the current time. :param utc: If ``True``, returns a timezone-aware ``datetime`` object in UTC. When ``False`` (the default), returns a naive ``datetime`` object in local time. :return: A ``datetime`` object representing the current time at the time of the call.
[ "Returns", "the", "current", "time", "." ]
train
https://github.com/smartmob-project/strawboss/blob/b295a7d0e3c1d95c4bb687f7f1bcae9605b3bbdc/strawboss/__init__.py#L22-L34
smartmob-project/strawboss
strawboss/__init__.py
parse_scale
def parse_scale(x): """Splits a "%s:%d" string and returns the string and number. :return: A ``(string, int)`` pair extracted from ``x``. :raise ValueError: the string ``x`` does not respect the input format. """ match = re.match(r'^(.+?):(\d+)$', x) if not match: raise ValueError('Inv...
python
def parse_scale(x): """Splits a "%s:%d" string and returns the string and number. :return: A ``(string, int)`` pair extracted from ``x``. :raise ValueError: the string ``x`` does not respect the input format. """ match = re.match(r'^(.+?):(\d+)$', x) if not match: raise ValueError('Inv...
[ "def", "parse_scale", "(", "x", ")", ":", "match", "=", "re", ".", "match", "(", "r'^(.+?):(\\d+)$'", ",", "x", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "'Invalid scale \"%s\".'", "%", "x", ")", "return", "match", ".", "group", "(", ...
Splits a "%s:%d" string and returns the string and number. :return: A ``(string, int)`` pair extracted from ``x``. :raise ValueError: the string ``x`` does not respect the input format.
[ "Splits", "a", "%s", ":", "%d", "string", "and", "returns", "the", "string", "and", "number", "." ]
train
https://github.com/smartmob-project/strawboss/blob/b295a7d0e3c1d95c4bb687f7f1bcae9605b3bbdc/strawboss/__init__.py#L53-L63
smartmob-project/strawboss
strawboss/__init__.py
merge_envs
def merge_envs(*args): """Union of one or more dictionaries. In case of duplicate keys, the values in the right-most arguments will squash (overwrite) the value provided by any dict preceding it. :param args: Sequence of ``dict`` objects that should be merged. :return: A ``dict`` containing the un...
python
def merge_envs(*args): """Union of one or more dictionaries. In case of duplicate keys, the values in the right-most arguments will squash (overwrite) the value provided by any dict preceding it. :param args: Sequence of ``dict`` objects that should be merged. :return: A ``dict`` containing the un...
[ "def", "merge_envs", "(", "*", "args", ")", ":", "env", "=", "{", "}", "for", "arg", "in", "args", ":", "if", "not", "arg", ":", "continue", "env", ".", "update", "(", "arg", ")", "return", "env" ]
Union of one or more dictionaries. In case of duplicate keys, the values in the right-most arguments will squash (overwrite) the value provided by any dict preceding it. :param args: Sequence of ``dict`` objects that should be merged. :return: A ``dict`` containing the union of keys in all input dicts...
[ "Union", "of", "one", "or", "more", "dictionaries", "." ]
train
https://github.com/smartmob-project/strawboss/blob/b295a7d0e3c1d95c4bb687f7f1bcae9605b3bbdc/strawboss/__init__.py#L66-L81
smartmob-project/strawboss
strawboss/__init__.py
run_once
def run_once(name, cmd, env, shutdown, loop=None, utc=False): """Starts a child process and waits for its completion. .. note:: This function is a coroutine. Standard output and error streams are captured and forwarded to the parent process' standard output. Each line is prefixed with the current tim...
python
def run_once(name, cmd, env, shutdown, loop=None, utc=False): """Starts a child process and waits for its completion. .. note:: This function is a coroutine. Standard output and error streams are captured and forwarded to the parent process' standard output. Each line is prefixed with the current tim...
[ "def", "run_once", "(", "name", ",", "cmd", ",", "env", ",", "shutdown", ",", "loop", "=", "None", ",", "utc", "=", "False", ")", ":", "# Get the default event loop if necessary.", "loop", "=", "loop", "or", "asyncio", ".", "get_event_loop", "(", ")", "# L...
Starts a child process and waits for its completion. .. note:: This function is a coroutine. Standard output and error streams are captured and forwarded to the parent process' standard output. Each line is prefixed with the current time (as measured by the parent process) and the child process ``nam...
[ "Starts", "a", "child", "process", "and", "waits", "for", "its", "completion", "." ]
train
https://github.com/smartmob-project/strawboss/blob/b295a7d0e3c1d95c4bb687f7f1bcae9605b3bbdc/strawboss/__init__.py#L85-L192
smartmob-project/strawboss
strawboss/__init__.py
run_and_respawn
def run_and_respawn(shutdown, loop=None, **kwds): """Starts a child process and re-spawns it every time it completes. .. note:: This function is a coroutine. :param shutdown: Future that the caller will fulfill to indicate that the process should not be re-spawned. It is also passed to ``run_once(...
python
def run_and_respawn(shutdown, loop=None, **kwds): """Starts a child process and re-spawns it every time it completes. .. note:: This function is a coroutine. :param shutdown: Future that the caller will fulfill to indicate that the process should not be re-spawned. It is also passed to ``run_once(...
[ "def", "run_and_respawn", "(", "shutdown", ",", "loop", "=", "None", ",", "*", "*", "kwds", ")", ":", "# Get the default event loop if necessary.", "loop", "=", "loop", "or", "asyncio", ".", "get_event_loop", "(", ")", "while", "not", "shutdown", ".", "done", ...
Starts a child process and re-spawns it every time it completes. .. note:: This function is a coroutine. :param shutdown: Future that the caller will fulfill to indicate that the process should not be re-spawned. It is also passed to ``run_once()`` to indicate that the currently running process...
[ "Starts", "a", "child", "process", "and", "re", "-", "spawns", "it", "every", "time", "it", "completes", "." ]
train
https://github.com/smartmob-project/strawboss/blob/b295a7d0e3c1d95c4bb687f7f1bcae9605b3bbdc/strawboss/__init__.py#L196-L217
smartmob-project/strawboss
strawboss/__init__.py
main
def main(arguments=None): """Command-line entry point. :param arguments: List of strings that contain the command-line arguments. When ``None``, the command-line arguments are looked up in ``sys.argv`` (``sys.argv[0]`` is ignored). :return: This function has no return value. :raise System...
python
def main(arguments=None): """Command-line entry point. :param arguments: List of strings that contain the command-line arguments. When ``None``, the command-line arguments are looked up in ``sys.argv`` (``sys.argv[0]`` is ignored). :return: This function has no return value. :raise System...
[ "def", "main", "(", "arguments", "=", "None", ")", ":", "# Parse command-line arguments.", "if", "arguments", "is", "None", ":", "arguments", "=", "sys", ".", "argv", "[", "1", ":", "]", "arguments", "=", "cli", ".", "parse_args", "(", "arguments", ")", ...
Command-line entry point. :param arguments: List of strings that contain the command-line arguments. When ``None``, the command-line arguments are looked up in ``sys.argv`` (``sys.argv[0]`` is ignored). :return: This function has no return value. :raise SystemExit: The command-line arguments ...
[ "Command", "-", "line", "entry", "point", "." ]
train
https://github.com/smartmob-project/strawboss/blob/b295a7d0e3c1d95c4bb687f7f1bcae9605b3bbdc/strawboss/__init__.py#L234-L311
timeyyy/apptools
peasoup/uploadlogs.py
add_date
def add_date(log): '''Userful for randomizing the name of a log''' return '{base} - {time}.log'.format( base=os.path.splitext(log)[0], time=strftime("%a, %d %b %Y %H-%M-%S", gmtime()))
python
def add_date(log): '''Userful for randomizing the name of a log''' return '{base} - {time}.log'.format( base=os.path.splitext(log)[0], time=strftime("%a, %d %b %Y %H-%M-%S", gmtime()))
[ "def", "add_date", "(", "log", ")", ":", "return", "'{base} - {time}.log'", ".", "format", "(", "base", "=", "os", ".", "path", ".", "splitext", "(", "log", ")", "[", "0", "]", ",", "time", "=", "strftime", "(", "\"%a, %d %b %Y %H-%M-%S\"", ",", "gmtime"...
Userful for randomizing the name of a log
[ "Userful", "for", "randomizing", "the", "name", "of", "a", "log" ]
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L133-L137
timeyyy/apptools
peasoup/uploadlogs.py
LogUploader.logexception
def logexception(self, logger=None): ''' calls exception method on a loger and prints the log to stdout logger is set in the cfg #Todo more details here on the cfg etc :param logger: :return: ''' traceback.print_exc() if logger: logger...
python
def logexception(self, logger=None): ''' calls exception method on a loger and prints the log to stdout logger is set in the cfg #Todo more details here on the cfg etc :param logger: :return: ''' traceback.print_exc() if logger: logger...
[ "def", "logexception", "(", "self", ",", "logger", "=", "None", ")", ":", "traceback", ".", "print_exc", "(", ")", "if", "logger", ":", "logger", ".", "exception", "(", "'Unexpected runtime Error...'", ")", "else", ":", "self", ".", "logger", ".", "excepti...
calls exception method on a loger and prints the log to stdout logger is set in the cfg #Todo more details here on the cfg etc :param logger: :return:
[ "calls", "exception", "method", "on", "a", "loger", "and", "prints", "the", "log", "to", "stdout", "logger", "is", "set", "in", "the", "cfg", "#Todo", "more", "details", "here", "on", "the", "cfg", "etc", ":", "param", "logger", ":", ":", "return", ":"...
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L31-L43
timeyyy/apptools
peasoup/uploadlogs.py
LogUploader.upload_logs
def upload_logs(self, release_singleton=True): ''' uploads a log to a server using the method and gui specifed in self.pcfg singleton mode can be disabled so a new version can be restarted whille uploading oges on typicallin in the case of uploadnig after a crash or sys exit ...
python
def upload_logs(self, release_singleton=True): ''' uploads a log to a server using the method and gui specifed in self.pcfg singleton mode can be disabled so a new version can be restarted whille uploading oges on typicallin in the case of uploadnig after a crash or sys exit ...
[ "def", "upload_logs", "(", "self", ",", "release_singleton", "=", "True", ")", ":", "if", "release_singleton", ":", "self", ".", "release_singleton", "(", ")", "def", "_upload", "(", ")", ":", "for", "log", "in", "self", ".", "get_logs", "(", ")", ":", ...
uploads a log to a server using the method and gui specifed in self.pcfg singleton mode can be disabled so a new version can be restarted whille uploading oges on typicallin in the case of uploadnig after a crash or sys exit set self.cfg log_upload_interface to gui/cli/or background
[ "uploads", "a", "log", "to", "a", "server", "using", "the", "method", "and", "gui", "specifed", "in", "self", ".", "pcfg", "singleton", "mode", "can", "be", "disabled", "so", "a", "new", "version", "can", "be", "restarted", "whille", "uploading", "oges", ...
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L45-L70
timeyyy/apptools
peasoup/uploadlogs.py
LogUploader.delete_log
def delete_log(self, log): '''check we don't delte anythin unintended''' if os.path.splitext(log)[-1] != '.log': raise Exception('File without .log was passed in for deletoin') with suppress(Exception): os.remove(log)
python
def delete_log(self, log): '''check we don't delte anythin unintended''' if os.path.splitext(log)[-1] != '.log': raise Exception('File without .log was passed in for deletoin') with suppress(Exception): os.remove(log)
[ "def", "delete_log", "(", "self", ",", "log", ")", ":", "if", "os", ".", "path", ".", "splitext", "(", "log", ")", "[", "-", "1", "]", "!=", "'.log'", ":", "raise", "Exception", "(", "'File without .log was passed in for deletoin'", ")", "with", "suppress"...
check we don't delte anythin unintended
[ "check", "we", "don", "t", "delte", "anythin", "unintended" ]
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L72-L77
timeyyy/apptools
peasoup/uploadlogs.py
LogUploader.get_logs
def get_logs(self): '''returns logs from disk, requires .log extenstion''' folder = os.path.dirname(self.pcfg['log_file']) for path, dir, files in os.walk(folder): for file in files: if os.path.splitext(file)[-1] == '.log': yield os.path.join(path,...
python
def get_logs(self): '''returns logs from disk, requires .log extenstion''' folder = os.path.dirname(self.pcfg['log_file']) for path, dir, files in os.walk(folder): for file in files: if os.path.splitext(file)[-1] == '.log': yield os.path.join(path,...
[ "def", "get_logs", "(", "self", ")", ":", "folder", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "pcfg", "[", "'log_file'", "]", ")", "for", "path", ",", "dir", ",", "files", "in", "os", ".", "walk", "(", "folder", ")", ":", "for", ...
returns logs from disk, requires .log extenstion
[ "returns", "logs", "from", "disk", "requires", ".", "log", "extenstion" ]
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L80-L86
timeyyy/apptools
peasoup/uploadlogs.py
LogUploader._uniquename
def _uniquename(self, log): ''' renames the log to ensure we get no clashes on the server subclass this to change the path etc''' return '{hostname} - {time}.log'.format( hostname=os.getenv('USERNAME'), time=strftime("%a, %d...
python
def _uniquename(self, log): ''' renames the log to ensure we get no clashes on the server subclass this to change the path etc''' return '{hostname} - {time}.log'.format( hostname=os.getenv('USERNAME'), time=strftime("%a, %d...
[ "def", "_uniquename", "(", "self", ",", "log", ")", ":", "return", "'{hostname} - {time}.log'", ".", "format", "(", "hostname", "=", "os", ".", "getenv", "(", "'USERNAME'", ")", ",", "time", "=", "strftime", "(", "\"%a, %d %b %Y %H-%M-%S\"", ",", "gmtime", "...
renames the log to ensure we get no clashes on the server subclass this to change the path etc
[ "renames", "the", "log", "to", "ensure", "we", "get", "no", "clashes", "on", "the", "server", "subclass", "this", "to", "change", "the", "path", "etc" ]
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L89-L95
timeyyy/apptools
peasoup/uploadlogs.py
LogUploader.rot13
def rot13(self, encrypyted): ''' Very secure encryption (ceaser used it), apply it multiple times''' def random(): # guarnteed random from fair dice roll return 4 return codecs.encode( codecs.encode( crypto(encrypyte...
python
def rot13(self, encrypyted): ''' Very secure encryption (ceaser used it), apply it multiple times''' def random(): # guarnteed random from fair dice roll return 4 return codecs.encode( codecs.encode( crypto(encrypyte...
[ "def", "rot13", "(", "self", ",", "encrypyted", ")", ":", "def", "random", "(", ")", ":", "# guarnteed random from fair dice roll", "return", "4", "return", "codecs", ".", "encode", "(", "codecs", ".", "encode", "(", "crypto", "(", "encrypyted", ")", ".", ...
Very secure encryption (ceaser used it), apply it multiple times
[ "Very", "secure", "encryption", "(", "ceaser", "used", "it", ")", "apply", "it", "multiple", "times" ]
train
https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/uploadlogs.py#L122-L131
jalanb/pysyte
pysyte/args.py
parser
def parser(description=None, usage=None): """Parse out command line arguments""" class ArgNamespace(object): def __init__(self, result): self._result = result def __getattr__(self, name): try: super(ArgNamespace, self).__getattr__(name) excep...
python
def parser(description=None, usage=None): """Parse out command line arguments""" class ArgNamespace(object): def __init__(self, result): self._result = result def __getattr__(self, name): try: super(ArgNamespace, self).__getattr__(name) excep...
[ "def", "parser", "(", "description", "=", "None", ",", "usage", "=", "None", ")", ":", "class", "ArgNamespace", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "result", ")", ":", "self", ".", "_result", "=", "result", "def", "__getattr__...
Parse out command line arguments
[ "Parse", "out", "command", "line", "arguments" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/args.py#L29-L84
jalanb/pysyte
pysyte/args.py
arg_strings
def arg_strings(parsed_args, name=None): """A list of all strings for the named arg""" name = name or 'arg_strings' value = getattr(parsed_args, name, []) if isinstance(value, str): return [value] try: return [v for v in value if isinstance(v, str)] except TypeError: retu...
python
def arg_strings(parsed_args, name=None): """A list of all strings for the named arg""" name = name or 'arg_strings' value = getattr(parsed_args, name, []) if isinstance(value, str): return [value] try: return [v for v in value if isinstance(v, str)] except TypeError: retu...
[ "def", "arg_strings", "(", "parsed_args", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "'arg_strings'", "value", "=", "getattr", "(", "parsed_args", ",", "name", ",", "[", "]", ")", "if", "isinstance", "(", "value", ",", "str", ")", ...
A list of all strings for the named arg
[ "A", "list", "of", "all", "strings", "for", "the", "named", "arg" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/args.py#L87-L96
pydron/twistit
twistit/_events.py
Event.next_event
def next_event(self, canceller=None): """ Returns a :class:`~defer.Deferred` that will be called back with the value of the next event. """ d = defer.Deferred(canceller) def cb(value): self.remove_callback(d.callback) return value ...
python
def next_event(self, canceller=None): """ Returns a :class:`~defer.Deferred` that will be called back with the value of the next event. """ d = defer.Deferred(canceller) def cb(value): self.remove_callback(d.callback) return value ...
[ "def", "next_event", "(", "self", ",", "canceller", "=", "None", ")", ":", "d", "=", "defer", ".", "Deferred", "(", "canceller", ")", "def", "cb", "(", "value", ")", ":", "self", ".", "remove_callback", "(", "d", ".", "callback", ")", "return", "valu...
Returns a :class:`~defer.Deferred` that will be called back with the value of the next event.
[ "Returns", "a", ":", "class", ":", "~defer", ".", "Deferred", "that", "will", "be", "called", "back", "with", "the", "value", "of", "the", "next", "event", "." ]
train
https://github.com/pydron/twistit/blob/23ac43b830083fd32c400fcdfa5300e302769c74/twistit/_events.py#L54-L67
pydron/twistit
twistit/_events.py
Event.derive
def derive(self, modifier): """ Returns a new :class:`Event` instance that will fire when this event fires. The value passed to the callbacks to the new event is the return value of the given `modifier` function which is passed the original value. """ def forward(...
python
def derive(self, modifier): """ Returns a new :class:`Event` instance that will fire when this event fires. The value passed to the callbacks to the new event is the return value of the given `modifier` function which is passed the original value. """ def forward(...
[ "def", "derive", "(", "self", ",", "modifier", ")", ":", "def", "forward", "(", "value", ")", ":", "changed_value", "=", "modifier", "(", "value", ")", "derived", ".", "fire", "(", "changed_value", ")", "derived", "=", "Event", "(", ")", "self", ".", ...
Returns a new :class:`Event` instance that will fire when this event fires. The value passed to the callbacks to the new event is the return value of the given `modifier` function which is passed the original value.
[ "Returns", "a", "new", ":", "class", ":", "Event", "instance", "that", "will", "fire", "when", "this", "event", "fires", ".", "The", "value", "passed", "to", "the", "callbacks", "to", "the", "new", "event", "is", "the", "return", "value", "of", "the", ...
train
https://github.com/pydron/twistit/blob/23ac43b830083fd32c400fcdfa5300e302769c74/twistit/_events.py#L77-L90
brycepg/mand
mand/util.py
create_module_file
def create_module_file(txt, directory): """Create a file in the given directory with a valid module name populated with the given txt. Returns: A path to the file""" name = nonpresent_module_filename() path = os.path.join(directory, name) with open(path, 'w') as fh: fh.write(txt...
python
def create_module_file(txt, directory): """Create a file in the given directory with a valid module name populated with the given txt. Returns: A path to the file""" name = nonpresent_module_filename() path = os.path.join(directory, name) with open(path, 'w') as fh: fh.write(txt...
[ "def", "create_module_file", "(", "txt", ",", "directory", ")", ":", "name", "=", "nonpresent_module_filename", "(", ")", "path", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "name", ")", "with", "open", "(", "path", ",", "'w'", ")", "as...
Create a file in the given directory with a valid module name populated with the given txt. Returns: A path to the file
[ "Create", "a", "file", "in", "the", "given", "directory", "with", "a", "valid", "module", "name", "populated", "with", "the", "given", "txt", "." ]
train
https://github.com/brycepg/mand/blob/3a8f9c1cc1bbe217aaca8c805113285ab02ecb7c/mand/util.py#L14-L24
brycepg/mand
mand/util.py
nonpresent_module_filename
def nonpresent_module_filename(): """Return module name that doesn't already exist""" while True: module_name = get_random_name() loader = pkgutil.find_loader(module_name) if loader is not None: continue importlib.invalidate_caches() return "{}.py".format(modu...
python
def nonpresent_module_filename(): """Return module name that doesn't already exist""" while True: module_name = get_random_name() loader = pkgutil.find_loader(module_name) if loader is not None: continue importlib.invalidate_caches() return "{}.py".format(modu...
[ "def", "nonpresent_module_filename", "(", ")", ":", "while", "True", ":", "module_name", "=", "get_random_name", "(", ")", "loader", "=", "pkgutil", ".", "find_loader", "(", "module_name", ")", "if", "loader", "is", "not", "None", ":", "continue", "importlib",...
Return module name that doesn't already exist
[ "Return", "module", "name", "that", "doesn", "t", "already", "exist" ]
train
https://github.com/brycepg/mand/blob/3a8f9c1cc1bbe217aaca8c805113285ab02ecb7c/mand/util.py#L42-L50
brycepg/mand
mand/util.py
get_random_name
def get_random_name(): """Return random lowercase name""" char_seq = [] name_source = random.randint(1, 2**8-1) current_value = name_source while current_value > 0: char_offset = current_value % 26 current_value = current_value - random.randint(1, 26) char_seq.append(chr(char...
python
def get_random_name(): """Return random lowercase name""" char_seq = [] name_source = random.randint(1, 2**8-1) current_value = name_source while current_value > 0: char_offset = current_value % 26 current_value = current_value - random.randint(1, 26) char_seq.append(chr(char...
[ "def", "get_random_name", "(", ")", ":", "char_seq", "=", "[", "]", "name_source", "=", "random", ".", "randint", "(", "1", ",", "2", "**", "8", "-", "1", ")", "current_value", "=", "name_source", "while", "current_value", ">", "0", ":", "char_offset", ...
Return random lowercase name
[ "Return", "random", "lowercase", "name" ]
train
https://github.com/brycepg/mand/blob/3a8f9c1cc1bbe217aaca8c805113285ab02ecb7c/mand/util.py#L53-L64
ironfroggy/django-better-cache
bettercache/utils.py
get_header_dict
def get_header_dict(response, header): """ returns a dictionary of the cache control headers the same as is used by django.utils.cache.patch_cache_control if there are no Cache-Control headers returns and empty dict """ def dictitem(s): t = s.split('=', 1) if len(t) > 1: ...
python
def get_header_dict(response, header): """ returns a dictionary of the cache control headers the same as is used by django.utils.cache.patch_cache_control if there are no Cache-Control headers returns and empty dict """ def dictitem(s): t = s.split('=', 1) if len(t) > 1: ...
[ "def", "get_header_dict", "(", "response", ",", "header", ")", ":", "def", "dictitem", "(", "s", ")", ":", "t", "=", "s", ".", "split", "(", "'='", ",", "1", ")", "if", "len", "(", "t", ")", ">", "1", ":", "return", "(", "t", "[", "0", "]", ...
returns a dictionary of the cache control headers the same as is used by django.utils.cache.patch_cache_control if there are no Cache-Control headers returns and empty dict
[ "returns", "a", "dictionary", "of", "the", "cache", "control", "headers", "the", "same", "as", "is", "used", "by", "django", ".", "utils", ".", "cache", ".", "patch_cache_control", "if", "there", "are", "no", "Cache", "-", "Control", "headers", "returns", ...
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L161-L177
ironfroggy/django-better-cache
bettercache/utils.py
set_header_dict
def set_header_dict(response, header, header_dict): """Formats and sets a header dict in a response, inververs of get_header_dict.""" def dictvalue(t): if t[1] is True: return t[0] return t[0] + '=' + smart_str(t[1]) response[header] = ', '.join([dictvalue(el) for el in header_d...
python
def set_header_dict(response, header, header_dict): """Formats and sets a header dict in a response, inververs of get_header_dict.""" def dictvalue(t): if t[1] is True: return t[0] return t[0] + '=' + smart_str(t[1]) response[header] = ', '.join([dictvalue(el) for el in header_d...
[ "def", "set_header_dict", "(", "response", ",", "header", ",", "header_dict", ")", ":", "def", "dictvalue", "(", "t", ")", ":", "if", "t", "[", "1", "]", "is", "True", ":", "return", "t", "[", "0", "]", "return", "t", "[", "0", "]", "+", "'='", ...
Formats and sets a header dict in a response, inververs of get_header_dict.
[ "Formats", "and", "sets", "a", "header", "dict", "in", "a", "response", "inververs", "of", "get_header_dict", "." ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L179-L186
ironfroggy/django-better-cache
bettercache/utils.py
smart_import
def smart_import(mpath): """Given a path smart_import will import the module and return the attr reffered to.""" try: rest = __import__(mpath) except ImportError: split = mpath.split('.') rest = smart_import('.'.join(split[:-1])) rest = getattr(rest, split[-1]) return res...
python
def smart_import(mpath): """Given a path smart_import will import the module and return the attr reffered to.""" try: rest = __import__(mpath) except ImportError: split = mpath.split('.') rest = smart_import('.'.join(split[:-1])) rest = getattr(rest, split[-1]) return res...
[ "def", "smart_import", "(", "mpath", ")", ":", "try", ":", "rest", "=", "__import__", "(", "mpath", ")", "except", "ImportError", ":", "split", "=", "mpath", ".", "split", "(", "'.'", ")", "rest", "=", "smart_import", "(", "'.'", ".", "join", "(", "s...
Given a path smart_import will import the module and return the attr reffered to.
[ "Given", "a", "path", "smart_import", "will", "import", "the", "module", "and", "return", "the", "attr", "reffered", "to", "." ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L188-L196
ironfroggy/django-better-cache
bettercache/utils.py
strip_wsgi
def strip_wsgi(request): """Strip WSGI data out of the request META data.""" meta = copy(request.META) for key in meta: if key[:4] == 'wsgi': meta[key] = None return meta
python
def strip_wsgi(request): """Strip WSGI data out of the request META data.""" meta = copy(request.META) for key in meta: if key[:4] == 'wsgi': meta[key] = None return meta
[ "def", "strip_wsgi", "(", "request", ")", ":", "meta", "=", "copy", "(", "request", ".", "META", ")", "for", "key", "in", "meta", ":", "if", "key", "[", ":", "4", "]", "==", "'wsgi'", ":", "meta", "[", "key", "]", "=", "None", "return", "meta" ]
Strip WSGI data out of the request META data.
[ "Strip", "WSGI", "data", "out", "of", "the", "request", "META", "data", "." ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L198-L205
ironfroggy/django-better-cache
bettercache/utils.py
CachingMixin.patch_headers
def patch_headers(self, response): """Set the headers we want for caching.""" # Remove Vary:Cookie if we want to cache non-anonymous if not getattr(settings, 'BETTERCACHE_ANONYMOUS_ONLY', False): vdict = get_header_dict(response, 'Vary') try: vdict.pop('c...
python
def patch_headers(self, response): """Set the headers we want for caching.""" # Remove Vary:Cookie if we want to cache non-anonymous if not getattr(settings, 'BETTERCACHE_ANONYMOUS_ONLY', False): vdict = get_header_dict(response, 'Vary') try: vdict.pop('c...
[ "def", "patch_headers", "(", "self", ",", "response", ")", ":", "# Remove Vary:Cookie if we want to cache non-anonymous", "if", "not", "getattr", "(", "settings", ",", "'BETTERCACHE_ANONYMOUS_ONLY'", ",", "False", ")", ":", "vdict", "=", "get_header_dict", "(", "respo...
Set the headers we want for caching.
[ "Set", "the", "headers", "we", "want", "for", "caching", "." ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L18-L50
ironfroggy/django-better-cache
bettercache/utils.py
CachingMixin.should_cache
def should_cache(self, request, response): """ Given the request and response should it be cached """ if not getattr(request, '_cache_update_cache', False): return False if not response.status_code in getattr(settings, 'BETTERCACHE_CACHEABLE_STATUS', CACHEABLE_STATUS): r...
python
def should_cache(self, request, response): """ Given the request and response should it be cached """ if not getattr(request, '_cache_update_cache', False): return False if not response.status_code in getattr(settings, 'BETTERCACHE_CACHEABLE_STATUS', CACHEABLE_STATUS): r...
[ "def", "should_cache", "(", "self", ",", "request", ",", "response", ")", ":", "if", "not", "getattr", "(", "request", ",", "'_cache_update_cache'", ",", "False", ")", ":", "return", "False", "if", "not", "response", ".", "status_code", "in", "getattr", "(...
Given the request and response should it be cached
[ "Given", "the", "request", "and", "response", "should", "it", "be", "cached" ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L61-L72
ironfroggy/django-better-cache
bettercache/utils.py
CachingMixin.should_regenerate
def should_regenerate(self, response): """ Check if this page was originally generated less than LOCAL_POSTCHECK seconds ago """ if response.has_header('Last-Modified'): last_modified = parse_http_date(response['Last-Modified']) next_regen = last_modified + settings.BETTERCACHE_...
python
def should_regenerate(self, response): """ Check if this page was originally generated less than LOCAL_POSTCHECK seconds ago """ if response.has_header('Last-Modified'): last_modified = parse_http_date(response['Last-Modified']) next_regen = last_modified + settings.BETTERCACHE_...
[ "def", "should_regenerate", "(", "self", ",", "response", ")", ":", "if", "response", ".", "has_header", "(", "'Last-Modified'", ")", ":", "last_modified", "=", "parse_http_date", "(", "response", "[", "'Last-Modified'", "]", ")", "next_regen", "=", "last_modifi...
Check if this page was originally generated less than LOCAL_POSTCHECK seconds ago
[ "Check", "if", "this", "page", "was", "originally", "generated", "less", "than", "LOCAL_POSTCHECK", "seconds", "ago" ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L85-L91
ironfroggy/django-better-cache
bettercache/utils.py
CachingMixin.has_uncacheable_headers
def has_uncacheable_headers(self, response): """ Should this response be cached based on it's headers broken out from should_cache for flexibility """ cc_dict = get_header_dict(response, 'Cache-Control') if cc_dict: if 'max-age' in cc_dict and cc_dict['max-age'] ...
python
def has_uncacheable_headers(self, response): """ Should this response be cached based on it's headers broken out from should_cache for flexibility """ cc_dict = get_header_dict(response, 'Cache-Control') if cc_dict: if 'max-age' in cc_dict and cc_dict['max-age'] ...
[ "def", "has_uncacheable_headers", "(", "self", ",", "response", ")", ":", "cc_dict", "=", "get_header_dict", "(", "response", ",", "'Cache-Control'", ")", "if", "cc_dict", ":", "if", "'max-age'", "in", "cc_dict", "and", "cc_dict", "[", "'max-age'", "]", "==", ...
Should this response be cached based on it's headers broken out from should_cache for flexibility
[ "Should", "this", "response", "be", "cached", "based", "on", "it", "s", "headers", "broken", "out", "from", "should_cache", "for", "flexibility" ]
train
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/utils.py#L93-L109