repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
DeV1doR/aioethereum | aioethereum/utils.py | add_0x | def add_0x(string):
"""Add 0x to string at start.
"""
if isinstance(string, bytes):
string = string.decode('utf-8')
return '0x' + str(string) | python | def add_0x(string):
"""Add 0x to string at start.
"""
if isinstance(string, bytes):
string = string.decode('utf-8')
return '0x' + str(string) | [
"def",
"add_0x",
"(",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"bytes",
")",
":",
"string",
"=",
"string",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"'0x'",
"+",
"str",
"(",
"string",
")"
] | Add 0x to string at start. | [
"Add",
"0x",
"to",
"string",
"at",
"start",
"."
] | 85eb46550d862b3ccc309914ea871ca1c7b42157 | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/utils.py#L4-L9 | train |
Genida/dependenpy | src/dependenpy/helpers.py | guess_depth | def guess_depth(packages):
"""
Guess the optimal depth to use for the given list of arguments.
Args:
packages (list of str): list of packages.
Returns:
int: guessed depth to use.
"""
if len(packages) == 1:
return packages[0].count('.') + 2
return min(p.count('.') fo... | python | def guess_depth(packages):
"""
Guess the optimal depth to use for the given list of arguments.
Args:
packages (list of str): list of packages.
Returns:
int: guessed depth to use.
"""
if len(packages) == 1:
return packages[0].count('.') + 2
return min(p.count('.') fo... | [
"def",
"guess_depth",
"(",
"packages",
")",
":",
"if",
"len",
"(",
"packages",
")",
"==",
"1",
":",
"return",
"packages",
"[",
"0",
"]",
".",
"count",
"(",
"'.'",
")",
"+",
"2",
"return",
"min",
"(",
"p",
".",
"count",
"(",
"'.'",
")",
"for",
"... | Guess the optimal depth to use for the given list of arguments.
Args:
packages (list of str): list of packages.
Returns:
int: guessed depth to use. | [
"Guess",
"the",
"optimal",
"depth",
"to",
"use",
"for",
"the",
"given",
"list",
"of",
"arguments",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/helpers.py#L45-L57 | train |
Genida/dependenpy | src/dependenpy/helpers.py | PrintMixin.print | def print(self, format=TEXT, output=sys.stdout, **kwargs):
"""
Print the object in a file or on standard output by default.
Args:
format (str): output format (csv, json or text).
output (file):
descriptor to an opened file (default to standard output).
... | python | def print(self, format=TEXT, output=sys.stdout, **kwargs):
"""
Print the object in a file or on standard output by default.
Args:
format (str): output format (csv, json or text).
output (file):
descriptor to an opened file (default to standard output).
... | [
"def",
"print",
"(",
"self",
",",
"format",
"=",
"TEXT",
",",
"output",
"=",
"sys",
".",
"stdout",
",",
"**",
"kwargs",
")",
":",
"if",
"format",
"is",
"None",
":",
"format",
"=",
"TEXT",
"if",
"format",
"==",
"TEXT",
":",
"print",
"(",
"self",
"... | Print the object in a file or on standard output by default.
Args:
format (str): output format (csv, json or text).
output (file):
descriptor to an opened file (default to standard output).
**kwargs (): additional arguments. | [
"Print",
"the",
"object",
"in",
"a",
"file",
"or",
"on",
"standard",
"output",
"by",
"default",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/helpers.py#L16-L33 | train |
sengupta/twss | twss/twsslib.py | TWSS.import_training_data | def import_training_data(self,
positive_corpus_file=os.path.join(os.path.dirname(__file__),
"positive.txt"),
negative_corpus_file=os.path.join(os.path.dirname(__file__),
"negative.txt")
):
"""
This method imports the positive and negati... | python | def import_training_data(self,
positive_corpus_file=os.path.join(os.path.dirname(__file__),
"positive.txt"),
negative_corpus_file=os.path.join(os.path.dirname(__file__),
"negative.txt")
):
"""
This method imports the positive and negati... | [
"def",
"import_training_data",
"(",
"self",
",",
"positive_corpus_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"positive.txt\"",
")",
",",
"negative_corpus_file",
"=",
"os",
".",
"path",
"... | This method imports the positive and negative training data from the
two corpus files and creates the training data list. | [
"This",
"method",
"imports",
"the",
"positive",
"and",
"negative",
"training",
"data",
"from",
"the",
"two",
"corpus",
"files",
"and",
"creates",
"the",
"training",
"data",
"list",
"."
] | 69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f | https://github.com/sengupta/twss/blob/69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f/twss/twsslib.py#L24-L48 | train |
sengupta/twss | twss/twsslib.py | TWSS.train | def train(self):
"""
This method generates the classifier. This method assumes that the
training data has been loaded
"""
if not self.training_data:
self.import_training_data()
training_feature_set = [(self.extract_features(line), label)
... | python | def train(self):
"""
This method generates the classifier. This method assumes that the
training data has been loaded
"""
if not self.training_data:
self.import_training_data()
training_feature_set = [(self.extract_features(line), label)
... | [
"def",
"train",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"training_data",
":",
"self",
".",
"import_training_data",
"(",
")",
"training_feature_set",
"=",
"[",
"(",
"self",
".",
"extract_features",
"(",
"line",
")",
",",
"label",
")",
"for",
"(",... | This method generates the classifier. This method assumes that the
training data has been loaded | [
"This",
"method",
"generates",
"the",
"classifier",
".",
"This",
"method",
"assumes",
"that",
"the",
"training",
"data",
"has",
"been",
"loaded"
] | 69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f | https://github.com/sengupta/twss/blob/69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f/twss/twsslib.py#L50-L59 | train |
sengupta/twss | twss/twsslib.py | TWSS.extract_features | def extract_features(self, phrase):
"""
This function will extract features from the phrase being used.
Currently, the feature we are extracting are unigrams of the text corpus.
"""
words = nltk.word_tokenize(phrase)
features = {}
for word in words:
... | python | def extract_features(self, phrase):
"""
This function will extract features from the phrase being used.
Currently, the feature we are extracting are unigrams of the text corpus.
"""
words = nltk.word_tokenize(phrase)
features = {}
for word in words:
... | [
"def",
"extract_features",
"(",
"self",
",",
"phrase",
")",
":",
"words",
"=",
"nltk",
".",
"word_tokenize",
"(",
"phrase",
")",
"features",
"=",
"{",
"}",
"for",
"word",
"in",
"words",
":",
"features",
"[",
"'contains(%s)'",
"%",
"word",
"]",
"=",
"("... | This function will extract features from the phrase being used.
Currently, the feature we are extracting are unigrams of the text corpus. | [
"This",
"function",
"will",
"extract",
"features",
"from",
"the",
"phrase",
"being",
"used",
".",
"Currently",
"the",
"feature",
"we",
"are",
"extracting",
"are",
"unigrams",
"of",
"the",
"text",
"corpus",
"."
] | 69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f | https://github.com/sengupta/twss/blob/69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f/twss/twsslib.py#L61-L71 | train |
sengupta/twss | twss/twsslib.py | TWSS.is_twss | def is_twss(self, phrase):
"""
The magic function- this accepts a phrase and tells you if it
classifies as an entendre
"""
featureset = self.extract_features(phrase)
return self.classifier.classify(featureset) | python | def is_twss(self, phrase):
"""
The magic function- this accepts a phrase and tells you if it
classifies as an entendre
"""
featureset = self.extract_features(phrase)
return self.classifier.classify(featureset) | [
"def",
"is_twss",
"(",
"self",
",",
"phrase",
")",
":",
"featureset",
"=",
"self",
".",
"extract_features",
"(",
"phrase",
")",
"return",
"self",
".",
"classifier",
".",
"classify",
"(",
"featureset",
")"
] | The magic function- this accepts a phrase and tells you if it
classifies as an entendre | [
"The",
"magic",
"function",
"-",
"this",
"accepts",
"a",
"phrase",
"and",
"tells",
"you",
"if",
"it",
"classifies",
"as",
"an",
"entendre"
] | 69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f | https://github.com/sengupta/twss/blob/69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f/twss/twsslib.py#L73-L79 | train |
sengupta/twss | twss/twsslib.py | TWSS.save | def save(self, filename='classifier.dump'):
"""
Pickles the classifier and dumps it into a file
"""
ofile = open(filename,'w+')
pickle.dump(self.classifier, ofile)
ofile.close() | python | def save(self, filename='classifier.dump'):
"""
Pickles the classifier and dumps it into a file
"""
ofile = open(filename,'w+')
pickle.dump(self.classifier, ofile)
ofile.close() | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"'classifier.dump'",
")",
":",
"ofile",
"=",
"open",
"(",
"filename",
",",
"'w+'",
")",
"pickle",
".",
"dump",
"(",
"self",
".",
"classifier",
",",
"ofile",
")",
"ofile",
".",
"close",
"(",
")"
] | Pickles the classifier and dumps it into a file | [
"Pickles",
"the",
"classifier",
"and",
"dumps",
"it",
"into",
"a",
"file"
] | 69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f | https://github.com/sengupta/twss/blob/69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f/twss/twsslib.py#L81-L87 | train |
sengupta/twss | twss/twsslib.py | TWSS.load | def load(self, filename='classifier.dump'):
"""
Unpickles the classifier used
"""
ifile = open(filename, 'r+')
self.classifier = pickle.load(ifile)
ifile.close() | python | def load(self, filename='classifier.dump'):
"""
Unpickles the classifier used
"""
ifile = open(filename, 'r+')
self.classifier = pickle.load(ifile)
ifile.close() | [
"def",
"load",
"(",
"self",
",",
"filename",
"=",
"'classifier.dump'",
")",
":",
"ifile",
"=",
"open",
"(",
"filename",
",",
"'r+'",
")",
"self",
".",
"classifier",
"=",
"pickle",
".",
"load",
"(",
"ifile",
")",
"ifile",
".",
"close",
"(",
")"
] | Unpickles the classifier used | [
"Unpickles",
"the",
"classifier",
"used"
] | 69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f | https://github.com/sengupta/twss/blob/69269b58bc1c388f53b181ecb7c5d6ee5ee8c03f/twss/twsslib.py#L89-L95 | train |
catch22/pw | pw/__main__.py | pw | def pw(
ctx,
key_pattern,
user_pattern,
mode,
strict_flag,
user_flag,
file,
edit_subcommand,
gen_subcommand,
):
"""Search for USER and KEY in GPG-encrypted password file."""
# install silent Ctrl-C handler
def handle_sigint(*_):
click.echo()
ctx.exit(1)
... | python | def pw(
ctx,
key_pattern,
user_pattern,
mode,
strict_flag,
user_flag,
file,
edit_subcommand,
gen_subcommand,
):
"""Search for USER and KEY in GPG-encrypted password file."""
# install silent Ctrl-C handler
def handle_sigint(*_):
click.echo()
ctx.exit(1)
... | [
"def",
"pw",
"(",
"ctx",
",",
"key_pattern",
",",
"user_pattern",
",",
"mode",
",",
"strict_flag",
",",
"user_flag",
",",
"file",
",",
"edit_subcommand",
",",
"gen_subcommand",
",",
")",
":",
"def",
"handle_sigint",
"(",
"*",
"_",
")",
":",
"click",
".",... | Search for USER and KEY in GPG-encrypted password file. | [
"Search",
"for",
"USER",
"and",
"KEY",
"in",
"GPG",
"-",
"encrypted",
"password",
"file",
"."
] | 2452924bbdccad28b21290b6ce062809c3d1c5f2 | https://github.com/catch22/pw/blob/2452924bbdccad28b21290b6ce062809c3d1c5f2/pw/__main__.py#L91-L182 | train |
catch22/pw | pw/__main__.py | launch_editor | def launch_editor(ctx, file):
"""launch editor with decrypted password database"""
# do not use EDITOR environment variable (rather force user to make a concious choice)
editor = os.environ.get("PW_EDITOR")
if not editor:
click.echo("error: no editor set in PW_EDITOR environment variables")
... | python | def launch_editor(ctx, file):
"""launch editor with decrypted password database"""
# do not use EDITOR environment variable (rather force user to make a concious choice)
editor = os.environ.get("PW_EDITOR")
if not editor:
click.echo("error: no editor set in PW_EDITOR environment variables")
... | [
"def",
"launch_editor",
"(",
"ctx",
",",
"file",
")",
":",
"editor",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"PW_EDITOR\"",
")",
"if",
"not",
"editor",
":",
"click",
".",
"echo",
"(",
"\"error: no editor set in PW_EDITOR environment variables\"",
")",
"c... | launch editor with decrypted password database | [
"launch",
"editor",
"with",
"decrypted",
"password",
"database"
] | 2452924bbdccad28b21290b6ce062809c3d1c5f2 | https://github.com/catch22/pw/blob/2452924bbdccad28b21290b6ce062809c3d1c5f2/pw/__main__.py#L185-L231 | train |
catch22/pw | pw/__main__.py | generate_password | def generate_password(mode, length):
"""generate a random password"""
# generate random password
r = random.SystemRandom()
length = length or RANDOM_PASSWORD_DEFAULT_LENGTH
password = "".join(r.choice(RANDOM_PASSWORD_ALPHABET) for _ in range(length))
# copy or echo generated password
if mod... | python | def generate_password(mode, length):
"""generate a random password"""
# generate random password
r = random.SystemRandom()
length = length or RANDOM_PASSWORD_DEFAULT_LENGTH
password = "".join(r.choice(RANDOM_PASSWORD_ALPHABET) for _ in range(length))
# copy or echo generated password
if mod... | [
"def",
"generate_password",
"(",
"mode",
",",
"length",
")",
":",
"r",
"=",
"random",
".",
"SystemRandom",
"(",
")",
"length",
"=",
"length",
"or",
"RANDOM_PASSWORD_DEFAULT_LENGTH",
"password",
"=",
"\"\"",
".",
"join",
"(",
"r",
".",
"choice",
"(",
"RANDO... | generate a random password | [
"generate",
"a",
"random",
"password"
] | 2452924bbdccad28b21290b6ce062809c3d1c5f2 | https://github.com/catch22/pw/blob/2452924bbdccad28b21290b6ce062809c3d1c5f2/pw/__main__.py#L234-L254 | train |
striglia/stockfighter | stockfighter/gm.py | GM._load_data | def _load_data(self):
"""Internal method for querying the GM api for currently running levels
and storing that state."""
url = urljoin(self.base_url, 'levels')
resp = requests.get(url, headers=self.headers)
# TOOD: Confirm/deny that this is a real API for the levels currenlty run... | python | def _load_data(self):
"""Internal method for querying the GM api for currently running levels
and storing that state."""
url = urljoin(self.base_url, 'levels')
resp = requests.get(url, headers=self.headers)
# TOOD: Confirm/deny that this is a real API for the levels currenlty run... | [
"def",
"_load_data",
"(",
"self",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"'levels'",
")",
"resp",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"if",
"resp",
".",
"content",
... | Internal method for querying the GM api for currently running levels
and storing that state. | [
"Internal",
"method",
"for",
"querying",
"the",
"GM",
"api",
"for",
"currently",
"running",
"levels",
"and",
"storing",
"that",
"state",
"."
] | df908f5919d6f861601cd00c906a049d04253d47 | https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/gm.py#L16-L25 | train |
mkoura/dump2polarion | dump2polarion/csv2sqlite_cli.py | dump2sqlite | def dump2sqlite(records, output_file):
"""Dumps tests results to database."""
results_keys = list(records.results[0].keys())
pad_data = []
for key in REQUIRED_KEYS:
if key not in results_keys:
results_keys.append(key)
pad_data.append("")
conn = sqlite3.connect(os.pa... | python | def dump2sqlite(records, output_file):
"""Dumps tests results to database."""
results_keys = list(records.results[0].keys())
pad_data = []
for key in REQUIRED_KEYS:
if key not in results_keys:
results_keys.append(key)
pad_data.append("")
conn = sqlite3.connect(os.pa... | [
"def",
"dump2sqlite",
"(",
"records",
",",
"output_file",
")",
":",
"results_keys",
"=",
"list",
"(",
"records",
".",
"results",
"[",
"0",
"]",
".",
"keys",
"(",
")",
")",
"pad_data",
"=",
"[",
"]",
"for",
"key",
"in",
"REQUIRED_KEYS",
":",
"if",
"ke... | Dumps tests results to database. | [
"Dumps",
"tests",
"results",
"to",
"database",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/csv2sqlite_cli.py#L42-L77 | train |
romanorac/discomll | discomll/ensemble/core/k_medoids.py | fit | def fit(sim_mat, D_len, cidx):
"""
Algorithm maximizes energy between clusters, which is distinction in this algorithm. Distance matrix contains mostly 0, which are overlooked due to search of maximal distances. Algorithm does not try to retain k clusters.
D: numpy array - Symmetric distance matrix
k: ... | python | def fit(sim_mat, D_len, cidx):
"""
Algorithm maximizes energy between clusters, which is distinction in this algorithm. Distance matrix contains mostly 0, which are overlooked due to search of maximal distances. Algorithm does not try to retain k clusters.
D: numpy array - Symmetric distance matrix
k: ... | [
"def",
"fit",
"(",
"sim_mat",
",",
"D_len",
",",
"cidx",
")",
":",
"min_energy",
"=",
"np",
".",
"inf",
"for",
"j",
"in",
"range",
"(",
"3",
")",
":",
"inds",
"=",
"[",
"np",
".",
"argmin",
"(",
"[",
"sim_mat",
"[",
"idy",
"]",
".",
"get",
"(... | Algorithm maximizes energy between clusters, which is distinction in this algorithm. Distance matrix contains mostly 0, which are overlooked due to search of maximal distances. Algorithm does not try to retain k clusters.
D: numpy array - Symmetric distance matrix
k: int - number of clusters | [
"Algorithm",
"maximizes",
"energy",
"between",
"clusters",
"which",
"is",
"distinction",
"in",
"this",
"algorithm",
".",
"Distance",
"matrix",
"contains",
"mostly",
"0",
"which",
"are",
"overlooked",
"due",
"to",
"search",
"of",
"maximal",
"distances",
".",
"Alg... | a4703daffb2ba3c9f614bc3dbe45ae55884aea00 | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/ensemble/core/k_medoids.py#L8-L41 | train |
ngmarchant/oasis | oasis/oasis.py | BetaBernoulliModel._calc_theta | def _calc_theta(self):
"""Calculate an estimate of theta"""
if self.decaying_prior:
n_sampled = np.clip(self.alpha_ + self.beta_, 1, np.inf)
prior_weight = 1/n_sampled
alpha = self.alpha_ + prior_weight * self.alpha_0
beta = self.beta_ + prior_weight * sel... | python | def _calc_theta(self):
"""Calculate an estimate of theta"""
if self.decaying_prior:
n_sampled = np.clip(self.alpha_ + self.beta_, 1, np.inf)
prior_weight = 1/n_sampled
alpha = self.alpha_ + prior_weight * self.alpha_0
beta = self.beta_ + prior_weight * sel... | [
"def",
"_calc_theta",
"(",
"self",
")",
":",
"if",
"self",
".",
"decaying_prior",
":",
"n_sampled",
"=",
"np",
".",
"clip",
"(",
"self",
".",
"alpha_",
"+",
"self",
".",
"beta_",
",",
"1",
",",
"np",
".",
"inf",
")",
"prior_weight",
"=",
"1",
"/",
... | Calculate an estimate of theta | [
"Calculate",
"an",
"estimate",
"of",
"theta"
] | 28a037a8924b85ae97db8a93960a910a219d6a4a | https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/oasis.py#L81-L99 | train |
ngmarchant/oasis | oasis/oasis.py | BetaBernoulliModel.update | def update(self, ell, k):
"""Update the posterior and estimates after a label is sampled
Parameters
----------
ell : int
sampled label: 0 or 1
k : int
index of stratum where label was sampled
"""
self.alpha_[k] += ell
self.beta_[k... | python | def update(self, ell, k):
"""Update the posterior and estimates after a label is sampled
Parameters
----------
ell : int
sampled label: 0 or 1
k : int
index of stratum where label was sampled
"""
self.alpha_[k] += ell
self.beta_[k... | [
"def",
"update",
"(",
"self",
",",
"ell",
",",
"k",
")",
":",
"self",
".",
"alpha_",
"[",
"k",
"]",
"+=",
"ell",
"self",
".",
"beta_",
"[",
"k",
"]",
"+=",
"1",
"-",
"ell",
"self",
".",
"_calc_theta",
"(",
")",
"if",
"self",
".",
"store_varianc... | Update the posterior and estimates after a label is sampled
Parameters
----------
ell : int
sampled label: 0 or 1
k : int
index of stratum where label was sampled | [
"Update",
"the",
"posterior",
"and",
"estimates",
"after",
"a",
"label",
"is",
"sampled"
] | 28a037a8924b85ae97db8a93960a910a219d6a4a | https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/oasis.py#L115-L131 | train |
ngmarchant/oasis | oasis/oasis.py | BetaBernoulliModel.reset | def reset(self):
"""Reset the instance to its initial state"""
self.alpha_ = np.zeros(self._size, dtype=int)
self.beta_ = np.zeros(self._size, dtype=int)
self.theta_ = np.empty(self._size, dtype=float)
if self.store_variance:
self.var_theta_ = np.empty(self._size, dty... | python | def reset(self):
"""Reset the instance to its initial state"""
self.alpha_ = np.zeros(self._size, dtype=int)
self.beta_ = np.zeros(self._size, dtype=int)
self.theta_ = np.empty(self._size, dtype=float)
if self.store_variance:
self.var_theta_ = np.empty(self._size, dty... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"alpha_",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"_size",
",",
"dtype",
"=",
"int",
")",
"self",
".",
"beta_",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"_size",
",",
"dtype",
"=",
"int",... | Reset the instance to its initial state | [
"Reset",
"the",
"instance",
"to",
"its",
"initial",
"state"
] | 28a037a8924b85ae97db8a93960a910a219d6a4a | https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/oasis.py#L133-L145 | train |
ngmarchant/oasis | oasis/oasis.py | OASISSampler._calc_BB_prior | def _calc_BB_prior(self, theta_0):
"""Generate a prior for the BB model
Parameters
----------
theta_0 : array-like, shape=(n_strata,)
array of oracle probabilities (probability of a "1" label)
for each stratum. This is just a guess.
Returns
-----... | python | def _calc_BB_prior(self, theta_0):
"""Generate a prior for the BB model
Parameters
----------
theta_0 : array-like, shape=(n_strata,)
array of oracle probabilities (probability of a "1" label)
for each stratum. This is just a guess.
Returns
-----... | [
"def",
"_calc_BB_prior",
"(",
"self",
",",
"theta_0",
")",
":",
"prior_strength",
"=",
"self",
".",
"prior_strength",
"n_strata",
"=",
"len",
"(",
"theta_0",
")",
"weighted_strength",
"=",
"prior_strength",
"/",
"n_strata",
"alpha_0",
"=",
"theta_0",
"*",
"wei... | Generate a prior for the BB model
Parameters
----------
theta_0 : array-like, shape=(n_strata,)
array of oracle probabilities (probability of a "1" label)
for each stratum. This is just a guess.
Returns
-------
alpha_0 : numpy.ndarray, shape=(n_s... | [
"Generate",
"a",
"prior",
"for",
"the",
"BB",
"model"
] | 28a037a8924b85ae97db8a93960a910a219d6a4a | https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/oasis.py#L379-L404 | train |
djaodjin/djaodjin-deployutils | deployutils/apps/django/backends/auth.py | ProxyUserBackend.authenticate | def authenticate(self, request, remote_user=None):
#pylint:disable=arguments-differ
# Django <=1.8 and >=1.9 have different signatures.
"""
The ``username`` passed here is considered trusted. This
method simply returns the ``User`` object with the given username.
In ord... | python | def authenticate(self, request, remote_user=None):
#pylint:disable=arguments-differ
# Django <=1.8 and >=1.9 have different signatures.
"""
The ``username`` passed here is considered trusted. This
method simply returns the ``User`` object with the given username.
In ord... | [
"def",
"authenticate",
"(",
"self",
",",
"request",
",",
"remote_user",
"=",
"None",
")",
":",
"if",
"not",
"remote_user",
":",
"remote_user",
"=",
"request",
"if",
"not",
"remote_user",
":",
"return",
"None",
"user",
"=",
"None",
"username",
"=",
"self",
... | The ``username`` passed here is considered trusted. This
method simply returns the ``User`` object with the given username.
In order to support older Django versions
(before commit 4b9330ccc04575f9e5126529ec355a450d12e77c), if username
is None, we will assume request is the ``remote_us... | [
"The",
"username",
"passed",
"here",
"is",
"considered",
"trusted",
".",
"This",
"method",
"simply",
"returns",
"the",
"User",
"object",
"with",
"the",
"given",
"username",
"."
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/backends/auth.py#L55-L117 | train |
DavidMStraub/pylha | pylha/parse.py | numval | def numval(token):
"""Return the numerical value of token.value if it is a number"""
if token.type == 'INTEGER':
return int(token.value)
elif token.type == 'FLOAT':
return float(token.value)
else:
return token.value | python | def numval(token):
"""Return the numerical value of token.value if it is a number"""
if token.type == 'INTEGER':
return int(token.value)
elif token.type == 'FLOAT':
return float(token.value)
else:
return token.value | [
"def",
"numval",
"(",
"token",
")",
":",
"if",
"token",
".",
"type",
"==",
"'INTEGER'",
":",
"return",
"int",
"(",
"token",
".",
"value",
")",
"elif",
"token",
".",
"type",
"==",
"'FLOAT'",
":",
"return",
"float",
"(",
"token",
".",
"value",
")",
"... | Return the numerical value of token.value if it is a number | [
"Return",
"the",
"numerical",
"value",
"of",
"token",
".",
"value",
"if",
"it",
"is",
"a",
"number"
] | 8d65074609321e5eaf97fe962c56f6d79a3ad2b6 | https://github.com/DavidMStraub/pylha/blob/8d65074609321e5eaf97fe962c56f6d79a3ad2b6/pylha/parse.py#L6-L13 | train |
DavidMStraub/pylha | pylha/parse.py | tokenize | def tokenize(code):
"""Tokenize the string `code`"""
tok_regex = '|'.join('(?P<{}>{})'.format(*pair) for pair in _tokens)
tok_regex = re.compile(tok_regex, re.IGNORECASE|re.M)
line_num = 1
line_start = 0
for mo in re.finditer(tok_regex, code):
kind = mo.lastgroup
value = mo.group... | python | def tokenize(code):
"""Tokenize the string `code`"""
tok_regex = '|'.join('(?P<{}>{})'.format(*pair) for pair in _tokens)
tok_regex = re.compile(tok_regex, re.IGNORECASE|re.M)
line_num = 1
line_start = 0
for mo in re.finditer(tok_regex, code):
kind = mo.lastgroup
value = mo.group... | [
"def",
"tokenize",
"(",
"code",
")",
":",
"tok_regex",
"=",
"'|'",
".",
"join",
"(",
"'(?P<{}>{})'",
".",
"format",
"(",
"*",
"pair",
")",
"for",
"pair",
"in",
"_tokens",
")",
"tok_regex",
"=",
"re",
".",
"compile",
"(",
"tok_regex",
",",
"re",
".",
... | Tokenize the string `code` | [
"Tokenize",
"the",
"string",
"code"
] | 8d65074609321e5eaf97fe962c56f6d79a3ad2b6 | https://github.com/DavidMStraub/pylha/blob/8d65074609321e5eaf97fe962c56f6d79a3ad2b6/pylha/parse.py#L26-L42 | train |
DavidMStraub/pylha | pylha/parse.py | parse | def parse(tokens):
"""Parse the token list into a hierarchical data structure"""
d = collections.OrderedDict()
prev_line = 0
blockname = None
blockline = None
for token in tokens:
if token.type == 'COMMENT':
continue
elif token.type == 'BLOCK':
block = tok... | python | def parse(tokens):
"""Parse the token list into a hierarchical data structure"""
d = collections.OrderedDict()
prev_line = 0
blockname = None
blockline = None
for token in tokens:
if token.type == 'COMMENT':
continue
elif token.type == 'BLOCK':
block = tok... | [
"def",
"parse",
"(",
"tokens",
")",
":",
"d",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"prev_line",
"=",
"0",
"blockname",
"=",
"None",
"blockline",
"=",
"None",
"for",
"token",
"in",
"tokens",
":",
"if",
"token",
".",
"type",
"==",
"'COMMENT'... | Parse the token list into a hierarchical data structure | [
"Parse",
"the",
"token",
"list",
"into",
"a",
"hierarchical",
"data",
"structure"
] | 8d65074609321e5eaf97fe962c56f6d79a3ad2b6 | https://github.com/DavidMStraub/pylha/blob/8d65074609321e5eaf97fe962c56f6d79a3ad2b6/pylha/parse.py#L47-L78 | train |
DavidMStraub/pylha | pylha/parse.py | load | def load(stream):
"""Parse the LHA document and produce the corresponding Python object.
Accepts a string or a file-like object."""
if isinstance(stream, str):
string = stream
else:
string = stream.read()
tokens = tokenize(string)
return parse(tokens) | python | def load(stream):
"""Parse the LHA document and produce the corresponding Python object.
Accepts a string or a file-like object."""
if isinstance(stream, str):
string = stream
else:
string = stream.read()
tokens = tokenize(string)
return parse(tokens) | [
"def",
"load",
"(",
"stream",
")",
":",
"if",
"isinstance",
"(",
"stream",
",",
"str",
")",
":",
"string",
"=",
"stream",
"else",
":",
"string",
"=",
"stream",
".",
"read",
"(",
")",
"tokens",
"=",
"tokenize",
"(",
"string",
")",
"return",
"parse",
... | Parse the LHA document and produce the corresponding Python object.
Accepts a string or a file-like object. | [
"Parse",
"the",
"LHA",
"document",
"and",
"produce",
"the",
"corresponding",
"Python",
"object",
".",
"Accepts",
"a",
"string",
"or",
"a",
"file",
"-",
"like",
"object",
"."
] | 8d65074609321e5eaf97fe962c56f6d79a3ad2b6 | https://github.com/DavidMStraub/pylha/blob/8d65074609321e5eaf97fe962c56f6d79a3ad2b6/pylha/parse.py#L80-L88 | train |
coopernurse/barrister | barrister/parser.py | IdlScanner.get_checksum | def get_checksum(self):
"""
Returns a checksum based on the IDL that ignores comments and
ordering, but detects changes to types, parameter order,
and enum values.
"""
arr = [ ]
for elem in self.parsed:
s = elem_checksum(elem)
if s:
... | python | def get_checksum(self):
"""
Returns a checksum based on the IDL that ignores comments and
ordering, but detects changes to types, parameter order,
and enum values.
"""
arr = [ ]
for elem in self.parsed:
s = elem_checksum(elem)
if s:
... | [
"def",
"get_checksum",
"(",
"self",
")",
":",
"arr",
"=",
"[",
"]",
"for",
"elem",
"in",
"self",
".",
"parsed",
":",
"s",
"=",
"elem_checksum",
"(",
"elem",
")",
"if",
"s",
":",
"arr",
".",
"append",
"(",
"s",
")",
"arr",
".",
"sort",
"(",
")",... | Returns a checksum based on the IDL that ignores comments and
ordering, but detects changes to types, parameter order,
and enum values. | [
"Returns",
"a",
"checksum",
"based",
"on",
"the",
"IDL",
"that",
"ignores",
"comments",
"and",
"ordering",
"but",
"detects",
"changes",
"to",
"types",
"parameter",
"order",
"and",
"enum",
"values",
"."
] | 0471b1d98d3327ba381684db496ec94c79c20848 | https://github.com/coopernurse/barrister/blob/0471b1d98d3327ba381684db496ec94c79c20848/barrister/parser.py#L204-L217 | train |
ngmarchant/oasis | oasis/kad.py | KadaneSampler._update_estimate_and_sampler | def _update_estimate_and_sampler(self, ell, ell_hat, weight, extra_info,
**kwargs):
"""Update the BB models and the estimates"""
stratum_idx = extra_info['stratum']
self._BB_TP.update(ell*ell_hat, stratum_idx)
self._BB_PP.update(ell_hat, stratum_idx)
... | python | def _update_estimate_and_sampler(self, ell, ell_hat, weight, extra_info,
**kwargs):
"""Update the BB models and the estimates"""
stratum_idx = extra_info['stratum']
self._BB_TP.update(ell*ell_hat, stratum_idx)
self._BB_PP.update(ell_hat, stratum_idx)
... | [
"def",
"_update_estimate_and_sampler",
"(",
"self",
",",
"ell",
",",
"ell_hat",
",",
"weight",
",",
"extra_info",
",",
"**",
"kwargs",
")",
":",
"stratum_idx",
"=",
"extra_info",
"[",
"'stratum'",
"]",
"self",
".",
"_BB_TP",
".",
"update",
"(",
"ell",
"*",... | Update the BB models and the estimates | [
"Update",
"the",
"BB",
"models",
"and",
"the",
"estimates"
] | 28a037a8924b85ae97db8a93960a910a219d6a4a | https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/kad.py#L133-L145 | train |
mkoura/dump2polarion | dump2polarion/svn_polarion.py | WorkItemCache.get_path | def get_path(num):
"""Gets a path from the workitem number.
For example: 31942 will return 30000-39999/31000-31999/31900-31999
"""
num = int(num)
dig_len = len(str(num))
paths = []
for i in range(dig_len - 2):
divisor = 10 ** (dig_len - i - 1)
... | python | def get_path(num):
"""Gets a path from the workitem number.
For example: 31942 will return 30000-39999/31000-31999/31900-31999
"""
num = int(num)
dig_len = len(str(num))
paths = []
for i in range(dig_len - 2):
divisor = 10 ** (dig_len - i - 1)
... | [
"def",
"get_path",
"(",
"num",
")",
":",
"num",
"=",
"int",
"(",
"num",
")",
"dig_len",
"=",
"len",
"(",
"str",
"(",
"num",
")",
")",
"paths",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"dig_len",
"-",
"2",
")",
":",
"divisor",
"=",
"10",... | Gets a path from the workitem number.
For example: 31942 will return 30000-39999/31000-31999/31900-31999 | [
"Gets",
"a",
"path",
"from",
"the",
"workitem",
"number",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/svn_polarion.py#L31-L44 | train |
mkoura/dump2polarion | dump2polarion/svn_polarion.py | WorkItemCache.get_tree | def get_tree(self, work_item_id):
"""Gets XML tree of the workitem."""
try:
__, tcid = work_item_id.split("-")
except ValueError:
logger.warning("Couldn't load workitem %s, bad format", work_item_id)
self._cache[work_item_id] = InvalidObject()
retu... | python | def get_tree(self, work_item_id):
"""Gets XML tree of the workitem."""
try:
__, tcid = work_item_id.split("-")
except ValueError:
logger.warning("Couldn't load workitem %s, bad format", work_item_id)
self._cache[work_item_id] = InvalidObject()
retu... | [
"def",
"get_tree",
"(",
"self",
",",
"work_item_id",
")",
":",
"try",
":",
"__",
",",
"tcid",
"=",
"work_item_id",
".",
"split",
"(",
"\"-\"",
")",
"except",
"ValueError",
":",
"logger",
".",
"warning",
"(",
"\"Couldn't load workitem %s, bad format\"",
",",
... | Gets XML tree of the workitem. | [
"Gets",
"XML",
"tree",
"of",
"the",
"workitem",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/svn_polarion.py#L46-L63 | train |
mkoura/dump2polarion | dump2polarion/svn_polarion.py | WorkItemCache.get_all_items | def get_all_items(self):
"""Walks the repo and returns work items."""
for item in os.walk(self.test_case_dir):
if "workitem.xml" not in item[2]:
continue
case_id = os.path.split(item[0])[-1]
if not (case_id and "*" not in case_id):
cont... | python | def get_all_items(self):
"""Walks the repo and returns work items."""
for item in os.walk(self.test_case_dir):
if "workitem.xml" not in item[2]:
continue
case_id = os.path.split(item[0])[-1]
if not (case_id and "*" not in case_id):
cont... | [
"def",
"get_all_items",
"(",
"self",
")",
":",
"for",
"item",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"test_case_dir",
")",
":",
"if",
"\"workitem.xml\"",
"not",
"in",
"item",
"[",
"2",
"]",
":",
"continue",
"case_id",
"=",
"os",
".",
"path",
".",... | Walks the repo and returns work items. | [
"Walks",
"the",
"repo",
"and",
"returns",
"work",
"items",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/svn_polarion.py#L135-L148 | train |
ckcollab/polished | polished/backends/base.py | BaseBackend._remove_files | def _remove_files(self, directory, pattern):
'''
Removes all files matching the search path
Arguments:
search_path -- The path you would like to remove, can contain wildcards
Example:
self._remove_files("output/*.html")
'''
for root, dirnames, file_names... | python | def _remove_files(self, directory, pattern):
'''
Removes all files matching the search path
Arguments:
search_path -- The path you would like to remove, can contain wildcards
Example:
self._remove_files("output/*.html")
'''
for root, dirnames, file_names... | [
"def",
"_remove_files",
"(",
"self",
",",
"directory",
",",
"pattern",
")",
":",
"for",
"root",
",",
"dirnames",
",",
"file_names",
"in",
"os",
".",
"walk",
"(",
"directory",
")",
":",
"for",
"file_name",
"in",
"fnmatch",
".",
"filter",
"(",
"file_names"... | Removes all files matching the search path
Arguments:
search_path -- The path you would like to remove, can contain wildcards
Example:
self._remove_files("output/*.html") | [
"Removes",
"all",
"files",
"matching",
"the",
"search",
"path"
] | 5a00b2fbe569bc957d1647c0849fd344db29b644 | https://github.com/ckcollab/polished/blob/5a00b2fbe569bc957d1647c0849fd344db29b644/polished/backends/base.py#L52-L64 | train |
praekeltfoundation/seed-message-sender | message_sender/views.py | EventListener.post | def post(self, request, *args, **kwargs):
"""
Checks for expect event types before continuing
"""
serializer = EventSerializer(data=request.data)
if not serializer.is_valid():
return Response(
{"accepted": False, "reason": serializer.errors}, status=4... | python | def post(self, request, *args, **kwargs):
"""
Checks for expect event types before continuing
"""
serializer = EventSerializer(data=request.data)
if not serializer.is_valid():
return Response(
{"accepted": False, "reason": serializer.errors}, status=4... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"serializer",
"=",
"EventSerializer",
"(",
"data",
"=",
"request",
".",
"data",
")",
"if",
"not",
"serializer",
".",
"is_valid",
"(",
")",
":",
"return",
"Re... | Checks for expect event types before continuing | [
"Checks",
"for",
"expect",
"event",
"types",
"before",
"continuing"
] | 257b01635171b9dbe1f5f13baa810c971bb2620e | https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/views.py#L384-L409 | train |
carta/ldap_tools | src/ldap_tools/group.py | API.create | def create(self, group, grouptype):
"""
Create an LDAP Group.
Raises:
ldap3.core.exceptions.LDAPNoSuchObjectResult:
an object involved with the request is missing
ldap3.core.exceptions.LDAPEntryAlreadyExistsResult:
the entity being create... | python | def create(self, group, grouptype):
"""
Create an LDAP Group.
Raises:
ldap3.core.exceptions.LDAPNoSuchObjectResult:
an object involved with the request is missing
ldap3.core.exceptions.LDAPEntryAlreadyExistsResult:
the entity being create... | [
"def",
"create",
"(",
"self",
",",
"group",
",",
"grouptype",
")",
":",
"try",
":",
"self",
".",
"client",
".",
"add",
"(",
"self",
".",
"__distinguished_name",
"(",
"group",
")",
",",
"API",
".",
"__object_class",
"(",
")",
",",
"self",
".",
"__ldap... | Create an LDAP Group.
Raises:
ldap3.core.exceptions.LDAPNoSuchObjectResult:
an object involved with the request is missing
ldap3.core.exceptions.LDAPEntryAlreadyExistsResult:
the entity being created already exists | [
"Create",
"an",
"LDAP",
"Group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L18-L47 | train |
carta/ldap_tools | src/ldap_tools/group.py | API.add_user | def add_user(self, group, username):
"""
Add a user to the specified LDAP group.
Args:
group: Name of group to update
username: Username of user to add
Raises:
ldap_tools.exceptions.InvalidResult:
Results of the query were invalid. T... | python | def add_user(self, group, username):
"""
Add a user to the specified LDAP group.
Args:
group: Name of group to update
username: Username of user to add
Raises:
ldap_tools.exceptions.InvalidResult:
Results of the query were invalid. T... | [
"def",
"add_user",
"(",
"self",
",",
"group",
",",
"username",
")",
":",
"try",
":",
"self",
".",
"lookup_id",
"(",
"group",
")",
"except",
"ldap_tools",
".",
"exceptions",
".",
"InvalidResult",
"as",
"err",
":",
"raise",
"err",
"from",
"None",
"operatio... | Add a user to the specified LDAP group.
Args:
group: Name of group to update
username: Username of user to add
Raises:
ldap_tools.exceptions.InvalidResult:
Results of the query were invalid. The actual exception raised
inherits from ... | [
"Add",
"a",
"user",
"to",
"the",
"specified",
"LDAP",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L53-L73 | train |
carta/ldap_tools | src/ldap_tools/group.py | API.remove_user | def remove_user(self, group, username):
"""
Remove a user from the specified LDAP group.
Args:
group: Name of group to update
username: Username of user to remove
Raises:
ldap_tools.exceptions.InvalidResult:
Results of the query were ... | python | def remove_user(self, group, username):
"""
Remove a user from the specified LDAP group.
Args:
group: Name of group to update
username: Username of user to remove
Raises:
ldap_tools.exceptions.InvalidResult:
Results of the query were ... | [
"def",
"remove_user",
"(",
"self",
",",
"group",
",",
"username",
")",
":",
"try",
":",
"self",
".",
"lookup_id",
"(",
"group",
")",
"except",
"ldap_tools",
".",
"exceptions",
".",
"InvalidResult",
"as",
"err",
":",
"raise",
"err",
"from",
"None",
"opera... | Remove a user from the specified LDAP group.
Args:
group: Name of group to update
username: Username of user to remove
Raises:
ldap_tools.exceptions.InvalidResult:
Results of the query were invalid. The actual exception raised
inheri... | [
"Remove",
"a",
"user",
"from",
"the",
"specified",
"LDAP",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L75-L95 | train |
carta/ldap_tools | src/ldap_tools/group.py | API.lookup_id | def lookup_id(self, group):
"""
Lookup GID for the given group.
Args:
group: Name of group whose ID needs to be looked up
Returns:
A bytestring representation of the group ID (gid)
for the group specified
Raises:
ldap_tools.excep... | python | def lookup_id(self, group):
"""
Lookup GID for the given group.
Args:
group: Name of group whose ID needs to be looked up
Returns:
A bytestring representation of the group ID (gid)
for the group specified
Raises:
ldap_tools.excep... | [
"def",
"lookup_id",
"(",
"self",
",",
"group",
")",
":",
"filter",
"=",
"[",
"\"(cn={})\"",
".",
"format",
"(",
"group",
")",
",",
"\"(objectclass=posixGroup)\"",
"]",
"results",
"=",
"self",
".",
"client",
".",
"search",
"(",
"filter",
",",
"[",
"'gidNu... | Lookup GID for the given group.
Args:
group: Name of group whose ID needs to be looked up
Returns:
A bytestring representation of the group ID (gid)
for the group specified
Raises:
ldap_tools.exceptions.NoGroupsFound:
No Groups w... | [
"Lookup",
"GID",
"for",
"the",
"given",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L101-L130 | train |
carta/ldap_tools | src/ldap_tools/group.py | CLI.create | def create(config, group, type):
"""Create an LDAP group."""
if type not in ('user', 'service'):
raise click.BadOptionUsage( # pragma: no cover
"--grouptype must be 'user' or 'service'")
client = Client()
client.prepare_connection()
group_api = API(c... | python | def create(config, group, type):
"""Create an LDAP group."""
if type not in ('user', 'service'):
raise click.BadOptionUsage( # pragma: no cover
"--grouptype must be 'user' or 'service'")
client = Client()
client.prepare_connection()
group_api = API(c... | [
"def",
"create",
"(",
"config",
",",
"group",
",",
"type",
")",
":",
"if",
"type",
"not",
"in",
"(",
"'user'",
",",
"'service'",
")",
":",
"raise",
"click",
".",
"BadOptionUsage",
"(",
"\"--grouptype must be 'user' or 'service'\"",
")",
"client",
"=",
"Clien... | Create an LDAP group. | [
"Create",
"an",
"LDAP",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L165-L174 | train |
carta/ldap_tools | src/ldap_tools/group.py | CLI.delete | def delete(config, group, force):
"""Delete an LDAP group."""
if not force:
if not click.confirm(
'Confirm that you want to delete group {}'.format(group)):
sys.exit("Deletion of {} aborted".format(group))
client = Client()
client.prepare_... | python | def delete(config, group, force):
"""Delete an LDAP group."""
if not force:
if not click.confirm(
'Confirm that you want to delete group {}'.format(group)):
sys.exit("Deletion of {} aborted".format(group))
client = Client()
client.prepare_... | [
"def",
"delete",
"(",
"config",
",",
"group",
",",
"force",
")",
":",
"if",
"not",
"force",
":",
"if",
"not",
"click",
".",
"confirm",
"(",
"'Confirm that you want to delete group {}'",
".",
"format",
"(",
"group",
")",
")",
":",
"sys",
".",
"exit",
"(",... | Delete an LDAP group. | [
"Delete",
"an",
"LDAP",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L180-L190 | train |
carta/ldap_tools | src/ldap_tools/group.py | CLI.add_user | def add_user(config, group, username):
"""Add specified user to specified group."""
client = Client()
client.prepare_connection()
group_api = API(client)
try:
group_api.add_user(group, username)
except ldap_tools.exceptions.NoGroupsFound: # pragma: no cover
... | python | def add_user(config, group, username):
"""Add specified user to specified group."""
client = Client()
client.prepare_connection()
group_api = API(client)
try:
group_api.add_user(group, username)
except ldap_tools.exceptions.NoGroupsFound: # pragma: no cover
... | [
"def",
"add_user",
"(",
"config",
",",
"group",
",",
"username",
")",
":",
"client",
"=",
"Client",
"(",
")",
"client",
".",
"prepare_connection",
"(",
")",
"group_api",
"=",
"API",
"(",
"client",
")",
"try",
":",
"group_api",
".",
"add_user",
"(",
"gr... | Add specified user to specified group. | [
"Add",
"specified",
"user",
"to",
"specified",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L201-L214 | train |
carta/ldap_tools | src/ldap_tools/group.py | CLI.remove_user | def remove_user(config, group, username):
"""Remove specified user from specified group."""
client = Client()
client.prepare_connection()
group_api = API(client)
try:
group_api.remove_user(group, username)
except ldap_tools.exceptions.NoGroupsFound: # pragma:... | python | def remove_user(config, group, username):
"""Remove specified user from specified group."""
client = Client()
client.prepare_connection()
group_api = API(client)
try:
group_api.remove_user(group, username)
except ldap_tools.exceptions.NoGroupsFound: # pragma:... | [
"def",
"remove_user",
"(",
"config",
",",
"group",
",",
"username",
")",
":",
"client",
"=",
"Client",
"(",
")",
"client",
".",
"prepare_connection",
"(",
")",
"group_api",
"=",
"API",
"(",
"client",
")",
"try",
":",
"group_api",
".",
"remove_user",
"(",... | Remove specified user from specified group. | [
"Remove",
"specified",
"user",
"from",
"specified",
"group",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L228-L241 | train |
carta/ldap_tools | src/ldap_tools/group.py | CLI.index | def index(config): # pragma: no cover
"""Display group info in raw format."""
client = Client()
client.prepare_connection()
group_api = API(client)
print(group_api.index()) | python | def index(config): # pragma: no cover
"""Display group info in raw format."""
client = Client()
client.prepare_connection()
group_api = API(client)
print(group_api.index()) | [
"def",
"index",
"(",
"config",
")",
":",
"client",
"=",
"Client",
"(",
")",
"client",
".",
"prepare_connection",
"(",
")",
"group_api",
"=",
"API",
"(",
"client",
")",
"print",
"(",
"group_api",
".",
"index",
"(",
")",
")"
] | Display group info in raw format. | [
"Display",
"group",
"info",
"in",
"raw",
"format",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/group.py#L245-L250 | train |
mkoura/dump2polarion | dump2polarion/results/importer.py | _get_importer | def _get_importer(input_file):
"""Selects importer based on input file type."""
__, ext = os.path.splitext(input_file)
ext = ext.lower()
if "ostriz" in input_file:
from dump2polarion.results import ostriztools
importer = ostriztools.import_ostriz
elif ext == ".xml":
# expec... | python | def _get_importer(input_file):
"""Selects importer based on input file type."""
__, ext = os.path.splitext(input_file)
ext = ext.lower()
if "ostriz" in input_file:
from dump2polarion.results import ostriztools
importer = ostriztools.import_ostriz
elif ext == ".xml":
# expec... | [
"def",
"_get_importer",
"(",
"input_file",
")",
":",
"__",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"input_file",
")",
"ext",
"=",
"ext",
".",
"lower",
"(",
")",
"if",
"\"ostriz\"",
"in",
"input_file",
":",
"from",
"dump2polarion",
"."... | Selects importer based on input file type. | [
"Selects",
"importer",
"based",
"on",
"input",
"file",
"type",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/importer.py#L14-L41 | train |
smnorris/bcdata | bcdata/cli.py | parse_db_url | def parse_db_url(db_url):
"""provided a db url, return a dict with connection properties
"""
u = urlparse(db_url)
db = {}
db["database"] = u.path[1:]
db["user"] = u.username
db["password"] = u.password
db["host"] = u.hostname
db["port"] = u.port
return db | python | def parse_db_url(db_url):
"""provided a db url, return a dict with connection properties
"""
u = urlparse(db_url)
db = {}
db["database"] = u.path[1:]
db["user"] = u.username
db["password"] = u.password
db["host"] = u.hostname
db["port"] = u.port
return db | [
"def",
"parse_db_url",
"(",
"db_url",
")",
":",
"u",
"=",
"urlparse",
"(",
"db_url",
")",
"db",
"=",
"{",
"}",
"db",
"[",
"\"database\"",
"]",
"=",
"u",
".",
"path",
"[",
"1",
":",
"]",
"db",
"[",
"\"user\"",
"]",
"=",
"u",
".",
"username",
"db... | provided a db url, return a dict with connection properties | [
"provided",
"a",
"db",
"url",
"return",
"a",
"dict",
"with",
"connection",
"properties"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L27-L37 | train |
smnorris/bcdata | bcdata/cli.py | bounds_handler | def bounds_handler(ctx, param, value):
"""Handle different forms of bounds."""
retval = from_like_context(ctx, param, value)
if retval is None and value is not None:
try:
value = value.strip(", []")
retval = tuple(float(x) for x in re.split(r"[,\s]+", value))
asse... | python | def bounds_handler(ctx, param, value):
"""Handle different forms of bounds."""
retval = from_like_context(ctx, param, value)
if retval is None and value is not None:
try:
value = value.strip(", []")
retval = tuple(float(x) for x in re.split(r"[,\s]+", value))
asse... | [
"def",
"bounds_handler",
"(",
"ctx",
",",
"param",
",",
"value",
")",
":",
"retval",
"=",
"from_like_context",
"(",
"ctx",
",",
"param",
",",
"value",
")",
"if",
"retval",
"is",
"None",
"and",
"value",
"is",
"not",
"None",
":",
"try",
":",
"value",
"... | Handle different forms of bounds. | [
"Handle",
"different",
"forms",
"of",
"bounds",
"."
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L58-L72 | train |
smnorris/bcdata | bcdata/cli.py | info | def info(dataset, indent, meta_member):
"""Print basic metadata about a DataBC WFS layer as JSON.
Optionally print a single metadata item as a string.
"""
table = bcdata.validate_name(dataset)
wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0")
info = {}
info["name"] = table
in... | python | def info(dataset, indent, meta_member):
"""Print basic metadata about a DataBC WFS layer as JSON.
Optionally print a single metadata item as a string.
"""
table = bcdata.validate_name(dataset)
wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0")
info = {}
info["name"] = table
in... | [
"def",
"info",
"(",
"dataset",
",",
"indent",
",",
"meta_member",
")",
":",
"table",
"=",
"bcdata",
".",
"validate_name",
"(",
"dataset",
")",
"wfs",
"=",
"WebFeatureService",
"(",
"url",
"=",
"bcdata",
".",
"OWS_URL",
",",
"version",
"=",
"\"2.0.0\"",
"... | Print basic metadata about a DataBC WFS layer as JSON.
Optionally print a single metadata item as a string. | [
"Print",
"basic",
"metadata",
"about",
"a",
"DataBC",
"WFS",
"layer",
"as",
"JSON",
"."
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L120-L134 | train |
smnorris/bcdata | bcdata/cli.py | dem | def dem(bounds, src_crs, dst_crs, out_file, resolution):
"""Dump BC DEM to TIFF
"""
if not dst_crs:
dst_crs = "EPSG:3005"
bcdata.get_dem(bounds, out_file=out_file, src_crs=src_crs, dst_crs=dst_crs, resolution=resolution) | python | def dem(bounds, src_crs, dst_crs, out_file, resolution):
"""Dump BC DEM to TIFF
"""
if not dst_crs:
dst_crs = "EPSG:3005"
bcdata.get_dem(bounds, out_file=out_file, src_crs=src_crs, dst_crs=dst_crs, resolution=resolution) | [
"def",
"dem",
"(",
"bounds",
",",
"src_crs",
",",
"dst_crs",
",",
"out_file",
",",
"resolution",
")",
":",
"if",
"not",
"dst_crs",
":",
"dst_crs",
"=",
"\"EPSG:3005\"",
"bcdata",
".",
"get_dem",
"(",
"bounds",
",",
"out_file",
"=",
"out_file",
",",
"src_... | Dump BC DEM to TIFF | [
"Dump",
"BC",
"DEM",
"to",
"TIFF"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L143-L148 | train |
smnorris/bcdata | bcdata/cli.py | dump | def dump(dataset, query, out_file, bounds):
"""Write DataBC features to stdout as GeoJSON feature collection.
\b
$ bcdata dump bc-airports
$ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'"
$ bcdata dump bc-airports --bounds xmin ymin xmax ymax
The... | python | def dump(dataset, query, out_file, bounds):
"""Write DataBC features to stdout as GeoJSON feature collection.
\b
$ bcdata dump bc-airports
$ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'"
$ bcdata dump bc-airports --bounds xmin ymin xmax ymax
The... | [
"def",
"dump",
"(",
"dataset",
",",
"query",
",",
"out_file",
",",
"bounds",
")",
":",
"table",
"=",
"bcdata",
".",
"validate_name",
"(",
"dataset",
")",
"data",
"=",
"bcdata",
".",
"get_data",
"(",
"table",
",",
"query",
"=",
"query",
",",
"bounds",
... | Write DataBC features to stdout as GeoJSON feature collection.
\b
$ bcdata dump bc-airports
$ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'"
$ bcdata dump bc-airports --bounds xmin ymin xmax ymax
The values of --bounds must be in BC Albers.
It ... | [
"Write",
"DataBC",
"features",
"to",
"stdout",
"as",
"GeoJSON",
"feature",
"collection",
"."
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L159-L181 | train |
smnorris/bcdata | bcdata/cli.py | cat | def cat(dataset, query, bounds, indent, compact, dst_crs, pagesize, sortby):
"""Write DataBC features to stdout as GeoJSON feature objects.
"""
# Note that cat does not concatenate!
dump_kwds = {"sort_keys": True}
if indent:
dump_kwds["indent"] = indent
if compact:
dump_kwds["sep... | python | def cat(dataset, query, bounds, indent, compact, dst_crs, pagesize, sortby):
"""Write DataBC features to stdout as GeoJSON feature objects.
"""
# Note that cat does not concatenate!
dump_kwds = {"sort_keys": True}
if indent:
dump_kwds["indent"] = indent
if compact:
dump_kwds["sep... | [
"def",
"cat",
"(",
"dataset",
",",
"query",
",",
"bounds",
",",
"indent",
",",
"compact",
",",
"dst_crs",
",",
"pagesize",
",",
"sortby",
")",
":",
"dump_kwds",
"=",
"{",
"\"sort_keys\"",
":",
"True",
"}",
"if",
"indent",
":",
"dump_kwds",
"[",
"\"inde... | Write DataBC features to stdout as GeoJSON feature objects. | [
"Write",
"DataBC",
"features",
"to",
"stdout",
"as",
"GeoJSON",
"feature",
"objects",
"."
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L198-L211 | train |
smnorris/bcdata | bcdata/cli.py | bc2pg | def bc2pg(dataset, db_url, table, schema, query, append, pagesize, sortby, max_workers):
"""Download a DataBC WFS layer to postgres - an ogr2ogr wrapper.
\b
$ bcdata bc2pg bc-airports --db_url postgresql://postgres:postgres@localhost:5432/postgis
The default target database can be specified by sett... | python | def bc2pg(dataset, db_url, table, schema, query, append, pagesize, sortby, max_workers):
"""Download a DataBC WFS layer to postgres - an ogr2ogr wrapper.
\b
$ bcdata bc2pg bc-airports --db_url postgresql://postgres:postgres@localhost:5432/postgis
The default target database can be specified by sett... | [
"def",
"bc2pg",
"(",
"dataset",
",",
"db_url",
",",
"table",
",",
"schema",
",",
"query",
",",
"append",
",",
"pagesize",
",",
"sortby",
",",
"max_workers",
")",
":",
"src",
"=",
"bcdata",
".",
"validate_name",
"(",
"dataset",
")",
"src_schema",
",",
"... | Download a DataBC WFS layer to postgres - an ogr2ogr wrapper.
\b
$ bcdata bc2pg bc-airports --db_url postgresql://postgres:postgres@localhost:5432/postgis
The default target database can be specified by setting the $DATABASE_URL
environment variable.
https://docs.sqlalchemy.org/en/latest/core/e... | [
"Download",
"a",
"DataBC",
"WFS",
"layer",
"to",
"postgres",
"-",
"an",
"ogr2ogr",
"wrapper",
"."
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/cli.py#L235-L333 | train |
mgoral/subconvert | src/subconvert/parsing/Core.py | SubParser.__parseFormat | def __parseFormat(self, fmt, content, fps = 25):
'''Actual parser. Please note that time_to is not required to process as not all subtitles
provide it.'''
headerFound = False
subSection = ''
for lineNo, line in enumerate(content):
line = self._initialLinePrepare(line... | python | def __parseFormat(self, fmt, content, fps = 25):
'''Actual parser. Please note that time_to is not required to process as not all subtitles
provide it.'''
headerFound = False
subSection = ''
for lineNo, line in enumerate(content):
line = self._initialLinePrepare(line... | [
"def",
"__parseFormat",
"(",
"self",
",",
"fmt",
",",
"content",
",",
"fps",
"=",
"25",
")",
":",
"headerFound",
"=",
"False",
"subSection",
"=",
"''",
"for",
"lineNo",
",",
"line",
"in",
"enumerate",
"(",
"content",
")",
":",
"line",
"=",
"self",
".... | Actual parser. Please note that time_to is not required to process as not all subtitles
provide it. | [
"Actual",
"parser",
".",
"Please",
"note",
"that",
"time_to",
"is",
"not",
"required",
"to",
"process",
"as",
"not",
"all",
"subtitles",
"provide",
"it",
"."
] | 59701e5e69ef1ca26ce7d1d766c936664aa2cb32 | https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Core.py#L312-L353 | train |
mkoura/dump2polarion | dump2polarion/dumper_cli.py | get_args | def get_args(args=None):
"""Get command line arguments."""
parser = argparse.ArgumentParser(description="dump2polarion")
parser.add_argument(
"-i",
"--input_file",
required=True,
help="Path to CSV, SQLite or JUnit reports file or importers XML file",
)
parser.add_argu... | python | def get_args(args=None):
"""Get command line arguments."""
parser = argparse.ArgumentParser(description="dump2polarion")
parser.add_argument(
"-i",
"--input_file",
required=True,
help="Path to CSV, SQLite or JUnit reports file or importers XML file",
)
parser.add_argu... | [
"def",
"get_args",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"dump2polarion\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-i\"",
",",
"\"--input_file\"",
",",
"required",
"=",
"True",
"... | Get command line arguments. | [
"Get",
"command",
"line",
"arguments",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/dumper_cli.py#L26-L61 | train |
mkoura/dump2polarion | dump2polarion/dumper_cli.py | get_submit_args | def get_submit_args(args):
"""Gets arguments for the `submit_and_verify` method."""
submit_args = dict(
testrun_id=args.testrun_id,
user=args.user,
password=args.password,
no_verify=args.no_verify,
verify_timeout=args.verify_timeout,
log_file=args.job_log,
... | python | def get_submit_args(args):
"""Gets arguments for the `submit_and_verify` method."""
submit_args = dict(
testrun_id=args.testrun_id,
user=args.user,
password=args.password,
no_verify=args.no_verify,
verify_timeout=args.verify_timeout,
log_file=args.job_log,
... | [
"def",
"get_submit_args",
"(",
"args",
")",
":",
"submit_args",
"=",
"dict",
"(",
"testrun_id",
"=",
"args",
".",
"testrun_id",
",",
"user",
"=",
"args",
".",
"user",
",",
"password",
"=",
"args",
".",
"password",
",",
"no_verify",
"=",
"args",
".",
"n... | Gets arguments for the `submit_and_verify` method. | [
"Gets",
"arguments",
"for",
"the",
"submit_and_verify",
"method",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/dumper_cli.py#L64-L76 | train |
mkoura/dump2polarion | dump2polarion/dumper_cli.py | process_args | def process_args(args):
"""Processes passed arguments."""
passed_args = args
if isinstance(args, argparse.Namespace):
passed_args = vars(passed_args)
elif hasattr(args, "to_dict"):
passed_args = passed_args.to_dict()
return Box(passed_args, frozen_box=True, default_box=True) | python | def process_args(args):
"""Processes passed arguments."""
passed_args = args
if isinstance(args, argparse.Namespace):
passed_args = vars(passed_args)
elif hasattr(args, "to_dict"):
passed_args = passed_args.to_dict()
return Box(passed_args, frozen_box=True, default_box=True) | [
"def",
"process_args",
"(",
"args",
")",
":",
"passed_args",
"=",
"args",
"if",
"isinstance",
"(",
"args",
",",
"argparse",
".",
"Namespace",
")",
":",
"passed_args",
"=",
"vars",
"(",
"passed_args",
")",
"elif",
"hasattr",
"(",
"args",
",",
"\"to_dict\"",... | Processes passed arguments. | [
"Processes",
"passed",
"arguments",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/dumper_cli.py#L79-L87 | train |
mkoura/dump2polarion | dump2polarion/dumper_cli.py | submit_if_ready | def submit_if_ready(args, submit_args, config):
"""Submits the input XML file if it's already in the expected format."""
__, ext = os.path.splitext(args.input_file)
if ext.lower() != ".xml":
return None
with io.open(args.input_file, encoding="utf-8") as input_file:
xml = input_file.read... | python | def submit_if_ready(args, submit_args, config):
"""Submits the input XML file if it's already in the expected format."""
__, ext = os.path.splitext(args.input_file)
if ext.lower() != ".xml":
return None
with io.open(args.input_file, encoding="utf-8") as input_file:
xml = input_file.read... | [
"def",
"submit_if_ready",
"(",
"args",
",",
"submit_args",
",",
"config",
")",
":",
"__",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"args",
".",
"input_file",
")",
"if",
"ext",
".",
"lower",
"(",
")",
"!=",
"\".xml\"",
":",
"return",
... | Submits the input XML file if it's already in the expected format. | [
"Submits",
"the",
"input",
"XML",
"file",
"if",
"it",
"s",
"already",
"in",
"the",
"expected",
"format",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/dumper_cli.py#L119-L139 | train |
mkoura/dump2polarion | dump2polarion/dumper_cli.py | dumper | def dumper(args, config, transform_func=None):
"""Dumper main function."""
args = process_args(args)
submit_args = get_submit_args(args)
submit_outcome = submit_if_ready(args, submit_args, config)
if submit_outcome is not None:
# submitted, nothing more to do
return submit_outcome
... | python | def dumper(args, config, transform_func=None):
"""Dumper main function."""
args = process_args(args)
submit_args = get_submit_args(args)
submit_outcome = submit_if_ready(args, submit_args, config)
if submit_outcome is not None:
# submitted, nothing more to do
return submit_outcome
... | [
"def",
"dumper",
"(",
"args",
",",
"config",
",",
"transform_func",
"=",
"None",
")",
":",
"args",
"=",
"process_args",
"(",
"args",
")",
"submit_args",
"=",
"get_submit_args",
"(",
"args",
")",
"submit_outcome",
"=",
"submit_if_ready",
"(",
"args",
",",
"... | Dumper main function. | [
"Dumper",
"main",
"function",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/dumper_cli.py#L150-L190 | train |
carta/ldap_tools | src/ldap_tools/client.py | Client.load_ldap_config | def load_ldap_config(self): # pragma: no cover
"""Configure LDAP Client settings."""
try:
with open('{}/ldap_info.yaml'.format(self.config_dir),
'r') as FILE:
config = yaml.load(FILE)
self.host = config['server']
self.use... | python | def load_ldap_config(self): # pragma: no cover
"""Configure LDAP Client settings."""
try:
with open('{}/ldap_info.yaml'.format(self.config_dir),
'r') as FILE:
config = yaml.load(FILE)
self.host = config['server']
self.use... | [
"def",
"load_ldap_config",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"'{}/ldap_info.yaml'",
".",
"format",
"(",
"self",
".",
"config_dir",
")",
",",
"'r'",
")",
"as",
"FILE",
":",
"config",
"=",
"yaml",
".",
"load",
"(",
"FILE",
")",
"s... | Configure LDAP Client settings. | [
"Configure",
"LDAP",
"Client",
"settings",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L24-L38 | train |
carta/ldap_tools | src/ldap_tools/client.py | Client.load_ldap_password | def load_ldap_password(self): # pragma: no cover
"""Import LDAP password from file."""
with open('{}/ldap.secret'.format(self.config_dir), 'r') as FILE:
secure_config = FILE.read()
self.user_pw = base64.b64decode(secure_config.encode()) | python | def load_ldap_password(self): # pragma: no cover
"""Import LDAP password from file."""
with open('{}/ldap.secret'.format(self.config_dir), 'r') as FILE:
secure_config = FILE.read()
self.user_pw = base64.b64decode(secure_config.encode()) | [
"def",
"load_ldap_password",
"(",
"self",
")",
":",
"with",
"open",
"(",
"'{}/ldap.secret'",
".",
"format",
"(",
"self",
".",
"config_dir",
")",
",",
"'r'",
")",
"as",
"FILE",
":",
"secure_config",
"=",
"FILE",
".",
"read",
"(",
")",
"self",
".",
"user... | Import LDAP password from file. | [
"Import",
"LDAP",
"password",
"from",
"file",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L40-L44 | train |
carta/ldap_tools | src/ldap_tools/client.py | Client.connection | def connection(self): # pragma: no cover
"""Establish LDAP connection."""
# self.server allows us to fetch server info
# (including LDAP schema list) if we wish to
# add this feature later
self.server = ldap3.Server(self.host, port=self.port, get_info=ldap3.ALL)
self.con... | python | def connection(self): # pragma: no cover
"""Establish LDAP connection."""
# self.server allows us to fetch server info
# (including LDAP schema list) if we wish to
# add this feature later
self.server = ldap3.Server(self.host, port=self.port, get_info=ldap3.ALL)
self.con... | [
"def",
"connection",
"(",
"self",
")",
":",
"self",
".",
"server",
"=",
"ldap3",
".",
"Server",
"(",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
",",
"get_info",
"=",
"ldap3",
".",
"ALL",
")",
"self",
".",
"conn",
"=",
"ldap3",
".... | Establish LDAP connection. | [
"Establish",
"LDAP",
"connection",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L46-L58 | train |
carta/ldap_tools | src/ldap_tools/client.py | Client.add | def add(self, distinguished_name, object_class, attributes):
"""
Add object to LDAP.
Args:
distinguished_name: the DN of the LDAP record to be added
object_class: The objectClass of the record to be added.
This is a list of length >= 1.
attrib... | python | def add(self, distinguished_name, object_class, attributes):
"""
Add object to LDAP.
Args:
distinguished_name: the DN of the LDAP record to be added
object_class: The objectClass of the record to be added.
This is a list of length >= 1.
attrib... | [
"def",
"add",
"(",
"self",
",",
"distinguished_name",
",",
"object_class",
",",
"attributes",
")",
":",
"self",
".",
"conn",
".",
"add",
"(",
"distinguished_name",
",",
"object_class",
",",
"attributes",
")"
] | Add object to LDAP.
Args:
distinguished_name: the DN of the LDAP record to be added
object_class: The objectClass of the record to be added.
This is a list of length >= 1.
attributes: a dictionary of LDAP attributes to add
See ldap_tools.api.g... | [
"Add",
"object",
"to",
"LDAP",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L60-L72 | train |
carta/ldap_tools | src/ldap_tools/client.py | Client.search | def search(self, filter, attributes=None):
"""Search LDAP for records."""
if attributes is None:
attributes = ['*']
if filter is None:
filter = ["(objectclass=*)"]
# Convert filter list into an LDAP-consumable format
filterstr = "(&{})".format(''.join(fi... | python | def search(self, filter, attributes=None):
"""Search LDAP for records."""
if attributes is None:
attributes = ['*']
if filter is None:
filter = ["(objectclass=*)"]
# Convert filter list into an LDAP-consumable format
filterstr = "(&{})".format(''.join(fi... | [
"def",
"search",
"(",
"self",
",",
"filter",
",",
"attributes",
"=",
"None",
")",
":",
"if",
"attributes",
"is",
"None",
":",
"attributes",
"=",
"[",
"'*'",
"]",
"if",
"filter",
"is",
"None",
":",
"filter",
"=",
"[",
"\"(objectclass=*)\"",
"]",
"filter... | Search LDAP for records. | [
"Search",
"LDAP",
"for",
"records",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L93-L108 | train |
carta/ldap_tools | src/ldap_tools/client.py | Client.get_max_id | def get_max_id(self, object_type, role):
"""Get the highest used ID."""
if object_type == 'user':
objectclass = 'posixAccount'
ldap_attr = 'uidNumber'
elif object_type == 'group': # pragma: no cover
objectclass = 'posixGroup'
ldap_attr = 'gidNumbe... | python | def get_max_id(self, object_type, role):
"""Get the highest used ID."""
if object_type == 'user':
objectclass = 'posixAccount'
ldap_attr = 'uidNumber'
elif object_type == 'group': # pragma: no cover
objectclass = 'posixGroup'
ldap_attr = 'gidNumbe... | [
"def",
"get_max_id",
"(",
"self",
",",
"object_type",
",",
"role",
")",
":",
"if",
"object_type",
"==",
"'user'",
":",
"objectclass",
"=",
"'posixAccount'",
"ldap_attr",
"=",
"'uidNumber'",
"elif",
"object_type",
"==",
"'group'",
":",
"objectclass",
"=",
"'pos... | Get the highest used ID. | [
"Get",
"the",
"highest",
"used",
"ID",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L110-L142 | train |
smnorris/bcdata | bcdata/wcs.py | get_dem | def get_dem(bounds, out_file="dem.tif", src_crs="EPSG:3005", dst_crs="EPSG:3005", resolution=25):
"""Get 25m DEM for provided bounds, write to GeoTIFF
"""
bbox = ",".join([str(b) for b in bounds])
# todo: validate resolution units are equivalent to src_crs units
# build request
payload = {
... | python | def get_dem(bounds, out_file="dem.tif", src_crs="EPSG:3005", dst_crs="EPSG:3005", resolution=25):
"""Get 25m DEM for provided bounds, write to GeoTIFF
"""
bbox = ",".join([str(b) for b in bounds])
# todo: validate resolution units are equivalent to src_crs units
# build request
payload = {
... | [
"def",
"get_dem",
"(",
"bounds",
",",
"out_file",
"=",
"\"dem.tif\"",
",",
"src_crs",
"=",
"\"EPSG:3005\"",
",",
"dst_crs",
"=",
"\"EPSG:3005\"",
",",
"resolution",
"=",
"25",
")",
":",
"bbox",
"=",
"\",\"",
".",
"join",
"(",
"[",
"str",
"(",
"b",
")",... | Get 25m DEM for provided bounds, write to GeoTIFF | [
"Get",
"25m",
"DEM",
"for",
"provided",
"bounds",
"write",
"to",
"GeoTIFF"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wcs.py#L10-L38 | train |
carta/ldap_tools | src/ldap_tools/commands.py | main | def main(): # pragma: no cover
"""Enter main function."""
entry_point.add_command(CLI.version)
entry_point.add_command(UserCLI.user)
entry_point.add_command(GroupCLI.group)
entry_point.add_command(AuditCLI.audit)
entry_point.add_command(KeyCLI.key)
entry_point() | python | def main(): # pragma: no cover
"""Enter main function."""
entry_point.add_command(CLI.version)
entry_point.add_command(UserCLI.user)
entry_point.add_command(GroupCLI.group)
entry_point.add_command(AuditCLI.audit)
entry_point.add_command(KeyCLI.key)
entry_point() | [
"def",
"main",
"(",
")",
":",
"entry_point",
".",
"add_command",
"(",
"CLI",
".",
"version",
")",
"entry_point",
".",
"add_command",
"(",
"UserCLI",
".",
"user",
")",
"entry_point",
".",
"add_command",
"(",
"GroupCLI",
".",
"group",
")",
"entry_point",
"."... | Enter main function. | [
"Enter",
"main",
"function",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/commands.py#L29-L37 | train |
rgmining/common | common/decorator.py | print_args | def print_args(output=sys.stdout):
"""Decorate a function so that print arguments before calling it.
Args:
output: writable to print args. (Default: sys.stdout)
"""
def decorator(func):
"""The decorator function.
"""
@wraps(func)
def _(*args, **kwargs):
... | python | def print_args(output=sys.stdout):
"""Decorate a function so that print arguments before calling it.
Args:
output: writable to print args. (Default: sys.stdout)
"""
def decorator(func):
"""The decorator function.
"""
@wraps(func)
def _(*args, **kwargs):
... | [
"def",
"print_args",
"(",
"output",
"=",
"sys",
".",
"stdout",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"output",
".",
"write",
"(",
"\"Args:... | Decorate a function so that print arguments before calling it.
Args:
output: writable to print args. (Default: sys.stdout) | [
"Decorate",
"a",
"function",
"so",
"that",
"print",
"arguments",
"before",
"calling",
"it",
"."
] | 2462a4d54f32a82eadd7b1e28675b3c8bcd172b2 | https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/common/decorator.py#L30-L47 | train |
rgmining/common | common/decorator.py | constant | def constant(func):
"""Decorate a function so that the result is a constant value.
Functions wraped by this decorator will be run just one time.
The computational result will be stored and reused for any other input.
To store each result for each input, use :func:`memoized` instead.
"""
@wraps... | python | def constant(func):
"""Decorate a function so that the result is a constant value.
Functions wraped by this decorator will be run just one time.
The computational result will be stored and reused for any other input.
To store each result for each input, use :func:`memoized` instead.
"""
@wraps... | [
"def",
"constant",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"_",
".",
"res",
":",
"_",
".",
"res",
"=",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",
"... | Decorate a function so that the result is a constant value.
Functions wraped by this decorator will be run just one time.
The computational result will be stored and reused for any other input.
To store each result for each input, use :func:`memoized` instead. | [
"Decorate",
"a",
"function",
"so",
"that",
"the",
"result",
"is",
"a",
"constant",
"value",
"."
] | 2462a4d54f32a82eadd7b1e28675b3c8bcd172b2 | https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/common/decorator.py#L70-L86 | train |
rgmining/common | common/decorator.py | memoized | def memoized(func):
"""Decorate a function to memoize results.
Functions wraped by this decorator won't compute twice for each input.
Any results will be stored. This decorator might increase used memory
in order to shorten computational time.
"""
cache = {}
@wraps(func)
def memoized_fu... | python | def memoized(func):
"""Decorate a function to memoize results.
Functions wraped by this decorator won't compute twice for each input.
Any results will be stored. This decorator might increase used memory
in order to shorten computational time.
"""
cache = {}
@wraps(func)
def memoized_fu... | [
"def",
"memoized",
"(",
"func",
")",
":",
"cache",
"=",
"{",
"}",
"@",
"wraps",
"(",
"func",
")",
"def",
"memoized_function",
"(",
"*",
"args",
")",
":",
"try",
":",
"return",
"cache",
"[",
"args",
"]",
"except",
"KeyError",
":",
"value",
"=",
"fun... | Decorate a function to memoize results.
Functions wraped by this decorator won't compute twice for each input.
Any results will be stored. This decorator might increase used memory
in order to shorten computational time. | [
"Decorate",
"a",
"function",
"to",
"memoize",
"results",
"."
] | 2462a4d54f32a82eadd7b1e28675b3c8bcd172b2 | https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/common/decorator.py#L89-L111 | train |
mkoura/dump2polarion | dump2polarion/results/dbtools.py | _open_sqlite | def _open_sqlite(db_file):
"""Opens database connection."""
db_file = os.path.expanduser(db_file)
try:
with open(db_file):
# test that the file can be accessed
pass
return sqlite3.connect(db_file, detect_types=sqlite3.PARSE_DECLTYPES)
except (IOError, sqlite3.Erro... | python | def _open_sqlite(db_file):
"""Opens database connection."""
db_file = os.path.expanduser(db_file)
try:
with open(db_file):
# test that the file can be accessed
pass
return sqlite3.connect(db_file, detect_types=sqlite3.PARSE_DECLTYPES)
except (IOError, sqlite3.Erro... | [
"def",
"_open_sqlite",
"(",
"db_file",
")",
":",
"db_file",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"db_file",
")",
"try",
":",
"with",
"open",
"(",
"db_file",
")",
":",
"pass",
"return",
"sqlite3",
".",
"connect",
"(",
"db_file",
",",
"detect_... | Opens database connection. | [
"Opens",
"database",
"connection",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/dbtools.py#L33-L42 | train |
mkoura/dump2polarion | dump2polarion/results/dbtools.py | import_sqlite | def import_sqlite(db_file, older_than=None, **kwargs):
"""Reads the content of the database file and returns imported data."""
conn = _open_sqlite(db_file)
cur = conn.cursor()
# get rows that were not exported yet
select = "SELECT * FROM testcases WHERE exported != 'yes'"
if older_than:
... | python | def import_sqlite(db_file, older_than=None, **kwargs):
"""Reads the content of the database file and returns imported data."""
conn = _open_sqlite(db_file)
cur = conn.cursor()
# get rows that were not exported yet
select = "SELECT * FROM testcases WHERE exported != 'yes'"
if older_than:
... | [
"def",
"import_sqlite",
"(",
"db_file",
",",
"older_than",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"conn",
"=",
"_open_sqlite",
"(",
"db_file",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"select",
"=",
"\"SELECT * FROM testcases WHERE exported != 'y... | Reads the content of the database file and returns imported data. | [
"Reads",
"the",
"content",
"of",
"the",
"database",
"file",
"and",
"returns",
"imported",
"data",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/dbtools.py#L46-L69 | train |
mkoura/dump2polarion | dump2polarion/results/dbtools.py | mark_exported_sqlite | def mark_exported_sqlite(db_file, older_than=None):
"""Marks rows with verdict as exported."""
logger.debug("Marking rows in database as exported")
conn = _open_sqlite(db_file)
cur = conn.cursor()
update = "UPDATE testcases SET exported = 'yes' WHERE verdict IS NOT null AND verdict != ''"
if old... | python | def mark_exported_sqlite(db_file, older_than=None):
"""Marks rows with verdict as exported."""
logger.debug("Marking rows in database as exported")
conn = _open_sqlite(db_file)
cur = conn.cursor()
update = "UPDATE testcases SET exported = 'yes' WHERE verdict IS NOT null AND verdict != ''"
if old... | [
"def",
"mark_exported_sqlite",
"(",
"db_file",
",",
"older_than",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Marking rows in database as exported\"",
")",
"conn",
"=",
"_open_sqlite",
"(",
"db_file",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")"... | Marks rows with verdict as exported. | [
"Marks",
"rows",
"with",
"verdict",
"as",
"exported",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/dbtools.py#L72-L83 | train |
mgoral/subconvert | src/subconvert/parsing/Formats.py | SubFormat.createSubtitle | def createSubtitle(self, fps, section):
"""Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot
be parsed, None is returned.
By default 'section' is checked against 'subPattern' regular expression."""
matched = self._pattern.search(section)
if m... | python | def createSubtitle(self, fps, section):
"""Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot
be parsed, None is returned.
By default 'section' is checked against 'subPattern' regular expression."""
matched = self._pattern.search(section)
if m... | [
"def",
"createSubtitle",
"(",
"self",
",",
"fps",
",",
"section",
")",
":",
"matched",
"=",
"self",
".",
"_pattern",
".",
"search",
"(",
"section",
")",
"if",
"matched",
"is",
"not",
"None",
":",
"matchedDict",
"=",
"matched",
".",
"groupdict",
"(",
")... | Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot
be parsed, None is returned.
By default 'section' is checked against 'subPattern' regular expression. | [
"Returns",
"a",
"correct",
"Subtitle",
"object",
"from",
"a",
"text",
"given",
"in",
"section",
".",
"If",
"section",
"cannot",
"be",
"parsed",
"None",
"is",
"returned",
".",
"By",
"default",
"section",
"is",
"checked",
"against",
"subPattern",
"regular",
"e... | 59701e5e69ef1ca26ce7d1d766c936664aa2cb32 | https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Formats.py#L130-L142 | train |
mgoral/subconvert | src/subconvert/parsing/Formats.py | SubFormat.convertTime | def convertTime(self, frametime, which):
"""Convert FrameTime object to properly formatted string that describes subtitle start or
end time."""
SubAssert(frametime.frame >= 0, _("Negative time present."))
return frametime.frame | python | def convertTime(self, frametime, which):
"""Convert FrameTime object to properly formatted string that describes subtitle start or
end time."""
SubAssert(frametime.frame >= 0, _("Negative time present."))
return frametime.frame | [
"def",
"convertTime",
"(",
"self",
",",
"frametime",
",",
"which",
")",
":",
"SubAssert",
"(",
"frametime",
".",
"frame",
">=",
"0",
",",
"_",
"(",
"\"Negative time present.\"",
")",
")",
"return",
"frametime",
".",
"frame"
] | Convert FrameTime object to properly formatted string that describes subtitle start or
end time. | [
"Convert",
"FrameTime",
"object",
"to",
"properly",
"formatted",
"string",
"that",
"describes",
"subtitle",
"start",
"or",
"end",
"time",
"."
] | 59701e5e69ef1ca26ce7d1d766c936664aa2cb32 | https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Formats.py#L181-L185 | train |
pneff/wsgiservice | wsgiservice/status.py | _set_location | def _set_location(instance, location):
"""Sets a ``Location`` response header. If the location does not start with
a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the request and
response)
:type instance: :class:`webob.resou... | python | def _set_location(instance, location):
"""Sets a ``Location`` response header. If the location does not start with
a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the request and
response)
:type instance: :class:`webob.resou... | [
"def",
"_set_location",
"(",
"instance",
",",
"location",
")",
":",
"location",
"=",
"str",
"(",
"location",
")",
"if",
"not",
"location",
".",
"startswith",
"(",
"'/'",
")",
":",
"location",
"=",
"urljoin",
"(",
"instance",
".",
"request_path",
".",
"rs... | Sets a ``Location`` response header. If the location does not start with
a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the request and
response)
:type instance: :class:`webob.resource.Resource` | [
"Sets",
"a",
"Location",
"response",
"header",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path",
"of",
"the",
"current",
"request",
"is",
"prepended",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L367-L378 | train |
djaodjin/djaodjin-deployutils | deployutils/apps/django/templatetags/deployutils_extratags.py | no_cache | def no_cache(asset_url):
"""
Removes query parameters
"""
pos = asset_url.rfind('?')
if pos > 0:
asset_url = asset_url[:pos]
return asset_url | python | def no_cache(asset_url):
"""
Removes query parameters
"""
pos = asset_url.rfind('?')
if pos > 0:
asset_url = asset_url[:pos]
return asset_url | [
"def",
"no_cache",
"(",
"asset_url",
")",
":",
"pos",
"=",
"asset_url",
".",
"rfind",
"(",
"'?'",
")",
"if",
"pos",
">",
"0",
":",
"asset_url",
"=",
"asset_url",
"[",
":",
"pos",
"]",
"return",
"asset_url"
] | Removes query parameters | [
"Removes",
"query",
"parameters"
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/templatetags/deployutils_extratags.py#L61-L68 | train |
SignalN/language | language/ngrams.py | __ngrams | def __ngrams(s, n=3):
""" Raw n-grams from a sequence
If the sequence is a string, it will return char-level n-grams.
If the sequence is a list of words, it will return word-level n-grams.
Note: it treats space (' ') and punctuation like any other character.
>>> ngrams('This i... | python | def __ngrams(s, n=3):
""" Raw n-grams from a sequence
If the sequence is a string, it will return char-level n-grams.
If the sequence is a list of words, it will return word-level n-grams.
Note: it treats space (' ') and punctuation like any other character.
>>> ngrams('This i... | [
"def",
"__ngrams",
"(",
"s",
",",
"n",
"=",
"3",
")",
":",
"return",
"list",
"(",
"zip",
"(",
"*",
"[",
"s",
"[",
"i",
":",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
")",
"]",
")",
")"
] | Raw n-grams from a sequence
If the sequence is a string, it will return char-level n-grams.
If the sequence is a list of words, it will return word-level n-grams.
Note: it treats space (' ') and punctuation like any other character.
>>> ngrams('This is not a test!')
[(... | [
"Raw",
"n",
"-",
"grams",
"from",
"a",
"sequence"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L3-L27 | train |
SignalN/language | language/ngrams.py | word_ngrams | def word_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Word-level n-grams in a string
By default, whitespace is assumed to be a word boundary.
>>> ng.word_ngrams('This is not a test!')
[('This', 'is', 'not'), ('is', 'not', 'a'), ('not', 'a', 'test!')]
If the sequence'... | python | def word_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Word-level n-grams in a string
By default, whitespace is assumed to be a word boundary.
>>> ng.word_ngrams('This is not a test!')
[('This', 'is', 'not'), ('is', 'not', 'a'), ('not', 'a', 'test!')]
If the sequence'... | [
"def",
"word_ngrams",
"(",
"s",
",",
"n",
"=",
"3",
",",
"token_fn",
"=",
"tokens",
".",
"on_whitespace",
")",
":",
"tokens",
"=",
"token_fn",
"(",
"s",
")",
"return",
"__ngrams",
"(",
"tokens",
",",
"n",
"=",
"min",
"(",
"len",
"(",
"tokens",
")",... | Word-level n-grams in a string
By default, whitespace is assumed to be a word boundary.
>>> ng.word_ngrams('This is not a test!')
[('This', 'is', 'not'), ('is', 'not', 'a'), ('not', 'a', 'test!')]
If the sequence's length is less than or equal to n, the n-grams are
simply the ... | [
"Word",
"-",
"level",
"n",
"-",
"grams",
"in",
"a",
"string"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L29-L51 | train |
SignalN/language | language/ngrams.py | char_ngrams | def char_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Character-level n-grams from within the words in a string.
By default, the word boundary is assumed to be whitespace. n-grams are
not taken across word boundaries, only within words.
If a word's length is less than or equ... | python | def char_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Character-level n-grams from within the words in a string.
By default, the word boundary is assumed to be whitespace. n-grams are
not taken across word boundaries, only within words.
If a word's length is less than or equ... | [
"def",
"char_ngrams",
"(",
"s",
",",
"n",
"=",
"3",
",",
"token_fn",
"=",
"tokens",
".",
"on_whitespace",
")",
":",
"tokens",
"=",
"token_fn",
"(",
"s",
")",
"ngram_tuples",
"=",
"[",
"__ngrams",
"(",
"t",
",",
"n",
"=",
"min",
"(",
"len",
"(",
"... | Character-level n-grams from within the words in a string.
By default, the word boundary is assumed to be whitespace. n-grams are
not taken across word boundaries, only within words.
If a word's length is less than or equal to n, the n-grams are simply a
list with the word itself.
... | [
"Character",
"-",
"level",
"n",
"-",
"grams",
"from",
"within",
"the",
"words",
"in",
"a",
"string",
"."
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L53-L83 | train |
SignalN/language | language/ngrams.py | __matches | def __matches(s1, s2, ngrams_fn, n=3):
"""
Returns the n-grams that match between two sequences
See also: SequenceMatcher.get_matching_blocks
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set:
"""
... | python | def __matches(s1, s2, ngrams_fn, n=3):
"""
Returns the n-grams that match between two sequences
See also: SequenceMatcher.get_matching_blocks
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set:
"""
... | [
"def",
"__matches",
"(",
"s1",
",",
"s2",
",",
"ngrams_fn",
",",
"n",
"=",
"3",
")",
":",
"ngrams1",
",",
"ngrams2",
"=",
"set",
"(",
"ngrams_fn",
"(",
"s1",
",",
"n",
"=",
"n",
")",
")",
",",
"set",
"(",
"ngrams_fn",
"(",
"s2",
",",
"n",
"="... | Returns the n-grams that match between two sequences
See also: SequenceMatcher.get_matching_blocks
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: | [
"Returns",
"the",
"n",
"-",
"grams",
"that",
"match",
"between",
"two",
"sequences"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L86-L101 | train |
SignalN/language | language/ngrams.py | char_matches | def char_matches(s1, s2, n=3):
"""
Character-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2,... | python | def char_matches(s1, s2, n=3):
"""
Character-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2,... | [
"def",
"char_matches",
"(",
"s1",
",",
"s2",
",",
"n",
"=",
"3",
")",
":",
"return",
"__matches",
"(",
"s1",
",",
"s2",
",",
"char_ngrams",
",",
"n",
"=",
"n",
")"
] | Character-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings | [
"Character",
"-",
"level",
"n",
"-",
"grams",
"that",
"match",
"between",
"two",
"strings"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L103-L115 | train |
SignalN/language | language/ngrams.py | word_matches | def word_matches(s1, s2, n=3):
"""
Word-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2, word... | python | def word_matches(s1, s2, n=3):
"""
Word-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2, word... | [
"def",
"word_matches",
"(",
"s1",
",",
"s2",
",",
"n",
"=",
"3",
")",
":",
"return",
"__matches",
"(",
"s1",
",",
"s2",
",",
"word_ngrams",
",",
"n",
"=",
"n",
")"
] | Word-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings | [
"Word",
"-",
"level",
"n",
"-",
"grams",
"that",
"match",
"between",
"two",
"strings"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L117-L129 | train |
SignalN/language | language/ngrams.py | __similarity | def __similarity(s1, s2, ngrams_fn, n=3):
"""
The fraction of n-grams matching between two sequences
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
float: the fraction of n-grams matching
"""
ngrams1, ngr... | python | def __similarity(s1, s2, ngrams_fn, n=3):
"""
The fraction of n-grams matching between two sequences
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
float: the fraction of n-grams matching
"""
ngrams1, ngr... | [
"def",
"__similarity",
"(",
"s1",
",",
"s2",
",",
"ngrams_fn",
",",
"n",
"=",
"3",
")",
":",
"ngrams1",
",",
"ngrams2",
"=",
"set",
"(",
"ngrams_fn",
"(",
"s1",
",",
"n",
"=",
"n",
")",
")",
",",
"set",
"(",
"ngrams_fn",
"(",
"s2",
",",
"n",
... | The fraction of n-grams matching between two sequences
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
float: the fraction of n-grams matching | [
"The",
"fraction",
"of",
"n",
"-",
"grams",
"matching",
"between",
"two",
"sequences"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L131-L145 | train |
markfinger/assembla | assembla/api.py | API._get_json | def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
"""
Base level method for fetching data from the API
"""
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not in (Space, Event):
... | python | def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
"""
Base level method for fetching data from the API
"""
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not in (Space, Event):
... | [
"def",
"_get_json",
"(",
"self",
",",
"model",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
",",
"get_all",
"=",
"None",
")",
":",
"if",
"space",
"is",
"None",
"and",
"model",
"not",
"in",
"(",
"Space",
... | Base level method for fetching data from the API | [
"Base",
"level",
"method",
"for",
"fetching",
"data",
"from",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L42-L112 | train |
markfinger/assembla | assembla/api.py | API._post_json | def _post_json(self, instance, space=None, rel_path=None, extra_params=None):
"""
Base level method for updating data via the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not i... | python | def _post_json(self, instance, space=None, rel_path=None, extra_params=None):
"""
Base level method for updating data via the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not i... | [
"def",
"_post_json",
"(",
"self",
",",
"instance",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
")",
":",
"model",
"=",
"type",
"(",
"instance",
")",
"if",
"space",
"is",
"None",
"and",
"model",
"not",
"i... | Base level method for updating data via the API | [
"Base",
"level",
"method",
"for",
"updating",
"data",
"via",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L114-L169 | train |
markfinger/assembla | assembla/api.py | API._put_json | def _put_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None):
"""
Base level method for adding new data to the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None ... | python | def _put_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None):
"""
Base level method for adding new data to the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None ... | [
"def",
"_put_json",
"(",
"self",
",",
"instance",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
",",
"id_field",
"=",
"None",
")",
":",
"model",
"=",
"type",
"(",
"instance",
")",
"if",
"space",
"is",
"Non... | Base level method for adding new data to the API | [
"Base",
"level",
"method",
"for",
"adding",
"new",
"data",
"to",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L171-L221 | train |
markfinger/assembla | assembla/api.py | API._delete_json | def _delete_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None, append_to_path=None):
"""
Base level method for removing data from the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
... | python | def _delete_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None, append_to_path=None):
"""
Base level method for removing data from the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
... | [
"def",
"_delete_json",
"(",
"self",
",",
"instance",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
",",
"id_field",
"=",
"None",
",",
"append_to_path",
"=",
"None",
")",
":",
"model",
"=",
"type",
"(",
"inst... | Base level method for removing data from the API | [
"Base",
"level",
"method",
"for",
"removing",
"data",
"from",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L223-L281 | train |
markfinger/assembla | assembla/api.py | API._bind_variables | def _bind_variables(self, instance, space):
"""
Bind related variables to the instance
"""
instance.api = self
if space:
instance.space = space
return instance | python | def _bind_variables(self, instance, space):
"""
Bind related variables to the instance
"""
instance.api = self
if space:
instance.space = space
return instance | [
"def",
"_bind_variables",
"(",
"self",
",",
"instance",
",",
"space",
")",
":",
"instance",
".",
"api",
"=",
"self",
"if",
"space",
":",
"instance",
".",
"space",
"=",
"space",
"return",
"instance"
] | Bind related variables to the instance | [
"Bind",
"related",
"variables",
"to",
"the",
"instance"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L283-L290 | train |
markfinger/assembla | assembla/api.py | Space.tickets | def tickets(self, extra_params=None):
"""
All Tickets in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
'report': 0, # Report 0 is all tickets
}
if extra_params:
params.update(extra_params)
... | python | def tickets(self, extra_params=None):
"""
All Tickets in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
'report': 0, # Report 0 is all tickets
}
if extra_params:
params.update(extra_params)
... | [
"def",
"tickets",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"'report'",
":",
"0",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params... | All Tickets in this Space | [
"All",
"Tickets",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L301-L321 | train |
markfinger/assembla | assembla/api.py | Space.milestones | def milestones(self, extra_params=None):
"""
All Milestones in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_... | python | def milestones(self, extra_params=None):
"""
All Milestones in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_... | [
"def",
"milestones",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params",
")",
"return",
"self",
... | All Milestones in this Space | [
"All",
"Milestones",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L324-L343 | train |
markfinger/assembla | assembla/api.py | Space.tools | def tools(self, extra_params=None):
""""
All Tools in this Space
"""
return self.api._get_json(
SpaceTool,
space=self,
rel_path=self._build_rel_path('space_tools'),
extra_params=extra_params,
) | python | def tools(self, extra_params=None):
""""
All Tools in this Space
"""
return self.api._get_json(
SpaceTool,
space=self,
rel_path=self._build_rel_path('space_tools'),
extra_params=extra_params,
) | [
"def",
"tools",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"SpaceTool",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'space_tools'",
")",
",",
... | All Tools in this Space | [
"All",
"Tools",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L346-L355 | train |
markfinger/assembla | assembla/api.py | Space.components | def components(self, extra_params=None):
""""
All components in this Space
"""
return self.api._get_json(
Component,
space=self,
rel_path=self._build_rel_path('ticket_components'),
extra_params=extra_params,
) | python | def components(self, extra_params=None):
""""
All components in this Space
"""
return self.api._get_json(
Component,
space=self,
rel_path=self._build_rel_path('ticket_components'),
extra_params=extra_params,
) | [
"def",
"components",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"Component",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'ticket_components'",
")"... | All components in this Space | [
"All",
"components",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L358-L367 | train |
markfinger/assembla | assembla/api.py | Space.users | def users(self, extra_params=None):
"""
All Users with access to this Space
"""
return self.api._get_json(
User,
space=self,
rel_path=self._build_rel_path('users'),
extra_params=extra_params,
) | python | def users(self, extra_params=None):
"""
All Users with access to this Space
"""
return self.api._get_json(
User,
space=self,
rel_path=self._build_rel_path('users'),
extra_params=extra_params,
) | [
"def",
"users",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"User",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'users'",
")",
",",
"extra_para... | All Users with access to this Space | [
"All",
"Users",
"with",
"access",
"to",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L370-L379 | train |
markfinger/assembla | assembla/api.py | Space.tags | def tags(self, extra_params=None):
""""
All Tags in this Space
"""
return self.api._get_json(
Tag,
space=self,
rel_path=self._build_rel_path('tags'),
extra_params=extra_params,
) | python | def tags(self, extra_params=None):
""""
All Tags in this Space
"""
return self.api._get_json(
Tag,
space=self,
rel_path=self._build_rel_path('tags'),
extra_params=extra_params,
) | [
"def",
"tags",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"Tag",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'tags'",
")",
",",
"extra_params"... | All Tags in this Space | [
"All",
"Tags",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L382-L391 | train |
markfinger/assembla | assembla/api.py | Space.wiki_pages | def wiki_pages(self, extra_params=None):
"""
All Wiki Pages with access to this Space
"""
return self.api._get_json(
WikiPage,
space=self,
rel_path=self._build_rel_path('wiki_pages'),
extra_params=extra_params,
) | python | def wiki_pages(self, extra_params=None):
"""
All Wiki Pages with access to this Space
"""
return self.api._get_json(
WikiPage,
space=self,
rel_path=self._build_rel_path('wiki_pages'),
extra_params=extra_params,
) | [
"def",
"wiki_pages",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"WikiPage",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'wiki_pages'",
")",
",",... | All Wiki Pages with access to this Space | [
"All",
"Wiki",
"Pages",
"with",
"access",
"to",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L394-L403 | train |
markfinger/assembla | assembla/api.py | Milestone.tickets | def tickets(self, extra_params=None):
"""
All Tickets which are a part of this Milestone
"""
return filter(
lambda ticket: ticket.get('milestone_id', None) == self['id'],
self.space.tickets(extra_params=extra_params)
) | python | def tickets(self, extra_params=None):
"""
All Tickets which are a part of this Milestone
"""
return filter(
lambda ticket: ticket.get('milestone_id', None) == self['id'],
self.space.tickets(extra_params=extra_params)
) | [
"def",
"tickets",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"filter",
"(",
"lambda",
"ticket",
":",
"ticket",
".",
"get",
"(",
"'milestone_id'",
",",
"None",
")",
"==",
"self",
"[",
"'id'",
"]",
",",
"self",
".",
"space",
"."... | All Tickets which are a part of this Milestone | [
"All",
"Tickets",
"which",
"are",
"a",
"part",
"of",
"this",
"Milestone"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L426-L433 | train |
markfinger/assembla | assembla/api.py | Ticket.tags | def tags(self, extra_params=None):
"""
All Tags in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Tag,
... | python | def tags(self, extra_params=None):
"""
All Tags in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Tag,
... | [
"def",
"tags",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params",
")",
"return",
"self",
".",... | All Tags in this Ticket | [
"All",
"Tags",
"in",
"this",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L438-L459 | train |
markfinger/assembla | assembla/api.py | Ticket.milestone | def milestone(self, extra_params=None):
"""
The Milestone that the Ticket is a part of
"""
if self.get('milestone_id', None):
milestones = self.space.milestones(id=self['milestone_id'], extra_params=extra_params)
if milestones:
return milestones[0] | python | def milestone(self, extra_params=None):
"""
The Milestone that the Ticket is a part of
"""
if self.get('milestone_id', None):
milestones = self.space.milestones(id=self['milestone_id'], extra_params=extra_params)
if milestones:
return milestones[0] | [
"def",
"milestone",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"get",
"(",
"'milestone_id'",
",",
"None",
")",
":",
"milestones",
"=",
"self",
".",
"space",
".",
"milestones",
"(",
"id",
"=",
"self",
"[",
"'milestone_id... | The Milestone that the Ticket is a part of | [
"The",
"Milestone",
"that",
"the",
"Ticket",
"is",
"a",
"part",
"of"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L462-L469 | train |
markfinger/assembla | assembla/api.py | Ticket.user | def user(self, extra_params=None):
"""
The User currently assigned to the Ticket
"""
if self.get('assigned_to_id', None):
users = self.space.users(
id=self['assigned_to_id'],
extra_params=extra_params
)
if users:
... | python | def user(self, extra_params=None):
"""
The User currently assigned to the Ticket
"""
if self.get('assigned_to_id', None):
users = self.space.users(
id=self['assigned_to_id'],
extra_params=extra_params
)
if users:
... | [
"def",
"user",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"get",
"(",
"'assigned_to_id'",
",",
"None",
")",
":",
"users",
"=",
"self",
".",
"space",
".",
"users",
"(",
"id",
"=",
"self",
"[",
"'assigned_to_id'",
"]",
... | The User currently assigned to the Ticket | [
"The",
"User",
"currently",
"assigned",
"to",
"the",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L471-L481 | train |
markfinger/assembla | assembla/api.py | Ticket.component | def component(self, extra_params=None):
"""
The Component currently assigned to the Ticket
"""
if self.get('component_id', None):
components = self.space.components(id=self['component_id'], extra_params=extra_params)
if components:
return component... | python | def component(self, extra_params=None):
"""
The Component currently assigned to the Ticket
"""
if self.get('component_id', None):
components = self.space.components(id=self['component_id'], extra_params=extra_params)
if components:
return component... | [
"def",
"component",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"get",
"(",
"'component_id'",
",",
"None",
")",
":",
"components",
"=",
"self",
".",
"space",
".",
"components",
"(",
"id",
"=",
"self",
"[",
"'component_id... | The Component currently assigned to the Ticket | [
"The",
"Component",
"currently",
"assigned",
"to",
"the",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L483-L490 | train |
markfinger/assembla | assembla/api.py | Ticket.comments | def comments(self, extra_params=None):
"""
All Comments in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Ticke... | python | def comments(self, extra_params=None):
"""
All Comments in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Ticke... | [
"def",
"comments",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params",
")",
"return",
"self",
... | All Comments in this Ticket | [
"All",
"Comments",
"in",
"this",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L493-L514 | train |
markfinger/assembla | assembla/api.py | Ticket.write | def write(self):
"""
Create or update the Ticket on Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can write it to Assembla.")
if self.get('number'): # Modifying an existing ticket
meth... | python | def write(self):
"""
Create or update the Ticket on Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can write it to Assembla.")
if self.get('number'): # Modifying an existing ticket
meth... | [
"def",
"write",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'space'",
")",
":",
"raise",
"AttributeError",
"(",
"\"A ticket must have a 'space' attribute before you can write it to Assembla.\"",
")",
"if",
"self",
".",
"get",
"(",
"'number'",
... | Create or update the Ticket on Assembla | [
"Create",
"or",
"update",
"the",
"Ticket",
"on",
"Assembla"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L517-L533 | train |
markfinger/assembla | assembla/api.py | Ticket.delete | def delete(self):
"""
Remove the Ticket from Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can remove it from Assembla.")
return self.space.api._delete_json(
self,
space=sel... | python | def delete(self):
"""
Remove the Ticket from Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can remove it from Assembla.")
return self.space.api._delete_json(
self,
space=sel... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'space'",
")",
":",
"raise",
"AttributeError",
"(",
"\"A ticket must have a 'space' attribute before you can remove it from Assembla.\"",
")",
"return",
"self",
".",
"space",
".",
"ap... | Remove the Ticket from Assembla | [
"Remove",
"the",
"Ticket",
"from",
"Assembla"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L535-L546 | train |
markfinger/assembla | assembla/api.py | User.tickets | def tickets(self, extra_params=None):
"""
A User's tickets across all available spaces
"""
tickets = []
for space in self.api.spaces():
tickets += filter(
lambda ticket: ticket.get('assigned_to_id', None) == self['id'],
space.tickets(ex... | python | def tickets(self, extra_params=None):
"""
A User's tickets across all available spaces
"""
tickets = []
for space in self.api.spaces():
tickets += filter(
lambda ticket: ticket.get('assigned_to_id', None) == self['id'],
space.tickets(ex... | [
"def",
"tickets",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"tickets",
"=",
"[",
"]",
"for",
"space",
"in",
"self",
".",
"api",
".",
"spaces",
"(",
")",
":",
"tickets",
"+=",
"filter",
"(",
"lambda",
"ticket",
":",
"ticket",
".",
"ge... | A User's tickets across all available spaces | [
"A",
"User",
"s",
"tickets",
"across",
"all",
"available",
"spaces"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L559-L569 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.