repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
kodexlab/reliure
reliure/pipeline.py
Optionable.change_option_default
def change_option_default(self, opt_name, default_val): """ Change the default value of an option :param opt_name: option name :type opt_name: str :param value: new default option value """ if not self.has_option(opt_name): raise ValueError("...
python
def change_option_default(self, opt_name, default_val): """ Change the default value of an option :param opt_name: option name :type opt_name: str :param value: new default option value """ if not self.has_option(opt_name): raise ValueError("...
[ "def", "change_option_default", "(", "self", ",", "opt_name", ",", "default_val", ")", ":", "if", "not", "self", ".", "has_option", "(", "opt_name", ")", ":", "raise", "ValueError", "(", "\"Unknow option name (%s)\"", "%", "opt_name", ")", "self", ".", "_optio...
Change the default value of an option :param opt_name: option name :type opt_name: str :param value: new default option value
[ "Change", "the", "default", "value", "of", "an", "option", ":", "param", "opt_name", ":", "option", "name", ":", "type", "opt_name", ":", "str", ":", "param", "value", ":", "new", "default", "option", "value" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L221-L231
kodexlab/reliure
reliure/pipeline.py
Optionable.force_option_value
def force_option_value(self, opt_name, value): """ force the (default) value of an option. The option is then no more listed by :func:`get_options()`. :param opt_name: option name :type opt_name: str :param value: option value """ if not self.has_option(o...
python
def force_option_value(self, opt_name, value): """ force the (default) value of an option. The option is then no more listed by :func:`get_options()`. :param opt_name: option name :type opt_name: str :param value: option value """ if not self.has_option(o...
[ "def", "force_option_value", "(", "self", ",", "opt_name", ",", "value", ")", ":", "if", "not", "self", ".", "has_option", "(", "opt_name", ")", ":", "raise", "ValueError", "(", "\"Unknow option name (%s)\"", "%", "opt_name", ")", "self", ".", "_options", "[...
force the (default) value of an option. The option is then no more listed by :func:`get_options()`. :param opt_name: option name :type opt_name: str :param value: option value
[ "force", "the", "(", "default", ")", "value", "of", "an", "option", ".", "The", "option", "is", "then", "no", "more", "listed", "by", ":", "func", ":", "get_options", "()", ".", ":", "param", "opt_name", ":", "option", "name", ":", "type", "opt_name", ...
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L233-L244
kodexlab/reliure
reliure/pipeline.py
Optionable.get_option_default
def get_option_default(self, opt_name): """ Return the default value of a given option :param opt_name: option name :type opt_name: str :returns: the default value of the option """ if not self.has_option(opt_name): raise ValueError("Unknow o...
python
def get_option_default(self, opt_name): """ Return the default value of a given option :param opt_name: option name :type opt_name: str :returns: the default value of the option """ if not self.has_option(opt_name): raise ValueError("Unknow o...
[ "def", "get_option_default", "(", "self", ",", "opt_name", ")", ":", "if", "not", "self", ".", "has_option", "(", "opt_name", ")", ":", "raise", "ValueError", "(", "\"Unknow option name (%s)\"", "%", "opt_name", ")", "return", "self", ".", "_options", "[", "...
Return the default value of a given option :param opt_name: option name :type opt_name: str :returns: the default value of the option
[ "Return", "the", "default", "value", "of", "a", "given", "option", ":", "param", "opt_name", ":", "option", "name", ":", "type", "opt_name", ":", "str", ":", "returns", ":", "the", "default", "value", "of", "the", "option" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L246-L256
kodexlab/reliure
reliure/pipeline.py
Optionable.set_options_values
def set_options_values(self, options, parse=False, strict=False): """ Set the options from a dict of values (in string). :param option_values: the values of options (in format `{"opt_name": "new_value"}`) :type option_values: dict :param parse: whether to parse the given value ...
python
def set_options_values(self, options, parse=False, strict=False): """ Set the options from a dict of values (in string). :param option_values: the values of options (in format `{"opt_name": "new_value"}`) :type option_values: dict :param parse: whether to parse the given value ...
[ "def", "set_options_values", "(", "self", ",", "options", ",", "parse", "=", "False", ",", "strict", "=", "False", ")", ":", "if", "strict", ":", "for", "opt_name", "in", "options", ".", "keys", "(", ")", ":", "if", "not", "self", ".", "has_option", ...
Set the options from a dict of values (in string). :param option_values: the values of options (in format `{"opt_name": "new_value"}`) :type option_values: dict :param parse: whether to parse the given value :type parse: bool :param strict: if True the given `option_valu...
[ "Set", "the", "options", "from", "a", "dict", "of", "values", "(", "in", "string", ")", ".", ":", "param", "option_values", ":", "the", "values", "of", "options", "(", "in", "format", "{", "opt_name", ":", "new_value", "}", ")", ":", "type", "option_va...
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L264-L285
kodexlab/reliure
reliure/pipeline.py
Optionable.get_options_values
def get_options_values(self, hidden=False): """ return a dictionary of options values :param hidden: whether to return hidden options :type hidden: bool :returns: dictionary of all option values :rtype: dict """ values = {} for opt_name, opt in se...
python
def get_options_values(self, hidden=False): """ return a dictionary of options values :param hidden: whether to return hidden options :type hidden: bool :returns: dictionary of all option values :rtype: dict """ values = {} for opt_name, opt in se...
[ "def", "get_options_values", "(", "self", ",", "hidden", "=", "False", ")", ":", "values", "=", "{", "}", "for", "opt_name", ",", "opt", "in", "self", ".", "_options", ".", "items", "(", ")", ":", "if", "hidden", "or", "not", "opt", ".", "hidden", ...
return a dictionary of options values :param hidden: whether to return hidden options :type hidden: bool :returns: dictionary of all option values :rtype: dict
[ "return", "a", "dictionary", "of", "options", "values", ":", "param", "hidden", ":", "whether", "to", "return", "hidden", "options", ":", "type", "hidden", ":", "bool", ":", "returns", ":", "dictionary", "of", "all", "option", "values", ":", "rtype", ":", ...
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L287-L299
kodexlab/reliure
reliure/pipeline.py
Optionable.parse_options
def parse_options(self, option_values): """ Set the options (with parsing) and returns a dict of all options values """ self.set_options_values(option_values, parse=True) return self.get_options_values(hidden=False)
python
def parse_options(self, option_values): """ Set the options (with parsing) and returns a dict of all options values """ self.set_options_values(option_values, parse=True) return self.get_options_values(hidden=False)
[ "def", "parse_options", "(", "self", ",", "option_values", ")", ":", "self", ".", "set_options_values", "(", "option_values", ",", "parse", "=", "True", ")", "return", "self", ".", "get_options_values", "(", "hidden", "=", "False", ")" ]
Set the options (with parsing) and returns a dict of all options values
[ "Set", "the", "options", "(", "with", "parsing", ")", "and", "returns", "a", "dict", "of", "all", "options", "values" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L301-L305
kodexlab/reliure
reliure/pipeline.py
Optionable.get_options
def get_options(self, hidden=False): """ :param hidden: whether to return hidden options :type hidden: bool :returns: dictionary of all options (with option's information) :rtype: dict """ return dict((opt['name'], opt) for opt in self.get_ordered_options(hidden=h...
python
def get_options(self, hidden=False): """ :param hidden: whether to return hidden options :type hidden: bool :returns: dictionary of all options (with option's information) :rtype: dict """ return dict((opt['name'], opt) for opt in self.get_ordered_options(hidden=h...
[ "def", "get_options", "(", "self", ",", "hidden", "=", "False", ")", ":", "return", "dict", "(", "(", "opt", "[", "'name'", "]", ",", "opt", ")", "for", "opt", "in", "self", ".", "get_ordered_options", "(", "hidden", "=", "hidden", ")", ")" ]
:param hidden: whether to return hidden options :type hidden: bool :returns: dictionary of all options (with option's information) :rtype: dict
[ ":", "param", "hidden", ":", "whether", "to", "return", "hidden", "options", ":", "type", "hidden", ":", "bool", ":", "returns", ":", "dictionary", "of", "all", "options", "(", "with", "option", "s", "information", ")", ":", "rtype", ":", "dict" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L307-L314
kodexlab/reliure
reliure/pipeline.py
Optionable.get_ordered_options
def get_ordered_options(self, hidden=False): """ :param hidden: whether to return hidden option :type hidden: bool :returns: **ordered** list of options pre-serialised (as_dict) :rtype: list `[opt_dict, ...]` """ return [opt.as_dict() for opt in self.options.value...
python
def get_ordered_options(self, hidden=False): """ :param hidden: whether to return hidden option :type hidden: bool :returns: **ordered** list of options pre-serialised (as_dict) :rtype: list `[opt_dict, ...]` """ return [opt.as_dict() for opt in self.options.value...
[ "def", "get_ordered_options", "(", "self", ",", "hidden", "=", "False", ")", ":", "return", "[", "opt", ".", "as_dict", "(", ")", "for", "opt", "in", "self", ".", "options", ".", "values", "(", ")", "if", "hidden", "or", "(", "not", "opt", ".", "hi...
:param hidden: whether to return hidden option :type hidden: bool :returns: **ordered** list of options pre-serialised (as_dict) :rtype: list `[opt_dict, ...]`
[ ":", "param", "hidden", ":", "whether", "to", "return", "hidden", "option", ":", "type", "hidden", ":", "bool", ":", "returns", ":", "**", "ordered", "**", "list", "of", "options", "pre", "-", "serialised", "(", "as_dict", ")", ":", "rtype", ":", "list...
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L316-L324
kodexlab/reliure
reliure/pipeline.py
Optionable.check
def check(call_fct): """ Decorator for optionable __call__ method It check the given option values """ # wrap the method @wraps(call_fct) def checked_call(self, *args, **kwargs): self.set_options_values(kwargs, parse=False, strict=True) options_val...
python
def check(call_fct): """ Decorator for optionable __call__ method It check the given option values """ # wrap the method @wraps(call_fct) def checked_call(self, *args, **kwargs): self.set_options_values(kwargs, parse=False, strict=True) options_val...
[ "def", "check", "(", "call_fct", ")", ":", "# wrap the method", "@", "wraps", "(", "call_fct", ")", "def", "checked_call", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "set_options_values", "(", "kwargs", ",", "parse", ...
Decorator for optionable __call__ method It check the given option values
[ "Decorator", "for", "optionable", "__call__", "method", "It", "check", "the", "given", "option", "values" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L327-L340
tomnor/channelpack
channelpack/pulltxt.py
loadtxt
def loadtxt(fn, **kwargs): """Study the text data file fn. Call numpys loadtxt with keyword arguments based on the study. Return data returned from numpy `loadtxt <http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy-loadtxt>`. kwargs: keyword arguments accepted by numpys loadt...
python
def loadtxt(fn, **kwargs): """Study the text data file fn. Call numpys loadtxt with keyword arguments based on the study. Return data returned from numpy `loadtxt <http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy-loadtxt>`. kwargs: keyword arguments accepted by numpys loadt...
[ "def", "loadtxt", "(", "fn", ",", "*", "*", "kwargs", ")", ":", "global", "PP", "PP", "=", "PatternPull", "(", "fn", ")", "txtargs", "=", "PP", ".", "loadtxtargs", "(", ")", "txtargs", ".", "update", "(", "kwargs", ")", "# Let kwargs dominate.", "retur...
Study the text data file fn. Call numpys loadtxt with keyword arguments based on the study. Return data returned from numpy `loadtxt <http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy-loadtxt>`. kwargs: keyword arguments accepted by numpys loadtxt. Any keyword arguments prov...
[ "Study", "the", "text", "data", "file", "fn", ".", "Call", "numpys", "loadtxt", "with", "keyword", "arguments", "based", "on", "the", "study", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L325-L342
tomnor/channelpack
channelpack/pulltxt.py
loadtxt_asdict
def loadtxt_asdict(fn, **kwargs): """Return what is returned from loadtxt as a dict. The 'unpack' keyword is enforced to True. The keys in the dict is the column numbers loaded. It is the integers 0...N-1 for N loaded columns, or the numbers in usecols.""" kwargs.update(unpack=True) d = loadtx...
python
def loadtxt_asdict(fn, **kwargs): """Return what is returned from loadtxt as a dict. The 'unpack' keyword is enforced to True. The keys in the dict is the column numbers loaded. It is the integers 0...N-1 for N loaded columns, or the numbers in usecols.""" kwargs.update(unpack=True) d = loadtx...
[ "def", "loadtxt_asdict", "(", "fn", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "unpack", "=", "True", ")", "d", "=", "loadtxt", "(", "fn", ",", "*", "*", "kwargs", ")", "if", "len", "(", "np", ".", "shape", "(", "d", ")", ...
Return what is returned from loadtxt as a dict. The 'unpack' keyword is enforced to True. The keys in the dict is the column numbers loaded. It is the integers 0...N-1 for N loaded columns, or the numbers in usecols.
[ "Return", "what", "is", "returned", "from", "loadtxt", "as", "a", "dict", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L345-L363
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.file_rows
def file_rows(self, fo): """Return the lines in the file as a list. fo is the open file object.""" rows = [] for i in range(NUMROWS): line = fo.readline() if not line: break rows += [line] return rows
python
def file_rows(self, fo): """Return the lines in the file as a list. fo is the open file object.""" rows = [] for i in range(NUMROWS): line = fo.readline() if not line: break rows += [line] return rows
[ "def", "file_rows", "(", "self", ",", "fo", ")", ":", "rows", "=", "[", "]", "for", "i", "in", "range", "(", "NUMROWS", ")", ":", "line", "=", "fo", ".", "readline", "(", ")", "if", "not", "line", ":", "break", "rows", "+=", "[", "line", "]", ...
Return the lines in the file as a list. fo is the open file object.
[ "Return", "the", "lines", "in", "the", "file", "as", "a", "list", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L101-L113
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.count_matches
def count_matches(self): """Set the matches_p, matches_c and rows attributes.""" try: self.fn = self.fo.name rows = self.file_rows(self.fo) self.fo.seek(0) except AttributeError: with open(self.fn) as fo: rows = self.file_rows(fo)...
python
def count_matches(self): """Set the matches_p, matches_c and rows attributes.""" try: self.fn = self.fo.name rows = self.file_rows(self.fo) self.fo.seek(0) except AttributeError: with open(self.fn) as fo: rows = self.file_rows(fo)...
[ "def", "count_matches", "(", "self", ")", ":", "try", ":", "self", ".", "fn", "=", "self", ".", "fo", ".", "name", "rows", "=", "self", ".", "file_rows", "(", "self", ".", "fo", ")", "self", ".", "fo", ".", "seek", "(", "0", ")", "except", "Att...
Set the matches_p, matches_c and rows attributes.
[ "Set", "the", "matches_p", "matches_c", "and", "rows", "attributes", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L115-L137
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.rows2skip
def rows2skip(self, decdel): """ Return the number of rows to skip based on the decimal delimiter decdel. When each record start to have the same number of matches, this is where the data starts. This is the idea. And the number of consecutive records to have the same nu...
python
def rows2skip(self, decdel): """ Return the number of rows to skip based on the decimal delimiter decdel. When each record start to have the same number of matches, this is where the data starts. This is the idea. And the number of consecutive records to have the same nu...
[ "def", "rows2skip", "(", "self", ",", "decdel", ")", ":", "if", "decdel", "==", "'.'", ":", "ms", "=", "self", ".", "matches_p", "elif", "decdel", "==", "','", ":", "ms", "=", "self", ".", "matches_c", "# else make error...", "cnt", "=", "row", "=", ...
Return the number of rows to skip based on the decimal delimiter decdel. When each record start to have the same number of matches, this is where the data starts. This is the idea. And the number of consecutive records to have the same number of matches is to be EQUAL_CNT_REQ.
[ "Return", "the", "number", "of", "rows", "to", "skip", "based", "on", "the", "decimal", "delimiter", "decdel", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L139-L173
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.set_decdel_rts
def set_decdel_rts(self): """Figure out the decimal seperator and rows to skip and set corresponding attributes. """ lnr = max(self.rows2skip(','), self.rows2skip('.')) + 1 # If EQUAL_CNT_REQ was not met, raise error. Implement! if self.cnt > EQUAL_CNT_REQ: r...
python
def set_decdel_rts(self): """Figure out the decimal seperator and rows to skip and set corresponding attributes. """ lnr = max(self.rows2skip(','), self.rows2skip('.')) + 1 # If EQUAL_CNT_REQ was not met, raise error. Implement! if self.cnt > EQUAL_CNT_REQ: r...
[ "def", "set_decdel_rts", "(", "self", ")", ":", "lnr", "=", "max", "(", "self", ".", "rows2skip", "(", "','", ")", ",", "self", ".", "rows2skip", "(", "'.'", ")", ")", "+", "1", "# If EQUAL_CNT_REQ was not met, raise error. Implement!", "if", "self", ".", ...
Figure out the decimal seperator and rows to skip and set corresponding attributes.
[ "Figure", "out", "the", "decimal", "seperator", "and", "rows", "to", "skip", "and", "set", "corresponding", "attributes", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L175-L197
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.study_datdel
def study_datdel(self): """Figure out the data delimiter.""" nodigs = r'(\D+)' line = self.rows[self.rts + 1] # Study second line of data only. digs = re.findall(self.datrx, line) # if any of the numbers contain a '+' in it, it need to be escaped # before used in the ...
python
def study_datdel(self): """Figure out the data delimiter.""" nodigs = r'(\D+)' line = self.rows[self.rts + 1] # Study second line of data only. digs = re.findall(self.datrx, line) # if any of the numbers contain a '+' in it, it need to be escaped # before used in the ...
[ "def", "study_datdel", "(", "self", ")", ":", "nodigs", "=", "r'(\\D+)'", "line", "=", "self", ".", "rows", "[", "self", ".", "rts", "+", "1", "]", "# Study second line of data only.", "digs", "=", "re", ".", "findall", "(", "self", ".", "datrx", ",", ...
Figure out the data delimiter.
[ "Figure", "out", "the", "data", "delimiter", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L199-L244
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.loadtxtargs
def loadtxtargs(self): """Return a dict (kwargs) to provide to numpys loadtxt, based on the resulting attributes. The usecols attribute is set to be all columns in the file. This is done because some data file exporters put an (extra) data delimiter just after last data on each ...
python
def loadtxtargs(self): """Return a dict (kwargs) to provide to numpys loadtxt, based on the resulting attributes. The usecols attribute is set to be all columns in the file. This is done because some data file exporters put an (extra) data delimiter just after last data on each ...
[ "def", "loadtxtargs", "(", "self", ")", ":", "d", "=", "dict", "(", ")", "d", ".", "update", "(", "delimiter", "=", "self", ".", "datdel", ",", "skiprows", "=", "self", ".", "rts", ")", "if", "self", ".", "decdel", "==", "'.'", ":", "# First valid ...
Return a dict (kwargs) to provide to numpys loadtxt, based on the resulting attributes. The usecols attribute is set to be all columns in the file. This is done because some data file exporters put an (extra) data delimiter just after last data on each row. This is not expected ...
[ "Return", "a", "dict", "(", "kwargs", ")", "to", "provide", "to", "numpys", "loadtxt", "based", "on", "the", "resulting", "attributes", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L246-L271
tomnor/channelpack
channelpack/pulltxt.py
PatternPull.channel_names
def channel_names(self, usecols=None): """Attempt to extract the channel names from the data file. Return a list with names. Return None on failed attempt. usecols: A list with columns to use. If present, the returned list will include only names for columns requested. It will a...
python
def channel_names(self, usecols=None): """Attempt to extract the channel names from the data file. Return a list with names. Return None on failed attempt. usecols: A list with columns to use. If present, the returned list will include only names for columns requested. It will a...
[ "def", "channel_names", "(", "self", ",", "usecols", "=", "None", ")", ":", "# Search from [rts - 1] and up (last row before data). Split respective", "# row on datdel. Accept consecutive elements starting with alphas", "# character after strip. If the count of elements equals the data count...
Attempt to extract the channel names from the data file. Return a list with names. Return None on failed attempt. usecols: A list with columns to use. If present, the returned list will include only names for columns requested. It will align with the columns returned by numpys loadtxt b...
[ "Attempt", "to", "extract", "the", "channel", "names", "from", "the", "data", "file", ".", "Return", "a", "list", "with", "names", ".", "Return", "None", "on", "failed", "attempt", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L273-L317
rraadd88/meld
meld/seqs.py
align
def align(s1,s2,test=False): """ Creates pairwise local alignment between seqeunces. Get the visualization and alignment scores. :param s1: seqeunce 1 :param s2: seqeunce 2 """ import operator from Bio import pairwise2 alignments = pairwise2.align.localms(s1.upper(),s2.upper(),1,...
python
def align(s1,s2,test=False): """ Creates pairwise local alignment between seqeunces. Get the visualization and alignment scores. :param s1: seqeunce 1 :param s2: seqeunce 2 """ import operator from Bio import pairwise2 alignments = pairwise2.align.localms(s1.upper(),s2.upper(),1,...
[ "def", "align", "(", "s1", ",", "s2", ",", "test", "=", "False", ")", ":", "import", "operator", "from", "Bio", "import", "pairwise2", "alignments", "=", "pairwise2", ".", "align", ".", "localms", "(", "s1", ".", "upper", "(", ")", ",", "s2", ".", ...
Creates pairwise local alignment between seqeunces. Get the visualization and alignment scores. :param s1: seqeunce 1 :param s2: seqeunce 2
[ "Creates", "pairwise", "local", "alignment", "between", "seqeunces", ".", "Get", "the", "visualization", "and", "alignment", "scores", ".", ":", "param", "s1", ":", "seqeunce", "1", ":", "param", "s2", ":", "seqeunce", "2" ]
train
https://github.com/rraadd88/meld/blob/e25aba1c07b2c775031224a8b55bf006ccb24dfd/meld/seqs.py#L88-L110
exekias/droplet
droplet/catalog.py
LocalCatalog.register
def register(self, cls, instance): """ Register the given instance as implementation for a class interface """ if not issubclass(cls, DropletInterface): raise TypeError('Given class is not a NAZInterface subclass: %s' % cls) if not isinsta...
python
def register(self, cls, instance): """ Register the given instance as implementation for a class interface """ if not issubclass(cls, DropletInterface): raise TypeError('Given class is not a NAZInterface subclass: %s' % cls) if not isinsta...
[ "def", "register", "(", "self", ",", "cls", ",", "instance", ")", ":", "if", "not", "issubclass", "(", "cls", ",", "DropletInterface", ")", ":", "raise", "TypeError", "(", "'Given class is not a NAZInterface subclass: %s'", "%", "cls", ")", "if", "not", "isins...
Register the given instance as implementation for a class interface
[ "Register", "the", "given", "instance", "as", "implementation", "for", "a", "class", "interface" ]
train
https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/catalog.py#L34-L52
jjjake/giganews
giganews/__init__.py
set_logger
def set_logger(log_level, path, logger_name='giganews'): """Convenience function to quickly configure any level of logging to a file. :type log_level: int :param log_level: A log level as specified in the `logging` module :type path: string :param path: Path to the log file. The file will be c...
python
def set_logger(log_level, path, logger_name='giganews'): """Convenience function to quickly configure any level of logging to a file. :type log_level: int :param log_level: A log level as specified in the `logging` module :type path: string :param path: Path to the log file. The file will be c...
[ "def", "set_logger", "(", "log_level", ",", "path", ",", "logger_name", "=", "'giganews'", ")", ":", "FmtString", "=", "'%(asctime)s - %(name)s - %(levelname)s - %(message)s'", "log", "=", "logging", ".", "getLogger", "(", "logger_name", ")", "log", ".", "setLevel",...
Convenience function to quickly configure any level of logging to a file. :type log_level: int :param log_level: A log level as specified in the `logging` module :type path: string :param path: Path to the log file. The file will be created if it doesn't already exist.
[ "Convenience", "function", "to", "quickly", "configure", "any", "level", "of", "logging", "to", "a", "file", "." ]
train
https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/__init__.py#L38-L68
johnwlockwood/stream_tap
stream_tap/__init__.py
stream_tap
def stream_tap(callables, stream): """ Calls each callable with each item in the stream. Use with Buckets. Make a Bucket with a callable and then pass a tuple of those buckets in as the callables. After iterating over this generator, get contents from each Spigot. :param callables: collecti...
python
def stream_tap(callables, stream): """ Calls each callable with each item in the stream. Use with Buckets. Make a Bucket with a callable and then pass a tuple of those buckets in as the callables. After iterating over this generator, get contents from each Spigot. :param callables: collecti...
[ "def", "stream_tap", "(", "callables", ",", "stream", ")", ":", "for", "item", "in", "stream", ":", "for", "caller", "in", "callables", ":", "caller", "(", "item", ")", "yield", "item" ]
Calls each callable with each item in the stream. Use with Buckets. Make a Bucket with a callable and then pass a tuple of those buckets in as the callables. After iterating over this generator, get contents from each Spigot. :param callables: collection of callable. :param stream: Iterator if ...
[ "Calls", "each", "callable", "with", "each", "item", "in", "the", "stream", ".", "Use", "with", "Buckets", ".", "Make", "a", "Bucket", "with", "a", "callable", "and", "then", "pass", "a", "tuple", "of", "those", "buckets", "in", "as", "the", "callables",...
train
https://github.com/johnwlockwood/stream_tap/blob/068f6427c39202991a1db2be842b0fa43c6c5b91/stream_tap/__init__.py#L40-L54
tbreitenfeldt/invisible_ui
invisible_ui/elements/element.py
Element.selected
def selected(self, interrupt=False): """This object has been selected.""" self.ao2.output(self.get_title(), interrupt=interrupt)
python
def selected(self, interrupt=False): """This object has been selected.""" self.ao2.output(self.get_title(), interrupt=interrupt)
[ "def", "selected", "(", "self", ",", "interrupt", "=", "False", ")", ":", "self", ".", "ao2", ".", "output", "(", "self", ".", "get_title", "(", ")", ",", "interrupt", "=", "interrupt", ")" ]
This object has been selected.
[ "This", "object", "has", "been", "selected", "." ]
train
https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/elements/element.py#L42-L44
l-hedgehog/sulu
sulu.py
serialize_rdf
def serialize_rdf(update_graph, signing): '''Tweak rdflib's pretty-xml serialization of update_graph into the "indentical" representation as defined in http://mzl.la/x4XF6o ''' unsorted_s = update_graph.serialize(format = 'pretty-xml') unsorted_s = unsorted_s.replace('xmlns:rdf', 'xmlns:RDF') un...
python
def serialize_rdf(update_graph, signing): '''Tweak rdflib's pretty-xml serialization of update_graph into the "indentical" representation as defined in http://mzl.la/x4XF6o ''' unsorted_s = update_graph.serialize(format = 'pretty-xml') unsorted_s = unsorted_s.replace('xmlns:rdf', 'xmlns:RDF') un...
[ "def", "serialize_rdf", "(", "update_graph", ",", "signing", ")", ":", "unsorted_s", "=", "update_graph", ".", "serialize", "(", "format", "=", "'pretty-xml'", ")", "unsorted_s", "=", "unsorted_s", ".", "replace", "(", "'xmlns:rdf'", ",", "'xmlns:RDF'", ")", "...
Tweak rdflib's pretty-xml serialization of update_graph into the "indentical" representation as defined in http://mzl.la/x4XF6o
[ "Tweak", "rdflib", "s", "pretty", "-", "xml", "serialization", "of", "update_graph", "into", "the", "indentical", "representation", "as", "defined", "in", "http", ":", "//", "mzl", ".", "la", "/", "x4XF6o" ]
train
https://github.com/l-hedgehog/sulu/blob/3fe2c318d842873ba06b2d84c3e80625ab486f94/sulu.py#L45-L82
tomokinakamaru/mapletree
mapletree/response.py
Response.header
def header(self, k, v, replace=True): """ Sets header value. Replaces existing value if `replace` is True. Otherwise create a list of existing values and `v` :param k: Header key :param v: Header value :param replace: flag for setting mode. :type k: str :type v: ...
python
def header(self, k, v, replace=True): """ Sets header value. Replaces existing value if `replace` is True. Otherwise create a list of existing values and `v` :param k: Header key :param v: Header value :param replace: flag for setting mode. :type k: str :type v: ...
[ "def", "header", "(", "self", ",", "k", ",", "v", ",", "replace", "=", "True", ")", ":", "if", "replace", ":", "self", ".", "_headers", "[", "k", "]", "=", "[", "v", "]", "else", ":", "self", ".", "_headers", ".", "setdefault", "(", "k", ",", ...
Sets header value. Replaces existing value if `replace` is True. Otherwise create a list of existing values and `v` :param k: Header key :param v: Header value :param replace: flag for setting mode. :type k: str :type v: str :type replace: bool
[ "Sets", "header", "value", ".", "Replaces", "existing", "value", "if", "replace", "is", "True", ".", "Otherwise", "create", "a", "list", "of", "existing", "values", "and", "v" ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/response.py#L41-L58
tomokinakamaru/mapletree
mapletree/response.py
Response.cookie
def cookie(self, k, v, expires=None, domain=None, path='/', secure=False): """ Sets cookie value. :param k: Name for cookie value :param v: Cookie value :param expires: Cookie expiration date :param domain: Cookie domain :param path: Cookie path :param secure: Fl...
python
def cookie(self, k, v, expires=None, domain=None, path='/', secure=False): """ Sets cookie value. :param k: Name for cookie value :param v: Cookie value :param expires: Cookie expiration date :param domain: Cookie domain :param path: Cookie path :param secure: Fl...
[ "def", "cookie", "(", "self", ",", "k", ",", "v", ",", "expires", "=", "None", ",", "domain", "=", "None", ",", "path", "=", "'/'", ",", "secure", "=", "False", ")", ":", "ls", "=", "[", "'{}={}'", ".", "format", "(", "k", ",", "v", ")", "]",...
Sets cookie value. :param k: Name for cookie value :param v: Cookie value :param expires: Cookie expiration date :param domain: Cookie domain :param path: Cookie path :param secure: Flag for `https only` :type k: str :type v: str :type expires: da...
[ "Sets", "cookie", "value", "." ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/response.py#L85-L116
pjuren/pyokit
src/pyokit/util/meta.py
decorate_all_methods
def decorate_all_methods(decorator): """ Build and return a decorator that will decorate all class members. This will apply the passed decorator to all of the methods in the decorated class, except the __init__ method, when a class is decorated with it. """ def decorate_class(cls): for name, m in inspe...
python
def decorate_all_methods(decorator): """ Build and return a decorator that will decorate all class members. This will apply the passed decorator to all of the methods in the decorated class, except the __init__ method, when a class is decorated with it. """ def decorate_class(cls): for name, m in inspe...
[ "def", "decorate_all_methods", "(", "decorator", ")", ":", "def", "decorate_class", "(", "cls", ")", ":", "for", "name", ",", "m", "in", "inspect", ".", "getmembers", "(", "cls", ",", "inspect", ".", "ismethod", ")", ":", "if", "name", "!=", "\"__init__\...
Build and return a decorator that will decorate all class members. This will apply the passed decorator to all of the methods in the decorated class, except the __init__ method, when a class is decorated with it.
[ "Build", "and", "return", "a", "decorator", "that", "will", "decorate", "all", "class", "members", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L49-L61
pjuren/pyokit
src/pyokit/util/meta.py
decorate_all_methods_and_properties
def decorate_all_methods_and_properties(method_decorator, property_decorator): """ ... """ def decorate_class(cls): for name, m in inspect.getmembers(cls, inspect.ismethod): if name != "__init__": setattr(cls, name, method_decorator(m)) for name, p in inspect.getmembers(cls, lambda x: isin...
python
def decorate_all_methods_and_properties(method_decorator, property_decorator): """ ... """ def decorate_class(cls): for name, m in inspect.getmembers(cls, inspect.ismethod): if name != "__init__": setattr(cls, name, method_decorator(m)) for name, p in inspect.getmembers(cls, lambda x: isin...
[ "def", "decorate_all_methods_and_properties", "(", "method_decorator", ",", "property_decorator", ")", ":", "def", "decorate_class", "(", "cls", ")", ":", "for", "name", ",", "m", "in", "inspect", ".", "getmembers", "(", "cls", ",", "inspect", ".", "ismethod", ...
...
[ "..." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L64-L76
pjuren/pyokit
src/pyokit/util/meta.py
just_in_time_method
def just_in_time_method(func): """ This is a dcorator for methods. It redirect calls to the decorated method to the equivalent method in a class member called 'item'. 'item' is expected to be None when the class is instantiated. The point is to easily allow on-demand construction or loading of large, expensiv...
python
def just_in_time_method(func): """ This is a dcorator for methods. It redirect calls to the decorated method to the equivalent method in a class member called 'item'. 'item' is expected to be None when the class is instantiated. The point is to easily allow on-demand construction or loading of large, expensiv...
[ "def", "just_in_time_method", "(", "func", ")", ":", "if", "not", "inspect", ".", "ismethod", ":", "raise", "MetaError", "(", "\"oops\"", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "ite...
This is a dcorator for methods. It redirect calls to the decorated method to the equivalent method in a class member called 'item'. 'item' is expected to be None when the class is instantiated. The point is to easily allow on-demand construction or loading of large, expensive objects just-in-time. To apply thi...
[ "This", "is", "a", "dcorator", "for", "methods", ".", "It", "redirect", "calls", "to", "the", "decorated", "method", "to", "the", "equivalent", "method", "in", "a", "class", "member", "called", "item", ".", "item", "is", "expected", "to", "be", "None", "...
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L79-L118
pjuren/pyokit
src/pyokit/util/meta.py
PeekableIterator._fill
def _fill(self): """Advance the iterator without returning the old head.""" try: self._head = self._iterable.next() except StopIteration: self._head = None
python
def _fill(self): """Advance the iterator without returning the old head.""" try: self._head = self._iterable.next() except StopIteration: self._head = None
[ "def", "_fill", "(", "self", ")", ":", "try", ":", "self", ".", "_head", "=", "self", ".", "_iterable", ".", "next", "(", ")", "except", "StopIteration", ":", "self", ".", "_head", "=", "None" ]
Advance the iterator without returning the old head.
[ "Advance", "the", "iterator", "without", "returning", "the", "old", "head", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L159-L164
pjuren/pyokit
src/pyokit/util/meta.py
AutoApplyIterator._fill
def _fill(self): """Advance the iterator without returning the old head.""" prev = self._head super(AutoApplyIterator, self)._fill() if self._head is not None: self.on_next(self._head, prev)
python
def _fill(self): """Advance the iterator without returning the old head.""" prev = self._head super(AutoApplyIterator, self)._fill() if self._head is not None: self.on_next(self._head, prev)
[ "def", "_fill", "(", "self", ")", ":", "prev", "=", "self", ".", "_head", "super", "(", "AutoApplyIterator", ",", "self", ")", ".", "_fill", "(", ")", "if", "self", ".", "_head", "is", "not", "None", ":", "self", ".", "on_next", "(", "self", ".", ...
Advance the iterator without returning the old head.
[ "Advance", "the", "iterator", "without", "returning", "the", "old", "head", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L198-L203
chrisnorman7/MyGui
MyGui/frame.py
AddAccelerator
def AddAccelerator(self, modifiers, key, action): """ Add an accelerator. Modifiers and key follow the same pattern as the list used to create wx.AcceleratorTable objects. """ newId = wx.NewId() self.Bind(wx.EVT_MENU, action, id = newId) self.RawAcceleratorTable.append((modifiers, key, newId)) self.SetAcceler...
python
def AddAccelerator(self, modifiers, key, action): """ Add an accelerator. Modifiers and key follow the same pattern as the list used to create wx.AcceleratorTable objects. """ newId = wx.NewId() self.Bind(wx.EVT_MENU, action, id = newId) self.RawAcceleratorTable.append((modifiers, key, newId)) self.SetAcceler...
[ "def", "AddAccelerator", "(", "self", ",", "modifiers", ",", "key", ",", "action", ")", ":", "newId", "=", "wx", ".", "NewId", "(", ")", "self", ".", "Bind", "(", "wx", ".", "EVT_MENU", ",", "action", ",", "id", "=", "newId", ")", "self", ".", "R...
Add an accelerator. Modifiers and key follow the same pattern as the list used to create wx.AcceleratorTable objects.
[ "Add", "an", "accelerator", ".", "Modifiers", "and", "key", "follow", "the", "same", "pattern", "as", "the", "list", "used", "to", "create", "wx", ".", "AcceleratorTable", "objects", "." ]
train
https://github.com/chrisnorman7/MyGui/blob/83aecb9c24107b41085cd0047a3e5b3fa18fac35/MyGui/frame.py#L11-L21
dhain/potpy
potpy/configparser.py
parse_config
def parse_config(lines, module=None): """Parse a config file. Names referenced within the config file are found within the calling scope. For example:: >>> from potpy.configparser import parse_config >>> class foo: ... @staticmethod ... def bar(): ... ...
python
def parse_config(lines, module=None): """Parse a config file. Names referenced within the config file are found within the calling scope. For example:: >>> from potpy.configparser import parse_config >>> class foo: ... @staticmethod ... def bar(): ... ...
[ "def", "parse_config", "(", "lines", ",", "module", "=", "None", ")", ":", "if", "module", "is", "None", ":", "module", "=", "_calling_scope", "(", "2", ")", "lines", "=", "IndentChecker", "(", "lines", ")", "path_router", "=", "PathRouter", "(", ")", ...
Parse a config file. Names referenced within the config file are found within the calling scope. For example:: >>> from potpy.configparser import parse_config >>> class foo: ... @staticmethod ... def bar(): ... pass ... >>> config = ''' ...
[ "Parse", "a", "config", "file", "." ]
train
https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/configparser.py#L244-L287
dhain/potpy
potpy/configparser.py
load_config
def load_config(name='urls.conf'): """Load a config from a resource file. The resource is found using `pkg_resources.resource_stream()`_, relative to the calling module. See :func:`parse_config` for config file details. :param name: The name of the resource, relative to the calling module. ....
python
def load_config(name='urls.conf'): """Load a config from a resource file. The resource is found using `pkg_resources.resource_stream()`_, relative to the calling module. See :func:`parse_config` for config file details. :param name: The name of the resource, relative to the calling module. ....
[ "def", "load_config", "(", "name", "=", "'urls.conf'", ")", ":", "module", "=", "_calling_scope", "(", "2", ")", "config", "=", "resource_stream", "(", "module", ".", "__name__", ",", "name", ")", "return", "parse_config", "(", "config", ",", "module", ")"...
Load a config from a resource file. The resource is found using `pkg_resources.resource_stream()`_, relative to the calling module. See :func:`parse_config` for config file details. :param name: The name of the resource, relative to the calling module. .. _pkg_resources.resource_stream(): http:/...
[ "Load", "a", "config", "from", "a", "resource", "file", "." ]
train
https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/configparser.py#L290-L304
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.to_placeholder
def to_placeholder(self, name=None, db_type=None): """Returns a placeholder for the specified name, by applying the instance's format strings. :name: if None an unamed placeholder is returned, otherwise a named placeholder is returned. :db_type: if not None the placeholder is typecast. """ if name ...
python
def to_placeholder(self, name=None, db_type=None): """Returns a placeholder for the specified name, by applying the instance's format strings. :name: if None an unamed placeholder is returned, otherwise a named placeholder is returned. :db_type: if not None the placeholder is typecast. """ if name ...
[ "def", "to_placeholder", "(", "self", ",", "name", "=", "None", ",", "db_type", "=", "None", ")", ":", "if", "name", "is", "None", ":", "placeholder", "=", "self", ".", "unnamed_placeholder", "else", ":", "placeholder", "=", "self", ".", "named_placeholder...
Returns a placeholder for the specified name, by applying the instance's format strings. :name: if None an unamed placeholder is returned, otherwise a named placeholder is returned. :db_type: if not None the placeholder is typecast.
[ "Returns", "a", "placeholder", "for", "the", "specified", "name", "by", "applying", "the", "instance", "s", "format", "strings", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L29-L43
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.to_tuple
def to_tuple(self, iterable, surround="()", joiner=", "): """Returns the iterable as a SQL tuple.""" return "{0}{1}{2}".format(surround[0], joiner.join(iterable), surround[1])
python
def to_tuple(self, iterable, surround="()", joiner=", "): """Returns the iterable as a SQL tuple.""" return "{0}{1}{2}".format(surround[0], joiner.join(iterable), surround[1])
[ "def", "to_tuple", "(", "self", ",", "iterable", ",", "surround", "=", "\"()\"", ",", "joiner", "=", "\", \"", ")", ":", "return", "\"{0}{1}{2}\"", ".", "format", "(", "surround", "[", "0", "]", ",", "joiner", ".", "join", "(", "iterable", ")", ",", ...
Returns the iterable as a SQL tuple.
[ "Returns", "the", "iterable", "as", "a", "SQL", "tuple", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L45-L47
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.to_expression
def to_expression(self, lhs, rhs, op): """Builds a binary sql expression. At its most basic, returns 'lhs op rhs' such as '5 + 3'. However, it also specially handles the 'in' and 'between' operators. For each of these operators it is expected that rhs will be iterable. If the comparison operator i...
python
def to_expression(self, lhs, rhs, op): """Builds a binary sql expression. At its most basic, returns 'lhs op rhs' such as '5 + 3'. However, it also specially handles the 'in' and 'between' operators. For each of these operators it is expected that rhs will be iterable. If the comparison operator i...
[ "def", "to_expression", "(", "self", ",", "lhs", ",", "rhs", ",", "op", ")", ":", "if", "op", "==", "\"raw\"", ":", "# TODO: This is not documented", "return", "lhs", "elif", "op", "==", "\"between\"", ":", "return", "\"{0} between {1} and {2}\"", ".", "format...
Builds a binary sql expression. At its most basic, returns 'lhs op rhs' such as '5 + 3'. However, it also specially handles the 'in' and 'between' operators. For each of these operators it is expected that rhs will be iterable. If the comparison operator is of the form 'not(op)' where op is the operat...
[ "Builds", "a", "binary", "sql", "expression", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L49-L76
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.transform_op
def transform_op(self, op, value): """For comparisons, if the value is None (null), the '=' operator must be replaced with ' is ' and the '!=' operator must be replaced with ' is not '. This function handles that conversion. It's up to the caller to call this function only on comparisons and not on assignme...
python
def transform_op(self, op, value): """For comparisons, if the value is None (null), the '=' operator must be replaced with ' is ' and the '!=' operator must be replaced with ' is not '. This function handles that conversion. It's up to the caller to call this function only on comparisons and not on assignme...
[ "def", "transform_op", "(", "self", ",", "op", ",", "value", ")", ":", "if", "value", "is", "None", ":", "if", "_EQ_RE", ".", "match", "(", "op", ")", ":", "return", "\"is\"", "elif", "_NEQ_RE", ".", "match", "(", "op", ")", ":", "return", "\"is no...
For comparisons, if the value is None (null), the '=' operator must be replaced with ' is ' and the '!=' operator must be replaced with ' is not '. This function handles that conversion. It's up to the caller to call this function only on comparisons and not on assignments.
[ "For", "comparisons", "if", "the", "value", "is", "None", "(", "null", ")", "the", "=", "operator", "must", "be", "replaced", "with", "is", "and", "the", "!", "=", "operator", "must", "be", "replaced", "with", "is", "not", ".", "This", "function", "han...
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L78-L89
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.value_comparisons
def value_comparisons(self, values, comp="=", is_assignment=False): """Builds out a series of value comparisions. :values: can either be a dictionary, in which case the return will compare a name to a named placeholder, using the comp argument. I.E. values = {"first_name": "John", "last_name": "Smith"} ...
python
def value_comparisons(self, values, comp="=", is_assignment=False): """Builds out a series of value comparisions. :values: can either be a dictionary, in which case the return will compare a name to a named placeholder, using the comp argument. I.E. values = {"first_name": "John", "last_name": "Smith"} ...
[ "def", "value_comparisons", "(", "self", ",", "values", ",", "comp", "=", "\"=\"", ",", "is_assignment", "=", "False", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "if", "self", ".", "sort_columns", ":", "keys", "=", "sorted", "(...
Builds out a series of value comparisions. :values: can either be a dictionary, in which case the return will compare a name to a named placeholder, using the comp argument. I.E. values = {"first_name": "John", "last_name": "Smith"} will return ["first_name = %(first_name)s", "last_name = %(last_name)s"]. ...
[ "Builds", "out", "a", "series", "of", "value", "comparisions", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L91-L137
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.join_comparisons
def join_comparisons(self, values, joiner, *, is_assignment=False, comp="="): """Generates comparisons with the value_comparisions method, and joins them with joiner. :is_assignment: if false, transform_op will be called on each comparison operator. """ if isinstance(values, str): return values ...
python
def join_comparisons(self, values, joiner, *, is_assignment=False, comp="="): """Generates comparisons with the value_comparisions method, and joins them with joiner. :is_assignment: if false, transform_op will be called on each comparison operator. """ if isinstance(values, str): return values ...
[ "def", "join_comparisons", "(", "self", ",", "values", ",", "joiner", ",", "*", ",", "is_assignment", "=", "False", ",", "comp", "=", "\"=\"", ")", ":", "if", "isinstance", "(", "values", ",", "str", ")", ":", "return", "values", "else", ":", "return",...
Generates comparisons with the value_comparisions method, and joins them with joiner. :is_assignment: if false, transform_op will be called on each comparison operator.
[ "Generates", "comparisons", "with", "the", "value_comparisions", "method", "and", "joins", "them", "with", "joiner", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L139-L147
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.parse_constraints
def parse_constraints(self, constraints, joiner=" and ", *, is_assignment=False, comp="="): """Parses constraints into a (sql, params) tuple. :constraints: can either be a dict, an enumerable with a sql string and params, an enumerable of 2- or 3-tuples, or just a string. If is_assignment is false, tr...
python
def parse_constraints(self, constraints, joiner=" and ", *, is_assignment=False, comp="="): """Parses constraints into a (sql, params) tuple. :constraints: can either be a dict, an enumerable with a sql string and params, an enumerable of 2- or 3-tuples, or just a string. If is_assignment is false, tr...
[ "def", "parse_constraints", "(", "self", ",", "constraints", ",", "joiner", "=", "\" and \"", ",", "*", ",", "is_assignment", "=", "False", ",", "comp", "=", "\"=\"", ")", ":", "if", "constraints", "is", "None", ":", "return", "(", "None", ",", "None", ...
Parses constraints into a (sql, params) tuple. :constraints: can either be a dict, an enumerable with a sql string and params, an enumerable of 2- or 3-tuples, or just a string. If is_assignment is false, transform_op will be called on each comparison operator.
[ "Parses", "constraints", "into", "a", "(", "sql", "params", ")", "tuple", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L149-L175
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.get_params
def get_params(self, values): """Gets params to be passed to execute from values. :values: can either be a dict, in which case it will be returned as is, or can be an enumerable of 2- or 3-tuples. This will return an enumerable of the 2nd values, and in the case of some operators such as 'in' and 'betw...
python
def get_params(self, values): """Gets params to be passed to execute from values. :values: can either be a dict, in which case it will be returned as is, or can be an enumerable of 2- or 3-tuples. This will return an enumerable of the 2nd values, and in the case of some operators such as 'in' and 'betw...
[ "def", "get_params", "(", "self", ",", "values", ")", ":", "if", "values", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "values", ",", "dict", ")", ":", "return", "values", "elif", "isinstance", "(", "values", ",", "(", "list", ",", ...
Gets params to be passed to execute from values. :values: can either be a dict, in which case it will be returned as is, or can be an enumerable of 2- or 3-tuples. This will return an enumerable of the 2nd values, and in the case of some operators such as 'in' and 'between' the values will be specially han...
[ "Gets", "params", "to", "be", "passed", "to", "execute", "from", "values", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L177-L203
treycucco/bidon
bidon/db/core/sql_writer.py
SqlWriter.get_find_all_query
def get_find_all_query(self, table_name, constraints=None, *, columns=None, order_by=None, limiting=(None, None)): """Builds a find query. :limiting: if present must be a 2-tuple of (limit, offset) either of which can be None. """ where, params = self.parse_constraints(constrai...
python
def get_find_all_query(self, table_name, constraints=None, *, columns=None, order_by=None, limiting=(None, None)): """Builds a find query. :limiting: if present must be a 2-tuple of (limit, offset) either of which can be None. """ where, params = self.parse_constraints(constrai...
[ "def", "get_find_all_query", "(", "self", ",", "table_name", ",", "constraints", "=", "None", ",", "*", ",", "columns", "=", "None", ",", "order_by", "=", "None", ",", "limiting", "=", "(", "None", ",", "None", ")", ")", ":", "where", ",", "params", ...
Builds a find query. :limiting: if present must be a 2-tuple of (limit, offset) either of which can be None.
[ "Builds", "a", "find", "query", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L205-L240
mkouhei/tonicdnscli
src/tonicdnscli/utils.py
pretty_print
def pretty_print(rows, keyword, domain): """ rows is list when get domains dict when get specific domain """ if isinstance(rows, dict): pretty_print_domain(rows, keyword, domain) elif isinstance(rows, list): pretty_print_zones(rows)
python
def pretty_print(rows, keyword, domain): """ rows is list when get domains dict when get specific domain """ if isinstance(rows, dict): pretty_print_domain(rows, keyword, domain) elif isinstance(rows, list): pretty_print_zones(rows)
[ "def", "pretty_print", "(", "rows", ",", "keyword", ",", "domain", ")", ":", "if", "isinstance", "(", "rows", ",", "dict", ")", ":", "pretty_print_domain", "(", "rows", ",", "keyword", ",", "domain", ")", "elif", "isinstance", "(", "rows", ",", "list", ...
rows is list when get domains dict when get specific domain
[ "rows", "is", "list", "when", "get", "domains", "dict", "when", "get", "specific", "domain" ]
train
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/utils.py#L118-L127
mkouhei/tonicdnscli
src/tonicdnscli/utils.py
pretty_print_domain
def pretty_print_domain(rows, keyword, domain): """ Arguments: rows: get response data keyword: search keyword """ if len(rows.get('records')) == 0: return None # six columns; priority, name, content, ttl, change_date, type header_l = ['prio', 'name', 'content', ...
python
def pretty_print_domain(rows, keyword, domain): """ Arguments: rows: get response data keyword: search keyword """ if len(rows.get('records')) == 0: return None # six columns; priority, name, content, ttl, change_date, type header_l = ['prio', 'name', 'content', ...
[ "def", "pretty_print_domain", "(", "rows", ",", "keyword", ",", "domain", ")", ":", "if", "len", "(", "rows", ".", "get", "(", "'records'", ")", ")", "==", "0", ":", "return", "None", "# six columns; priority, name, content, ttl, change_date, type", "header_l", ...
Arguments: rows: get response data keyword: search keyword
[ "Arguments", ":" ]
train
https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/utils.py#L145-L233
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.check_status
def check_status(self): """ tests both the ext_url and local_url to see if the database is running returns: True if a connection can be made False if the connection cannot me made """ def validate_namespace(self): if not self....
python
def check_status(self): """ tests both the ext_url and local_url to see if the database is running returns: True if a connection can be made False if the connection cannot me made """ def validate_namespace(self): if not self....
[ "def", "check_status", "(", "self", ")", ":", "def", "validate_namespace", "(", "self", ")", ":", "if", "not", "self", ".", "has_namespace", "(", "self", ".", "namespace", ")", ":", "log", ".", "warning", "(", "format_multiline", "(", "[", "\"\"", ",", ...
tests both the ext_url and local_url to see if the database is running returns: True if a connection can be made False if the connection cannot me made
[ "tests", "both", "the", "ext_url", "and", "local_url", "to", "see", "if", "the", "database", "is", "running" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L132-L173
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.query
def query(self, sparql, mode="get", namespace=None, rtn_format="json", **kwargs): """ Runs a sparql query and returns the results Args: ----- sparql: the sparql query to run namespace: the name...
python
def query(self, sparql, mode="get", namespace=None, rtn_format="json", **kwargs): """ Runs a sparql query and returns the results Args: ----- sparql: the sparql query to run namespace: the name...
[ "def", "query", "(", "self", ",", "sparql", ",", "mode", "=", "\"get\"", ",", "namespace", "=", "None", ",", "rtn_format", "=", "\"json\"", ",", "*", "*", "kwargs", ")", ":", "namespace", "=", "pick", "(", "namespace", ",", "self", ".", "namespace", ...
Runs a sparql query and returns the results Args: ----- sparql: the sparql query to run namespace: the namespace to run the sparql query against mode: ['get'(default), 'update'] the type of sparql query rtn_format: ['json'(default), 'xml'] format of query...
[ "Runs", "a", "sparql", "query", "and", "returns", "the", "results" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L175-L262
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.load_data
def load_data(self, data, datatype="ttl", namespace=None, graph=None, is_file=False, **kwargs): """ Loads data via file stream from python to triplestore Args: ----- dat...
python
def load_data(self, data, datatype="ttl", namespace=None, graph=None, is_file=False, **kwargs): """ Loads data via file stream from python to triplestore Args: ----- dat...
[ "def", "load_data", "(", "self", ",", "data", ",", "datatype", "=", "\"ttl\"", ",", "namespace", "=", "None", ",", "graph", "=", "None", ",", "is_file", "=", "False", ",", "*", "*", "kwargs", ")", ":", "log", ".", "setLevel", "(", "kwargs", ".", "g...
Loads data via file stream from python to triplestore Args: ----- data: The data or filepath to load datatype(['ttl', 'xml', 'rdf']): the type of data to load namespace: the namespace to use graph: the graph to load the data to. is_file(False): If true ...
[ "Loads", "data", "via", "file", "stream", "from", "python", "to", "triplestore" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L273-L332
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.load_local_file
def load_local_file(self, file_path, namespace=None, graph=None, **kwargs): """ Uploads data to the Blazegraph Triplestore that is stored in files in directory that is available locally to blazegraph args: file_path: full path to the file namespace: the B...
python
def load_local_file(self, file_path, namespace=None, graph=None, **kwargs): """ Uploads data to the Blazegraph Triplestore that is stored in files in directory that is available locally to blazegraph args: file_path: full path to the file namespace: the B...
[ "def", "load_local_file", "(", "self", ",", "file_path", ",", "namespace", "=", "None", ",", "graph", "=", "None", ",", "*", "*", "kwargs", ")", ":", "time_start", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "url", "=", "self", ".", "_mak...
Uploads data to the Blazegraph Triplestore that is stored in files in directory that is available locally to blazegraph args: file_path: full path to the file namespace: the Blazegraph namespace to load the data graph: uri of the graph to load the...
[ "Uploads", "data", "to", "the", "Blazegraph", "Triplestore", "that", "is", "stored", "in", "files", "in", "directory", "that", "is", "available", "locally", "to", "blazegraph" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L439-L471
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.has_namespace
def has_namespace(self, namespace): """ tests to see if the namespace exists args: namespace: the name of the namespace """ result = requests.get(self._make_url(namespace)) if result.status_code == 200: return True elif result.status_code == 404: ...
python
def has_namespace(self, namespace): """ tests to see if the namespace exists args: namespace: the name of the namespace """ result = requests.get(self._make_url(namespace)) if result.status_code == 200: return True elif result.status_code == 404: ...
[ "def", "has_namespace", "(", "self", ",", "namespace", ")", ":", "result", "=", "requests", ".", "get", "(", "self", ".", "_make_url", "(", "namespace", ")", ")", "if", "result", ".", "status_code", "==", "200", ":", "return", "True", "elif", "result", ...
tests to see if the namespace exists args: namespace: the name of the namespace
[ "tests", "to", "see", "if", "the", "namespace", "exists" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L473-L483
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.create_namespace
def create_namespace(self, namespace=None, params=None): """ Creates a namespace in the triplestore args: namespace: the name of the namspace to create params: Dictionary of Blazegraph paramaters. defaults are: {'axioms': 'com.bigdata.rdf.axioms.NoAxioms', ...
python
def create_namespace(self, namespace=None, params=None): """ Creates a namespace in the triplestore args: namespace: the name of the namspace to create params: Dictionary of Blazegraph paramaters. defaults are: {'axioms': 'com.bigdata.rdf.axioms.NoAxioms', ...
[ "def", "create_namespace", "(", "self", ",", "namespace", "=", "None", ",", "params", "=", "None", ")", ":", "namespace", "=", "pick", "(", "namespace", ",", "self", ".", "namespace", ")", "params", "=", "pick", "(", "params", ",", "self", ".", "namesp...
Creates a namespace in the triplestore args: namespace: the name of the namspace to create params: Dictionary of Blazegraph paramaters. defaults are: {'axioms': 'com.bigdata.rdf.axioms.NoAxioms', 'geoSpatial': False, 'isolat...
[ "Creates", "a", "namespace", "in", "the", "triplestore" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L485-L535
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.delete_namespace
def delete_namespace(self, namespace): """ Deletes a namespace fromt the triplestore args: namespace: the name of the namespace """ # if not self.has_namespace(namespace): # return "Namespace does not exists" # log = logging.getLogger("%s.%s" % (self.lo...
python
def delete_namespace(self, namespace): """ Deletes a namespace fromt the triplestore args: namespace: the name of the namespace """ # if not self.has_namespace(namespace): # return "Namespace does not exists" # log = logging.getLogger("%s.%s" % (self.lo...
[ "def", "delete_namespace", "(", "self", ",", "namespace", ")", ":", "# if not self.has_namespace(namespace):", "# return \"Namespace does not exists\"", "# log = logging.getLogger(\"%s.%s\" % (self.log_name,", "# inspect.stack()[0][3]))", "# log.setLeve...
Deletes a namespace fromt the triplestore args: namespace: the name of the namespace
[ "Deletes", "a", "namespace", "fromt", "the", "triplestore" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L537-L556
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph._make_url
def _make_url(self, namespace=None, url=None, **kwargs): """ Creates the REST Url based on the supplied namespace args: namespace: string of the namespace kwargs: check_status_call: True/False, whether the function is called from check_status. Used to...
python
def _make_url(self, namespace=None, url=None, **kwargs): """ Creates the REST Url based on the supplied namespace args: namespace: string of the namespace kwargs: check_status_call: True/False, whether the function is called from check_status. Used to...
[ "def", "_make_url", "(", "self", ",", "namespace", "=", "None", ",", "url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "kwargs", ".", "get", "(", "\"check_status_call\"", ")", ":", "if", "not", "self", ".", "url", ":", "self", "."...
Creates the REST Url based on the supplied namespace args: namespace: string of the namespace kwargs: check_status_call: True/False, whether the function is called from check_status. Used to avoid recurrsion error
[ "Creates", "the", "REST", "Url", "based", "on", "the", "supplied", "namespace" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L558-L583
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.reset_namespace
def reset_namespace(self, namespace=None, params=None): """ Will delete and recreate specified namespace args: namespace(str): Namespace to reset params(dict): params used to reset the namespace """ log = logging.getLogger("%s.%s" % (self.log_name, ...
python
def reset_namespace(self, namespace=None, params=None): """ Will delete and recreate specified namespace args: namespace(str): Namespace to reset params(dict): params used to reset the namespace """ log = logging.getLogger("%s.%s" % (self.log_name, ...
[ "def", "reset_namespace", "(", "self", ",", "namespace", "=", "None", ",", "params", "=", "None", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "\"%s.%s\"", "%", "(", "self", ".", "log_name", ",", "inspect", ".", "stack", "(", ")", "[", "0"...
Will delete and recreate specified namespace args: namespace(str): Namespace to reset params(dict): params used to reset the namespace
[ "Will", "delete", "and", "recreate", "specified", "namespace" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L585-L604
KnowledgeLinks/rdfframework
rdfframework/connections/blazegraph.py
Blazegraph.bulk_load
def bulk_load(self, **kwargs): """ Uploads data to the Blazegraph Triplestore that is stored in files that are in a local directory kwargs: file_directory: a string path to the file directory file_extensions: a list of file extensions to filter ...
python
def bulk_load(self, **kwargs): """ Uploads data to the Blazegraph Triplestore that is stored in files that are in a local directory kwargs: file_directory: a string path to the file directory file_extensions: a list of file extensions to filter ...
[ "def", "bulk_load", "(", "self", ",", "*", "*", "kwargs", ")", ":", "namespace", "=", "kwargs", ".", "get", "(", "'namespace'", ",", "self", ".", "namespace", ")", "graph", "=", "kwargs", ".", "get", "(", "'graph'", ",", "self", ".", "graph", ")", ...
Uploads data to the Blazegraph Triplestore that is stored in files that are in a local directory kwargs: file_directory: a string path to the file directory file_extensions: a list of file extensions to filter example ['xml', 'rdf']. If no...
[ "Uploads", "data", "to", "the", "Blazegraph", "Triplestore", "that", "is", "stored", "in", "files", "that", "are", "in", "a", "local", "directory" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L606-L696
20tab/twentytab-tree
tree/views.py
tree_render
def tree_render(request, upy_context, vars_dictionary): """ It renders template defined in upy_context's page passed in arguments """ page = upy_context['PAGE'] return render_to_response(page.template.file_name, vars_dictionary, context_instance=RequestContext(request))
python
def tree_render(request, upy_context, vars_dictionary): """ It renders template defined in upy_context's page passed in arguments """ page = upy_context['PAGE'] return render_to_response(page.template.file_name, vars_dictionary, context_instance=RequestContext(request))
[ "def", "tree_render", "(", "request", ",", "upy_context", ",", "vars_dictionary", ")", ":", "page", "=", "upy_context", "[", "'PAGE'", "]", "return", "render_to_response", "(", "page", ".", "template", ".", "file_name", ",", "vars_dictionary", ",", "context_inst...
It renders template defined in upy_context's page passed in arguments
[ "It", "renders", "template", "defined", "in", "upy_context", "s", "page", "passed", "in", "arguments" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L8-L13
20tab/twentytab-tree
tree/views.py
view_404
def view_404(request, url=None): """ It returns a 404 http response """ res = render_to_response("404.html", {"PAGE_URL": request.get_full_path()}, context_instance=RequestContext(request)) res.status_code = 404 return res
python
def view_404(request, url=None): """ It returns a 404 http response """ res = render_to_response("404.html", {"PAGE_URL": request.get_full_path()}, context_instance=RequestContext(request)) res.status_code = 404 return res
[ "def", "view_404", "(", "request", ",", "url", "=", "None", ")", ":", "res", "=", "render_to_response", "(", "\"404.html\"", ",", "{", "\"PAGE_URL\"", ":", "request", ".", "get_full_path", "(", ")", "}", ",", "context_instance", "=", "RequestContext", "(", ...
It returns a 404 http response
[ "It", "returns", "a", "404", "http", "response" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L16-L23
20tab/twentytab-tree
tree/views.py
view_500
def view_500(request, url=None): """ it returns a 500 http response """ res = render_to_response("500.html", context_instance=RequestContext(request)) res.status_code = 500 return res
python
def view_500(request, url=None): """ it returns a 500 http response """ res = render_to_response("500.html", context_instance=RequestContext(request)) res.status_code = 500 return res
[ "def", "view_500", "(", "request", ",", "url", "=", "None", ")", ":", "res", "=", "render_to_response", "(", "\"500.html\"", ",", "context_instance", "=", "RequestContext", "(", "request", ")", ")", "res", ".", "status_code", "=", "500", "return", "res" ]
it returns a 500 http response
[ "it", "returns", "a", "500", "http", "response" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L26-L32
20tab/twentytab-tree
tree/views.py
favicon
def favicon(request): """ It returns favicon's location """ favicon = u"{}tree/images/favicon.ico".format(settings.STATIC_URL) try: from seo.models import MetaSite site = MetaSite.objects.get(default=True) return HttpResponseRedirect(site.favicon.url) except: retu...
python
def favicon(request): """ It returns favicon's location """ favicon = u"{}tree/images/favicon.ico".format(settings.STATIC_URL) try: from seo.models import MetaSite site = MetaSite.objects.get(default=True) return HttpResponseRedirect(site.favicon.url) except: retu...
[ "def", "favicon", "(", "request", ")", ":", "favicon", "=", "u\"{}tree/images/favicon.ico\"", ".", "format", "(", "settings", ".", "STATIC_URL", ")", "try", ":", "from", "seo", ".", "models", "import", "MetaSite", "site", "=", "MetaSite", ".", "objects", "."...
It returns favicon's location
[ "It", "returns", "favicon", "s", "location" ]
train
https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L51-L61
thespacedoctor/sloancone
build/lib/sloancone/cl_utils.py
main
def main(arguments=None): """ *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* """ # setup the command-line util settings su = tools( arguments=arguments, docString=__doc__, logLevel="WARNING", opti...
python
def main(arguments=None): """ *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* """ # setup the command-line util settings su = tools( arguments=arguments, docString=__doc__, logLevel="WARNING", opti...
[ "def", "main", "(", "arguments", "=", "None", ")", ":", "# setup the command-line util settings", "su", "=", "tools", "(", "arguments", "=", "arguments", ",", "docString", "=", "__doc__", ",", "logLevel", "=", "\"WARNING\"", ",", "options_first", "=", "True", ...
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
[ "*", "The", "main", "function", "used", "when", "cl_utils", ".", "py", "is", "run", "as", "a", "single", "script", "from", "the", "cl", "or", "when", "installed", "as", "a", "cl", "command", "*" ]
train
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/cl_utils.py#L38-L141
thespacedoctor/sloancone
build/lib/sloancone/cl_utils.py
main
def main(arguments=None): """ *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* """ # setup the command-line util settings su = tools( arguments=arguments, docString=__doc__, logLevel="DEBUG", option...
python
def main(arguments=None): """ *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* """ # setup the command-line util settings su = tools( arguments=arguments, docString=__doc__, logLevel="DEBUG", option...
[ "def", "main", "(", "arguments", "=", "None", ")", ":", "# setup the command-line util settings", "su", "=", "tools", "(", "arguments", "=", "arguments", ",", "docString", "=", "__doc__", ",", "logLevel", "=", "\"DEBUG\"", ",", "options_first", "=", "False", "...
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
[ "*", "The", "main", "function", "used", "when", "cl_utils", ".", "py", "is", "run", "as", "a", "single", "script", "from", "the", "cl", "or", "when", "installed", "as", "a", "cl", "command", "*" ]
train
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/cl_utils.py#L178-L258
minhhoit/yacms
yacms/accounts/forms.py
LoginForm.clean
def clean(self): """ Authenticate the given username/email and password. If the fields are valid, store the authenticated user for returning via save(). """ username = self.cleaned_data.get("username") password = self.cleaned_data.get("password") self._user = auth...
python
def clean(self): """ Authenticate the given username/email and password. If the fields are valid, store the authenticated user for returning via save(). """ username = self.cleaned_data.get("username") password = self.cleaned_data.get("password") self._user = auth...
[ "def", "clean", "(", "self", ")", ":", "username", "=", "self", ".", "cleaned_data", ".", "get", "(", "\"username\"", ")", "password", "=", "self", ".", "cleaned_data", ".", "get", "(", "\"password\"", ")", "self", ".", "_user", "=", "authenticate", "(",...
Authenticate the given username/email and password. If the fields are valid, store the authenticated user for returning via save().
[ "Authenticate", "the", "given", "username", "/", "email", "and", "password", ".", "If", "the", "fields", "are", "valid", "store", "the", "authenticated", "user", "for", "returning", "via", "save", "()", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L50-L63
minhhoit/yacms
yacms/accounts/forms.py
ProfileForm.clean_username
def clean_username(self): """ Ensure the username doesn't exist or contain invalid chars. We limit it to slugifiable chars since it's used as the slug for the user's profile view. """ username = self.cleaned_data.get("username") if username.lower() != slugify(user...
python
def clean_username(self): """ Ensure the username doesn't exist or contain invalid chars. We limit it to slugifiable chars since it's used as the slug for the user's profile view. """ username = self.cleaned_data.get("username") if username.lower() != slugify(user...
[ "def", "clean_username", "(", "self", ")", ":", "username", "=", "self", ".", "cleaned_data", ".", "get", "(", "\"username\"", ")", "if", "username", ".", "lower", "(", ")", "!=", "slugify", "(", "username", ")", ".", "lower", "(", ")", ":", "raise", ...
Ensure the username doesn't exist or contain invalid chars. We limit it to slugifiable chars since it's used as the slug for the user's profile view.
[ "Ensure", "the", "username", "doesn", "t", "exist", "or", "contain", "invalid", "chars", ".", "We", "limit", "it", "to", "slugifiable", "chars", "since", "it", "s", "used", "as", "the", "slug", "for", "the", "user", "s", "profile", "view", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L130-L147
minhhoit/yacms
yacms/accounts/forms.py
ProfileForm.clean_password2
def clean_password2(self): """ Ensure the password fields are equal, and match the minimum length defined by ``ACCOUNTS_MIN_PASSWORD_LENGTH``. """ password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1: ...
python
def clean_password2(self): """ Ensure the password fields are equal, and match the minimum length defined by ``ACCOUNTS_MIN_PASSWORD_LENGTH``. """ password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1: ...
[ "def", "clean_password2", "(", "self", ")", ":", "password1", "=", "self", ".", "cleaned_data", ".", "get", "(", "\"password1\"", ")", "password2", "=", "self", ".", "cleaned_data", ".", "get", "(", "\"password2\"", ")", "if", "password1", ":", "errors", "...
Ensure the password fields are equal, and match the minimum length defined by ``ACCOUNTS_MIN_PASSWORD_LENGTH``.
[ "Ensure", "the", "password", "fields", "are", "equal", "and", "match", "the", "minimum", "length", "defined", "by", "ACCOUNTS_MIN_PASSWORD_LENGTH", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L149-L167
minhhoit/yacms
yacms/accounts/forms.py
ProfileForm.clean_email
def clean_email(self): """ Ensure the email address is not already registered. """ email = self.cleaned_data.get("email") qs = User.objects.exclude(id=self.instance.id).filter(email=email) if len(qs) == 0: return email raise forms.ValidationError( ...
python
def clean_email(self): """ Ensure the email address is not already registered. """ email = self.cleaned_data.get("email") qs = User.objects.exclude(id=self.instance.id).filter(email=email) if len(qs) == 0: return email raise forms.ValidationError( ...
[ "def", "clean_email", "(", "self", ")", ":", "email", "=", "self", ".", "cleaned_data", ".", "get", "(", "\"email\"", ")", "qs", "=", "User", ".", "objects", ".", "exclude", "(", "id", "=", "self", ".", "instance", ".", "id", ")", ".", "filter", "(...
Ensure the email address is not already registered.
[ "Ensure", "the", "email", "address", "is", "not", "already", "registered", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L169-L178
minhhoit/yacms
yacms/accounts/forms.py
ProfileForm.save
def save(self, *args, **kwargs): """ Create the new user. If no username is supplied (may be hidden via ``ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS`` or ``ACCOUNTS_NO_USERNAME``), we generate a unique username, so that if profile pages are enabled, we still have something to u...
python
def save(self, *args, **kwargs): """ Create the new user. If no username is supplied (may be hidden via ``ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS`` or ``ACCOUNTS_NO_USERNAME``), we generate a unique username, so that if profile pages are enabled, we still have something to u...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"commit\"", "]", "=", "False", "user", "=", "super", "(", "ProfileForm", ",", "self", ")", ".", "save", "(", "*", "args", ",", "*", "*", "kwargs", ...
Create the new user. If no username is supplied (may be hidden via ``ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS`` or ``ACCOUNTS_NO_USERNAME``), we generate a unique username, so that if profile pages are enabled, we still have something to use as the profile's slug.
[ "Create", "the", "new", "user", ".", "If", "no", "username", "is", "supplied", "(", "may", "be", "hidden", "via", "ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS", "or", "ACCOUNTS_NO_USERNAME", ")", "we", "generate", "a", "unique", "username", "so", "that", "if", "profile...
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L180-L233
voidabhi/TheZineAPI
tz/tz.py
TZ.get_articles
def get_articles(self, issue=''): """ Yields a list of articles from the given issue. """ soup = get_soup() # get soup of all articles issues = soup.find_all('ul') # validating and assigning default value for issue if not type(issue) is int or issue < 0 : issue = 1 if issue > len(is...
python
def get_articles(self, issue=''): """ Yields a list of articles from the given issue. """ soup = get_soup() # get soup of all articles issues = soup.find_all('ul') # validating and assigning default value for issue if not type(issue) is int or issue < 0 : issue = 1 if issue > len(is...
[ "def", "get_articles", "(", "self", ",", "issue", "=", "''", ")", ":", "soup", "=", "get_soup", "(", ")", "# get soup of all articles ", "issues", "=", "soup", ".", "find_all", "(", "'ul'", ")", "# validating and assigning default value for issue", "if", "not", ...
Yields a list of articles from the given issue.
[ "Yields", "a", "list", "of", "articles", "from", "the", "given", "issue", "." ]
train
https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L30-L54
voidabhi/TheZineAPI
tz/tz.py
Article.fromLink
def fromLink(self, link): """ Factory Method. Fetches article data from given link and builds the object """ soup = get_article_soup(link) head = soup.find_all('article',class_='')[0] parts = link.split('/') id = '%s-%s'%(parts[0],parts[-1]) issue = parts[0].split('-')[-1] #fetching head title =...
python
def fromLink(self, link): """ Factory Method. Fetches article data from given link and builds the object """ soup = get_article_soup(link) head = soup.find_all('article',class_='')[0] parts = link.split('/') id = '%s-%s'%(parts[0],parts[-1]) issue = parts[0].split('-')[-1] #fetching head title =...
[ "def", "fromLink", "(", "self", ",", "link", ")", ":", "soup", "=", "get_article_soup", "(", "link", ")", "head", "=", "soup", ".", "find_all", "(", "'article'", ",", "class_", "=", "''", ")", "[", "0", "]", "parts", "=", "link", ".", "split", "(",...
Factory Method. Fetches article data from given link and builds the object
[ "Factory", "Method", ".", "Fetches", "article", "data", "from", "given", "link", "and", "builds", "the", "object" ]
train
https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L73-L95
voidabhi/TheZineAPI
tz/tz.py
Author.from_soup
def from_soup(self,soup): """ Factory Pattern. Fetches author data from given soup and builds the object """ if soup is None or soup is '': return None else: author_name = soup.find('em').contents[0].strip() if soup.find('em') else '' author_image = soup.find('img').get('src') if soup.find('img') ...
python
def from_soup(self,soup): """ Factory Pattern. Fetches author data from given soup and builds the object """ if soup is None or soup is '': return None else: author_name = soup.find('em').contents[0].strip() if soup.find('em') else '' author_image = soup.find('img').get('src') if soup.find('img') ...
[ "def", "from_soup", "(", "self", ",", "soup", ")", ":", "if", "soup", "is", "None", "or", "soup", "is", "''", ":", "return", "None", "else", ":", "author_name", "=", "soup", ".", "find", "(", "'em'", ")", ".", "contents", "[", "0", "]", ".", "str...
Factory Pattern. Fetches author data from given soup and builds the object
[ "Factory", "Pattern", ".", "Fetches", "author", "data", "from", "given", "soup", "and", "builds", "the", "object" ]
train
https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L122-L132
voidabhi/TheZineAPI
tz/tz.py
Contact.from_soup
def from_soup(self,author,soup): """ Factory Pattern. Fetches contact data from given soup and builds the object """ email = soup.find('span',class_='icon icon-mail').findParent('a').get('href').split(':')[-1] if soup.find('span',class_='icon icon-mail') else '' facebook = soup.find('span',class_='icon ico...
python
def from_soup(self,author,soup): """ Factory Pattern. Fetches contact data from given soup and builds the object """ email = soup.find('span',class_='icon icon-mail').findParent('a').get('href').split(':')[-1] if soup.find('span',class_='icon icon-mail') else '' facebook = soup.find('span',class_='icon ico...
[ "def", "from_soup", "(", "self", ",", "author", ",", "soup", ")", ":", "email", "=", "soup", ".", "find", "(", "'span'", ",", "class_", "=", "'icon icon-mail'", ")", ".", "findParent", "(", "'a'", ")", ".", "get", "(", "'href'", ")", ".", "split", ...
Factory Pattern. Fetches contact data from given soup and builds the object
[ "Factory", "Pattern", ".", "Fetches", "contact", "data", "from", "given", "soup", "and", "builds", "the", "object" ]
train
https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L148-L156
FujiMakoto/IPS-Vagrant
ips_vagrant/commands/versions/__init__.py
cli
def cli(ctx, resource): """ Displays all locally cached <resource> versions available for installation. \b Available resources: ips (default) dev_tools """ log = logging.getLogger('ipsv.setup') assert isinstance(ctx, Context) resource = str(resource).lower() if res...
python
def cli(ctx, resource): """ Displays all locally cached <resource> versions available for installation. \b Available resources: ips (default) dev_tools """ log = logging.getLogger('ipsv.setup') assert isinstance(ctx, Context) resource = str(resource).lower() if res...
[ "def", "cli", "(", "ctx", ",", "resource", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "'ipsv.setup'", ")", "assert", "isinstance", "(", "ctx", ",", "Context", ")", "resource", "=", "str", "(", "resource", ")", ".", "lower", "(", ")", "if...
Displays all locally cached <resource> versions available for installation. \b Available resources: ips (default) dev_tools
[ "Displays", "all", "locally", "cached", "<resource", ">", "versions", "available", "for", "installation", "." ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/versions/__init__.py#L11-L35
marteinn/genres
genres/finder.py
Finder.find
def find(self, text): """ Return a list of genres found in text. """ genres = [] text = text.lower() category_counter = Counter() counter = Counter() for genre in self.db.genres: found = self.contains_entity(genre, text) if found...
python
def find(self, text): """ Return a list of genres found in text. """ genres = [] text = text.lower() category_counter = Counter() counter = Counter() for genre in self.db.genres: found = self.contains_entity(genre, text) if found...
[ "def", "find", "(", "self", ",", "text", ")", ":", "genres", "=", "[", "]", "text", "=", "text", ".", "lower", "(", ")", "category_counter", "=", "Counter", "(", ")", "counter", "=", "Counter", "(", ")", "for", "genre", "in", "self", ".", "db", "...
Return a list of genres found in text.
[ "Return", "a", "list", "of", "genres", "found", "in", "text", "." ]
train
https://github.com/marteinn/genres/blob/4bbc90f7c2c527631380c08b4d99a4e40abed955/genres/finder.py#L22-L78
marteinn/genres
genres/finder.py
Finder.contains_entity
def contains_entity(entity, text): """ Attempt to try entity, return false if not found. Otherwise the amount of time entitu is occuring. """ try: entity = re.escape(entity) entity = entity.replace("\ ", "([^\w])?") pattern = "(\ |-|\\\|/|\.|,...
python
def contains_entity(entity, text): """ Attempt to try entity, return false if not found. Otherwise the amount of time entitu is occuring. """ try: entity = re.escape(entity) entity = entity.replace("\ ", "([^\w])?") pattern = "(\ |-|\\\|/|\.|,...
[ "def", "contains_entity", "(", "entity", ",", "text", ")", ":", "try", ":", "entity", "=", "re", ".", "escape", "(", "entity", ")", "entity", "=", "entity", ".", "replace", "(", "\"\\ \"", ",", "\"([^\\w])?\"", ")", "pattern", "=", "\"(\\ |-|\\\\\\|/|\\.|,...
Attempt to try entity, return false if not found. Otherwise the amount of time entitu is occuring.
[ "Attempt", "to", "try", "entity", "return", "false", "if", "not", "found", ".", "Otherwise", "the", "amount", "of", "time", "entitu", "is", "occuring", "." ]
train
https://github.com/marteinn/genres/blob/4bbc90f7c2c527631380c08b4d99a4e40abed955/genres/finder.py#L81-L95
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
jsonify
def jsonify(result, format=False): ''' format JSON output (uncompressed or uncompressed) ''' result2 = result.copy() if format: return json.dumps(result2, sort_keys=True, indent=4) else: return json.dumps(result2, sort_keys=True)
python
def jsonify(result, format=False): ''' format JSON output (uncompressed or uncompressed) ''' result2 = result.copy() if format: return json.dumps(result2, sort_keys=True, indent=4) else: return json.dumps(result2, sort_keys=True)
[ "def", "jsonify", "(", "result", ",", "format", "=", "False", ")", ":", "result2", "=", "result", ".", "copy", "(", ")", "if", "format", ":", "return", "json", ".", "dumps", "(", "result2", ",", "sort_keys", "=", "True", ",", "indent", "=", "4", ")...
format JSON output (uncompressed or uncompressed)
[ "format", "JSON", "output", "(", "uncompressed", "or", "uncompressed", ")" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L117-L124
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
write_tree_file
def write_tree_file(tree, hostname, buf): ''' write something into treedir/hostname ''' # TODO: might be nice to append playbook runs per host in a similar way # in which case, we'd want append mode. path = os.path.join(tree, hostname) fd = open(path, "w+") fd.write(buf) fd.close()
python
def write_tree_file(tree, hostname, buf): ''' write something into treedir/hostname ''' # TODO: might be nice to append playbook runs per host in a similar way # in which case, we'd want append mode. path = os.path.join(tree, hostname) fd = open(path, "w+") fd.write(buf) fd.close()
[ "def", "write_tree_file", "(", "tree", ",", "hostname", ",", "buf", ")", ":", "# TODO: might be nice to append playbook runs per host in a similar way", "# in which case, we'd want append mode.", "path", "=", "os", ".", "path", ".", "join", "(", "tree", ",", "hostname", ...
write something into treedir/hostname
[ "write", "something", "into", "treedir", "/", "hostname" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L126-L134
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
is_executable
def is_executable(path): '''is the given path executable?''' return (stat.S_IXUSR & os.stat(path)[stat.ST_MODE] or stat.S_IXGRP & os.stat(path)[stat.ST_MODE] or stat.S_IXOTH & os.stat(path)[stat.ST_MODE])
python
def is_executable(path): '''is the given path executable?''' return (stat.S_IXUSR & os.stat(path)[stat.ST_MODE] or stat.S_IXGRP & os.stat(path)[stat.ST_MODE] or stat.S_IXOTH & os.stat(path)[stat.ST_MODE])
[ "def", "is_executable", "(", "path", ")", ":", "return", "(", "stat", ".", "S_IXUSR", "&", "os", ".", "stat", "(", "path", ")", "[", "stat", ".", "ST_MODE", "]", "or", "stat", ".", "S_IXGRP", "&", "os", ".", "stat", "(", "path", ")", "[", "stat",...
is the given path executable?
[ "is", "the", "given", "path", "executable?" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L159-L163
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
prepare_writeable_dir
def prepare_writeable_dir(tree): ''' make sure a directory exists and is writeable ''' if tree != '/': tree = os.path.realpath(os.path.expanduser(tree)) if not os.path.exists(tree): try: os.makedirs(tree) except (IOError, OSError), e: exit("Could not make dir...
python
def prepare_writeable_dir(tree): ''' make sure a directory exists and is writeable ''' if tree != '/': tree = os.path.realpath(os.path.expanduser(tree)) if not os.path.exists(tree): try: os.makedirs(tree) except (IOError, OSError), e: exit("Could not make dir...
[ "def", "prepare_writeable_dir", "(", "tree", ")", ":", "if", "tree", "!=", "'/'", ":", "tree", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "expanduser", "(", "tree", ")", ")", "if", "not", "os", ".", "path", ".", "exists",...
make sure a directory exists and is writeable
[ "make", "sure", "a", "directory", "exists", "and", "is", "writeable" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L165-L176
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
path_dwim
def path_dwim(basedir, given): ''' make relative paths work like folks expect. ''' if given.startswith("/"): return given elif given.startswith("~/"): return os.path.expanduser(given) else: return os.path.join(basedir, given)
python
def path_dwim(basedir, given): ''' make relative paths work like folks expect. ''' if given.startswith("/"): return given elif given.startswith("~/"): return os.path.expanduser(given) else: return os.path.join(basedir, given)
[ "def", "path_dwim", "(", "basedir", ",", "given", ")", ":", "if", "given", ".", "startswith", "(", "\"/\"", ")", ":", "return", "given", "elif", "given", ".", "startswith", "(", "\"~/\"", ")", ":", "return", "os", ".", "path", ".", "expanduser", "(", ...
make relative paths work like folks expect.
[ "make", "relative", "paths", "work", "like", "folks", "expect", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L178-L188
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
parse_json
def parse_json(raw_data): ''' this version for module return data only ''' orig_data = raw_data # ignore stuff like tcgetattr spewage or other warnings data = filter_leading_non_json_lines(raw_data) try: return json.loads(data) except: # not JSON, but try "Baby JSON" which all...
python
def parse_json(raw_data): ''' this version for module return data only ''' orig_data = raw_data # ignore stuff like tcgetattr spewage or other warnings data = filter_leading_non_json_lines(raw_data) try: return json.loads(data) except: # not JSON, but try "Baby JSON" which all...
[ "def", "parse_json", "(", "raw_data", ")", ":", "orig_data", "=", "raw_data", "# ignore stuff like tcgetattr spewage or other warnings", "data", "=", "filter_leading_non_json_lines", "(", "raw_data", ")", "try", ":", "return", "json", ".", "loads", "(", "data", ")", ...
this version for module return data only
[ "this", "version", "for", "module", "return", "data", "only" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L195-L229
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
parse_yaml_from_file
def parse_yaml_from_file(path): ''' convert a yaml file to a data structure ''' try: data = file(path).read() return parse_yaml(data) except IOError: raise errors.AnsibleError("file not found: %s" % path) except yaml.YAMLError, exc: if hasattr(exc, 'problem_mark'): ...
python
def parse_yaml_from_file(path): ''' convert a yaml file to a data structure ''' try: data = file(path).read() return parse_yaml(data) except IOError: raise errors.AnsibleError("file not found: %s" % path) except yaml.YAMLError, exc: if hasattr(exc, 'problem_mark'): ...
[ "def", "parse_yaml_from_file", "(", "path", ")", ":", "try", ":", "data", "=", "file", "(", "path", ")", ".", "read", "(", ")", "return", "parse_yaml", "(", "data", ")", "except", "IOError", ":", "raise", "errors", ".", "AnsibleError", "(", "\"file not f...
convert a yaml file to a data structure
[ "convert", "a", "yaml", "file", "to", "a", "data", "structure" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L235-L262
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
parse_kv
def parse_kv(args): ''' convert a string of key/value items to a dict ''' options = {} if args is not None: # attempting to split a unicode here does bad things vargs = shlex.split(str(args), posix=True) for x in vargs: if x.find("=") != -1: k, v = x.spli...
python
def parse_kv(args): ''' convert a string of key/value items to a dict ''' options = {} if args is not None: # attempting to split a unicode here does bad things vargs = shlex.split(str(args), posix=True) for x in vargs: if x.find("=") != -1: k, v = x.spli...
[ "def", "parse_kv", "(", "args", ")", ":", "options", "=", "{", "}", "if", "args", "is", "not", "None", ":", "# attempting to split a unicode here does bad things", "vargs", "=", "shlex", ".", "split", "(", "str", "(", "args", ")", ",", "posix", "=", "True"...
convert a string of key/value items to a dict
[ "convert", "a", "string", "of", "key", "/", "value", "items", "to", "a", "dict" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L264-L275
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
merge_hash
def merge_hash(a, b): ''' merges hash b into a this means that if b has key k, the resulting has will have a key k which value comes from b said differently, all key/value combination from b will override a's ''' # and iterate over b keys for k, v in b.iteritems(): if k in a and isinsta...
python
def merge_hash(a, b): ''' merges hash b into a this means that if b has key k, the resulting has will have a key k which value comes from b said differently, all key/value combination from b will override a's ''' # and iterate over b keys for k, v in b.iteritems(): if k in a and isinsta...
[ "def", "merge_hash", "(", "a", ",", "b", ")", ":", "# and iterate over b keys", "for", "k", ",", "v", "in", "b", ".", "iteritems", "(", ")", ":", "if", "k", "in", "a", "and", "isinstance", "(", "a", "[", "k", "]", ",", "dict", ")", ":", "# if thi...
merges hash b into a this means that if b has key k, the resulting has will have a key k which value comes from b said differently, all key/value combination from b will override a's
[ "merges", "hash", "b", "into", "a", "this", "means", "that", "if", "b", "has", "key", "k", "the", "resulting", "has", "will", "have", "a", "key", "k", "which", "value", "comes", "from", "b", "said", "differently", "all", "key", "/", "value", "combinati...
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L277-L295
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
md5
def md5(filename): ''' Return MD5 hex digest of local file, or None if file is not present. ''' if not os.path.exists(filename): return None digest = _md5() blocksize = 64 * 1024 infile = open(filename, 'rb') block = infile.read(blocksize) while block: digest.update(block) ...
python
def md5(filename): ''' Return MD5 hex digest of local file, or None if file is not present. ''' if not os.path.exists(filename): return None digest = _md5() blocksize = 64 * 1024 infile = open(filename, 'rb') block = infile.read(blocksize) while block: digest.update(block) ...
[ "def", "md5", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "return", "None", "digest", "=", "_md5", "(", ")", "blocksize", "=", "64", "*", "1024", "infile", "=", "open", "(", "filename", ",", ...
Return MD5 hex digest of local file, or None if file is not present.
[ "Return", "MD5", "hex", "digest", "of", "local", "file", "or", "None", "if", "file", "is", "not", "present", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L304-L317
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
_gitinfo
def _gitinfo(): ''' returns a string containing git branch, commit id and commit date ''' result = None repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '.git') if os.path.exists(repo_path): # Check if the .git is a file. If it is a file, it means that we are in a submodule...
python
def _gitinfo(): ''' returns a string containing git branch, commit id and commit date ''' result = None repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '.git') if os.path.exists(repo_path): # Check if the .git is a file. If it is a file, it means that we are in a submodule...
[ "def", "_gitinfo", "(", ")", ":", "result", "=", "None", "repo_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'..'", ",", "'..'", ",", "'..'", ",", "'.git'", ")", "if", "os", ".", ...
returns a string containing git branch, commit id and commit date
[ "returns", "a", "string", "containing", "git", "branch", "commit", "id", "and", "commit", "date" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L325-L359
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
base_parser
def base_parser(constants=C, usage="", output_opts=False, runas_opts=False, async_opts=False, connect_opts=False, subset_opts=False): ''' create an options parser for any ansible script ''' parser = SortedOptParser(usage, version=version("%prog")) parser.add_option('-v','--verbose', default=False, acti...
python
def base_parser(constants=C, usage="", output_opts=False, runas_opts=False, async_opts=False, connect_opts=False, subset_opts=False): ''' create an options parser for any ansible script ''' parser = SortedOptParser(usage, version=version("%prog")) parser.add_option('-v','--verbose', default=False, acti...
[ "def", "base_parser", "(", "constants", "=", "C", ",", "usage", "=", "\"\"", ",", "output_opts", "=", "False", ",", "runas_opts", "=", "False", ",", "async_opts", "=", "False", ",", "connect_opts", "=", "False", ",", "subset_opts", "=", "False", ")", ":"...
create an options parser for any ansible script
[ "create", "an", "options", "parser", "for", "any", "ansible", "script" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L394-L452
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
filter_leading_non_json_lines
def filter_leading_non_json_lines(buf): ''' used to avoid random output from SSH at the top of JSON output, like messages from tcagetattr, or where dropbear spews MOTD on every single command (which is nuts). need to filter anything which starts not with '{', '[', ', '=' or is an empty line. filter...
python
def filter_leading_non_json_lines(buf): ''' used to avoid random output from SSH at the top of JSON output, like messages from tcagetattr, or where dropbear spews MOTD on every single command (which is nuts). need to filter anything which starts not with '{', '[', ', '=' or is an empty line. filter...
[ "def", "filter_leading_non_json_lines", "(", "buf", ")", ":", "filtered_lines", "=", "StringIO", ".", "StringIO", "(", ")", "stop_filtering", "=", "False", "for", "line", "in", "buf", ".", "splitlines", "(", ")", ":", "if", "stop_filtering", "or", "\"=\"", "...
used to avoid random output from SSH at the top of JSON output, like messages from tcagetattr, or where dropbear spews MOTD on every single command (which is nuts). need to filter anything which starts not with '{', '[', ', '=' or is an empty line. filter only leading lines since multiline JSON is valid.
[ "used", "to", "avoid", "random", "output", "from", "SSH", "at", "the", "top", "of", "JSON", "output", "like", "messages", "from", "tcagetattr", "or", "where", "dropbear", "spews", "MOTD", "on", "every", "single", "command", "(", "which", "is", "nuts", ")",...
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L482-L497
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
compile_when_to_only_if
def compile_when_to_only_if(expression): ''' when is a shorthand for writing only_if conditionals. It requires less quoting magic. only_if is retained for backwards compatibility. ''' # when: set $variable # when: unset $variable # when: failed $json_result # when: changed $json_resul...
python
def compile_when_to_only_if(expression): ''' when is a shorthand for writing only_if conditionals. It requires less quoting magic. only_if is retained for backwards compatibility. ''' # when: set $variable # when: unset $variable # when: failed $json_result # when: changed $json_resul...
[ "def", "compile_when_to_only_if", "(", "expression", ")", ":", "# when: set $variable", "# when: unset $variable", "# when: failed $json_result", "# when: changed $json_result", "# when: int $x >= $z and $y < 3", "# when: int $x in $alist", "# when: float $x > 2 and $y <= $z", "# when: str...
when is a shorthand for writing only_if conditionals. It requires less quoting magic. only_if is retained for backwards compatibility.
[ "when", "is", "a", "shorthand", "for", "writing", "only_if", "conditionals", ".", "It", "requires", "less", "quoting", "magic", ".", "only_if", "is", "retained", "for", "backwards", "compatibility", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L506-L578
cirruscluster/cirruscluster
cirruscluster/ext/ansible/utils/__init__.py
make_sudo_cmd
def make_sudo_cmd(sudo_user, executable, cmd): """ helper function for connection plugins to create sudo commands """ # Rather than detect if sudo wants a password this time, -k makes # sudo always ask for a password if one is required. # Passing a quoted compound command to sudo (or sudo -s) ...
python
def make_sudo_cmd(sudo_user, executable, cmd): """ helper function for connection plugins to create sudo commands """ # Rather than detect if sudo wants a password this time, -k makes # sudo always ask for a password if one is required. # Passing a quoted compound command to sudo (or sudo -s) ...
[ "def", "make_sudo_cmd", "(", "sudo_user", ",", "executable", ",", "cmd", ")", ":", "# Rather than detect if sudo wants a password this time, -k makes", "# sudo always ask for a password if one is required.", "# Passing a quoted compound command to sudo (or sudo -s)", "# directly doesn't wo...
helper function for connection plugins to create sudo commands
[ "helper", "function", "for", "connection", "plugins", "to", "create", "sudo", "commands" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L580-L596
jmgilman/Neolib
neolib/user/User.py
User.login
def login(self): """ Logs the user in, returns the result Returns bool - Whether or not the user logged in successfully """ # Request index to obtain initial cookies and look more human pg = self.getPage("http://www.neopets.com") form = pg....
python
def login(self): """ Logs the user in, returns the result Returns bool - Whether or not the user logged in successfully """ # Request index to obtain initial cookies and look more human pg = self.getPage("http://www.neopets.com") form = pg....
[ "def", "login", "(", "self", ")", ":", "# Request index to obtain initial cookies and look more human", "pg", "=", "self", ".", "getPage", "(", "\"http://www.neopets.com\"", ")", "form", "=", "pg", ".", "form", "(", "action", "=", "\"/login.phtml\"", ")", "form", ...
Logs the user in, returns the result Returns bool - Whether or not the user logged in successfully
[ "Logs", "the", "user", "in", "returns", "the", "result", "Returns", "bool", "-", "Whether", "or", "not", "the", "user", "logged", "in", "successfully" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L158-L173
jmgilman/Neolib
neolib/user/User.py
User.sync
def sync(self, browser): """ Enables cookie synchronization with specified browser, returns result Returns bool - True if successful, false otherwise """ BrowserCookies.loadBrowsers() if not browser in BrowserCookies.browsers: return False ...
python
def sync(self, browser): """ Enables cookie synchronization with specified browser, returns result Returns bool - True if successful, false otherwise """ BrowserCookies.loadBrowsers() if not browser in BrowserCookies.browsers: return False ...
[ "def", "sync", "(", "self", ",", "browser", ")", ":", "BrowserCookies", ".", "loadBrowsers", "(", ")", "if", "not", "browser", "in", "BrowserCookies", ".", "browsers", ":", "return", "False", "self", ".", "browserSync", "=", "True", "self", ".", "browser",...
Enables cookie synchronization with specified browser, returns result Returns bool - True if successful, false otherwise
[ "Enables", "cookie", "synchronization", "with", "specified", "browser", "returns", "result", "Returns", "bool", "-", "True", "if", "successful", "false", "otherwise" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L185-L197
jmgilman/Neolib
neolib/user/User.py
User.save
def save(self): """ Exports all user attributes to the user's configuration and writes configuration Saves the values for each attribute stored in User.configVars into the user's configuration. The password is automatically encoded and salted to prevent saving it as plaintext. T...
python
def save(self): """ Exports all user attributes to the user's configuration and writes configuration Saves the values for each attribute stored in User.configVars into the user's configuration. The password is automatically encoded and salted to prevent saving it as plaintext. T...
[ "def", "save", "(", "self", ")", ":", "# Code to load all attributes", "for", "prop", "in", "dir", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "prop", ")", "==", "None", ":", "continue", "if", "not", "prop", "in", "self", ".", "configVars...
Exports all user attributes to the user's configuration and writes configuration Saves the values for each attribute stored in User.configVars into the user's configuration. The password is automatically encoded and salted to prevent saving it as plaintext. The session is pickl...
[ "Exports", "all", "user", "attributes", "to", "the", "user", "s", "configuration", "and", "writes", "configuration", "Saves", "the", "values", "for", "each", "attribute", "stored", "in", "User", ".", "configVars", "into", "the", "user", "s", "configuration", "...
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L204-L238
jmgilman/Neolib
neolib/user/User.py
User.getPage
def getPage(self, url, postData = None, vars = None, usePin = False): """ Requests and returns a page using the user's session If useRef is set to true, automatically appends a referer using the user's last page to the request. If usePin is set to true, automatically appends the...
python
def getPage(self, url, postData = None, vars = None, usePin = False): """ Requests and returns a page using the user's session If useRef is set to true, automatically appends a referer using the user's last page to the request. If usePin is set to true, automatically appends the...
[ "def", "getPage", "(", "self", ",", "url", ",", "postData", "=", "None", ",", "vars", "=", "None", ",", "usePin", "=", "False", ")", ":", "# If using a referer is desired and one has not already been supplied, ", "# then set the referer to the user's last visited page.", ...
Requests and returns a page using the user's session If useRef is set to true, automatically appends a referer using the user's last page to the request. If usePin is set to true, automatically appends the user's pin to the POST data. If browser sync is enabled, automatically re...
[ "Requests", "and", "returns", "a", "page", "using", "the", "user", "s", "session", "If", "useRef", "is", "set", "to", "true", "automatically", "appends", "a", "referer", "using", "the", "user", "s", "last", "page", "to", "the", "request", ".", "If", "use...
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L240-L291
KnowledgeLinks/rdfframework
rdfframework/utilities/gitutilities.py
mod_git_ignore
def mod_git_ignore(directory, ignore_item, action): """ checks if an item is in the specified gitignore file and adds it if it is not in the file """ if not os.path.isdir(directory): return ignore_filepath = os.path.join(directory,".gitignore") if not os.path.exists(ignore_filepath): ...
python
def mod_git_ignore(directory, ignore_item, action): """ checks if an item is in the specified gitignore file and adds it if it is not in the file """ if not os.path.isdir(directory): return ignore_filepath = os.path.join(directory,".gitignore") if not os.path.exists(ignore_filepath): ...
[ "def", "mod_git_ignore", "(", "directory", ",", "ignore_item", ",", "action", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "directory", ")", ":", "return", "ignore_filepath", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "...
checks if an item is in the specified gitignore file and adds it if it is not in the file
[ "checks", "if", "an", "item", "is", "in", "the", "specified", "gitignore", "file", "and", "adds", "it", "if", "it", "is", "not", "in", "the", "file" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/gitutilities.py#L3-L27
etcher-be/elib_run
elib_run/_run/_monitor_running_process.py
monitor_running_process
def monitor_running_process(context: RunContext): """ Runs an infinite loop that waits for the process to either exit on its or time out Captures all output from the running process :param context: run context :type context: RunContext """ while True: capture_output_from_running_pr...
python
def monitor_running_process(context: RunContext): """ Runs an infinite loop that waits for the process to either exit on its or time out Captures all output from the running process :param context: run context :type context: RunContext """ while True: capture_output_from_running_pr...
[ "def", "monitor_running_process", "(", "context", ":", "RunContext", ")", ":", "while", "True", ":", "capture_output_from_running_process", "(", "context", ")", "if", "context", ".", "process_finished", "(", ")", ":", "context", ".", "return_code", "=", "context",...
Runs an infinite loop that waits for the process to either exit on its or time out Captures all output from the running process :param context: run context :type context: RunContext
[ "Runs", "an", "infinite", "loop", "that", "waits", "for", "the", "process", "to", "either", "exit", "on", "its", "or", "time", "out" ]
train
https://github.com/etcher-be/elib_run/blob/c9d8ba9f067ab90c5baa27375a92b23f1b97cdde/elib_run/_run/_monitor_running_process.py#L12-L33
b3j0f/utils
b3j0f/utils/reflect.py
base_elts
def base_elts(elt, cls=None, depth=None): """Get bases elements of the input elt. - If elt is an instance, get class and all base classes. - If elt is a method, get all base methods. - If elt is a class, get all base classes. - In other case, get an empty list. :param elt: supposed inherited e...
python
def base_elts(elt, cls=None, depth=None): """Get bases elements of the input elt. - If elt is an instance, get class and all base classes. - If elt is a method, get all base methods. - If elt is a class, get all base classes. - In other case, get an empty list. :param elt: supposed inherited e...
[ "def", "base_elts", "(", "elt", ",", "cls", "=", "None", ",", "depth", "=", "None", ")", ":", "result", "=", "[", "]", "elt_name", "=", "getattr", "(", "elt", ",", "'__name__'", ",", "None", ")", "if", "elt_name", "is", "not", "None", ":", "cls", ...
Get bases elements of the input elt. - If elt is an instance, get class and all base classes. - If elt is a method, get all base methods. - If elt is a class, get all base classes. - In other case, get an empty list. :param elt: supposed inherited elt. :param cls: cls from where find attribute...
[ "Get", "bases", "elements", "of", "the", "input", "elt", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/reflect.py#L48-L145
b3j0f/utils
b3j0f/utils/reflect.py
find_embedding
def find_embedding(elt, embedding=None): """Try to get elt embedding elements. :param embedding: embedding element. Must have a module. :return: a list of [module [,class]*] embedding elements which define elt. :rtype: list """ result = [] # result is empty in the worst case # start to ...
python
def find_embedding(elt, embedding=None): """Try to get elt embedding elements. :param embedding: embedding element. Must have a module. :return: a list of [module [,class]*] embedding elements which define elt. :rtype: list """ result = [] # result is empty in the worst case # start to ...
[ "def", "find_embedding", "(", "elt", ",", "embedding", "=", "None", ")", ":", "result", "=", "[", "]", "# result is empty in the worst case", "# start to get module", "module", "=", "getmodule", "(", "elt", ")", "if", "module", "is", "not", "None", ":", "# if ...
Try to get elt embedding elements. :param embedding: embedding element. Must have a module. :return: a list of [module [,class]*] embedding elements which define elt. :rtype: list
[ "Try", "to", "get", "elt", "embedding", "elements", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/reflect.py#L160-L223
telminov/sw-python-utils
swutils/string.py
map_rus_to_lat
def map_rus_to_lat(char): """ функция преобразует русские символы в такие же (по написанию) латинские """ map_dict = { u'Е': u'E', u'Т': u'T', u'У': u'Y', u'О': u'O', u'Р': u'P', u'А': u'A', u'Н': u'H', u'К': u'K', u'Х': u'X', u'С':...
python
def map_rus_to_lat(char): """ функция преобразует русские символы в такие же (по написанию) латинские """ map_dict = { u'Е': u'E', u'Т': u'T', u'У': u'Y', u'О': u'O', u'Р': u'P', u'А': u'A', u'Н': u'H', u'К': u'K', u'Х': u'X', u'С':...
[ "def", "map_rus_to_lat", "(", "char", ")", ":", "map_dict", "=", "{", "u'Е':", " ", "'E',", "", "u'Т':", " ", "'T',", "", "u'У':", " ", "'Y',", "", "u'О':", " ", "'O',", "", "u'Р':", " ", "'P',", "", "u'А':", " ", "'A',", "", "u'Н':", " ", "'H',"...
функция преобразует русские символы в такие же (по написанию) латинские
[ "функция", "преобразует", "русские", "символы", "в", "такие", "же", "(", "по", "написанию", ")", "латинские" ]
train
https://github.com/telminov/sw-python-utils/blob/68f976122dd26a581b8d833c023f7f06542ca85c/swutils/string.py#L4-L24
wohlgejm/accountable
accountable/cli.py
configure
def configure(username, password, domain): """ Initial configuration. Used to specify your username, password and domain. Configuration is stored in ~/.accountable/config.yaml. """ art = r''' Welcome! __ ___. .__ _____ ____ ____ ____ __ __ _____/ |____...
python
def configure(username, password, domain): """ Initial configuration. Used to specify your username, password and domain. Configuration is stored in ~/.accountable/config.yaml. """ art = r''' Welcome! __ ___. .__ _____ ____ ____ ____ __ __ _____/ |____...
[ "def", "configure", "(", "username", ",", "password", ",", "domain", ")", ":", "art", "=", "r'''\nWelcome! __ ___. .__\n_____ ____ ____ ____ __ __ _____/ |______ \\_ |__ | | ____\n\\__ \\ _/ ___\\/ ___\\/ _ \\| | \\/ \\ __\\__ \\ |...
Initial configuration. Used to specify your username, password and domain. Configuration is stored in ~/.accountable/config.yaml.
[ "Initial", "configuration", ".", "Used", "to", "specify", "your", "username", "password", "and", "domain", ".", "Configuration", "is", "stored", "in", "~", "/", ".", "accountable", "/", "config", ".", "yaml", "." ]
train
https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L52-L66
wohlgejm/accountable
accountable/cli.py
projects
def projects(accountable): """ List all projects. """ projects = accountable.metadata()['projects'] headers = sorted(['id', 'key', 'self']) rows = [[v for k, v in sorted(p.items()) if k in headers] for p in projects] rows.insert(0, headers) print_table(SingleTable(rows))
python
def projects(accountable): """ List all projects. """ projects = accountable.metadata()['projects'] headers = sorted(['id', 'key', 'self']) rows = [[v for k, v in sorted(p.items()) if k in headers] for p in projects] rows.insert(0, headers) print_table(SingleTable(rows))
[ "def", "projects", "(", "accountable", ")", ":", "projects", "=", "accountable", ".", "metadata", "(", ")", "[", "'projects'", "]", "headers", "=", "sorted", "(", "[", "'id'", ",", "'key'", ",", "'self'", "]", ")", "rows", "=", "[", "[", "v", "for", ...
List all projects.
[ "List", "all", "projects", "." ]
train
https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L71-L79
wohlgejm/accountable
accountable/cli.py
issuetypes
def issuetypes(accountable, project_key): """ List all issue types. Optional parameter to list issue types by a given project. """ projects = accountable.issue_types(project_key) headers = sorted(['id', 'name', 'description']) rows = [] for key, issue_types in sorted(projects.items()): ...
python
def issuetypes(accountable, project_key): """ List all issue types. Optional parameter to list issue types by a given project. """ projects = accountable.issue_types(project_key) headers = sorted(['id', 'name', 'description']) rows = [] for key, issue_types in sorted(projects.items()): ...
[ "def", "issuetypes", "(", "accountable", ",", "project_key", ")", ":", "projects", "=", "accountable", ".", "issue_types", "(", "project_key", ")", "headers", "=", "sorted", "(", "[", "'id'", ",", "'name'", ",", "'description'", "]", ")", "rows", "=", "[",...
List all issue types. Optional parameter to list issue types by a given project.
[ "List", "all", "issue", "types", ".", "Optional", "parameter", "to", "list", "issue", "types", "by", "a", "given", "project", "." ]
train
https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L85-L100