repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
fitnr/twitter_bot_utils
twitter_bot_utils/helpers.py
chomp
def chomp(text, max_len=280, split=None): ''' Shorten a string so that it fits under max_len, splitting it at 'split'. Not guaranteed to return a string under max_len, as it may not be possible Args: text (str): String to shorten max_len (int): maximum length. default 140 split ...
python
def chomp(text, max_len=280, split=None): ''' Shorten a string so that it fits under max_len, splitting it at 'split'. Not guaranteed to return a string under max_len, as it may not be possible Args: text (str): String to shorten max_len (int): maximum length. default 140 split ...
[ "def", "chomp", "(", "text", ",", "max_len", "=", "280", ",", "split", "=", "None", ")", ":", "split", "=", "split", "or", "'—;,.'", "while", "length", "(", "text", ")", ">", "max_len", ":", "try", ":", "text", "=", "re", ".", "split", "(", "r'['...
Shorten a string so that it fits under max_len, splitting it at 'split'. Not guaranteed to return a string under max_len, as it may not be possible Args: text (str): String to shorten max_len (int): maximum length. default 140 split (str): strings to split on (default is common punctuat...
[ "Shorten", "a", "string", "so", "that", "it", "fits", "under", "max_len", "splitting", "it", "at", "split", ".", "Not", "guaranteed", "to", "return", "a", "string", "under", "max_len", "as", "it", "may", "not", "be", "possible" ]
train
https://github.com/fitnr/twitter_bot_utils/blob/21f35afa5048cd3efa54db8cb87d405f69a78a62/twitter_bot_utils/helpers.py#L184-L201
fitnr/twitter_bot_utils
twitter_bot_utils/helpers.py
length
def length(text, maxval=None, encoding=None): ''' Count the length of a str the way Twitter does, double-counting "wide" characters (e.g. ideographs, emoji) Args: text (str): Text to count. Must be a unicode string in Python 2 maxval (int): The maximum encoding that will be counted as 1...
python
def length(text, maxval=None, encoding=None): ''' Count the length of a str the way Twitter does, double-counting "wide" characters (e.g. ideographs, emoji) Args: text (str): Text to count. Must be a unicode string in Python 2 maxval (int): The maximum encoding that will be counted as 1...
[ "def", "length", "(", "text", ",", "maxval", "=", "None", ",", "encoding", "=", "None", ")", ":", "maxval", "=", "maxval", "or", "4351", "try", ":", "assert", "not", "isinstance", "(", "text", ",", "six", ".", "binary_type", ")", "except", "AssertionEr...
Count the length of a str the way Twitter does, double-counting "wide" characters (e.g. ideographs, emoji) Args: text (str): Text to count. Must be a unicode string in Python 2 maxval (int): The maximum encoding that will be counted as 1 character. Defaults to 4351 (ჿ GEORGIAN LETTE...
[ "Count", "the", "length", "of", "a", "str", "the", "way", "Twitter", "does", "double", "-", "counting", "wide", "characters", "(", "e", ".", "g", ".", "ideographs", "emoji", ")" ]
train
https://github.com/fitnr/twitter_bot_utils/blob/21f35afa5048cd3efa54db8cb87d405f69a78a62/twitter_bot_utils/helpers.py#L204-L222
carta/franz
franz/rabbitmq/producer.py
Producer._send_message_to_topic
def _send_message_to_topic(self, topic, message, correlation_id=None): """ Send a message to RabbitMQ based on the routing key (topic). Parameters ---------- topic : str The routing key (topic) where the message should be sent to. message : FranzEvent ...
python
def _send_message_to_topic(self, topic, message, correlation_id=None): """ Send a message to RabbitMQ based on the routing key (topic). Parameters ---------- topic : str The routing key (topic) where the message should be sent to. message : FranzEvent ...
[ "def", "_send_message_to_topic", "(", "self", ",", "topic", ",", "message", ",", "correlation_id", "=", "None", ")", ":", "exchange", "=", "self", ".", "get_exchange_name", "(", "topic", ")", "self", ".", "_channel", ".", "exchange_declare", "(", "exchange", ...
Send a message to RabbitMQ based on the routing key (topic). Parameters ---------- topic : str The routing key (topic) where the message should be sent to. message : FranzEvent The message to be sent. Raises ------ franz.InvalidMessage
[ "Send", "a", "message", "to", "RabbitMQ", "based", "on", "the", "routing", "key", "(", "topic", ")", "." ]
train
https://github.com/carta/franz/blob/85678878eee8dad0fbe933d0cff819c2d16caa12/franz/rabbitmq/producer.py#L59-L85
quantmind/pulsar-odm
odm/utils.py
get_columns
def get_columns(mixed): """ Return a collection of all Column objects for given SQLAlchemy object. The type of the collection depends on the type of the object to return the columns from. :: get_columns(User) get_columns(User()) get_columns(User.__table__) get_col...
python
def get_columns(mixed): """ Return a collection of all Column objects for given SQLAlchemy object. The type of the collection depends on the type of the object to return the columns from. :: get_columns(User) get_columns(User()) get_columns(User.__table__) get_col...
[ "def", "get_columns", "(", "mixed", ")", ":", "if", "isinstance", "(", "mixed", ",", "sa", ".", "Table", ")", ":", "return", "mixed", ".", "c", "if", "isinstance", "(", "mixed", ",", "sa", ".", "orm", ".", "util", ".", "AliasedClass", ")", ":", "re...
Return a collection of all Column objects for given SQLAlchemy object. The type of the collection depends on the type of the object to return the columns from. :: get_columns(User) get_columns(User()) get_columns(User.__table__) get_columns(User.__mapper__) get_co...
[ "Return", "a", "collection", "of", "all", "Column", "objects", "for", "given", "SQLAlchemy", "object", ".", "The", "type", "of", "the", "collection", "depends", "on", "the", "type", "of", "the", "object", "to", "return", "the", "columns", "from", ".", "::"...
train
https://github.com/quantmind/pulsar-odm/blob/5955c20beca0a89270c2b390335838deb7d5915e/odm/utils.py#L9-L37
PMBio/limix-backup
limix/deprecated/core.py
train_associations_SingleSNP
def train_associations_SingleSNP(X, Y, U, S, C, numintervals, ldeltamin, ldeltamax): """ train_associations_SingleSNP(MatrixXd const & X, MatrixXd const & Y, MatrixXd const & U, MatrixXd const & S, MatrixXd const & C, int numintervals, double ldeltamin, double ldeltamax) Parameters ---------- X: Ma...
python
def train_associations_SingleSNP(X, Y, U, S, C, numintervals, ldeltamin, ldeltamax): """ train_associations_SingleSNP(MatrixXd const & X, MatrixXd const & Y, MatrixXd const & U, MatrixXd const & S, MatrixXd const & C, int numintervals, double ldeltamin, double ldeltamax) Parameters ---------- X: Ma...
[ "def", "train_associations_SingleSNP", "(", "X", ",", "Y", ",", "U", ",", "S", ",", "C", ",", "numintervals", ",", "ldeltamin", ",", "ldeltamax", ")", ":", "return", "_core", ".", "train_associations_SingleSNP", "(", "X", ",", "Y", ",", "U", ",", "S", ...
train_associations_SingleSNP(MatrixXd const & X, MatrixXd const & Y, MatrixXd const & U, MatrixXd const & S, MatrixXd const & C, int numintervals, double ldeltamin, double ldeltamax) Parameters ---------- X: MatrixXd const & Y: MatrixXd const & U: MatrixXd const & S: MatrixXd const & C: Mat...
[ "train_associations_SingleSNP", "(", "MatrixXd", "const", "&", "X", "MatrixXd", "const", "&", "Y", "MatrixXd", "const", "&", "U", "MatrixXd", "const", "&", "S", "MatrixXd", "const", "&", "C", "int", "numintervals", "double", "ldeltamin", "double", "ldeltamax", ...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11876-L11892
PMBio/limix-backup
limix/deprecated/core.py
optdelta
def optdelta(UY, UX, S, numintervals, ldeltamin, ldeltamax, REML=False): """ optdelta(MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, int numintervals, double ldeltamin, double ldeltamax, bool REML=False) -> double Parameters ---------- UY: MatrixXd const & UX: MatrixXd const & ...
python
def optdelta(UY, UX, S, numintervals, ldeltamin, ldeltamax, REML=False): """ optdelta(MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, int numintervals, double ldeltamin, double ldeltamax, bool REML=False) -> double Parameters ---------- UY: MatrixXd const & UX: MatrixXd const & ...
[ "def", "optdelta", "(", "UY", ",", "UX", ",", "S", ",", "numintervals", ",", "ldeltamin", ",", "ldeltamax", ",", "REML", "=", "False", ")", ":", "return", "_core", ".", "optdelta", "(", "UY", ",", "UX", ",", "S", ",", "numintervals", ",", "ldeltamin"...
optdelta(MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, int numintervals, double ldeltamin, double ldeltamax, bool REML=False) -> double Parameters ---------- UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & numintervals: int ldeltamin: double ldeltamax: doub...
[ "optdelta", "(", "MatrixXd", "const", "&", "UY", "MatrixXd", "const", "&", "UX", "MatrixXd", "const", "&", "S", "int", "numintervals", "double", "ldeltamin", "double", "ldeltamax", "bool", "REML", "=", "False", ")", "-", ">", "double" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11894-L11920
PMBio/limix-backup
limix/deprecated/core.py
optdeltaAllY
def optdeltaAllY(UY, UX, S, ldeltagrid): """ optdeltaAllY(MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, MatrixXd const & ldeltagrid) Parameters ---------- UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & ldeltagrid: MatrixXd const & """ return _core...
python
def optdeltaAllY(UY, UX, S, ldeltagrid): """ optdeltaAllY(MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, MatrixXd const & ldeltagrid) Parameters ---------- UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & ldeltagrid: MatrixXd const & """ return _core...
[ "def", "optdeltaAllY", "(", "UY", ",", "UX", ",", "S", ",", "ldeltagrid", ")", ":", "return", "_core", ".", "optdeltaAllY", "(", "UY", ",", "UX", ",", "S", ",", "ldeltagrid", ")" ]
optdeltaAllY(MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, MatrixXd const & ldeltagrid) Parameters ---------- UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & ldeltagrid: MatrixXd const &
[ "optdeltaAllY", "(", "MatrixXd", "const", "&", "UY", "MatrixXd", "const", "&", "UX", "MatrixXd", "const", "&", "S", "MatrixXd", "const", "&", "ldeltagrid", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11922-L11934
PMBio/limix-backup
limix/deprecated/core.py
nLLeval
def nLLeval(ldelta, UY, UX, S, REML=False): """ nLLeval(double ldelta, MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, bool REML=False) -> double Parameters ---------- ldelta: double UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & REML: bool nLLeval(...
python
def nLLeval(ldelta, UY, UX, S, REML=False): """ nLLeval(double ldelta, MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, bool REML=False) -> double Parameters ---------- ldelta: double UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & REML: bool nLLeval(...
[ "def", "nLLeval", "(", "ldelta", ",", "UY", ",", "UX", ",", "S", ",", "REML", "=", "False", ")", ":", "return", "_core", ".", "nLLeval", "(", "ldelta", ",", "UY", ",", "UX", ",", "S", ",", "REML", ")" ]
nLLeval(double ldelta, MatrixXd const & UY, MatrixXd const & UX, MatrixXd const & S, bool REML=False) -> double Parameters ---------- ldelta: double UY: MatrixXd const & UX: MatrixXd const & S: MatrixXd const & REML: bool nLLeval(double ldelta, MatrixXd const & UY, MatrixXd const & UX,...
[ "nLLeval", "(", "double", "ldelta", "MatrixXd", "const", "&", "UY", "MatrixXd", "const", "&", "UX", "MatrixXd", "const", "&", "S", "bool", "REML", "=", "False", ")", "-", ">", "double" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11936-L11958
PMBio/limix-backup
limix/deprecated/core.py
nLLevalAllY
def nLLevalAllY(ldelta, UY, UX, S): """ nLLevalAllY(double ldelta, MatrixXd const & UY, MatrixXd const & UX, VectorXd const & S) Parameters ---------- ldelta: double UY: MatrixXd const & UX: MatrixXd const & S: VectorXd const & """ return _core.nLLevalAllY(ldelta, UY, UX, S)
python
def nLLevalAllY(ldelta, UY, UX, S): """ nLLevalAllY(double ldelta, MatrixXd const & UY, MatrixXd const & UX, VectorXd const & S) Parameters ---------- ldelta: double UY: MatrixXd const & UX: MatrixXd const & S: VectorXd const & """ return _core.nLLevalAllY(ldelta, UY, UX, S)
[ "def", "nLLevalAllY", "(", "ldelta", ",", "UY", ",", "UX", ",", "S", ")", ":", "return", "_core", ".", "nLLevalAllY", "(", "ldelta", ",", "UY", ",", "UX", ",", "S", ")" ]
nLLevalAllY(double ldelta, MatrixXd const & UY, MatrixXd const & UX, VectorXd const & S) Parameters ---------- ldelta: double UY: MatrixXd const & UX: MatrixXd const & S: VectorXd const &
[ "nLLevalAllY", "(", "double", "ldelta", "MatrixXd", "const", "&", "UY", "MatrixXd", "const", "&", "UX", "VectorXd", "const", "&", "S", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11960-L11972
PMBio/limix-backup
limix/deprecated/core.py
CKroneckerLMM_nLLeval
def CKroneckerLMM_nLLeval(ldelta, A, X, Y, S_C1, S_R1, S_C2, S_R2, W): """ CKroneckerLMM_nLLeval(limix::mfloat_t ldelta, MatrixXdVec A, MatrixXdVec X, MatrixXd const & Y, VectorXd const & S_C1, VectorXd const & S_R1, VectorXd const & S_C2, VectorXd const & S_R2, MatrixXd & W) -> limix::mfloat_t Parameters ...
python
def CKroneckerLMM_nLLeval(ldelta, A, X, Y, S_C1, S_R1, S_C2, S_R2, W): """ CKroneckerLMM_nLLeval(limix::mfloat_t ldelta, MatrixXdVec A, MatrixXdVec X, MatrixXd const & Y, VectorXd const & S_C1, VectorXd const & S_R1, VectorXd const & S_C2, VectorXd const & S_R2, MatrixXd & W) -> limix::mfloat_t Parameters ...
[ "def", "CKroneckerLMM_nLLeval", "(", "ldelta", ",", "A", ",", "X", ",", "Y", ",", "S_C1", ",", "S_R1", ",", "S_C2", ",", "S_R2", ",", "W", ")", ":", "return", "_core", ".", "CKroneckerLMM_nLLeval", "(", "ldelta", ",", "A", ",", "X", ",", "Y", ",", ...
CKroneckerLMM_nLLeval(limix::mfloat_t ldelta, MatrixXdVec A, MatrixXdVec X, MatrixXd const & Y, VectorXd const & S_C1, VectorXd const & S_R1, VectorXd const & S_C2, VectorXd const & S_R2, MatrixXd & W) -> limix::mfloat_t Parameters ---------- ldelta: limix::mfloat_t A: limix::MatrixXdVec const & X:...
[ "CKroneckerLMM_nLLeval", "(", "limix", "::", "mfloat_t", "ldelta", "MatrixXdVec", "A", "MatrixXdVec", "X", "MatrixXd", "const", "&", "Y", "VectorXd", "const", "&", "S_C1", "VectorXd", "const", "&", "S_R1", "VectorXd", "const", "&", "S_C2", "VectorXd", "const", ...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L12351-L12368
PMBio/limix-backup
limix/deprecated/core.py
CKroneckerLMM_optdelta
def CKroneckerLMM_optdelta(ldelta_opt, A, X, Y, S_C1, S_R1, S_C2, S_R2, ldeltamin, ldeltamax, numintervals): """ CKroneckerLMM_optdelta(limix::mfloat_t & ldelta_opt, MatrixXdVec A, MatrixXdVec X, MatrixXd const & Y, VectorXd const & S_C1, VectorXd const & S_R1, VectorXd const & S_C2, VectorXd const & S_R2, limi...
python
def CKroneckerLMM_optdelta(ldelta_opt, A, X, Y, S_C1, S_R1, S_C2, S_R2, ldeltamin, ldeltamax, numintervals): """ CKroneckerLMM_optdelta(limix::mfloat_t & ldelta_opt, MatrixXdVec A, MatrixXdVec X, MatrixXd const & Y, VectorXd const & S_C1, VectorXd const & S_R1, VectorXd const & S_C2, VectorXd const & S_R2, limi...
[ "def", "CKroneckerLMM_optdelta", "(", "ldelta_opt", ",", "A", ",", "X", ",", "Y", ",", "S_C1", ",", "S_R1", ",", "S_C2", ",", "S_R2", ",", "ldeltamin", ",", "ldeltamax", ",", "numintervals", ")", ":", "return", "_core", ".", "CKroneckerLMM_optdelta", "(", ...
CKroneckerLMM_optdelta(limix::mfloat_t & ldelta_opt, MatrixXdVec A, MatrixXdVec X, MatrixXd const & Y, VectorXd const & S_C1, VectorXd const & S_R1, VectorXd const & S_C2, VectorXd const & S_R2, limix::mfloat_t ldeltamin, limix::mfloat_t ldeltamax, limix::muint_t numintervals) -> limix::mfloat_t Parameters ---...
[ "CKroneckerLMM_optdelta", "(", "limix", "::", "mfloat_t", "&", "ldelta_opt", "MatrixXdVec", "A", "MatrixXdVec", "X", "MatrixXd", "const", "&", "Y", "VectorXd", "const", "&", "S_C1", "VectorXd", "const", "&", "S_R1", "VectorXd", "const", "&", "S_C2", "VectorXd", ...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L12370-L12389
PMBio/limix-backup
limix/deprecated/core.py
best_split_full_model
def best_split_full_model(X, UTy, C, S, U, noderange, delta): """ best_split_full_model(MatrixXd const & X, MatrixXd const & UTy, MatrixXd const & C, MatrixXd const & S, MatrixXd const & U, VectorXi const & noderange, limix::mfloat_t delta) Parameters ---------- X: MatrixXd const & UTy: MatrixX...
python
def best_split_full_model(X, UTy, C, S, U, noderange, delta): """ best_split_full_model(MatrixXd const & X, MatrixXd const & UTy, MatrixXd const & C, MatrixXd const & S, MatrixXd const & U, VectorXi const & noderange, limix::mfloat_t delta) Parameters ---------- X: MatrixXd const & UTy: MatrixX...
[ "def", "best_split_full_model", "(", "X", ",", "UTy", ",", "C", ",", "S", ",", "U", ",", "noderange", ",", "delta", ")", ":", "return", "_core", ".", "best_split_full_model", "(", "X", ",", "UTy", ",", "C", ",", "S", ",", "U", ",", "noderange", ","...
best_split_full_model(MatrixXd const & X, MatrixXd const & UTy, MatrixXd const & C, MatrixXd const & S, MatrixXd const & U, VectorXi const & noderange, limix::mfloat_t delta) Parameters ---------- X: MatrixXd const & UTy: MatrixXd const & C: MatrixXd const & S: MatrixXd const & U: MatrixXd ...
[ "best_split_full_model", "(", "MatrixXd", "const", "&", "X", "MatrixXd", "const", "&", "UTy", "MatrixXd", "const", "&", "C", "MatrixXd", "const", "&", "S", "MatrixXd", "const", "&", "U", "VectorXi", "const", "&", "noderange", "limix", "::", "mfloat_t", "delt...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L13934-L13949
PMBio/limix-backup
limix/deprecated/core.py
predict_lmm_forest
def predict_lmm_forest(tree_nodes, left_children, right_children, best_predictor, mean, splitting_value, X, depth): """ predict_lmm_forest(VectorXi const & tree_nodes, VectorXi const & left_children, VectorXi const & right_children, VectorXi const & best_predictor, MatrixXd const & mean, MatrixXd const & splitt...
python
def predict_lmm_forest(tree_nodes, left_children, right_children, best_predictor, mean, splitting_value, X, depth): """ predict_lmm_forest(VectorXi const & tree_nodes, VectorXi const & left_children, VectorXi const & right_children, VectorXi const & best_predictor, MatrixXd const & mean, MatrixXd const & splitt...
[ "def", "predict_lmm_forest", "(", "tree_nodes", ",", "left_children", ",", "right_children", ",", "best_predictor", ",", "mean", ",", "splitting_value", ",", "X", ",", "depth", ")", ":", "return", "_core", ".", "predict_lmm_forest", "(", "tree_nodes", ",", "left...
predict_lmm_forest(VectorXi const & tree_nodes, VectorXi const & left_children, VectorXi const & right_children, VectorXi const & best_predictor, MatrixXd const & mean, MatrixXd const & splitting_value, MatrixXd const & X, limix::mfloat_t depth) Parameters ---------- tree_nodes: VectorXi const & left_c...
[ "predict_lmm_forest", "(", "VectorXi", "const", "&", "tree_nodes", "VectorXi", "const", "&", "left_children", "VectorXi", "const", "&", "right_children", "VectorXi", "const", "&", "best_predictor", "MatrixXd", "const", "&", "mean", "MatrixXd", "const", "&", "splitti...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L13951-L13967
PMBio/limix-backup
limix/deprecated/core.py
ACovarianceFunction.check_covariance_Kgrad_x
def check_covariance_Kgrad_x(covar, relchange=1E-5, threshold=1E-2, check_diag=True): """ check_covariance_Kgrad_x(ACovarianceFunction covar, limix::mfloat_t relchange=1E-5, limix::mfloat_t threshold=1E-2, bool check_diag=True) -> bool Parameters ---------- covar: limix::ACovari...
python
def check_covariance_Kgrad_x(covar, relchange=1E-5, threshold=1E-2, check_diag=True): """ check_covariance_Kgrad_x(ACovarianceFunction covar, limix::mfloat_t relchange=1E-5, limix::mfloat_t threshold=1E-2, bool check_diag=True) -> bool Parameters ---------- covar: limix::ACovari...
[ "def", "check_covariance_Kgrad_x", "(", "covar", ",", "relchange", "=", "1E-5", ",", "threshold", "=", "1E-2", ",", "check_diag", "=", "True", ")", ":", "return", "_core", ".", "ACovarianceFunction_check_covariance_Kgrad_x", "(", "covar", ",", "relchange", ",", ...
check_covariance_Kgrad_x(ACovarianceFunction covar, limix::mfloat_t relchange=1E-5, limix::mfloat_t threshold=1E-2, bool check_diag=True) -> bool Parameters ---------- covar: limix::ACovarianceFunction & relchange: limix::mfloat_t threshold: limix::mfloat_t check_diag: b...
[ "check_covariance_Kgrad_x", "(", "ACovarianceFunction", "covar", "limix", "::", "mfloat_t", "relchange", "=", "1E", "-", "5", "limix", "::", "mfloat_t", "threshold", "=", "1E", "-", "2", "bool", "check_diag", "=", "True", ")", "-", ">", "bool" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L2799-L2832
PMBio/limix-backup
limix/deprecated/core.py
ALMM.setVarcompApprox0
def setVarcompApprox0(self, ldeltamin0=-5, ldeltamax0=5, num_intervals0=100): """ setVarcompApprox0(ALMM self, limix::mfloat_t ldeltamin0=-5, limix::mfloat_t ldeltamax0=5, limix::muint_t num_intervals0=100) Parameters ---------- ldeltamin0: limix::mfloat_t ldeltamax0: li...
python
def setVarcompApprox0(self, ldeltamin0=-5, ldeltamax0=5, num_intervals0=100): """ setVarcompApprox0(ALMM self, limix::mfloat_t ldeltamin0=-5, limix::mfloat_t ldeltamax0=5, limix::muint_t num_intervals0=100) Parameters ---------- ldeltamin0: limix::mfloat_t ldeltamax0: li...
[ "def", "setVarcompApprox0", "(", "self", ",", "ldeltamin0", "=", "-", "5", ",", "ldeltamax0", "=", "5", ",", "num_intervals0", "=", "100", ")", ":", "return", "_core", ".", "ALMM_setVarcompApprox0", "(", "self", ",", "ldeltamin0", ",", "ldeltamax0", ",", "...
setVarcompApprox0(ALMM self, limix::mfloat_t ldeltamin0=-5, limix::mfloat_t ldeltamax0=5, limix::muint_t num_intervals0=100) Parameters ---------- ldeltamin0: limix::mfloat_t ldeltamax0: limix::mfloat_t num_intervals0: limix::muint_t setVarcompApprox0(ALMM self, limix::...
[ "setVarcompApprox0", "(", "ALMM", "self", "limix", "::", "mfloat_t", "ldeltamin0", "=", "-", "5", "limix", "::", "mfloat_t", "ldeltamax0", "=", "5", "limix", "::", "muint_t", "num_intervals0", "=", "100", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11423-L11453
PMBio/limix-backup
limix/deprecated/core.py
ALMM.setVarcompExact
def setVarcompExact(self, ldeltamin=-5, ldeltamax=5, num_intervals=100): """ setVarcompExact(ALMM self, limix::mfloat_t ldeltamin=-5, limix::mfloat_t ldeltamax=5, limix::muint_t num_intervals=100) Parameters ---------- ldeltamin: limix::mfloat_t ldeltamax: limix::mfloat_...
python
def setVarcompExact(self, ldeltamin=-5, ldeltamax=5, num_intervals=100): """ setVarcompExact(ALMM self, limix::mfloat_t ldeltamin=-5, limix::mfloat_t ldeltamax=5, limix::muint_t num_intervals=100) Parameters ---------- ldeltamin: limix::mfloat_t ldeltamax: limix::mfloat_...
[ "def", "setVarcompExact", "(", "self", ",", "ldeltamin", "=", "-", "5", ",", "ldeltamax", "=", "5", ",", "num_intervals", "=", "100", ")", ":", "return", "_core", ".", "ALMM_setVarcompExact", "(", "self", ",", "ldeltamin", ",", "ldeltamax", ",", "num_inter...
setVarcompExact(ALMM self, limix::mfloat_t ldeltamin=-5, limix::mfloat_t ldeltamax=5, limix::muint_t num_intervals=100) Parameters ---------- ldeltamin: limix::mfloat_t ldeltamax: limix::mfloat_t num_intervals: limix::muint_t setVarcompExact(ALMM self, limix::mfloat_t l...
[ "setVarcompExact", "(", "ALMM", "self", "limix", "::", "mfloat_t", "ldeltamin", "=", "-", "5", "limix", "::", "mfloat_t", "ldeltamax", "=", "5", "limix", "::", "muint_t", "num_intervals", "=", "100", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11456-L11486
PMBio/limix-backup
limix/deprecated/core.py
CLMM.setKUS
def setKUS(self, K, U, S): """ setKUS(CLMM self, MatrixXd const & K, MatrixXd const & U, VectorXd const & S) Parameters ---------- K: MatrixXd const & U: MatrixXd const & S: VectorXd const & """ return _core.CLMM_setKUS(self, K, U, S)
python
def setKUS(self, K, U, S): """ setKUS(CLMM self, MatrixXd const & K, MatrixXd const & U, VectorXd const & S) Parameters ---------- K: MatrixXd const & U: MatrixXd const & S: VectorXd const & """ return _core.CLMM_setKUS(self, K, U, S)
[ "def", "setKUS", "(", "self", ",", "K", ",", "U", ",", "S", ")", ":", "return", "_core", ".", "CLMM_setKUS", "(", "self", ",", "K", ",", "U", ",", "S", ")" ]
setKUS(CLMM self, MatrixXd const & K, MatrixXd const & U, VectorXd const & S) Parameters ---------- K: MatrixXd const & U: MatrixXd const & S: VectorXd const &
[ "setKUS", "(", "CLMM", "self", "MatrixXd", "const", "&", "K", "MatrixXd", "const", "&", "U", "VectorXd", "const", "&", "S", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L11562-L11573
PMBio/limix-backup
limix/deprecated/core.py
CHeaderMap.setStr
def setStr(self, name, n, value): """ setStr(CHeaderMap self, std::string name, limix::muint_t n, std::string value) Parameters ---------- name: std::string n: limix::muint_t value: std::string """ return _core.CHeaderMap_setStr(self, name, n, va...
python
def setStr(self, name, n, value): """ setStr(CHeaderMap self, std::string name, limix::muint_t n, std::string value) Parameters ---------- name: std::string n: limix::muint_t value: std::string """ return _core.CHeaderMap_setStr(self, name, n, va...
[ "def", "setStr", "(", "self", ",", "name", ",", "n", ",", "value", ")", ":", "return", "_core", ".", "CHeaderMap_setStr", "(", "self", ",", "name", ",", "n", ",", "value", ")" ]
setStr(CHeaderMap self, std::string name, limix::muint_t n, std::string value) Parameters ---------- name: std::string n: limix::muint_t value: std::string
[ "setStr", "(", "CHeaderMap", "self", "std", "::", "string", "name", "limix", "::", "muint_t", "n", "std", "::", "string", "value", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L13425-L13436
PMBio/limix-backup
limix/deprecated/core.py
AGenotypeContainer.setSNPFilter
def setSNPFilter(self, chrom, start, stop): """ setSNPFilter(AGenotypeContainer self, std::string chrom, limix::muint_t start, limix::muint_t stop) Parameters ---------- chrom: std::string start: limix::muint_t stop: limix::muint_t """ return _co...
python
def setSNPFilter(self, chrom, start, stop): """ setSNPFilter(AGenotypeContainer self, std::string chrom, limix::muint_t start, limix::muint_t stop) Parameters ---------- chrom: std::string start: limix::muint_t stop: limix::muint_t """ return _co...
[ "def", "setSNPFilter", "(", "self", ",", "chrom", ",", "start", ",", "stop", ")", ":", "return", "_core", ".", "AGenotypeContainer_setSNPFilter", "(", "self", ",", "chrom", ",", "start", ",", "stop", ")" ]
setSNPFilter(AGenotypeContainer self, std::string chrom, limix::muint_t start, limix::muint_t stop) Parameters ---------- chrom: std::string start: limix::muint_t stop: limix::muint_t
[ "setSNPFilter", "(", "AGenotypeContainer", "self", "std", "::", "string", "chrom", "limix", "::", "muint_t", "start", "limix", "::", "muint_t", "stop", ")" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/core.py#L13694-L13705
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.buildSubscriptionList
def buildSubscriptionList(self): """ Hits Google Reader for a users's alphabetically ordered list of feeds. Returns true if succesful. """ self._clearLists() unreadById = {} if not self.userId: self.getUserInfo() unreadJson = self.httpGet(Re...
python
def buildSubscriptionList(self): """ Hits Google Reader for a users's alphabetically ordered list of feeds. Returns true if succesful. """ self._clearLists() unreadById = {} if not self.userId: self.getUserInfo() unreadJson = self.httpGet(Re...
[ "def", "buildSubscriptionList", "(", "self", ")", ":", "self", ".", "_clearLists", "(", ")", "unreadById", "=", "{", "}", "if", "not", "self", ".", "userId", ":", "self", ".", "getUserInfo", "(", ")", "unreadJson", "=", "self", ".", "httpGet", "(", "Re...
Hits Google Reader for a users's alphabetically ordered list of feeds. Returns true if succesful.
[ "Hits", "Google", "Reader", "for", "a", "users", "s", "alphabetically", "ordered", "list", "of", "feeds", "." ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L74-L134
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader._getFeedContent
def _getFeedContent(self, url, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ A list of items (from a feed, a category or from URLs made with SPECIAL_ITEMS_URL) Returns a dict with :param id: (str, feed's id) :param continuation: (str, to be u...
python
def _getFeedContent(self, url, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ A list of items (from a feed, a category or from URLs made with SPECIAL_ITEMS_URL) Returns a dict with :param id: (str, feed's id) :param continuation: (str, to be u...
[ "def", "_getFeedContent", "(", "self", ",", "url", ",", "excludeRead", "=", "False", ",", "continuation", "=", "None", ",", "loadLimit", "=", "20", ",", "since", "=", "None", ",", "until", "=", "None", ")", ":", "parameters", "=", "{", "}", "if", "ex...
A list of items (from a feed, a category or from URLs made with SPECIAL_ITEMS_URL) Returns a dict with :param id: (str, feed's id) :param continuation: (str, to be used to fetch more items) :param items: array of dits with : - update (update timestamp) - auth...
[ "A", "list", "of", "items", "(", "from", "a", "feed", "a", "category", "or", "from", "URLs", "made", "with", "SPECIAL_ITEMS_URL", ")" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L136-L162
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.getFeedContent
def getFeedContent(self, feed, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ Return items for a particular feed """ return self._getFeedContent(feed.fetchUrl, excludeRead, continuation, loadLimit, since, until)
python
def getFeedContent(self, feed, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ Return items for a particular feed """ return self._getFeedContent(feed.fetchUrl, excludeRead, continuation, loadLimit, since, until)
[ "def", "getFeedContent", "(", "self", ",", "feed", ",", "excludeRead", "=", "False", ",", "continuation", "=", "None", ",", "loadLimit", "=", "20", ",", "since", "=", "None", ",", "until", "=", "None", ")", ":", "return", "self", ".", "_getFeedContent", ...
Return items for a particular feed
[ "Return", "items", "for", "a", "particular", "feed" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L170-L174
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.getCategoryContent
def getCategoryContent(self, category, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ Return items for a particular category """ return self._getFeedContent(category.fetchUrl, excludeRead, continuation, loadLimit, since, until)
python
def getCategoryContent(self, category, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ Return items for a particular category """ return self._getFeedContent(category.fetchUrl, excludeRead, continuation, loadLimit, since, until)
[ "def", "getCategoryContent", "(", "self", ",", "category", ",", "excludeRead", "=", "False", ",", "continuation", "=", "None", ",", "loadLimit", "=", "20", ",", "since", "=", "None", ",", "until", "=", "None", ")", ":", "return", "self", ".", "_getFeedCo...
Return items for a particular category
[ "Return", "items", "for", "a", "particular", "category" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L176-L180
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader._modifyItemTag
def _modifyItemTag(self, item_id, action, tag): """ wrapper around actual HTTP POST string for modify tags """ return self.httpPost(ReaderUrl.EDIT_TAG_URL, {'i': item_id, action: tag, 'ac': 'edit-tags'})
python
def _modifyItemTag(self, item_id, action, tag): """ wrapper around actual HTTP POST string for modify tags """ return self.httpPost(ReaderUrl.EDIT_TAG_URL, {'i': item_id, action: tag, 'ac': 'edit-tags'})
[ "def", "_modifyItemTag", "(", "self", ",", "item_id", ",", "action", ",", "tag", ")", ":", "return", "self", ".", "httpPost", "(", "ReaderUrl", ".", "EDIT_TAG_URL", ",", "{", "'i'", ":", "item_id", ",", "action", ":", "tag", ",", "'ac'", ":", "'edit-ta...
wrapper around actual HTTP POST string for modify tags
[ "wrapper", "around", "actual", "HTTP", "POST", "string", "for", "modify", "tags" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L182-L185
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.addItemTag
def addItemTag(self, item, tag): """ Add a tag to an individal item. tag string must be in form "user/-/label/[tag]" """ if self.inItemTagTransaction: # XXX: what if item's parent is not a feed? if not tag in self.addTagBacklog: self.addTa...
python
def addItemTag(self, item, tag): """ Add a tag to an individal item. tag string must be in form "user/-/label/[tag]" """ if self.inItemTagTransaction: # XXX: what if item's parent is not a feed? if not tag in self.addTagBacklog: self.addTa...
[ "def", "addItemTag", "(", "self", ",", "item", ",", "tag", ")", ":", "if", "self", ".", "inItemTagTransaction", ":", "# XXX: what if item's parent is not a feed?", "if", "not", "tag", "in", "self", ".", "addTagBacklog", ":", "self", ".", "addTagBacklog", "[", ...
Add a tag to an individal item. tag string must be in form "user/-/label/[tag]"
[ "Add", "a", "tag", "to", "an", "individal", "item", "." ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L201-L214
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.subscribe
def subscribe(self, feedUrl): """ Adds a feed to the top-level subscription list Ubscribing seems idempotent, you can subscribe multiple times without error returns True or throws HTTPError """ response = self.httpPost( ReaderUrl.SUBSCRIPTION_EDIT_UR...
python
def subscribe(self, feedUrl): """ Adds a feed to the top-level subscription list Ubscribing seems idempotent, you can subscribe multiple times without error returns True or throws HTTPError """ response = self.httpPost( ReaderUrl.SUBSCRIPTION_EDIT_UR...
[ "def", "subscribe", "(", "self", ",", "feedUrl", ")", ":", "response", "=", "self", ".", "httpPost", "(", "ReaderUrl", ".", "SUBSCRIPTION_EDIT_URL", ",", "{", "'ac'", ":", "'subscribe'", ",", "'s'", ":", "feedUrl", "}", ")", "# FIXME - need better return API",...
Adds a feed to the top-level subscription list Ubscribing seems idempotent, you can subscribe multiple times without error returns True or throws HTTPError
[ "Adds", "a", "feed", "to", "the", "top", "-", "level", "subscription", "list" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L235-L251
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.getUserInfo
def getUserInfo(self): """ Returns a dictionary of user info that google stores. """ userJson = self.httpGet(ReaderUrl.USER_INFO_URL) result = json.loads(userJson, strict=False) self.userId = result['userId'] return result
python
def getUserInfo(self): """ Returns a dictionary of user info that google stores. """ userJson = self.httpGet(ReaderUrl.USER_INFO_URL) result = json.loads(userJson, strict=False) self.userId = result['userId'] return result
[ "def", "getUserInfo", "(", "self", ")", ":", "userJson", "=", "self", ".", "httpGet", "(", "ReaderUrl", ".", "USER_INFO_URL", ")", "result", "=", "json", ".", "loads", "(", "userJson", ",", "strict", "=", "False", ")", "self", ".", "userId", "=", "resu...
Returns a dictionary of user info that google stores.
[ "Returns", "a", "dictionary", "of", "user", "info", "that", "google", "stores", "." ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L271-L278
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader.getUserSignupDate
def getUserSignupDate(self): """ Returns the human readable date of when the user signed up for google reader. """ userinfo = self.getUserInfo() timestamp = int(float(userinfo["signupTimeSec"])) return time.strftime("%m/%d/%Y %H:%M", time.gmtime(timestamp))
python
def getUserSignupDate(self): """ Returns the human readable date of when the user signed up for google reader. """ userinfo = self.getUserInfo() timestamp = int(float(userinfo["signupTimeSec"])) return time.strftime("%m/%d/%Y %H:%M", time.gmtime(timestamp))
[ "def", "getUserSignupDate", "(", "self", ")", ":", "userinfo", "=", "self", ".", "getUserInfo", "(", ")", "timestamp", "=", "int", "(", "float", "(", "userinfo", "[", "\"signupTimeSec\"", "]", ")", ")", "return", "time", ".", "strftime", "(", "\"%m/%d/%Y %...
Returns the human readable date of when the user signed up for google reader.
[ "Returns", "the", "human", "readable", "date", "of", "when", "the", "user", "signed", "up", "for", "google", "reader", "." ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L280-L286
askedrelic/libgreader
libgreader/googlereader.py
GoogleReader._clearLists
def _clearLists(self): """ Clear all list before sync : feeds and categories """ self.feedsById = {} self.feeds = [] self.categoriesById = {} self.categories = [] self.orphanFeeds = []
python
def _clearLists(self): """ Clear all list before sync : feeds and categories """ self.feedsById = {} self.feeds = [] self.categoriesById = {} self.categories = [] self.orphanFeeds = []
[ "def", "_clearLists", "(", "self", ")", ":", "self", ".", "feedsById", "=", "{", "}", "self", ".", "feeds", "=", "[", "]", "self", ".", "categoriesById", "=", "{", "}", "self", ".", "categories", "=", "[", "]", "self", ".", "orphanFeeds", "=", "[",...
Clear all list before sync : feeds and categories
[ "Clear", "all", "list", "before", "sync", ":", "feeds", "and", "categories" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L316-L324
anayjoshi/cronus
cronus/timeout.py
timeout
def timeout(duration): """ A decorator to force a time limit on the execution of an external function. :param int duration: the timeout duration :raises: TypeError, if duration is anything other than integer :raises: ValueError, if duration is a negative integer :raises TimeoutError, if the ...
python
def timeout(duration): """ A decorator to force a time limit on the execution of an external function. :param int duration: the timeout duration :raises: TypeError, if duration is anything other than integer :raises: ValueError, if duration is a negative integer :raises TimeoutError, if the ...
[ "def", "timeout", "(", "duration", ")", ":", "if", "not", "isinstance", "(", "duration", ",", "int", ")", ":", "raise", "TypeError", "(", "\"timeout duration should be a positive integer\"", ")", "if", "duration", "<=", "0", ":", "raise", "ValueError", "(", "\...
A decorator to force a time limit on the execution of an external function. :param int duration: the timeout duration :raises: TypeError, if duration is anything other than integer :raises: ValueError, if duration is a negative integer :raises TimeoutError, if the external function execution crosses...
[ "A", "decorator", "to", "force", "a", "time", "limit", "on", "the", "execution", "of", "an", "external", "function", "." ]
train
https://github.com/anayjoshi/cronus/blob/52544e63913f37d7fca570168b878737f16fe39c/cronus/timeout.py#L23-L53
thomasleese/mo
mo/project.py
Project.find_task
def find_task(self, name): """ Find a task by name. If a task with the exact name cannot be found, then tasks with similar names are searched for. Returns ------- Task If the task is found. Raises ------ NoSuchTaskError ...
python
def find_task(self, name): """ Find a task by name. If a task with the exact name cannot be found, then tasks with similar names are searched for. Returns ------- Task If the task is found. Raises ------ NoSuchTaskError ...
[ "def", "find_task", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "tasks", "[", "name", "]", "except", "KeyError", ":", "pass", "similarities", "=", "[", "]", "for", "task_name", ",", "task", "in", "self", ".", "tasks", ".", ...
Find a task by name. If a task with the exact name cannot be found, then tasks with similar names are searched for. Returns ------- Task If the task is found. Raises ------ NoSuchTaskError If the task cannot be found.
[ "Find", "a", "task", "by", "name", "." ]
train
https://github.com/thomasleese/mo/blob/b757f52b42e51ad19c14724ceb7c5db5d52abaea/mo/project.py#L230-L263
bretth/woven
woven/management/base.py
WovenCommand.handle
def handle(self, *args, **options): """ Initializes the fabric environment """ self.style = no_style() #manage.py execution specific variables #verbosity 0 = No output at all, 1 = woven output only, 2 = Fabric outputlevel = everything except debug state.env.verbos...
python
def handle(self, *args, **options): """ Initializes the fabric environment """ self.style = no_style() #manage.py execution specific variables #verbosity 0 = No output at all, 1 = woven output only, 2 = Fabric outputlevel = everything except debug state.env.verbos...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "self", ".", "style", "=", "no_style", "(", ")", "#manage.py execution specific variables", "#verbosity 0 = No output at all, 1 = woven output only, 2 = Fabric outputlevel = everything excep...
Initializes the fabric environment
[ "Initializes", "the", "fabric", "environment" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/management/base.py#L68-L147
jf-parent/brome
brome/runner/virtualbox_instance.py
VirtualboxInstance.execute_command
def execute_command(self, command, **kwargs): """Execute a command on the node Args: command (str) Kwargs: username (str) """ self.info_log("executing command: %s" % command) try: ssh = paramiko.SSHClient() ssh.set_missi...
python
def execute_command(self, command, **kwargs): """Execute a command on the node Args: command (str) Kwargs: username (str) """ self.info_log("executing command: %s" % command) try: ssh = paramiko.SSHClient() ssh.set_missi...
[ "def", "execute_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "self", ".", "info_log", "(", "\"executing command: %s\"", "%", "command", ")", "try", ":", "ssh", "=", "paramiko", ".", "SSHClient", "(", ")", "ssh", ".", "set_mis...
Execute a command on the node Args: command (str) Kwargs: username (str)
[ "Execute", "a", "command", "on", "the", "node" ]
train
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/virtualbox_instance.py#L35-L68
jf-parent/brome
brome/runner/virtualbox_instance.py
VirtualboxInstance.scp_file_remote_to_local
def scp_file_remote_to_local(self, remote_path, local_path): """Scp a remote file to local Args: remote_path (str) local_path (str) """ sshadd_command = [ 'ssh-add', '/Users/pyrat/.ssh/ubuntuNode' ] self.info_log( ...
python
def scp_file_remote_to_local(self, remote_path, local_path): """Scp a remote file to local Args: remote_path (str) local_path (str) """ sshadd_command = [ 'ssh-add', '/Users/pyrat/.ssh/ubuntuNode' ] self.info_log( ...
[ "def", "scp_file_remote_to_local", "(", "self", ",", "remote_path", ",", "local_path", ")", ":", "sshadd_command", "=", "[", "'ssh-add'", ",", "'/Users/pyrat/.ssh/ubuntuNode'", "]", "self", ".", "info_log", "(", "\"executing command: %s\"", "%", "' '", ".", "join", ...
Scp a remote file to local Args: remote_path (str) local_path (str)
[ "Scp", "a", "remote", "file", "to", "local" ]
train
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/virtualbox_instance.py#L70-L106
jf-parent/brome
brome/runner/virtualbox_instance.py
VirtualboxInstance.startup
def startup(self): """This will launch and configure the virtual box machine """ # Do not launch the virtual machine if not self.browser_config.get('launch', False): return True self.info_log("Starting up...") try: vm_already_running_cmd = [ ...
python
def startup(self): """This will launch and configure the virtual box machine """ # Do not launch the virtual machine if not self.browser_config.get('launch', False): return True self.info_log("Starting up...") try: vm_already_running_cmd = [ ...
[ "def", "startup", "(", "self", ")", ":", "# Do not launch the virtual machine", "if", "not", "self", ".", "browser_config", ".", "get", "(", "'launch'", ",", "False", ")", ":", "return", "True", "self", ".", "info_log", "(", "\"Starting up...\"", ")", "try", ...
This will launch and configure the virtual box machine
[ "This", "will", "launch", "and", "configure", "the", "virtual", "box", "machine" ]
train
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/virtualbox_instance.py#L108-L249
jf-parent/brome
brome/runner/virtualbox_instance.py
VirtualboxInstance.tear_down
def tear_down(self): """Tear down the virtual box machine """ if not self.browser_config.get('terminate'): self.warning_log("Skipping terminate") return self.info_log("Tearing down") if self.browser_config.get('platform').lower() == 'linux': ...
python
def tear_down(self): """Tear down the virtual box machine """ if not self.browser_config.get('terminate'): self.warning_log("Skipping terminate") return self.info_log("Tearing down") if self.browser_config.get('platform').lower() == 'linux': ...
[ "def", "tear_down", "(", "self", ")", ":", "if", "not", "self", ".", "browser_config", ".", "get", "(", "'terminate'", ")", ":", "self", ".", "warning_log", "(", "\"Skipping terminate\"", ")", "return", "self", ".", "info_log", "(", "\"Tearing down\"", ")", ...
Tear down the virtual box machine
[ "Tear", "down", "the", "virtual", "box", "machine" ]
train
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/virtualbox_instance.py#L251-L265
jf-parent/brome
brome/runner/virtualbox_instance.py
VirtualboxInstance.start_video_recording
def start_video_recording(self, local_video_file_path, video_filename): """Start the video recording """ self.runner.info_log("Starting video recording...") self.local_video_recording_file_path = local_video_file_path self.remote_video_recording_file_path = video_filename ...
python
def start_video_recording(self, local_video_file_path, video_filename): """Start the video recording """ self.runner.info_log("Starting video recording...") self.local_video_recording_file_path = local_video_file_path self.remote_video_recording_file_path = video_filename ...
[ "def", "start_video_recording", "(", "self", ",", "local_video_file_path", ",", "video_filename", ")", ":", "self", ".", "runner", ".", "info_log", "(", "\"Starting video recording...\"", ")", "self", ".", "local_video_recording_file_path", "=", "local_video_file_path", ...
Start the video recording
[ "Start", "the", "video", "recording" ]
train
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/virtualbox_instance.py#L267-L278
jf-parent/brome
brome/runner/virtualbox_instance.py
VirtualboxInstance.stop_video_recording
def stop_video_recording(self): """Stop the video recording """ self.runner.info_log("Stopping video recording...") self.execute_command("./stop_recording.sh") # self.runner.info_log("output: %s"%output) sleep(5) self.scp_file_remote_to_local( self...
python
def stop_video_recording(self): """Stop the video recording """ self.runner.info_log("Stopping video recording...") self.execute_command("./stop_recording.sh") # self.runner.info_log("output: %s"%output) sleep(5) self.scp_file_remote_to_local( self...
[ "def", "stop_video_recording", "(", "self", ")", ":", "self", ".", "runner", ".", "info_log", "(", "\"Stopping video recording...\"", ")", "self", ".", "execute_command", "(", "\"./stop_recording.sh\"", ")", "# self.runner.info_log(\"output: %s\"%output)", "sleep", "(", ...
Stop the video recording
[ "Stop", "the", "video", "recording" ]
train
https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/virtualbox_instance.py#L280-L294
basilfx/flask-daapserver
utils/transformer.py
install_new_pipeline
def install_new_pipeline(): """ Install above transformer into the existing pipeline creator. """ def new_create_pipeline(context, *args, **kwargs): result = old_create_pipeline(context, *args, **kwargs) result.insert(1, DAAPObjectTransformer(context)) return result old_cr...
python
def install_new_pipeline(): """ Install above transformer into the existing pipeline creator. """ def new_create_pipeline(context, *args, **kwargs): result = old_create_pipeline(context, *args, **kwargs) result.insert(1, DAAPObjectTransformer(context)) return result old_cr...
[ "def", "install_new_pipeline", "(", ")", ":", "def", "new_create_pipeline", "(", "context", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "old_create_pipeline", "(", "context", ",", "*", "args", ",", "*", "*", "kwargs", ")", "result...
Install above transformer into the existing pipeline creator.
[ "Install", "above", "transformer", "into", "the", "existing", "pipeline", "creator", "." ]
train
https://github.com/basilfx/flask-daapserver/blob/ca595fcbc5b657cba826eccd3be5cebba0a1db0e/utils/transformer.py#L39-L51
askedrelic/libgreader
libgreader/items.py
ItemsContainer.loadItems
def loadItems(self, excludeRead=False, loadLimit=20, since=None, until=None): """ Load items and call itemsLoadedDone to transform data in objects """ self.clearItems() self.loadtLoadOk = False self.lastLoadLength = 0 self._itemsLoadedDone(self._getContent(excl...
python
def loadItems(self, excludeRead=False, loadLimit=20, since=None, until=None): """ Load items and call itemsLoadedDone to transform data in objects """ self.clearItems() self.loadtLoadOk = False self.lastLoadLength = 0 self._itemsLoadedDone(self._getContent(excl...
[ "def", "loadItems", "(", "self", ",", "excludeRead", "=", "False", ",", "loadLimit", "=", "20", ",", "since", "=", "None", ",", "until", "=", "None", ")", ":", "self", ".", "clearItems", "(", ")", "self", ".", "loadtLoadOk", "=", "False", "self", "."...
Load items and call itemsLoadedDone to transform data in objects
[ "Load", "items", "and", "call", "itemsLoadedDone", "to", "transform", "data", "in", "objects" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/items.py#L27-L34
askedrelic/libgreader
libgreader/items.py
ItemsContainer.loadMoreItems
def loadMoreItems(self, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ Load more items using the continuation parameters of previously loaded items. """ self.lastLoadOk = False self.lastLoadLength = 0 if not continuation and not self....
python
def loadMoreItems(self, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None): """ Load more items using the continuation parameters of previously loaded items. """ self.lastLoadOk = False self.lastLoadLength = 0 if not continuation and not self....
[ "def", "loadMoreItems", "(", "self", ",", "excludeRead", "=", "False", ",", "continuation", "=", "None", ",", "loadLimit", "=", "20", ",", "since", "=", "None", ",", "until", "=", "None", ")", ":", "self", ".", "lastLoadOk", "=", "False", "self", ".", ...
Load more items using the continuation parameters of previously loaded items.
[ "Load", "more", "items", "using", "the", "continuation", "parameters", "of", "previously", "loaded", "items", "." ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/items.py#L36-L44
askedrelic/libgreader
libgreader/items.py
ItemsContainer._itemsLoadedDone
def _itemsLoadedDone(self, data): """ Called when all items are loaded """ if data is None: return self.continuation = data.get('continuation', None) self.lastUpdated = data.get('updated', None) self.lastLoadLength = len(data.get('items', [])) ...
python
def _itemsLoadedDone(self, data): """ Called when all items are loaded """ if data is None: return self.continuation = data.get('continuation', None) self.lastUpdated = data.get('updated', None) self.lastLoadLength = len(data.get('items', [])) ...
[ "def", "_itemsLoadedDone", "(", "self", ",", "data", ")", ":", "if", "data", "is", "None", ":", "return", "self", ".", "continuation", "=", "data", ".", "get", "(", "'continuation'", ",", "None", ")", "self", ".", "lastUpdated", "=", "data", ".", "get"...
Called when all items are loaded
[ "Called", "when", "all", "items", "are", "loaded" ]
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/items.py#L46-L56
ParthKolekar/parthsql
parthsql/main.py
main
def main(): """ The main loop for the commandline parser. """ DATABASE.load_contents() continue_flag = False while not continue_flag: DATABASE.print_contents() try: command = raw_input(">>> ") for stmnt_unformated in sqlparse.parse(command): ...
python
def main(): """ The main loop for the commandline parser. """ DATABASE.load_contents() continue_flag = False while not continue_flag: DATABASE.print_contents() try: command = raw_input(">>> ") for stmnt_unformated in sqlparse.parse(command): ...
[ "def", "main", "(", ")", ":", "DATABASE", ".", "load_contents", "(", ")", "continue_flag", "=", "False", "while", "not", "continue_flag", ":", "DATABASE", ".", "print_contents", "(", ")", "try", ":", "command", "=", "raw_input", "(", "\">>> \"", ")", "for"...
The main loop for the commandline parser.
[ "The", "main", "loop", "for", "the", "commandline", "parser", "." ]
train
https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/main.py#L18-L209
theonion/djes
djes/apps.py
IndexableRegistry.register
def register(self, cls): """Adds a new PolymorphicIndexable to the registry.""" doc_type = cls.search_objects.mapping.doc_type self.all_models[doc_type] = cls base_class = cls.get_base_class() if base_class not in self.families: self.families[base_class] = {} ...
python
def register(self, cls): """Adds a new PolymorphicIndexable to the registry.""" doc_type = cls.search_objects.mapping.doc_type self.all_models[doc_type] = cls base_class = cls.get_base_class() if base_class not in self.families: self.families[base_class] = {} ...
[ "def", "register", "(", "self", ",", "cls", ")", ":", "doc_type", "=", "cls", ".", "search_objects", ".", "mapping", ".", "doc_type", "self", ".", "all_models", "[", "doc_type", "]", "=", "cls", "base_class", "=", "cls", ".", "get_base_class", "(", ")", ...
Adds a new PolymorphicIndexable to the registry.
[ "Adds", "a", "new", "PolymorphicIndexable", "to", "the", "registry", "." ]
train
https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/apps.py#L15-L28
StyXman/ayrton
ayrton/utils.py
copy_loop
def copy_loop (copy_to, finished=None, buf_len=10240): """copy_to is a dict(in: out). When any in is ready to read, data is read from it and writen in its out. When any in is closed, it's removed from copy_to. finished is a pipe; when data comes from the read end, or when no more ins are present, the lo...
python
def copy_loop (copy_to, finished=None, buf_len=10240): """copy_to is a dict(in: out). When any in is ready to read, data is read from it and writen in its out. When any in is closed, it's removed from copy_to. finished is a pipe; when data comes from the read end, or when no more ins are present, the lo...
[ "def", "copy_loop", "(", "copy_to", ",", "finished", "=", "None", ",", "buf_len", "=", "10240", ")", ":", "if", "finished", "is", "not", "None", ":", "copy_to", "[", "finished", "]", "=", "None", "# NOTE:", "# os.sendfile (self.dst, self.src, None, 0)", "# OSE...
copy_to is a dict(in: out). When any in is ready to read, data is read from it and writen in its out. When any in is closed, it's removed from copy_to. finished is a pipe; when data comes from the read end, or when no more ins are present, the loop finishes.
[ "copy_to", "is", "a", "dict", "(", "in", ":", "out", ")", ".", "When", "any", "in", "is", "ready", "to", "read", "data", "is", "read", "from", "it", "and", "writen", "in", "its", "out", ".", "When", "any", "in", "is", "closed", "it", "s", "remove...
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/utils.py#L137-L214
PMBio/limix-backup
limix/deprecated/archive/FastVDMM.py
CFastVDMM.fit
def fit(self,Params0=None,grad_threshold=1e-2): """ fit a variance component model with the predefined design and the initialization and returns all the results """ # GPVD initialization lik = limix.CLikNormalNULL() # Initial Params if Params0==None: ...
python
def fit(self,Params0=None,grad_threshold=1e-2): """ fit a variance component model with the predefined design and the initialization and returns all the results """ # GPVD initialization lik = limix.CLikNormalNULL() # Initial Params if Params0==None: ...
[ "def", "fit", "(", "self", ",", "Params0", "=", "None", ",", "grad_threshold", "=", "1e-2", ")", ":", "# GPVD initialization", "lik", "=", "limix", ".", "CLikNormalNULL", "(", ")", "# Initial Params", "if", "Params0", "==", "None", ":", "n_params", "=", "s...
fit a variance component model with the predefined design and the initialization and returns all the results
[ "fit", "a", "variance", "component", "model", "with", "the", "predefined", "design", "and", "the", "initialization", "and", "returns", "all", "the", "results" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/FastVDMM.py#L145-L199
anayjoshi/cronus
cronus/beat.py
set_rate
def set_rate(rate): """Defines the ideal rate at which computation is to be performed :arg rate: the frequency in Hertz :type rate: int or float :raises: TypeError: if argument 'rate' is not int or float """ if not (isinstance(rate, int) or isinstance(rate, float)): raise TypeError("a...
python
def set_rate(rate): """Defines the ideal rate at which computation is to be performed :arg rate: the frequency in Hertz :type rate: int or float :raises: TypeError: if argument 'rate' is not int or float """ if not (isinstance(rate, int) or isinstance(rate, float)): raise TypeError("a...
[ "def", "set_rate", "(", "rate", ")", ":", "if", "not", "(", "isinstance", "(", "rate", ",", "int", ")", "or", "isinstance", "(", "rate", ",", "float", ")", ")", ":", "raise", "TypeError", "(", "\"argument to set_rate is expected to be int or float\"", ")", "...
Defines the ideal rate at which computation is to be performed :arg rate: the frequency in Hertz :type rate: int or float :raises: TypeError: if argument 'rate' is not int or float
[ "Defines", "the", "ideal", "rate", "at", "which", "computation", "is", "to", "be", "performed" ]
train
https://github.com/anayjoshi/cronus/blob/52544e63913f37d7fca570168b878737f16fe39c/cronus/beat.py#L13-L24
anayjoshi/cronus
cronus/beat.py
sleep
def sleep(): """Sleeps for a dynamic duration of time as determined by set_rate() and true(). :raises: BeatError: if this function is called before calling set_rate() or \ before calling true() """ if loop_duration == 0: raise BeatError("call beat.set_rate() before calling sleep...
python
def sleep(): """Sleeps for a dynamic duration of time as determined by set_rate() and true(). :raises: BeatError: if this function is called before calling set_rate() or \ before calling true() """ if loop_duration == 0: raise BeatError("call beat.set_rate() before calling sleep...
[ "def", "sleep", "(", ")", ":", "if", "loop_duration", "==", "0", ":", "raise", "BeatError", "(", "\"call beat.set_rate() before calling sleep\"", ")", "if", "loop_start_time", "==", "None", ":", "raise", "BeatError", "(", "\"call beat.true() before calling sleep\"", "...
Sleeps for a dynamic duration of time as determined by set_rate() and true(). :raises: BeatError: if this function is called before calling set_rate() or \ before calling true()
[ "Sleeps", "for", "a", "dynamic", "duration", "of", "time", "as", "determined", "by", "set_rate", "()", "and", "true", "()", ".", ":", "raises", ":", "BeatError", ":", "if", "this", "function", "is", "called", "before", "calling", "set_rate", "()", "or", ...
train
https://github.com/anayjoshi/cronus/blob/52544e63913f37d7fca570168b878737f16fe39c/cronus/beat.py#L26-L40
StyXman/ayrton
ayrton/parser/pyparser/pyparse.py
_normalize_encoding
def _normalize_encoding(encoding): """returns normalized name for <encoding> see dist/src/Parser/tokenizer.c 'get_normal_name()' for implementation details / reference NOTE: for now, parser.suite() raises a MemoryError when a bad encoding is used. (SF bug #979739) """ if encoding is ...
python
def _normalize_encoding(encoding): """returns normalized name for <encoding> see dist/src/Parser/tokenizer.c 'get_normal_name()' for implementation details / reference NOTE: for now, parser.suite() raises a MemoryError when a bad encoding is used. (SF bug #979739) """ if encoding is ...
[ "def", "_normalize_encoding", "(", "encoding", ")", ":", "if", "encoding", "is", "None", ":", "return", "None", "# lower() + '_' / '-' conversion", "encoding", "=", "encoding", ".", "replace", "(", "'_'", ",", "'-'", ")", ".", "lower", "(", ")", "if", "encod...
returns normalized name for <encoding> see dist/src/Parser/tokenizer.c 'get_normal_name()' for implementation details / reference NOTE: for now, parser.suite() raises a MemoryError when a bad encoding is used. (SF bug #979739)
[ "returns", "normalized", "name", "for", "<encoding", ">" ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/pyparse.py#L14-L33
StyXman/ayrton
ayrton/parser/pyparser/pyparse.py
_check_for_encoding
def _check_for_encoding(b): """You can use a different encoding from UTF-8 by putting a specially-formatted comment as the first or second line of the source code.""" eol = b.find(b'\n') if eol < 0: return _check_line_for_encoding(b)[0] enc, again = _check_line_for_encoding(b[:eol]) if e...
python
def _check_for_encoding(b): """You can use a different encoding from UTF-8 by putting a specially-formatted comment as the first or second line of the source code.""" eol = b.find(b'\n') if eol < 0: return _check_line_for_encoding(b)[0] enc, again = _check_line_for_encoding(b[:eol]) if e...
[ "def", "_check_for_encoding", "(", "b", ")", ":", "eol", "=", "b", ".", "find", "(", "b'\\n'", ")", "if", "eol", "<", "0", ":", "return", "_check_line_for_encoding", "(", "b", ")", "[", "0", "]", "enc", ",", "again", "=", "_check_line_for_encoding", "(...
You can use a different encoding from UTF-8 by putting a specially-formatted comment as the first or second line of the source code.
[ "You", "can", "use", "a", "different", "encoding", "from", "UTF", "-", "8", "by", "putting", "a", "specially", "-", "formatted", "comment", "as", "the", "first", "or", "second", "line", "of", "the", "source", "code", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/pyparse.py#L35-L47
StyXman/ayrton
ayrton/parser/pyparser/pyparse.py
_check_line_for_encoding
def _check_line_for_encoding(line): """returns the declared encoding or None""" i = 0 for i in range(len(line)): if line[i] == b'#': break if line[i] not in b' \t\014': return None, False # Not a comment, don't read the second line. return pytokenizer.match_encod...
python
def _check_line_for_encoding(line): """returns the declared encoding or None""" i = 0 for i in range(len(line)): if line[i] == b'#': break if line[i] not in b' \t\014': return None, False # Not a comment, don't read the second line. return pytokenizer.match_encod...
[ "def", "_check_line_for_encoding", "(", "line", ")", ":", "i", "=", "0", "for", "i", "in", "range", "(", "len", "(", "line", ")", ")", ":", "if", "line", "[", "i", "]", "==", "b'#'", ":", "break", "if", "line", "[", "i", "]", "not", "in", "b' \...
returns the declared encoding or None
[ "returns", "the", "declared", "encoding", "or", "None" ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/pyparse.py#L50-L58
StyXman/ayrton
ayrton/parser/pyparser/pyparse.py
PythonParser.parse_source
def parse_source(self, bytessrc, compile_info): """Main entry point for parsing Python source. Everything from decoding the source to tokenizing to building the parse tree is handled here. """ # Detect source encoding. enc = None if compile_info.flags & consts.Py...
python
def parse_source(self, bytessrc, compile_info): """Main entry point for parsing Python source. Everything from decoding the source to tokenizing to building the parse tree is handled here. """ # Detect source encoding. enc = None if compile_info.flags & consts.Py...
[ "def", "parse_source", "(", "self", ",", "bytessrc", ",", "compile_info", ")", ":", "# Detect source encoding.", "enc", "=", "None", "if", "compile_info", ".", "flags", "&", "consts", ".", "PyCF_SOURCE_IS_UTF8", ":", "enc", "=", "'utf-8'", "if", "compile_info", ...
Main entry point for parsing Python source. Everything from decoding the source to tokenizing to building the parse tree is handled here.
[ "Main", "entry", "point", "for", "parsing", "Python", "source", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/pyparse.py#L111-L228
bretth/woven
woven/environment.py
_parse_project_version
def _parse_project_version(version=''): """ Returns the significant part of the version excluding the build The final forms returned can be major.minor major.minor stage (spaces will be replaced with '-') major.minor.stage major.minor-stage major.minorstage (eg 1.0rc1) m...
python
def _parse_project_version(version=''): """ Returns the significant part of the version excluding the build The final forms returned can be major.minor major.minor stage (spaces will be replaced with '-') major.minor.stage major.minor-stage major.minorstage (eg 1.0rc1) m...
[ "def", "_parse_project_version", "(", "version", "=", "''", ")", ":", "def", "mm_version", "(", "vers", ")", ":", "stage", "=", "''", "stage_sep", "=", "''", "finalvers", "=", "''", "if", "not", "vers", ".", "isdigit", "(", ")", ":", "for", "num", ",...
Returns the significant part of the version excluding the build The final forms returned can be major.minor major.minor stage (spaces will be replaced with '-') major.minor.stage major.minor-stage major.minorstage (eg 1.0rc1) major.minor.maintenance major.minor.maintenance-s...
[ "Returns", "the", "significant", "part", "of", "the", "version", "excluding", "the", "build", "The", "final", "forms", "returned", "can", "be", "major", ".", "minor", "major", ".", "minor", "stage", "(", "spaces", "will", "be", "replaced", "with", "-", ")"...
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L76-L150
bretth/woven
woven/environment.py
_root_domain
def _root_domain(): """ Deduce the root domain name - usually a 'naked' domain. This only needs to be done prior to the first deployment """ if not hasattr(env,'root_domain'): cwd = os.getcwd().split(os.sep) domain = '' #if the first env.host has a domain name then we'l...
python
def _root_domain(): """ Deduce the root domain name - usually a 'naked' domain. This only needs to be done prior to the first deployment """ if not hasattr(env,'root_domain'): cwd = os.getcwd().split(os.sep) domain = '' #if the first env.host has a domain name then we'l...
[ "def", "_root_domain", "(", ")", ":", "if", "not", "hasattr", "(", "env", ",", "'root_domain'", ")", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", ".", "split", "(", "os", ".", "sep", ")", "domain", "=", "''", "#if the first env.host has a domain name ...
Deduce the root domain name - usually a 'naked' domain. This only needs to be done prior to the first deployment
[ "Deduce", "the", "root", "domain", "name", "-", "usually", "a", "naked", "domain", ".", "This", "only", "needs", "to", "be", "done", "prior", "to", "the", "first", "deployment" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L152-L188
bretth/woven
woven/environment.py
check_settings
def check_settings(): """ Validate the users settings conf prior to deploy """ valid=True if not get_version() >= '1.0': print "FABRIC ERROR: Woven is only compatible with Fabric < 1.0" valid = False if not env.MEDIA_ROOT or not env.MEDIA_URL: print "MEDIA ERROR: You must...
python
def check_settings(): """ Validate the users settings conf prior to deploy """ valid=True if not get_version() >= '1.0': print "FABRIC ERROR: Woven is only compatible with Fabric < 1.0" valid = False if not env.MEDIA_ROOT or not env.MEDIA_URL: print "MEDIA ERROR: You must...
[ "def", "check_settings", "(", ")", ":", "valid", "=", "True", "if", "not", "get_version", "(", ")", ">=", "'1.0'", ":", "print", "\"FABRIC ERROR: Woven is only compatible with Fabric < 1.0\"", "valid", "=", "False", "if", "not", "env", ".", "MEDIA_ROOT", "or", "...
Validate the users settings conf prior to deploy
[ "Validate", "the", "users", "settings", "conf", "prior", "to", "deploy" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L190-L210
bretth/woven
woven/environment.py
set_env
def set_env(settings=None, setup_dir=''): """ Used in management commands or at the module level of a fabfile to integrate woven project django.conf settings into fabric, and set the local current working directory to the distribution root (where setup.py lives). ``settings`` is your django set...
python
def set_env(settings=None, setup_dir=''): """ Used in management commands or at the module level of a fabfile to integrate woven project django.conf settings into fabric, and set the local current working directory to the distribution root (where setup.py lives). ``settings`` is your django set...
[ "def", "set_env", "(", "settings", "=", "None", ",", "setup_dir", "=", "''", ")", ":", "#switch the working directory to the distribution root where setup.py is", "if", "hasattr", "(", "env", ",", "'setup_path'", ")", "and", "env", ".", "setup_path", ":", "setup_pat...
Used in management commands or at the module level of a fabfile to integrate woven project django.conf settings into fabric, and set the local current working directory to the distribution root (where setup.py lives). ``settings`` is your django settings module to pass in if you want to call this f...
[ "Used", "in", "management", "commands", "or", "at", "the", "module", "level", "of", "a", "fabfile", "to", "integrate", "woven", "project", "django", ".", "conf", "settings", "into", "fabric", "and", "set", "the", "local", "current", "working", "directory", "...
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L240-L447
bretth/woven
woven/environment.py
post_install_package
def post_install_package(): """ Run any functions post install a matching package. Hook functions are in the form post_install_[package name] and are defined in a deploy.py file Will be executed post install_packages and upload_etc """ module_name = '.'.join([env.project_package_name,'...
python
def post_install_package(): """ Run any functions post install a matching package. Hook functions are in the form post_install_[package name] and are defined in a deploy.py file Will be executed post install_packages and upload_etc """ module_name = '.'.join([env.project_package_name,'...
[ "def", "post_install_package", "(", ")", ":", "module_name", "=", "'.'", ".", "join", "(", "[", "env", ".", "project_package_name", ",", "'deploy'", "]", ")", "funcs_run", "=", "[", "]", "try", ":", "imported", "=", "import_module", "(", "module_name", ")"...
Run any functions post install a matching package. Hook functions are in the form post_install_[package name] and are defined in a deploy.py file Will be executed post install_packages and upload_etc
[ "Run", "any", "functions", "post", "install", "a", "matching", "package", ".", "Hook", "functions", "are", "in", "the", "form", "post_install_", "[", "package", "name", "]", "and", "are", "defined", "in", "a", "deploy", ".", "py", "file", "Will", "be", "...
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L460-L501
bretth/woven
woven/environment.py
post_exec_hook
def post_exec_hook(hook): """ Runs a hook function defined in a deploy.py file """ #post_setupnode hook module_name = '.'.join([env.project_package_name,'deploy']) funcs_run = [] try: imported = import_module(module_name) func = vars(imported).get(hook) if func: ...
python
def post_exec_hook(hook): """ Runs a hook function defined in a deploy.py file """ #post_setupnode hook module_name = '.'.join([env.project_package_name,'deploy']) funcs_run = [] try: imported = import_module(module_name) func = vars(imported).get(hook) if func: ...
[ "def", "post_exec_hook", "(", "hook", ")", ":", "#post_setupnode hook", "module_name", "=", "'.'", ".", "join", "(", "[", "env", ".", "project_package_name", ",", "'deploy'", "]", ")", "funcs_run", "=", "[", "]", "try", ":", "imported", "=", "import_module",...
Runs a hook function defined in a deploy.py file
[ "Runs", "a", "hook", "function", "defined", "in", "a", "deploy", ".", "py", "file" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L504-L534
bretth/woven
woven/environment.py
project_version
def project_version(full_version): """ project_version context manager """ project_full_version=full_version v = _parse_project_version(full_version) name = project_name() project_fullname = '-'.join([name,v]) return _setenv(project_full_version=project_full_version, project_version=v,...
python
def project_version(full_version): """ project_version context manager """ project_full_version=full_version v = _parse_project_version(full_version) name = project_name() project_fullname = '-'.join([name,v]) return _setenv(project_full_version=project_full_version, project_version=v,...
[ "def", "project_version", "(", "full_version", ")", ":", "project_full_version", "=", "full_version", "v", "=", "_parse_project_version", "(", "full_version", ")", "name", "=", "project_name", "(", ")", "project_fullname", "=", "'-'", ".", "join", "(", "[", "nam...
project_version context manager
[ "project_version", "context", "manager" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L536-L546
bretth/woven
woven/environment.py
set_server_state
def set_server_state(name,object=None,delete=False): """ Sets a simple 'state' on the server by creating a file with the desired state's name and storing ``content`` as json strings if supplied returns the filename used to store state """ with fab_settings(project_fullname=''): r...
python
def set_server_state(name,object=None,delete=False): """ Sets a simple 'state' on the server by creating a file with the desired state's name and storing ``content`` as json strings if supplied returns the filename used to store state """ with fab_settings(project_fullname=''): r...
[ "def", "set_server_state", "(", "name", ",", "object", "=", "None", ",", "delete", "=", "False", ")", ":", "with", "fab_settings", "(", "project_fullname", "=", "''", ")", ":", "return", "set_version_state", "(", "name", ",", "object", ",", "delete", ")" ]
Sets a simple 'state' on the server by creating a file with the desired state's name and storing ``content`` as json strings if supplied returns the filename used to store state
[ "Sets", "a", "simple", "state", "on", "the", "server", "by", "creating", "a", "file", "with", "the", "desired", "state", "s", "name", "and", "storing", "content", "as", "json", "strings", "if", "supplied", "returns", "the", "filename", "used", "to", "store...
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L576-L584
bretth/woven
woven/environment.py
set_version_state
def set_version_state(name,object=None,delete=False): """ Sets a simple 'state' on the server by creating a file with the desired state's name + version and storing ``content`` as json strings if supplied returns the filename used to store state """ if env.project_fullname: state_name = ...
python
def set_version_state(name,object=None,delete=False): """ Sets a simple 'state' on the server by creating a file with the desired state's name + version and storing ``content`` as json strings if supplied returns the filename used to store state """ if env.project_fullname: state_name = ...
[ "def", "set_version_state", "(", "name", ",", "object", "=", "None", ",", "delete", "=", "False", ")", ":", "if", "env", ".", "project_fullname", ":", "state_name", "=", "'-'", ".", "join", "(", "[", "env", ".", "project_fullname", ",", "name", "]", ")...
Sets a simple 'state' on the server by creating a file with the desired state's name + version and storing ``content`` as json strings if supplied returns the filename used to store state
[ "Sets", "a", "simple", "state", "on", "the", "server", "by", "creating", "a", "file", "with", "the", "desired", "state", "s", "name", "+", "version", "and", "storing", "content", "as", "json", "strings", "if", "supplied", "returns", "the", "filename", "use...
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L587-L612
bretth/woven
woven/environment.py
server_state
def server_state(name, no_content=False): """ If the server state exists return parsed json as a python object or True prefix=True returns True if any files exist with ls [prefix]* """ with fab_settings(project_fullname=''): return version_state(name, no_content=no_content)
python
def server_state(name, no_content=False): """ If the server state exists return parsed json as a python object or True prefix=True returns True if any files exist with ls [prefix]* """ with fab_settings(project_fullname=''): return version_state(name, no_content=no_content)
[ "def", "server_state", "(", "name", ",", "no_content", "=", "False", ")", ":", "with", "fab_settings", "(", "project_fullname", "=", "''", ")", ":", "return", "version_state", "(", "name", ",", "no_content", "=", "no_content", ")" ]
If the server state exists return parsed json as a python object or True prefix=True returns True if any files exist with ls [prefix]*
[ "If", "the", "server", "state", "exists", "return", "parsed", "json", "as", "a", "python", "object", "or", "True", "prefix", "=", "True", "returns", "True", "if", "any", "files", "exist", "with", "ls", "[", "prefix", "]", "*" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L615-L621
bretth/woven
woven/environment.py
version_state
def version_state(name, prefix=False, no_content=False): """ If the server state exists return parsed json as a python object or True prefix=True returns True if any files exist with ls [prefix]* """ if env.project_fullname: full_name = '-'.join([env.project_fullname,name]) else: full_name = na...
python
def version_state(name, prefix=False, no_content=False): """ If the server state exists return parsed json as a python object or True prefix=True returns True if any files exist with ls [prefix]* """ if env.project_fullname: full_name = '-'.join([env.project_fullname,name]) else: full_name = na...
[ "def", "version_state", "(", "name", ",", "prefix", "=", "False", ",", "no_content", "=", "False", ")", ":", "if", "env", ".", "project_fullname", ":", "full_name", "=", "'-'", ".", "join", "(", "[", "env", ".", "project_fullname", ",", "name", "]", ")...
If the server state exists return parsed json as a python object or True prefix=True returns True if any files exist with ls [prefix]*
[ "If", "the", "server", "state", "exists", "return", "parsed", "json", "as", "a", "python", "object", "or", "True", "prefix", "=", "True", "returns", "True", "if", "any", "files", "exist", "with", "ls", "[", "prefix", "]", "*" ]
train
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/environment.py#L624-L653
KelSolaar/Foundations
foundations/pkzip.py
Pkzip.archive
def archive(self, value): """ Setter for **self.__archive** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "archi...
python
def archive(self, value): """ Setter for **self.__archive** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "archi...
[ "def", "archive", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "unicode", ",", "\"'{0}' attribute: '{1}' type is not 'unicode'!\"", ".", "format", "(", "\"archive\"", ",", "value", "...
Setter for **self.__archive** attribute. :param value: Attribute value. :type value: unicode
[ "Setter", "for", "**", "self", ".", "__archive", "**", "attribute", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/pkzip.py#L79-L91
KelSolaar/Foundations
foundations/pkzip.py
Pkzip.extract
def extract(self, target): """ Extracts the archive file to given directory. :param target: Target extraction directory. :type target: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(self.__archive): ra...
python
def extract(self, target): """ Extracts the archive file to given directory. :param target: Target extraction directory. :type target: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(self.__archive): ra...
[ "def", "extract", "(", "self", ",", "target", ")", ":", "if", "not", "foundations", ".", "common", ".", "path_exists", "(", "self", ".", "__archive", ")", ":", "raise", "foundations", ".", "exceptions", ".", "FileExistsError", "(", "\"{0} | '{1}' file doesn't ...
Extracts the archive file to given directory. :param target: Target extraction directory. :type target: unicode :return: Method success. :rtype: bool
[ "Extracts", "the", "archive", "file", "to", "given", "directory", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/pkzip.py#L106-L146
ssato/python-anytemplate
anytemplate/utils.py
get_output_stream
def get_output_stream(encoding=anytemplate.compat.ENCODING, ostream=sys.stdout): """ Get output stream take care of characters encoding correctly. :param ostream: Output stream (file-like object); sys.stdout by default :param encoding: Characters set encoding, e.g. UTF-8 :retu...
python
def get_output_stream(encoding=anytemplate.compat.ENCODING, ostream=sys.stdout): """ Get output stream take care of characters encoding correctly. :param ostream: Output stream (file-like object); sys.stdout by default :param encoding: Characters set encoding, e.g. UTF-8 :retu...
[ "def", "get_output_stream", "(", "encoding", "=", "anytemplate", ".", "compat", ".", "ENCODING", ",", "ostream", "=", "sys", ".", "stdout", ")", ":", "return", "codecs", ".", "getwriter", "(", "encoding", ")", "(", "ostream", ")" ]
Get output stream take care of characters encoding correctly. :param ostream: Output stream (file-like object); sys.stdout by default :param encoding: Characters set encoding, e.g. UTF-8 :return: sys.stdout can output encoded strings >>> get_output_stream("UTF-8") # doctest: +ELLIPSIS <encodings....
[ "Get", "output", "stream", "take", "care", "of", "characters", "encoding", "correctly", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L29-L41
ssato/python-anytemplate
anytemplate/utils.py
uniq
def uniq(items): """Remove duplicates in given list with its order kept. >>> uniq([]) [] >>> uniq([1, 4, 5, 1, 2, 3, 5, 10]) [1, 4, 5, 2, 3, 10] """ acc = items[:1] for item in items[1:]: if item not in acc: acc += [item] return acc
python
def uniq(items): """Remove duplicates in given list with its order kept. >>> uniq([]) [] >>> uniq([1, 4, 5, 1, 2, 3, 5, 10]) [1, 4, 5, 2, 3, 10] """ acc = items[:1] for item in items[1:]: if item not in acc: acc += [item] return acc
[ "def", "uniq", "(", "items", ")", ":", "acc", "=", "items", "[", ":", "1", "]", "for", "item", "in", "items", "[", "1", ":", "]", ":", "if", "item", "not", "in", "acc", ":", "acc", "+=", "[", "item", "]", "return", "acc" ]
Remove duplicates in given list with its order kept. >>> uniq([]) [] >>> uniq([1, 4, 5, 1, 2, 3, 5, 10]) [1, 4, 5, 2, 3, 10]
[ "Remove", "duplicates", "in", "given", "list", "with", "its", "order", "kept", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L44-L57
ssato/python-anytemplate
anytemplate/utils.py
chaincalls
def chaincalls(callables, obj): """ :param callables: callable objects to apply to obj in this order :param obj: Object to apply callables >>> chaincalls([lambda a: a + 1, lambda b: b + 2], 0) 3 >>> chaincalls([[]], 0) Traceback (most recent call last): ValueError: Not callable: '[]' ...
python
def chaincalls(callables, obj): """ :param callables: callable objects to apply to obj in this order :param obj: Object to apply callables >>> chaincalls([lambda a: a + 1, lambda b: b + 2], 0) 3 >>> chaincalls([[]], 0) Traceback (most recent call last): ValueError: Not callable: '[]' ...
[ "def", "chaincalls", "(", "callables", ",", "obj", ")", ":", "for", "fun", "in", "callables", ":", "if", "not", "callable", "(", "fun", ")", ":", "raise", "ValueError", "(", "\"Not callable: %r\"", "%", "repr", "(", "fun", ")", ")", "obj", "=", "fun", ...
:param callables: callable objects to apply to obj in this order :param obj: Object to apply callables >>> chaincalls([lambda a: a + 1, lambda b: b + 2], 0) 3 >>> chaincalls([[]], 0) Traceback (most recent call last): ValueError: Not callable: '[]'
[ ":", "param", "callables", ":", "callable", "objects", "to", "apply", "to", "obj", "in", "this", "order", ":", "param", "obj", ":", "Object", "to", "apply", "callables" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L60-L76
ssato/python-anytemplate
anytemplate/utils.py
normpath
def normpath(path): """Normalize given path in various different forms. >>> normpath("/tmp/../etc/hosts") '/etc/hosts' >>> normpath("~root/t") '/root/t' """ funcs = [os.path.normpath, os.path.abspath] if "~" in path: funcs = [os.path.expanduser] + funcs return chaincalls(fu...
python
def normpath(path): """Normalize given path in various different forms. >>> normpath("/tmp/../etc/hosts") '/etc/hosts' >>> normpath("~root/t") '/root/t' """ funcs = [os.path.normpath, os.path.abspath] if "~" in path: funcs = [os.path.expanduser] + funcs return chaincalls(fu...
[ "def", "normpath", "(", "path", ")", ":", "funcs", "=", "[", "os", ".", "path", ".", "normpath", ",", "os", ".", "path", ".", "abspath", "]", "if", "\"~\"", "in", "path", ":", "funcs", "=", "[", "os", ".", "path", ".", "expanduser", "]", "+", "...
Normalize given path in various different forms. >>> normpath("/tmp/../etc/hosts") '/etc/hosts' >>> normpath("~root/t") '/root/t'
[ "Normalize", "given", "path", "in", "various", "different", "forms", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L79-L91
ssato/python-anytemplate
anytemplate/utils.py
parse_filespec
def parse_filespec(fspec, sep=':', gpat='*'): """ Parse given filespec `fspec` and return [(filetype, filepath)]. Because anyconfig.load should find correct file's type to load by the file extension, this function will not try guessing file's type if not file type is specified explicitly. :par...
python
def parse_filespec(fspec, sep=':', gpat='*'): """ Parse given filespec `fspec` and return [(filetype, filepath)]. Because anyconfig.load should find correct file's type to load by the file extension, this function will not try guessing file's type if not file type is specified explicitly. :par...
[ "def", "parse_filespec", "(", "fspec", ",", "sep", "=", "':'", ",", "gpat", "=", "'*'", ")", ":", "if", "sep", "in", "fspec", ":", "tpl", "=", "(", "ftype", ",", "fpath", ")", "=", "tuple", "(", "fspec", ".", "split", "(", "sep", ")", ")", "els...
Parse given filespec `fspec` and return [(filetype, filepath)]. Because anyconfig.load should find correct file's type to load by the file extension, this function will not try guessing file's type if not file type is specified explicitly. :param fspec: filespec :param sep: a char separating filet...
[ "Parse", "given", "filespec", "fspec", "and", "return", "[", "(", "filetype", "filepath", ")", "]", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L125-L156
ssato/python-anytemplate
anytemplate/utils.py
load_context
def load_context(ctx_path, ctx_type, scm=None): """ :param ctx_path: context file path or '-' (read from stdin) :param ctx_type: context file type :param scm: JSON schema file in any formats anyconfig supports, to validate given context files """ if ctx_path == '-': return loads(...
python
def load_context(ctx_path, ctx_type, scm=None): """ :param ctx_path: context file path or '-' (read from stdin) :param ctx_type: context file type :param scm: JSON schema file in any formats anyconfig supports, to validate given context files """ if ctx_path == '-': return loads(...
[ "def", "load_context", "(", "ctx_path", ",", "ctx_type", ",", "scm", "=", "None", ")", ":", "if", "ctx_path", "==", "'-'", ":", "return", "loads", "(", "sys", ".", "stdin", ".", "read", "(", ")", ",", "ac_parser", "=", "ctx_type", ",", "ac_schema", "...
:param ctx_path: context file path or '-' (read from stdin) :param ctx_type: context file type :param scm: JSON schema file in any formats anyconfig supports, to validate given context files
[ ":", "param", "ctx_path", ":", "context", "file", "path", "or", "-", "(", "read", "from", "stdin", ")", ":", "param", "ctx_type", ":", "context", "file", "type", ":", "param", "scm", ":", "JSON", "schema", "file", "in", "any", "formats", "anyconfig", "...
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L159-L169
ssato/python-anytemplate
anytemplate/utils.py
parse_and_load_contexts
def parse_and_load_contexts(contexts, schema=None, werr=False): """ :param contexts: list of context file specs :param schema: JSON schema file in any formats anyconfig supports, to validate given context files :param werr: Exit immediately if True and any errors occurrs while loading co...
python
def parse_and_load_contexts(contexts, schema=None, werr=False): """ :param contexts: list of context file specs :param schema: JSON schema file in any formats anyconfig supports, to validate given context files :param werr: Exit immediately if True and any errors occurrs while loading co...
[ "def", "parse_and_load_contexts", "(", "contexts", ",", "schema", "=", "None", ",", "werr", "=", "False", ")", ":", "ctx", "=", "dict", "(", ")", "diff", "=", "None", "if", "contexts", ":", "for", "ctx_path", ",", "ctx_type", "in", "concat", "(", "pars...
:param contexts: list of context file specs :param schema: JSON schema file in any formats anyconfig supports, to validate given context files :param werr: Exit immediately if True and any errors occurrs while loading context files
[ ":", "param", "contexts", ":", "list", "of", "context", "file", "specs", ":", "param", "schema", ":", "JSON", "schema", "file", "in", "any", "formats", "anyconfig", "supports", "to", "validate", "given", "context", "files", ":", "param", "werr", ":", "Exit...
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L172-L192
ssato/python-anytemplate
anytemplate/utils.py
_write_to_filepath
def _write_to_filepath(content, output): """ :param content: Content string to write to :param output: Output file path """ outdir = os.path.dirname(output) if outdir and not os.path.exists(outdir): os.makedirs(outdir) with anytemplate.compat.copen(output, 'w') as out: out.w...
python
def _write_to_filepath(content, output): """ :param content: Content string to write to :param output: Output file path """ outdir = os.path.dirname(output) if outdir and not os.path.exists(outdir): os.makedirs(outdir) with anytemplate.compat.copen(output, 'w') as out: out.w...
[ "def", "_write_to_filepath", "(", "content", ",", "output", ")", ":", "outdir", "=", "os", ".", "path", ".", "dirname", "(", "output", ")", "if", "outdir", "and", "not", "os", ".", "path", ".", "exists", "(", "outdir", ")", ":", "os", ".", "makedirs"...
:param content: Content string to write to :param output: Output file path
[ ":", "param", "content", ":", "Content", "string", "to", "write", "to", ":", "param", "output", ":", "Output", "file", "path" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L195-L205
ssato/python-anytemplate
anytemplate/utils.py
write_to_output
def write_to_output(content, output=None, encoding=anytemplate.compat.ENCODING): """ :param content: Content string to write to :param output: Output destination :param encoding: Character set encoding of outputs """ if anytemplate.compat.IS_PYTHON_3 and isinstance(content, b...
python
def write_to_output(content, output=None, encoding=anytemplate.compat.ENCODING): """ :param content: Content string to write to :param output: Output destination :param encoding: Character set encoding of outputs """ if anytemplate.compat.IS_PYTHON_3 and isinstance(content, b...
[ "def", "write_to_output", "(", "content", ",", "output", "=", "None", ",", "encoding", "=", "anytemplate", ".", "compat", ".", "ENCODING", ")", ":", "if", "anytemplate", ".", "compat", ".", "IS_PYTHON_3", "and", "isinstance", "(", "content", ",", "bytes", ...
:param content: Content string to write to :param output: Output destination :param encoding: Character set encoding of outputs
[ ":", "param", "content", ":", "Content", "string", "to", "write", "to", ":", "param", "output", ":", "Output", "destination", ":", "param", "encoding", ":", "Character", "set", "encoding", "of", "outputs" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L208-L223
ssato/python-anytemplate
anytemplate/utils.py
mk_template_paths
def mk_template_paths(filepath, paths=None): """ Make template paths from given filepath and paths list. :param filepath: (Base) filepath of template file or None :param paths: A list of template search paths or None >>> mk_template_paths("/tmp/t.j2", []) ['/tmp'] >>> mk_template_paths("/t...
python
def mk_template_paths(filepath, paths=None): """ Make template paths from given filepath and paths list. :param filepath: (Base) filepath of template file or None :param paths: A list of template search paths or None >>> mk_template_paths("/tmp/t.j2", []) ['/tmp'] >>> mk_template_paths("/t...
[ "def", "mk_template_paths", "(", "filepath", ",", "paths", "=", "None", ")", ":", "if", "filepath", "is", "None", ":", "return", "[", "os", ".", "curdir", "]", "if", "paths", "is", "None", "else", "paths", "tmpldir", "=", "os", ".", "path", ".", "dir...
Make template paths from given filepath and paths list. :param filepath: (Base) filepath of template file or None :param paths: A list of template search paths or None >>> mk_template_paths("/tmp/t.j2", []) ['/tmp'] >>> mk_template_paths("/tmp/t.j2", ["/etc"]) ['/etc', '/tmp'] >>> mk_templ...
[ "Make", "template", "paths", "from", "given", "filepath", "and", "paths", "list", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L226-L244
ssato/python-anytemplate
anytemplate/utils.py
find_template_from_path
def find_template_from_path(filepath, paths=None): """ Return resolved path of given template file :param filepath: (Base) filepath of template file :param paths: A list of template search paths """ if paths is None or not paths: paths = [os.path.dirname(filepath), os.curdir] for p...
python
def find_template_from_path(filepath, paths=None): """ Return resolved path of given template file :param filepath: (Base) filepath of template file :param paths: A list of template search paths """ if paths is None or not paths: paths = [os.path.dirname(filepath), os.curdir] for p...
[ "def", "find_template_from_path", "(", "filepath", ",", "paths", "=", "None", ")", ":", "if", "paths", "is", "None", "or", "not", "paths", ":", "paths", "=", "[", "os", ".", "path", ".", "dirname", "(", "filepath", ")", ",", "os", ".", "curdir", "]",...
Return resolved path of given template file :param filepath: (Base) filepath of template file :param paths: A list of template search paths
[ "Return", "resolved", "path", "of", "given", "template", "file" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/utils.py#L247-L263
ssato/python-anytemplate
anytemplate/api.py
find_engine
def find_engine(filepath=None, name=None): """ :param filepath: Template file path :param name: Specify the name of template engine to use explicitly or None; it will be selected automatically anyhow. :return: Template engine class found """ if name is None: engines = anytemplat...
python
def find_engine(filepath=None, name=None): """ :param filepath: Template file path :param name: Specify the name of template engine to use explicitly or None; it will be selected automatically anyhow. :return: Template engine class found """ if name is None: engines = anytemplat...
[ "def", "find_engine", "(", "filepath", "=", "None", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "engines", "=", "anytemplate", ".", "engine", ".", "find_by_filename", "(", "filepath", ")", "if", "not", "engines", ":", "raise", ...
:param filepath: Template file path :param name: Specify the name of template engine to use explicitly or None; it will be selected automatically anyhow. :return: Template engine class found
[ ":", "param", "filepath", ":", "Template", "file", "path", ":", "param", "name", ":", "Specify", "the", "name", "of", "template", "engine", "to", "use", "explicitly", "or", "None", ";", "it", "will", "be", "selected", "automatically", "anyhow", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/api.py#L29-L48
ssato/python-anytemplate
anytemplate/api.py
_render
def _render(template=None, filepath=None, context=None, at_paths=None, at_encoding=anytemplate.compat.ENCODING, at_engine=None, at_ask_missing=False, at_cls_args=None, _at_usr_tmpl=None, **kwargs): """ Compile and render given template string and return the result string. ...
python
def _render(template=None, filepath=None, context=None, at_paths=None, at_encoding=anytemplate.compat.ENCODING, at_engine=None, at_ask_missing=False, at_cls_args=None, _at_usr_tmpl=None, **kwargs): """ Compile and render given template string and return the result string. ...
[ "def", "_render", "(", "template", "=", "None", ",", "filepath", "=", "None", ",", "context", "=", "None", ",", "at_paths", "=", "None", ",", "at_encoding", "=", "anytemplate", ".", "compat", ".", "ENCODING", ",", "at_engine", "=", "None", ",", "at_ask_m...
Compile and render given template string and return the result string. :param template: Template content string or None :param filepath: Template file path or None :param context: A dict or dict-like object to instantiate given template file :param at_paths: Template search paths :param at_...
[ "Compile", "and", "render", "given", "template", "string", "and", "return", "the", "result", "string", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/api.py#L51-L108
ssato/python-anytemplate
anytemplate/api.py
render
def render(filepath, context=None, **options): """ Compile and render given template file and return the result string. :param filepath: Template file path or '-' :param context: A dict or dict-like object to instantiate given template file :param options: Optional keyword arguments such as...
python
def render(filepath, context=None, **options): """ Compile and render given template file and return the result string. :param filepath: Template file path or '-' :param context: A dict or dict-like object to instantiate given template file :param options: Optional keyword arguments such as...
[ "def", "render", "(", "filepath", ",", "context", "=", "None", ",", "*", "*", "options", ")", ":", "if", "filepath", "==", "'-'", ":", "return", "_render", "(", "sys", ".", "stdin", ".", "read", "(", ")", ",", "context", "=", "context", ",", "*", ...
Compile and render given template file and return the result string. :param filepath: Template file path or '-' :param context: A dict or dict-like object to instantiate given template file :param options: Optional keyword arguments such as: - at_paths: Template search paths - at_e...
[ "Compile", "and", "render", "given", "template", "file", "and", "return", "the", "result", "string", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/api.py#L133-L155
ssato/python-anytemplate
anytemplate/api.py
render_to
def render_to(filepath, context=None, output=None, at_encoding=anytemplate.compat.ENCODING, **options): """ Render given template file and write the result string to given `output`. The result string will be printed to sys.stdout if output is None or '-'. :param filepath: Template file pa...
python
def render_to(filepath, context=None, output=None, at_encoding=anytemplate.compat.ENCODING, **options): """ Render given template file and write the result string to given `output`. The result string will be printed to sys.stdout if output is None or '-'. :param filepath: Template file pa...
[ "def", "render_to", "(", "filepath", ",", "context", "=", "None", ",", "output", "=", "None", ",", "at_encoding", "=", "anytemplate", ".", "compat", ".", "ENCODING", ",", "*", "*", "options", ")", ":", "res", "=", "render", "(", "filepath", ",", "conte...
Render given template file and write the result string to given `output`. The result string will be printed to sys.stdout if output is None or '-'. :param filepath: Template file path :param context: A dict or dict-like object to instantiate given template file :param output: File path to write...
[ "Render", "given", "template", "file", "and", "write", "the", "result", "string", "to", "given", "output", ".", "The", "result", "string", "will", "be", "printed", "to", "sys", ".", "stdout", "if", "output", "is", "None", "or", "-", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/api.py#L158-L180
heuer/cablemap
cablemap.core/cablemap/core/utils.py
_fetch_url
def _fetch_url(url): """\ Returns the content of the provided URL. """ try: resp = urllib2.urlopen(_Request(url)) except urllib2.URLError: if 'wikileaks.org' in url: resp = urllib2.urlopen(_Request(url.replace('wikileaks.org', 'wikileaks.ch'))) else: r...
python
def _fetch_url(url): """\ Returns the content of the provided URL. """ try: resp = urllib2.urlopen(_Request(url)) except urllib2.URLError: if 'wikileaks.org' in url: resp = urllib2.urlopen(_Request(url.replace('wikileaks.org', 'wikileaks.ch'))) else: r...
[ "def", "_fetch_url", "(", "url", ")", ":", "try", ":", "resp", "=", "urllib2", ".", "urlopen", "(", "_Request", "(", "url", ")", ")", "except", "urllib2", ".", "URLError", ":", "if", "'wikileaks.org'", "in", "url", ":", "resp", "=", "urllib2", ".", "...
\ Returns the content of the provided URL.
[ "\\", "Returns", "the", "content", "of", "the", "provided", "URL", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L40-L53
heuer/cablemap
cablemap.core/cablemap/core/utils.py
cable_page_by_id
def cable_page_by_id(reference_id): """\ Experimental: Returns the HTML page of the cable identified by `reference_id`. >>> cable_page_by_id('09BERLIN1167') is not None True >>> cable_page_by_id('22BERLIN1167') is None True >>> cable_page_by_id('09MOSCOW3010') is not None True >>> c...
python
def cable_page_by_id(reference_id): """\ Experimental: Returns the HTML page of the cable identified by `reference_id`. >>> cable_page_by_id('09BERLIN1167') is not None True >>> cable_page_by_id('22BERLIN1167') is None True >>> cable_page_by_id('09MOSCOW3010') is not None True >>> c...
[ "def", "cable_page_by_id", "(", "reference_id", ")", ":", "global", "_CABLEID2MONTH", "def", "wikileaks_id", "(", "reference_id", ")", ":", "if", "reference_id", "in", "consts", ".", "INVALID_CABLE_IDS", ".", "values", "(", ")", ":", "for", "k", ",", "v", "i...
\ Experimental: Returns the HTML page of the cable identified by `reference_id`. >>> cable_page_by_id('09BERLIN1167') is not None True >>> cable_page_by_id('22BERLIN1167') is None True >>> cable_page_by_id('09MOSCOW3010') is not None True >>> cable_page_by_id('10MADRID87') is not None ...
[ "\\", "Experimental", ":", "Returns", "the", "HTML", "page", "of", "the", "cable", "identified", "by", "reference_id", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L59-L103
heuer/cablemap
cablemap.core/cablemap/core/utils.py
cables_from_source
def cables_from_source(path, predicate=None): """\ Returns a generator with ``ICable`` instances. `path` Either a directory or a CSV file. `predicate` A predicate that is invoked for each cable reference identifier. If the predicate evaluates to ``False`` the cable is ignored. ...
python
def cables_from_source(path, predicate=None): """\ Returns a generator with ``ICable`` instances. `path` Either a directory or a CSV file. `predicate` A predicate that is invoked for each cable reference identifier. If the predicate evaluates to ``False`` the cable is ignored. ...
[ "def", "cables_from_source", "(", "path", ",", "predicate", "=", "None", ")", ":", "return", "cables_from_directory", "(", "path", ",", "predicate", ")", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", "else", "cables_from_csv", "(", "path", ",", ...
\ Returns a generator with ``ICable`` instances. `path` Either a directory or a CSV file. `predicate` A predicate that is invoked for each cable reference identifier. If the predicate evaluates to ``False`` the cable is ignored. By default, all cables are used. I.e. ...
[ "\\", "Returns", "a", "generator", "with", "ICable", "instances", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L129-L142
heuer/cablemap
cablemap.core/cablemap/core/utils.py
cables_from_csv
def cables_from_csv(filename, predicate=None, encoding='utf-8'): """\ Returns a generator with ``ICable`` instances. Reads the provided CSV file and returns a cable for each row. `filename` Absolute path to a file to read the cables from. The file must be a CSV file with the following ...
python
def cables_from_csv(filename, predicate=None, encoding='utf-8'): """\ Returns a generator with ``ICable`` instances. Reads the provided CSV file and returns a cable for each row. `filename` Absolute path to a file to read the cables from. The file must be a CSV file with the following ...
[ "def", "cables_from_csv", "(", "filename", ",", "predicate", "=", "None", ",", "encoding", "=", "'utf-8'", ")", ":", "return", "(", "cable_from_row", "(", "row", ")", "for", "row", "in", "rows_from_csv", "(", "filename", ",", "predicate", ",", "encoding", ...
\ Returns a generator with ``ICable`` instances. Reads the provided CSV file and returns a cable for each row. `filename` Absolute path to a file to read the cables from. The file must be a CSV file with the following columns: <identifier>, <creation-date>, <reference-id>, <origin>...
[ "\\", "Returns", "a", "generator", "with", "ICable", "instances", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L145-L165
heuer/cablemap
cablemap.core/cablemap/core/utils.py
rows_from_csv
def rows_from_csv(filename, predicate=None, encoding='utf-8'): """\ Returns an iterator over all rows in the provided CSV `filename`. `filename` Absolute path to a file to read the cables from. The file must be a CSV file with the following columns: <identifier>, <creation-date>, <r...
python
def rows_from_csv(filename, predicate=None, encoding='utf-8'): """\ Returns an iterator over all rows in the provided CSV `filename`. `filename` Absolute path to a file to read the cables from. The file must be a CSV file with the following columns: <identifier>, <creation-date>, <r...
[ "def", "rows_from_csv", "(", "filename", ",", "predicate", "=", "None", ",", "encoding", "=", "'utf-8'", ")", ":", "pred", "=", "predicate", "or", "bool", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "for", "row", "in", "_UnicodeR...
\ Returns an iterator over all rows in the provided CSV `filename`. `filename` Absolute path to a file to read the cables from. The file must be a CSV file with the following columns: <identifier>, <creation-date>, <reference-id>, <origin>, <classification-level>, <references-to-other-c...
[ "\\", "Returns", "an", "iterator", "over", "all", "rows", "in", "the", "provided", "CSV", "filename", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L168-L191
heuer/cablemap
cablemap.core/cablemap/core/utils.py
cablefiles_from_directory
def cablefiles_from_directory(directory, predicate=None): """\ Returns a generator which yields absoulte filenames to cable HTML files. `directory` The directory. `predicate` A predicate that is invoked for each cable filename. If the predicate evaluates to ``False`` the fil...
python
def cablefiles_from_directory(directory, predicate=None): """\ Returns a generator which yields absoulte filenames to cable HTML files. `directory` The directory. `predicate` A predicate that is invoked for each cable filename. If the predicate evaluates to ``False`` the fil...
[ "def", "cablefiles_from_directory", "(", "directory", ",", "predicate", "=", "None", ")", ":", "pred", "=", "predicate", "or", "bool", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "directory", ")", ":", "for", "name", "in", "...
\ Returns a generator which yields absoulte filenames to cable HTML files. `directory` The directory. `predicate` A predicate that is invoked for each cable filename. If the predicate evaluates to ``False`` the file is ignored. By default, all files with the file extensi...
[ "\\", "Returns", "a", "generator", "which", "yields", "absoulte", "filenames", "to", "cable", "HTML", "files", ".", "directory", "The", "directory", ".", "predicate", "A", "predicate", "that", "is", "invoked", "for", "each", "cable", "filename", ".", "If", "...
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L244-L260
heuer/cablemap
cablemap.core/cablemap/core/utils.py
reference_id_parts
def reference_id_parts(reference_id): """\ Returns a tuple from the provided `reference_id`:: (YEAR, ORIGIN, S/N) `reference_id` Cable reference identifier or canonical identifier. """ m = consts.REFERENCE_ID_PATTERN.match(reference_id) if m: return m.groups() raise...
python
def reference_id_parts(reference_id): """\ Returns a tuple from the provided `reference_id`:: (YEAR, ORIGIN, S/N) `reference_id` Cable reference identifier or canonical identifier. """ m = consts.REFERENCE_ID_PATTERN.match(reference_id) if m: return m.groups() raise...
[ "def", "reference_id_parts", "(", "reference_id", ")", ":", "m", "=", "consts", ".", "REFERENCE_ID_PATTERN", ".", "match", "(", "reference_id", ")", "if", "m", ":", "return", "m", ".", "groups", "(", ")", "raise", "ValueError", "(", "'Illegal reference identif...
\ Returns a tuple from the provided `reference_id`:: (YEAR, ORIGIN, S/N) `reference_id` Cable reference identifier or canonical identifier.
[ "\\", "Returns", "a", "tuple", "from", "the", "provided", "reference_id", "::" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L263-L275
heuer/cablemap
cablemap.core/cablemap/core/utils.py
tag_kind
def tag_kind(tag, default=consts.TAG_KIND_UNKNOWN): """\ Returns the TAG kind. `tag` A string. `default` A value to return if the TAG kind is unknown (set to ``constants.TAG_KIND_UNKNOWN`` by default) """ if len(tag) == 2: return consts.TAG_KIND_GEO if u',' i...
python
def tag_kind(tag, default=consts.TAG_KIND_UNKNOWN): """\ Returns the TAG kind. `tag` A string. `default` A value to return if the TAG kind is unknown (set to ``constants.TAG_KIND_UNKNOWN`` by default) """ if len(tag) == 2: return consts.TAG_KIND_GEO if u',' i...
[ "def", "tag_kind", "(", "tag", ",", "default", "=", "consts", ".", "TAG_KIND_UNKNOWN", ")", ":", "if", "len", "(", "tag", ")", "==", "2", ":", "return", "consts", ".", "TAG_KIND_GEO", "if", "u','", "in", "tag", ":", "return", "consts", ".", "TAG_KIND_P...
\ Returns the TAG kind. `tag` A string. `default` A value to return if the TAG kind is unknown (set to ``constants.TAG_KIND_UNKNOWN`` by default)
[ "\\", "Returns", "the", "TAG", "kind", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L281-L302
heuer/cablemap
cablemap.core/cablemap/core/utils.py
clean_content
def clean_content(content): """\ Removes paragraph numbers, section delimiters, xxxx etc. from the content. This function can be used to clean-up the cable's content before it is processed by NLP tools or to create a search engine index. `content` The content of the cable. """ ...
python
def clean_content(content): """\ Removes paragraph numbers, section delimiters, xxxx etc. from the content. This function can be used to clean-up the cable's content before it is processed by NLP tools or to create a search engine index. `content` The content of the cable. """ ...
[ "def", "clean_content", "(", "content", ")", ":", "for", "pattern", ",", "subst", "in", "_CLEAN_PATTERNS", ":", "content", "=", "pattern", ".", "sub", "(", "subst", ",", "content", ")", "return", "content" ]
\ Removes paragraph numbers, section delimiters, xxxx etc. from the content. This function can be used to clean-up the cable's content before it is processed by NLP tools or to create a search engine index. `content` The content of the cable.
[ "\\", "Removes", "paragraph", "numbers", "section", "delimiters", "xxxx", "etc", ".", "from", "the", "content", ".", "This", "function", "can", "be", "used", "to", "clean", "-", "up", "the", "cable", "s", "content", "before", "it", "is", "processed", "by",...
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L319-L331
heuer/cablemap
cablemap.core/cablemap/core/utils.py
titlefy
def titlefy(subject): """\ Titlecases the provided subject but respects common abbreviations. This function returns ``None`` if the provided `subject` is ``None``. It returns an empty string if the provided subject is empty. `subject A cable's subject. """ def clean_word(word...
python
def titlefy(subject): """\ Titlecases the provided subject but respects common abbreviations. This function returns ``None`` if the provided `subject` is ``None``. It returns an empty string if the provided subject is empty. `subject A cable's subject. """ def clean_word(word...
[ "def", "titlefy", "(", "subject", ")", ":", "def", "clean_word", "(", "word", ")", ":", "return", "_APOS_PATTERN", ".", "sub", "(", "lambda", "m", ":", "u'%s%s%s'", "%", "(", "m", ".", "group", "(", "1", ")", ",", "m", ".", "group", "(", "2", ")"...
\ Titlecases the provided subject but respects common abbreviations. This function returns ``None`` if the provided `subject` is ``None``. It returns an empty string if the provided subject is empty. `subject A cable's subject.
[ "\\", "Titlecases", "the", "provided", "subject", "but", "respects", "common", "abbreviations", ".", "This", "function", "returns", "None", "if", "the", "provided", "subject", "is", "None", ".", "It", "returns", "an", "empty", "string", "if", "the", "provided"...
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/utils.py#L381-L417
peterldowns/djoauth2
djoauth2/decorators.py
oauth_scope
def oauth_scope(*scope_names): """ Return a decorator that restricts requests to those authorized with a certain scope or scopes. For example, to restrict access to a given endpoint like this: .. code-block:: python @require_login def secret_attribute_endpoint(request, *args, **kwargs): ...
python
def oauth_scope(*scope_names): """ Return a decorator that restricts requests to those authorized with a certain scope or scopes. For example, to restrict access to a given endpoint like this: .. code-block:: python @require_login def secret_attribute_endpoint(request, *args, **kwargs): ...
[ "def", "oauth_scope", "(", "*", "scope_names", ")", ":", "authenticator", "=", "AccessTokenAuthenticator", "(", "required_scope_names", "=", "scope_names", ")", "def", "scope_decorator", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "wr...
Return a decorator that restricts requests to those authorized with a certain scope or scopes. For example, to restrict access to a given endpoint like this: .. code-block:: python @require_login def secret_attribute_endpoint(request, *args, **kwargs): user = request.user return Ht...
[ "Return", "a", "decorator", "that", "restricts", "requests", "to", "those", "authorized", "with", "a", "certain", "scope", "or", "scopes", "." ]
train
https://github.com/peterldowns/djoauth2/blob/151c7619d1d7a91d720397cfecf3a29fcc9747a9/djoauth2/decorators.py#L6-L60
tapilab/twutil
twutil/preprocess.py
Tokenizer.do_tokenize
def do_tokenize(self, text): """ >>> tk = Tokenizer(ngrams=1, lc=True, collapse_urls=True, collapse_mentions=True, collapse_hashtags=False, retain_punc_toks=True) >>> tk.do_tokenize('http://www.foo.com fast-forward hi there :) how?? U.S.A. @you whaaaaaaat? #awesome.') ['THIS_IS_A_URL', '...
python
def do_tokenize(self, text): """ >>> tk = Tokenizer(ngrams=1, lc=True, collapse_urls=True, collapse_mentions=True, collapse_hashtags=False, retain_punc_toks=True) >>> tk.do_tokenize('http://www.foo.com fast-forward hi there :) how?? U.S.A. @you whaaaaaaat? #awesome.') ['THIS_IS_A_URL', '...
[ "def", "do_tokenize", "(", "self", ",", "text", ")", ":", "text", "=", "text", ".", "lower", "(", ")", "if", "self", ".", "lc", "else", "text", "if", "self", ".", "collapse_hashtags", ":", "text", "=", "re", ".", "sub", "(", "'#\\S+'", ",", "'THIS_...
>>> tk = Tokenizer(ngrams=1, lc=True, collapse_urls=True, collapse_mentions=True, collapse_hashtags=False, retain_punc_toks=True) >>> tk.do_tokenize('http://www.foo.com fast-forward hi there :) how?? U.S.A. @you whaaaaaaat? #awesome.') ['THIS_IS_A_URL', 'fast-forward', 'hi', 'there', ':)', 'how', '??', ...
[ ">>>", "tk", "=", "Tokenizer", "(", "ngrams", "=", "1", "lc", "=", "True", "collapse_urls", "=", "True", "collapse_mentions", "=", "True", "collapse_hashtags", "=", "False", "retain_punc_toks", "=", "True", ")", ">>>", "tk", ".", "do_tokenize", "(", "http", ...
train
https://github.com/tapilab/twutil/blob/c967120c41a6e216f3d476214b85a736cade0e29/twutil/preprocess.py#L36-L72
tapilab/twutil
twutil/preprocess.py
Tokenizer.tokenize
def tokenize(self, tw): """ Given a Tweet object, return a dict mapping field name to tokens. """ toks = defaultdict(lambda: []) for field in self.fields: if '.' in field: parts = field.split('.') value = tw.js for p in parts: ...
python
def tokenize(self, tw): """ Given a Tweet object, return a dict mapping field name to tokens. """ toks = defaultdict(lambda: []) for field in self.fields: if '.' in field: parts = field.split('.') value = tw.js for p in parts: ...
[ "def", "tokenize", "(", "self", ",", "tw", ")", ":", "toks", "=", "defaultdict", "(", "lambda", ":", "[", "]", ")", "for", "field", "in", "self", ".", "fields", ":", "if", "'.'", "in", "field", ":", "parts", "=", "field", ".", "split", "(", "'.'"...
Given a Tweet object, return a dict mapping field name to tokens.
[ "Given", "a", "Tweet", "object", "return", "a", "dict", "mapping", "field", "name", "to", "tokens", "." ]
train
https://github.com/tapilab/twutil/blob/c967120c41a6e216f3d476214b85a736cade0e29/twutil/preprocess.py#L74-L86
tapilab/twutil
twutil/preprocess.py
Tokenizer.tokenize_fielded
def tokenize_fielded(self, tw): """ Tokenize tweet and prepend field id before each token. >>> t = Tokenizer(fields=['text', 'user.name', 'user.location']) >>> list(t.tokenize_fielded(Tweet(json.loads(data.test_tweet)))) ['text___if', 'text___only', "text___bradley's", 'text___arm', 'tex...
python
def tokenize_fielded(self, tw): """ Tokenize tweet and prepend field id before each token. >>> t = Tokenizer(fields=['text', 'user.name', 'user.location']) >>> list(t.tokenize_fielded(Tweet(json.loads(data.test_tweet)))) ['text___if', 'text___only', "text___bradley's", 'text___arm', 'tex...
[ "def", "tokenize_fielded", "(", "self", ",", "tw", ")", ":", "toks", "=", "self", ".", "tokenize", "(", "tw", ")", "for", "field", ",", "tokens", "in", "sorted", "(", "toks", ".", "items", "(", ")", ")", ":", "for", "tok", "in", "tokens", ":", "y...
Tokenize tweet and prepend field id before each token. >>> t = Tokenizer(fields=['text', 'user.name', 'user.location']) >>> list(t.tokenize_fielded(Tweet(json.loads(data.test_tweet)))) ['text___if', 'text___only', "text___bradley's", 'text___arm', 'text___was', 'text___longer', 'text___.', 'text...
[ "Tokenize", "tweet", "and", "prepend", "field", "id", "before", "each", "token", ".", ">>>", "t", "=", "Tokenizer", "(", "fields", "=", "[", "text", "user", ".", "name", "user", ".", "location", "]", ")", ">>>", "list", "(", "t", ".", "tokenize_fielded...
train
https://github.com/tapilab/twutil/blob/c967120c41a6e216f3d476214b85a736cade0e29/twutil/preprocess.py#L88-L97
akfullfo/taskforce
taskforce/httpd.py
server
def server(service, log=None): """ Creates a threaded http service based on the passed HttpService instance. The returned object can be watched via taskforce.poll(), select.select(), etc. When activity is detected, the handle_request() method should be invoked. This starts a thread to handle the re...
python
def server(service, log=None): """ Creates a threaded http service based on the passed HttpService instance. The returned object can be watched via taskforce.poll(), select.select(), etc. When activity is detected, the handle_request() method should be invoked. This starts a thread to handle the re...
[ "def", "server", "(", "service", ",", "log", "=", "None", ")", ":", "if", "log", ":", "log", "=", "log", "else", ":", "# pragma: no cover", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", "log", ".", "addHandler", "(", "logging", ".", ...
Creates a threaded http service based on the passed HttpService instance. The returned object can be watched via taskforce.poll(), select.select(), etc. When activity is detected, the handle_request() method should be invoked. This starts a thread to handle the request. URL paths are handled with callback...
[ "Creates", "a", "threaded", "http", "service", "based", "on", "the", "passed", "HttpService", "instance", "." ]
train
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/httpd.py#L382-L466
akfullfo/taskforce
taskforce/httpd.py
_unicode
def _unicode(p): """ Used when force_unicode is True (default), the tags and values in the dict will be coerced as 'str' (or 'unicode' with Python2). In Python3 they can otherwise end up as a mixtures of 'str' and 'bytes'. """ q = {} for tag in p: vals = [] for v in p[tag]: ...
python
def _unicode(p): """ Used when force_unicode is True (default), the tags and values in the dict will be coerced as 'str' (or 'unicode' with Python2). In Python3 they can otherwise end up as a mixtures of 'str' and 'bytes'. """ q = {} for tag in p: vals = [] for v in p[tag]: ...
[ "def", "_unicode", "(", "p", ")", ":", "q", "=", "{", "}", "for", "tag", "in", "p", ":", "vals", "=", "[", "]", "for", "v", "in", "p", "[", "tag", "]", ":", "if", "type", "(", "v", ")", "is", "not", "str", ":", "# pragma: no cover", "v", "=...
Used when force_unicode is True (default), the tags and values in the dict will be coerced as 'str' (or 'unicode' with Python2). In Python3 they can otherwise end up as a mixtures of 'str' and 'bytes'.
[ "Used", "when", "force_unicode", "is", "True", "(", "default", ")", "the", "tags", "and", "values", "in", "the", "dict", "will", "be", "coerced", "as", "str", "(", "or", "unicode", "with", "Python2", ")", ".", "In", "Python3", "they", "can", "otherwise",...
train
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/httpd.py#L468-L484
akfullfo/taskforce
taskforce/httpd.py
get_query
def get_query(path, force_unicode=True): """ Convert the query path of the URL to a dict. See _unicode regarding force_unicode. """ u = urlparse(path) if not u.query: return {} p = parse_qs(u.query) if force_unicode: p = _unicode(p) return p
python
def get_query(path, force_unicode=True): """ Convert the query path of the URL to a dict. See _unicode regarding force_unicode. """ u = urlparse(path) if not u.query: return {} p = parse_qs(u.query) if force_unicode: p = _unicode(p) return p
[ "def", "get_query", "(", "path", ",", "force_unicode", "=", "True", ")", ":", "u", "=", "urlparse", "(", "path", ")", "if", "not", "u", ".", "query", ":", "return", "{", "}", "p", "=", "parse_qs", "(", "u", ".", "query", ")", "if", "force_unicode",...
Convert the query path of the URL to a dict. See _unicode regarding force_unicode.
[ "Convert", "the", "query", "path", "of", "the", "URL", "to", "a", "dict", ".", "See", "_unicode", "regarding", "force_unicode", "." ]
train
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/httpd.py#L486-L498
akfullfo/taskforce
taskforce/httpd.py
merge_query
def merge_query(path, postmap, force_unicode=True): """ Merges params parsed from the URI into the mapping from the POST body and returns a new dict with the values. This is a convenience function that gives use a dict a bit like PHP's $_REQUEST array. The original 'postmap' is preserved so the ca...
python
def merge_query(path, postmap, force_unicode=True): """ Merges params parsed from the URI into the mapping from the POST body and returns a new dict with the values. This is a convenience function that gives use a dict a bit like PHP's $_REQUEST array. The original 'postmap' is preserved so the ca...
[ "def", "merge_query", "(", "path", ",", "postmap", ",", "force_unicode", "=", "True", ")", ":", "if", "postmap", ":", "p", "=", "postmap", ".", "copy", "(", ")", "else", ":", "p", "=", "{", "}", "p", ".", "update", "(", "get_query", "(", "path", ...
Merges params parsed from the URI into the mapping from the POST body and returns a new dict with the values. This is a convenience function that gives use a dict a bit like PHP's $_REQUEST array. The original 'postmap' is preserved so the caller can identify a param's source if necessary.
[ "Merges", "params", "parsed", "from", "the", "URI", "into", "the", "mapping", "from", "the", "POST", "body", "and", "returns", "a", "new", "dict", "with", "the", "values", "." ]
train
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/httpd.py#L500-L517
akfullfo/taskforce
taskforce/httpd.py
truthy
def truthy(value): """ Evaluates True if "value" looks like it is intended to be true. This translates to an integer value greater than 0 or the first character starting with 'y' or 't' (case independent). """ if value is None or value == '': return False value = str(value) try: ...
python
def truthy(value): """ Evaluates True if "value" looks like it is intended to be true. This translates to an integer value greater than 0 or the first character starting with 'y' or 't' (case independent). """ if value is None or value == '': return False value = str(value) try: ...
[ "def", "truthy", "(", "value", ")", ":", "if", "value", "is", "None", "or", "value", "==", "''", ":", "return", "False", "value", "=", "str", "(", "value", ")", "try", ":", "return", "(", "int", "(", "value", ")", "!=", "0", ")", "except", ":", ...
Evaluates True if "value" looks like it is intended to be true. This translates to an integer value greater than 0 or the first character starting with 'y' or 't' (case independent).
[ "Evaluates", "True", "if", "value", "looks", "like", "it", "is", "intended", "to", "be", "true", ".", "This", "translates", "to", "an", "integer", "value", "greater", "than", "0", "or", "the", "first", "character", "starting", "with", "y", "or", "t", "("...
train
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/httpd.py#L520-L533
akfullfo/taskforce
taskforce/httpd.py
HttpService.cmp
def cmp(self, other_service): """ Compare with an instance of this object. Returns None if the object is not comparable, False is relevant attributes don't match and True if they do. """ if not isinstance(other_service, HttpService): return None for att i...
python
def cmp(self, other_service): """ Compare with an instance of this object. Returns None if the object is not comparable, False is relevant attributes don't match and True if they do. """ if not isinstance(other_service, HttpService): return None for att i...
[ "def", "cmp", "(", "self", ",", "other_service", ")", ":", "if", "not", "isinstance", "(", "other_service", ",", "HttpService", ")", ":", "return", "None", "for", "att", "in", "dir", "(", "self", ")", ":", "if", "att", "==", "'cmp'", "or", "att", "."...
Compare with an instance of this object. Returns None if the object is not comparable, False is relevant attributes don't match and True if they do.
[ "Compare", "with", "an", "instance", "of", "this", "object", ".", "Returns", "None", "if", "the", "object", "is", "not", "comparable", "False", "is", "relevant", "attributes", "don", "t", "match", "and", "True", "if", "they", "do", "." ]
train
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/httpd.py#L82-L97