partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
load_ensembl_coverage
Load in Pageant CoverageDepth results with Ensembl loci. coverage_path is a path to Pageant CoverageDepth output directory, with one subdirectory per patient and a `cdf.csv` file inside each patient subdir. If min_normal_depth is 0, calculate tumor coverage. Otherwise, calculate join tumor/normal cove...
cohorts/variant_filters.py
def load_ensembl_coverage(cohort, coverage_path, min_tumor_depth, min_normal_depth=0, pageant_dir_fn=None): """ Load in Pageant CoverageDepth results with Ensembl loci. coverage_path is a path to Pageant CoverageDepth output directory, with one subdirectory per patient and a `...
def load_ensembl_coverage(cohort, coverage_path, min_tumor_depth, min_normal_depth=0, pageant_dir_fn=None): """ Load in Pageant CoverageDepth results with Ensembl loci. coverage_path is a path to Pageant CoverageDepth output directory, with one subdirectory per patient and a `...
[ "Load", "in", "Pageant", "CoverageDepth", "results", "with", "Ensembl", "loci", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_filters.py#L87-L160
[ "def", "load_ensembl_coverage", "(", "cohort", ",", "coverage_path", ",", "min_tumor_depth", ",", "min_normal_depth", "=", "0", ",", "pageant_dir_fn", "=", "None", ")", ":", "# Function to grab the pageant file name using the Patient", "if", "pageant_dir_fn", "is", "None"...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
vertical_percent
Using the size of the y axis, return a fraction of that size.
cohorts/plot.py
def vertical_percent(plot, percent=0.1): """ Using the size of the y axis, return a fraction of that size. """ plot_bottom, plot_top = plot.get_ylim() return percent * (plot_top - plot_bottom)
def vertical_percent(plot, percent=0.1): """ Using the size of the y axis, return a fraction of that size. """ plot_bottom, plot_top = plot.get_ylim() return percent * (plot_top - plot_bottom)
[ "Using", "the", "size", "of", "the", "y", "axis", "return", "a", "fraction", "of", "that", "size", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L24-L29
[ "def", "vertical_percent", "(", "plot", ",", "percent", "=", "0.1", ")", ":", "plot_bottom", ",", "plot_top", "=", "plot", ".", "get_ylim", "(", ")", "return", "percent", "*", "(", "plot_top", "-", "plot_bottom", ")" ]
278b05e609e6c4d4a77c57d49446460be53ea33e
train
hide_ticks
Hide tick values that are outside of [min_tick_value, max_tick_value]
cohorts/plot.py
def hide_ticks(plot, min_tick_value=None, max_tick_value=None): """Hide tick values that are outside of [min_tick_value, max_tick_value]""" for tick, tick_value in zip(plot.get_yticklabels(), plot.get_yticks()): tick_label = as_numeric(tick_value) if tick_label: if (min_tick_value is...
def hide_ticks(plot, min_tick_value=None, max_tick_value=None): """Hide tick values that are outside of [min_tick_value, max_tick_value]""" for tick, tick_value in zip(plot.get_yticklabels(), plot.get_yticks()): tick_label = as_numeric(tick_value) if tick_label: if (min_tick_value is...
[ "Hide", "tick", "values", "that", "are", "outside", "of", "[", "min_tick_value", "max_tick_value", "]" ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L37-L44
[ "def", "hide_ticks", "(", "plot", ",", "min_tick_value", "=", "None", ",", "max_tick_value", "=", "None", ")", ":", "for", "tick", ",", "tick_value", "in", "zip", "(", "plot", ".", "get_yticklabels", "(", ")", ",", "plot", ".", "get_yticks", "(", ")", ...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
add_significance_indicator
Add a p-value significance indicator.
cohorts/plot.py
def add_significance_indicator(plot, col_a=0, col_b=1, significant=False): """ Add a p-value significance indicator. """ plot_bottom, plot_top = plot.get_ylim() # Give the plot a little room for the significance indicator line_height = vertical_percent(plot, 0.1) # Add some extra spacing bel...
def add_significance_indicator(plot, col_a=0, col_b=1, significant=False): """ Add a p-value significance indicator. """ plot_bottom, plot_top = plot.get_ylim() # Give the plot a little room for the significance indicator line_height = vertical_percent(plot, 0.1) # Add some extra spacing bel...
[ "Add", "a", "p", "-", "value", "significance", "indicator", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L55-L70
[ "def", "add_significance_indicator", "(", "plot", ",", "col_a", "=", "0", ",", "col_b", "=", "1", ",", "significant", "=", "False", ")", ":", "plot_bottom", ",", "plot_top", "=", "plot", ".", "get_ylim", "(", ")", "# Give the plot a little room for the significa...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
stripboxplot
Overlay a stripplot on top of a boxplot.
cohorts/plot.py
def stripboxplot(x, y, data, ax=None, significant=None, **kwargs): """ Overlay a stripplot on top of a boxplot. """ ax = sb.boxplot( x=x, y=y, data=data, ax=ax, fliersize=0, **kwargs ) plot = sb.stripplot( x=x, y=y, data=da...
def stripboxplot(x, y, data, ax=None, significant=None, **kwargs): """ Overlay a stripplot on top of a boxplot. """ ax = sb.boxplot( x=x, y=y, data=data, ax=ax, fliersize=0, **kwargs ) plot = sb.stripplot( x=x, y=y, data=da...
[ "Overlay", "a", "stripplot", "on", "top", "of", "a", "boxplot", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L72-L100
[ "def", "stripboxplot", "(", "x", ",", "y", ",", "data", ",", "ax", "=", "None", ",", "significant", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ax", "=", "sb", ".", "boxplot", "(", "x", "=", "x", ",", "y", "=", "y", ",", "data", "=", "...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
fishers_exact_plot
Perform a Fisher's exact test to compare to binary columns Parameters ---------- data: Pandas dataframe Dataframe to retrieve information from condition1: str First binary column to compare (and used for test sidedness) condition2: str Second binary column to compare ...
cohorts/plot.py
def fishers_exact_plot(data, condition1, condition2, ax=None, condition1_value=None, alternative="two-sided", **kwargs): """ Perform a Fisher's exact test to compare to binary columns Parameters ---------- data: Pandas dataframe Dataframe to ret...
def fishers_exact_plot(data, condition1, condition2, ax=None, condition1_value=None, alternative="two-sided", **kwargs): """ Perform a Fisher's exact test to compare to binary columns Parameters ---------- data: Pandas dataframe Dataframe to ret...
[ "Perform", "a", "Fisher", "s", "exact", "test", "to", "compare", "to", "binary", "columns" ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L130-L182
[ "def", "fishers_exact_plot", "(", "data", ",", "condition1", ",", "condition2", ",", "ax", "=", "None", ",", "condition1_value", "=", "None", ",", "alternative", "=", "\"two-sided\"", ",", "*", "*", "kwargs", ")", ":", "plot", "=", "sb", ".", "barplot", ...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
mann_whitney_plot
Create a box plot comparing a condition and perform a Mann Whitney test to compare the distribution in condition A v B Parameters ---------- data: Pandas dataframe Dataframe to retrieve information from condition: str Column to use as the splitting criteria distribution: str ...
cohorts/plot.py
def mann_whitney_plot(data, condition, distribution, ax=None, condition_value=None, alternative="two-sided", skip_plot=False, **kwargs): """ Create a box plot...
def mann_whitney_plot(data, condition, distribution, ax=None, condition_value=None, alternative="two-sided", skip_plot=False, **kwargs): """ Create a box plot...
[ "Create", "a", "box", "plot", "comparing", "a", "condition", "and", "perform", "a", "Mann", "Whitney", "test", "to", "compare", "the", "distribution", "in", "condition", "A", "v", "B" ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L192-L253
[ "def", "mann_whitney_plot", "(", "data", ",", "condition", ",", "distribution", ",", "ax", "=", "None", ",", "condition_value", "=", "None", ",", "alternative", "=", "\"two-sided\"", ",", "skip_plot", "=", "False", ",", "*", "*", "kwargs", ")", ":", "condi...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
roc_curve_plot
Create a ROC curve and compute the bootstrap AUC for the given variable and outcome Parameters ---------- data : Pandas dataframe Dataframe to retrieve information from value_column : str Column to retrieve the values from outcome_column : str Column to use as the outcome va...
cohorts/plot.py
def roc_curve_plot(data, value_column, outcome_column, bootstrap_samples=100, ax=None): """Create a ROC curve and compute the bootstrap AUC for the given variable and outcome Parameters ---------- data : Pandas dataframe Dataframe to retrieve information from value_column : str Colu...
def roc_curve_plot(data, value_column, outcome_column, bootstrap_samples=100, ax=None): """Create a ROC curve and compute the bootstrap AUC for the given variable and outcome Parameters ---------- data : Pandas dataframe Dataframe to retrieve information from value_column : str Colu...
[ "Create", "a", "ROC", "curve", "and", "compute", "the", "bootstrap", "AUC", "for", "the", "given", "variable", "and", "outcome" ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L263-L308
[ "def", "roc_curve_plot", "(", "data", ",", "value_column", ",", "outcome_column", ",", "bootstrap_samples", "=", "100", ",", "ax", "=", "None", ")", ":", "scores", "=", "bootstrap_auc", "(", "df", "=", "data", ",", "col", "=", "value_column", ",", "pred_co...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
get_cache_dir
Return full cache_dir, according to following logic: - if cache_dir is a full path (per path.isabs), return that value - if not and if cache_root_dir is not None, join two paths - otherwise, log warnings and return None Separately, if args or kwargs are given, format cache_dir using kwargs
cohorts/utils.py
def get_cache_dir(cache_dir, cache_root_dir=None, *args, **kwargs): """ Return full cache_dir, according to following logic: - if cache_dir is a full path (per path.isabs), return that value - if not and if cache_root_dir is not None, join two paths - otherwise, log warnings and return N...
def get_cache_dir(cache_dir, cache_root_dir=None, *args, **kwargs): """ Return full cache_dir, according to following logic: - if cache_dir is a full path (per path.isabs), return that value - if not and if cache_root_dir is not None, join two paths - otherwise, log warnings and return N...
[ "Return", "full", "cache_dir", "according", "to", "following", "logic", ":", "-", "if", "cache_dir", "is", "a", "full", "path", "(", "per", "path", ".", "isabs", ")", "return", "that", "value", "-", "if", "not", "and", "if", "cache_root_dir", "is", "not"...
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L24-L41
[ "def", "get_cache_dir", "(", "cache_dir", ",", "cache_root_dir", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cache_dir", "=", "cache_dir", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "path", ".", "isabs...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
_strip_column_name
Utility script applying several regexs to a string. Intended to be used by `strip_column_names`. This function will: 1. replace informative punctuation components with text 2. (optionally) remove text within parentheses 3. replace remaining punctuation/whitespace with _ 4. strip...
cohorts/utils.py
def _strip_column_name(col_name, keep_paren_contents=True): """ Utility script applying several regexs to a string. Intended to be used by `strip_column_names`. This function will: 1. replace informative punctuation components with text 2. (optionally) remove text within parentheses ...
def _strip_column_name(col_name, keep_paren_contents=True): """ Utility script applying several regexs to a string. Intended to be used by `strip_column_names`. This function will: 1. replace informative punctuation components with text 2. (optionally) remove text within parentheses ...
[ "Utility", "script", "applying", "several", "regexs", "to", "a", "string", ".", "Intended", "to", "be", "used", "by", "strip_column_names", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L84-L142
[ "def", "_strip_column_name", "(", "col_name", ",", "keep_paren_contents", "=", "True", ")", ":", "# start with input", "new_col_name", "=", "col_name", "# replace meaningful punctuation with text equivalents", "# surround each with whitespace to enforce consistent use of _", "punctua...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
strip_column_names
Utility script for renaming pandas columns to patsy-friendly names. Revised names have been: - stripped of all punctuation and whitespace (converted to text or `_`) - converted to lower case Takes a list of column names, returns a dict mapping names to revised names. If there are any ...
cohorts/utils.py
def strip_column_names(cols, keep_paren_contents=True): """ Utility script for renaming pandas columns to patsy-friendly names. Revised names have been: - stripped of all punctuation and whitespace (converted to text or `_`) - converted to lower case Takes a list of column names, retur...
def strip_column_names(cols, keep_paren_contents=True): """ Utility script for renaming pandas columns to patsy-friendly names. Revised names have been: - stripped of all punctuation and whitespace (converted to text or `_`) - converted to lower case Takes a list of column names, retur...
[ "Utility", "script", "for", "renaming", "pandas", "columns", "to", "patsy", "-", "friendly", "names", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L144-L201
[ "def", "strip_column_names", "(", "cols", ",", "keep_paren_contents", "=", "True", ")", ":", "# strip/replace punctuation", "new_cols", "=", "[", "_strip_column_name", "(", "col", ",", "keep_paren_contents", "=", "keep_paren_contents", ")", "for", "col", "in", "cols...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
set_attributes
Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters.
cohorts/utils.py
def set_attributes(obj, additional_data): """ Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters. """ for key, value in additional_data.items(): if hasattr(obj, key): ...
def set_attributes(obj, additional_data): """ Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters. """ for key, value in additional_data.items(): if hasattr(obj, key): ...
[ "Given", "an", "object", "and", "a", "dictionary", "give", "the", "object", "new", "attributes", "from", "that", "dictionary", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L210-L219
[ "def", "set_attributes", "(", "obj", ",", "additional_data", ")", ":", "for", "key", ",", "value", "in", "additional_data", ".", "items", "(", ")", ":", "if", "hasattr", "(", "obj", ",", "key", ")", ":", "raise", "ValueError", "(", "\"Key %s in additional_...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
DataFrameHolder.return_obj
Construct a DataFrameHolder and then return either that or the DataFrame.
cohorts/utils.py
def return_obj(cols, df, return_cols=False): """Construct a DataFrameHolder and then return either that or the DataFrame.""" df_holder = DataFrameHolder(cols=cols, df=df) return df_holder.return_self(return_cols=return_cols)
def return_obj(cols, df, return_cols=False): """Construct a DataFrameHolder and then return either that or the DataFrame.""" df_holder = DataFrameHolder(cols=cols, df=df) return df_holder.return_self(return_cols=return_cols)
[ "Construct", "a", "DataFrameHolder", "and", "then", "return", "either", "that", "or", "the", "DataFrame", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L54-L57
[ "def", "return_obj", "(", "cols", ",", "df", ",", "return_cols", "=", "False", ")", ":", "df_holder", "=", "DataFrameHolder", "(", "cols", "=", "cols", ",", "df", "=", "df", ")", "return", "df_holder", ".", "return_self", "(", "return_cols", "=", "return...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
compare_provenance
Utility function to compare two abritrary provenance dicts returns number of discrepancies. Parameters ---------- this_provenance: provenance dict (to be compared to "other_provenance") other_provenance: comparison provenance dict (optional) left_outer_diff: description/prefix used when pr...
cohorts/provenance.py
def compare_provenance( this_provenance, other_provenance, left_outer_diff = "In current but not comparison", right_outer_diff = "In comparison but not current"): """Utility function to compare two abritrary provenance dicts returns number of discrepancies. Parameters ----------...
def compare_provenance( this_provenance, other_provenance, left_outer_diff = "In current but not comparison", right_outer_diff = "In comparison but not current"): """Utility function to compare two abritrary provenance dicts returns number of discrepancies. Parameters ----------...
[ "Utility", "function", "to", "compare", "two", "abritrary", "provenance", "dicts", "returns", "number", "of", "discrepancies", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/provenance.py#L22-L65
[ "def", "compare_provenance", "(", "this_provenance", ",", "other_provenance", ",", "left_outer_diff", "=", "\"In current but not comparison\"", ",", "right_outer_diff", "=", "\"In comparison but not current\"", ")", ":", "## if either this or other items is null, return 0", "if", ...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
_plot_kmf_single
Helper function to produce a single KM survival plot, among observations in df by groups defined by condition_col. All inputs are required - this function is intended to be called by `plot_kmf`.
cohorts/survival.py
def _plot_kmf_single(df, condition_col, survival_col, censor_col, threshold, title, xlabel, ylabel, ax, with_condition_color, ...
def _plot_kmf_single(df, condition_col, survival_col, censor_col, threshold, title, xlabel, ylabel, ax, with_condition_color, ...
[ "Helper", "function", "to", "produce", "a", "single", "KM", "survival", "plot", "among", "observations", "in", "df", "by", "groups", "defined", "by", "condition_col", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/survival.py#L31-L171
[ "def", "_plot_kmf_single", "(", "df", ",", "condition_col", ",", "survival_col", ",", "censor_col", ",", "threshold", ",", "title", ",", "xlabel", ",", "ylabel", ",", "ax", ",", "with_condition_color", ",", "no_condition_color", ",", "with_condition_label", ",", ...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
plot_kmf
Plot survival curves by splitting the dataset into two groups based on condition_col. Report results for a log-rank test (if two groups are plotted) or CoxPH survival analysis (if >2 groups) for association with survival. Regarding definition of groups: If condition_col is numeric, values are split...
cohorts/survival.py
def plot_kmf(df, condition_col, censor_col, survival_col, strata_col=None, threshold=None, title=None, xlabel=None, ylabel=None, ax=None, with_condition_color="#B38600", no_cond...
def plot_kmf(df, condition_col, censor_col, survival_col, strata_col=None, threshold=None, title=None, xlabel=None, ylabel=None, ax=None, with_condition_color="#B38600", no_cond...
[ "Plot", "survival", "curves", "by", "splitting", "the", "dataset", "into", "two", "groups", "based", "on", "condition_col", ".", "Report", "results", "for", "a", "log", "-", "rank", "test", "(", "if", "two", "groups", "are", "plotted", ")", "or", "CoxPH", ...
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/survival.py#L174-L307
[ "def", "plot_kmf", "(", "df", ",", "condition_col", ",", "censor_col", ",", "survival_col", ",", "strata_col", "=", "None", ",", "threshold", "=", "None", ",", "title", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", "=", "None", ",", "ax", "="...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
FormattedText.concat
:type formatted_text: FormattedText
bot/action/util/textformat.py
def concat(self, formatted_text): """:type formatted_text: FormattedText""" assert self._is_compatible(formatted_text), "Cannot concat text with different modes" self.text += formatted_text.text return self
def concat(self, formatted_text): """:type formatted_text: FormattedText""" assert self._is_compatible(formatted_text), "Cannot concat text with different modes" self.text += formatted_text.text return self
[ ":", "type", "formatted_text", ":", "FormattedText" ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/textformat.py#L42-L46
[ "def", "concat", "(", "self", ",", "formatted_text", ")", ":", "assert", "self", ".", "_is_compatible", "(", "formatted_text", ")", ",", "\"Cannot concat text with different modes\"", "self", ".", "text", "+=", "formatted_text", ".", "text", "return", "self" ]
7b597a415c1901901c677976cb13100fc3083107
train
FormattedText.join
:type formatted_texts: list[FormattedText]
bot/action/util/textformat.py
def join(self, formatted_texts): """:type formatted_texts: list[FormattedText]""" formatted_texts = list(formatted_texts) # so that after the first iteration elements are not lost if generator for formatted_text in formatted_texts: assert self._is_compatible(formatted_text), "Cannot...
def join(self, formatted_texts): """:type formatted_texts: list[FormattedText]""" formatted_texts = list(formatted_texts) # so that after the first iteration elements are not lost if generator for formatted_text in formatted_texts: assert self._is_compatible(formatted_text), "Cannot...
[ ":", "type", "formatted_texts", ":", "list", "[", "FormattedText", "]" ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/textformat.py#L48-L54
[ "def", "join", "(", "self", ",", "formatted_texts", ")", ":", "formatted_texts", "=", "list", "(", "formatted_texts", ")", "# so that after the first iteration elements are not lost if generator", "for", "formatted_text", "in", "formatted_texts", ":", "assert", "self", "....
7b597a415c1901901c677976cb13100fc3083107
train
FormattedTextStringFormat.concat
:type args: FormattedText :type kwargs: FormattedText
bot/action/util/textformat.py
def concat(self, *args, **kwargs): """ :type args: FormattedText :type kwargs: FormattedText """ for arg in args: assert self.formatted_text._is_compatible(arg), "Cannot concat text with different modes" self.format_args.append(arg.text) for kwarg ...
def concat(self, *args, **kwargs): """ :type args: FormattedText :type kwargs: FormattedText """ for arg in args: assert self.formatted_text._is_compatible(arg), "Cannot concat text with different modes" self.format_args.append(arg.text) for kwarg ...
[ ":", "type", "args", ":", "FormattedText", ":", "type", "kwargs", ":", "FormattedText" ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/textformat.py#L251-L263
[ "def", "concat", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "assert", "self", ".", "formatted_text", ".", "_is_compatible", "(", "arg", ")", ",", "\"Cannot concat text with different modes\"", "self", ...
7b597a415c1901901c677976cb13100fc3083107
train
random_cohort
Parameters ---------- min_random_variants: optional, int Minimum number of random variants to be generated per patient. max_random_variants: optional, int Maximum number of random variants to be generated per patient.
cohorts/random.py
def random_cohort(size, cache_dir, data_dir=None, min_random_variants=None, max_random_variants=None, seed_val=1234): """ Parameters ---------- min_random_variants: optional, int Minimum number of random variants to be generated per patient. ...
def random_cohort(size, cache_dir, data_dir=None, min_random_variants=None, max_random_variants=None, seed_val=1234): """ Parameters ---------- min_random_variants: optional, int Minimum number of random variants to be generated per patient. ...
[ "Parameters", "----------", "min_random_variants", ":", "optional", "int", "Minimum", "number", "of", "random", "variants", "to", "be", "generated", "per", "patient", ".", "max_random_variants", ":", "optional", "int", "Maximum", "number", "of", "random", "variants"...
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/random.py#L24-L75
[ "def", "random_cohort", "(", "size", ",", "cache_dir", ",", "data_dir", "=", "None", ",", "min_random_variants", "=", "None", ",", "max_random_variants", "=", "None", ",", "seed_val", "=", "1234", ")", ":", "seed", "(", "seed_val", ")", "d", "=", "{", "}...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
generate_random_missense_variants
Generate a random collection of missense variants by trying random variants repeatedly.
cohorts/random.py
def generate_random_missense_variants(num_variants=10, max_search=100000, reference="GRCh37"): """ Generate a random collection of missense variants by trying random variants repeatedly. """ variants = [] for i in range(max_search): bases = ["A", "C", "T", "G"] random_ref = choice(ba...
def generate_random_missense_variants(num_variants=10, max_search=100000, reference="GRCh37"): """ Generate a random collection of missense variants by trying random variants repeatedly. """ variants = [] for i in range(max_search): bases = ["A", "C", "T", "G"] random_ref = choice(ba...
[ "Generate", "a", "random", "collection", "of", "missense", "variants", "by", "trying", "random", "variants", "repeatedly", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/random.py#L77-L100
[ "def", "generate_random_missense_variants", "(", "num_variants", "=", "10", ",", "max_search", "=", "100000", ",", "reference", "=", "\"GRCh37\"", ")", ":", "variants", "=", "[", "]", "for", "i", "in", "range", "(", "max_search", ")", ":", "bases", "=", "[...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
generate_simple_vcf
Output a very simple metadata-free VCF for each variant in a variant_collection.
cohorts/random.py
def generate_simple_vcf(filename, variant_collection): """ Output a very simple metadata-free VCF for each variant in a variant_collection. """ contigs = [] positions = [] refs = [] alts = [] for variant in variant_collection: contigs.append("chr" + variant.contig) positi...
def generate_simple_vcf(filename, variant_collection): """ Output a very simple metadata-free VCF for each variant in a variant_collection. """ contigs = [] positions = [] refs = [] alts = [] for variant in variant_collection: contigs.append("chr" + variant.contig) positi...
[ "Output", "a", "very", "simple", "metadata", "-", "free", "VCF", "for", "each", "variant", "in", "a", "variant_collection", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/random.py#L102-L140
[ "def", "generate_simple_vcf", "(", "filename", ",", "variant_collection", ")", ":", "contigs", "=", "[", "]", "positions", "=", "[", "]", "refs", "=", "[", "]", "alts", "=", "[", "]", "for", "variant", "in", "variant_collection", ":", "contigs", ".", "ap...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
SFTPServerInterface.list_folder
Looks up folder contents of `path.`
mockssh/sftp.py
def list_folder(self, path): """Looks up folder contents of `path.`""" # Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70 try: folder_contents = [] for f in os.listdir(path): attr = paramiko.SFTPAttributes.from_sta...
def list_folder(self, path): """Looks up folder contents of `path.`""" # Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70 try: folder_contents = [] for f in os.listdir(path): attr = paramiko.SFTPAttributes.from_sta...
[ "Looks", "up", "folder", "contents", "of", "path", "." ]
carletes/mock-ssh-server
python
https://github.com/carletes/mock-ssh-server/blob/0d724ad4a43bafcb6a4bbe28b52383528f3460cc/mockssh/sftp.py#L142-L153
[ "def", "list_folder", "(", "self", ",", "path", ")", ":", "# Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70", "try", ":", "folder_contents", "=", "[", "]", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "at...
0d724ad4a43bafcb6a4bbe28b52383528f3460cc
train
filter_variants
Filter variants from the Variant Collection Parameters ---------- variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn: function Takes a FilterableVariant and returns a boolean. Only variants returning True are preserved. Returns ------- varcode.Va...
cohorts/varcode_utils.py
def filter_variants(variant_collection, patient, filter_fn, **kwargs): """Filter variants from the Variant Collection Parameters ---------- variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn: function Takes a FilterableVariant and returns a boolean. Only ...
def filter_variants(variant_collection, patient, filter_fn, **kwargs): """Filter variants from the Variant Collection Parameters ---------- variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn: function Takes a FilterableVariant and returns a boolean. Only ...
[ "Filter", "variants", "from", "the", "Variant", "Collection" ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/varcode_utils.py#L79-L105
[ "def", "filter_variants", "(", "variant_collection", ",", "patient", ",", "filter_fn", ",", "*", "*", "kwargs", ")", ":", "if", "filter_fn", ":", "return", "variant_collection", ".", "clone_with_new_elements", "(", "[", "variant", "for", "variant", "in", "varian...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
filter_effects
Filter variants from the Effect Collection Parameters ---------- effect_collection : varcode.EffectCollection variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn : function Takes a FilterableEffect and returns a boolean. Only effects returning True are pre...
cohorts/varcode_utils.py
def filter_effects(effect_collection, variant_collection, patient, filter_fn, all_effects, **kwargs): """Filter variants from the Effect Collection Parameters ---------- effect_collection : varcode.EffectCollection variant_collection : varcode.VariantCollection patient : cohorts.Patient fil...
def filter_effects(effect_collection, variant_collection, patient, filter_fn, all_effects, **kwargs): """Filter variants from the Effect Collection Parameters ---------- effect_collection : varcode.EffectCollection variant_collection : varcode.VariantCollection patient : cohorts.Patient fil...
[ "Filter", "variants", "from", "the", "Effect", "Collection" ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/varcode_utils.py#L107-L157
[ "def", "filter_effects", "(", "effect_collection", ",", "variant_collection", ",", "patient", ",", "filter_fn", ",", "all_effects", ",", "*", "*", "kwargs", ")", ":", "def", "top_priority_maybe", "(", "effect_collection", ")", ":", "\"\"\"\n Always (unless all_...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
count_lines_in
Count lines in a file
src/timelog/lib.py
def count_lines_in(filename): "Count lines in a file" f = open(filename) lines = 0 buf_size = 1024 * 1024 read_f = f.read # loop optimization buf = read_f(buf_size) while buf: lines += buf.count('\n') buf = read_f(buf_size) return lines
def count_lines_in(filename): "Count lines in a file" f = open(filename) lines = 0 buf_size = 1024 * 1024 read_f = f.read # loop optimization buf = read_f(buf_size) while buf: lines += buf.count('\n') buf = read_f(buf_size) return lines
[ "Count", "lines", "in", "a", "file" ]
garethr/django-timelog
python
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L16-L28
[ "def", "count_lines_in", "(", "filename", ")", ":", "f", "=", "open", "(", "filename", ")", "lines", "=", "0", "buf_size", "=", "1024", "*", "1024", "read_f", "=", "f", ".", "read", "# loop optimization", "buf", "=", "read_f", "(", "buf_size", ")", "wh...
84c7015248a82faccb9d3fe4e6014645cc9ec103
train
view_name_from
Resolve a path to the full python module name of the related view function
src/timelog/lib.py
def view_name_from(path): "Resolve a path to the full python module name of the related view function" try: return CACHED_VIEWS[path] except KeyError: view = resolve(path) module = path name = '' if hasattr(view.func, '__module__'): module = resol...
def view_name_from(path): "Resolve a path to the full python module name of the related view function" try: return CACHED_VIEWS[path] except KeyError: view = resolve(path) module = path name = '' if hasattr(view.func, '__module__'): module = resol...
[ "Resolve", "a", "path", "to", "the", "full", "python", "module", "name", "of", "the", "related", "view", "function" ]
garethr/django-timelog
python
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L30-L46
[ "def", "view_name_from", "(", "path", ")", ":", "try", ":", "return", "CACHED_VIEWS", "[", "path", "]", "except", "KeyError", ":", "view", "=", "resolve", "(", "path", ")", "module", "=", "path", "name", "=", "''", "if", "hasattr", "(", "view", ".", ...
84c7015248a82faccb9d3fe4e6014645cc9ec103
train
generate_table_from
Output a nicely formatted ascii table
src/timelog/lib.py
def generate_table_from(data): "Output a nicely formatted ascii table" table = Texttable(max_width=120) table.add_row(["view", "method", "status", "count", "minimum", "maximum", "mean", "stdev", "queries", "querytime"]) table.set_cols_align(["l", "l", "l", "r", "r", "r", "r", "r", "r", "r"]) for i...
def generate_table_from(data): "Output a nicely formatted ascii table" table = Texttable(max_width=120) table.add_row(["view", "method", "status", "count", "minimum", "maximum", "mean", "stdev", "queries", "querytime"]) table.set_cols_align(["l", "l", "l", "r", "r", "r", "r", "r", "r", "r"]) for i...
[ "Output", "a", "nicely", "formatted", "ascii", "table" ]
garethr/django-timelog
python
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L48-L70
[ "def", "generate_table_from", "(", "data", ")", ":", "table", "=", "Texttable", "(", "max_width", "=", "120", ")", "table", ".", "add_row", "(", "[", "\"view\"", ",", "\"method\"", ",", "\"status\"", ",", "\"count\"", ",", "\"minimum\"", ",", "\"maximum\"", ...
84c7015248a82faccb9d3fe4e6014645cc9ec103
train
analyze_log_file
Given a log file and regex group and extract the performance data
src/timelog/lib.py
def analyze_log_file(logfile, pattern, reverse_paths=True, progress=True): "Given a log file and regex group and extract the performance data" if progress: lines = count_lines_in(logfile) pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=lines+1).start() counter = 0 data ...
def analyze_log_file(logfile, pattern, reverse_paths=True, progress=True): "Given a log file and regex group and extract the performance data" if progress: lines = count_lines_in(logfile) pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=lines+1).start() counter = 0 data ...
[ "Given", "a", "log", "file", "and", "regex", "group", "and", "extract", "the", "performance", "data" ]
garethr/django-timelog
python
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L72-L132
[ "def", "analyze_log_file", "(", "logfile", ",", "pattern", ",", "reverse_paths", "=", "True", ",", "progress", "=", "True", ")", ":", "if", "progress", ":", "lines", "=", "count_lines_in", "(", "logfile", ")", "pbar", "=", "ProgressBar", "(", "widgets", "=...
84c7015248a82faccb9d3fe4e6014645cc9ec103
train
Collection.to_string
Create a string representation of this collection, showing up to `limit` items.
cohorts/collection.py
def to_string(self, limit=None): """ Create a string representation of this collection, showing up to `limit` items. """ header = self.short_string() if len(self) == 0: return header contents = "" element_lines = [ " -- %s" % (elem...
def to_string(self, limit=None): """ Create a string representation of this collection, showing up to `limit` items. """ header = self.short_string() if len(self) == 0: return header contents = "" element_lines = [ " -- %s" % (elem...
[ "Create", "a", "string", "representation", "of", "this", "collection", "showing", "up", "to", "limit", "items", "." ]
hammerlab/cohorts
python
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/collection.py#L29-L46
[ "def", "to_string", "(", "self", ",", "limit", "=", "None", ")", ":", "header", "=", "self", ".", "short_string", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "header", "contents", "=", "\"\"", "element_lines", "=", "[", "\" --...
278b05e609e6c4d4a77c57d49446460be53ea33e
train
UserStorageHandler.get_instance
:rtype: UserStorageHandler
bot/action/standard/userinfo.py
def get_instance(cls, state): """:rtype: UserStorageHandler""" if cls.instance is None: cls.instance = UserStorageHandler(state) return cls.instance
def get_instance(cls, state): """:rtype: UserStorageHandler""" if cls.instance is None: cls.instance = UserStorageHandler(state) return cls.instance
[ ":", "rtype", ":", "UserStorageHandler" ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/userinfo.py#L26-L30
[ "def", "get_instance", "(", "cls", ",", "state", ")", ":", "if", "cls", ".", "instance", "is", "None", ":", "cls", ".", "instance", "=", "UserStorageHandler", "(", "state", ")", "return", "cls", ".", "instance" ]
7b597a415c1901901c677976cb13100fc3083107
train
WorkersAction._get_active_threads_names
May contain sensitive info (like user ids). Use with care.
bot/action/standard/benchmark.py
def _get_active_threads_names(): """May contain sensitive info (like user ids). Use with care.""" active_threads = threading.enumerate() return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=thread.name).end_format() ...
def _get_active_threads_names(): """May contain sensitive info (like user ids). Use with care.""" active_threads = threading.enumerate() return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=thread.name).end_format() ...
[ "May", "contain", "sensitive", "info", "(", "like", "user", "ids", ")", ".", "Use", "with", "care", "." ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/benchmark.py#L164-L172
[ "def", "_get_active_threads_names", "(", ")", ":", "active_threads", "=", "threading", ".", "enumerate", "(", ")", "return", "FormattedText", "(", ")", ".", "join", "(", "[", "FormattedText", "(", ")", ".", "newline", "(", ")", ".", "normal", "(", "\" - {n...
7b597a415c1901901c677976cb13100fc3083107
train
WorkersAction._get_running_workers_names
May contain sensitive info (like user ids). Use with care.
bot/action/standard/benchmark.py
def _get_running_workers_names(running_workers: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker i...
def _get_running_workers_names(running_workers: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker i...
[ "May", "contain", "sensitive", "info", "(", "like", "user", "ids", ")", ".", "Use", "with", "care", "." ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/benchmark.py#L187-L194
[ "def", "_get_running_workers_names", "(", "running_workers", ":", "list", ")", ":", "return", "FormattedText", "(", ")", ".", "join", "(", "[", "FormattedText", "(", ")", ".", "newline", "(", ")", ".", "normal", "(", "\" - {name}\"", ")", ".", "start_format"...
7b597a415c1901901c677976cb13100fc3083107
train
WorkersAction._get_worker_pools_names
May contain sensitive info (like user ids). Use with care.
bot/action/standard/benchmark.py
def _get_worker_pools_names(worker_pools: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker in work...
def _get_worker_pools_names(worker_pools: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker in work...
[ "May", "contain", "sensitive", "info", "(", "like", "user", "ids", ")", ".", "Use", "with", "care", "." ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/benchmark.py#L209-L216
[ "def", "_get_worker_pools_names", "(", "worker_pools", ":", "list", ")", ":", "return", "FormattedText", "(", ")", ".", "join", "(", "[", "FormattedText", "(", ")", ".", "newline", "(", ")", ".", "normal", "(", "\" - {name}\"", ")", ".", "start_format", "(...
7b597a415c1901901c677976cb13100fc3083107
train
UserInfoFormatter.format
:param member_info: If True, adds also chat member info. Please, note that this additional info requires to make ONE api call.
bot/action/standard/info/formatter/user.py
def format(self, member_info: bool = False): """ :param member_info: If True, adds also chat member info. Please, note that this additional info requires to make ONE api call. """ user = self.api_object self.__format_user(user) if member_info and self.chat.typ...
def format(self, member_info: bool = False): """ :param member_info: If True, adds also chat member info. Please, note that this additional info requires to make ONE api call. """ user = self.api_object self.__format_user(user) if member_info and self.chat.typ...
[ ":", "param", "member_info", ":", "If", "True", "adds", "also", "chat", "member", "info", ".", "Please", "note", "that", "this", "additional", "info", "requires", "to", "make", "ONE", "api", "call", "." ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/info/formatter/user.py#L19-L28
[ "def", "format", "(", "self", ",", "member_info", ":", "bool", "=", "False", ")", ":", "user", "=", "self", ".", "api_object", "self", ".", "__format_user", "(", "user", ")", "if", "member_info", "and", "self", ".", "chat", ".", "type", "!=", "CHAT_TYP...
7b597a415c1901901c677976cb13100fc3083107
train
UpdatesProcessor.safe_log_error
Log error failing silently on error
bot/bot.py
def safe_log_error(self, error: Exception, *info: str): """Log error failing silently on error""" self.__do_safe(lambda: self.logger.error(error, *info))
def safe_log_error(self, error: Exception, *info: str): """Log error failing silently on error""" self.__do_safe(lambda: self.logger.error(error, *info))
[ "Log", "error", "failing", "silently", "on", "error" ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/bot.py#L173-L175
[ "def", "safe_log_error", "(", "self", ",", "error", ":", "Exception", ",", "*", "info", ":", "str", ")", ":", "self", ".", "__do_safe", "(", "lambda", ":", "self", ".", "logger", ".", "error", "(", "error", ",", "*", "info", ")", ")" ]
7b597a415c1901901c677976cb13100fc3083107
train
UpdatesProcessor.safe_log_info
Log info failing silently on error
bot/bot.py
def safe_log_info(self, *info: str): """Log info failing silently on error""" self.__do_safe(lambda: self.logger.info(*info))
def safe_log_info(self, *info: str): """Log info failing silently on error""" self.__do_safe(lambda: self.logger.info(*info))
[ "Log", "info", "failing", "silently", "on", "error" ]
alvarogzp/telegram-bot-framework
python
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/bot.py#L177-L179
[ "def", "safe_log_info", "(", "self", ",", "*", "info", ":", "str", ")", ":", "self", ".", "__do_safe", "(", "lambda", ":", "self", ".", "logger", ".", "info", "(", "*", "info", ")", ")" ]
7b597a415c1901901c677976cb13100fc3083107
train
wald_wolfowitz
implements the wald-wolfowitz runs test: http://en.wikipedia.org/wiki/Wald-Wolfowitz_runs_test http://support.sas.com/kb/33/092.html :param sequence: any iterable with at most 2 values. e.g. '1001001' [1, 0, 1, 0, 1] 'abaaabbba' :rtype: a ...
skidmarks.py
def wald_wolfowitz(sequence): """ implements the wald-wolfowitz runs test: http://en.wikipedia.org/wiki/Wald-Wolfowitz_runs_test http://support.sas.com/kb/33/092.html :param sequence: any iterable with at most 2 values. e.g. '1001001' [1, 0, 1, 0, 1] ...
def wald_wolfowitz(sequence): """ implements the wald-wolfowitz runs test: http://en.wikipedia.org/wiki/Wald-Wolfowitz_runs_test http://support.sas.com/kb/33/092.html :param sequence: any iterable with at most 2 values. e.g. '1001001' [1, 0, 1, 0, 1] ...
[ "implements", "the", "wald", "-", "wolfowitz", "runs", "test", ":", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Wald", "-", "Wolfowitz_runs_test", "http", ":", "//", "support", ".", "sas", ".", "com", "/", "kb", "/", "33...
brentp/skidmarks
python
https://github.com/brentp/skidmarks/blob/f63b9f1b822cb47991215b655155b5041e86ea39/skidmarks.py#L51-L99
[ "def", "wald_wolfowitz", "(", "sequence", ")", ":", "R", "=", "n_runs", "=", "sum", "(", "1", "for", "s", "in", "groupby", "(", "sequence", ",", "lambda", "a", ":", "a", ")", ")", "n", "=", "float", "(", "sum", "(", "1", "for", "s", "in", "sequ...
f63b9f1b822cb47991215b655155b5041e86ea39
train
auto_correlation
test for the autocorrelation of a sequence between t and t - 1 as the 'auto_correlation' it is less likely that the sequence is generated randomly. :param sequence: any iterable with at most 2 values that can be turned into a float via np.float . e.g. '1001001' ...
skidmarks.py
def auto_correlation(sequence): """ test for the autocorrelation of a sequence between t and t - 1 as the 'auto_correlation' it is less likely that the sequence is generated randomly. :param sequence: any iterable with at most 2 values that can be turned into a float via np.floa...
def auto_correlation(sequence): """ test for the autocorrelation of a sequence between t and t - 1 as the 'auto_correlation' it is less likely that the sequence is generated randomly. :param sequence: any iterable with at most 2 values that can be turned into a float via np.floa...
[ "test", "for", "the", "autocorrelation", "of", "a", "sequence", "between", "t", "and", "t", "-", "1", "as", "the", "auto_correlation", "it", "is", "less", "likely", "that", "the", "sequence", "is", "generated", "randomly", ".", ":", "param", "sequence", ":...
brentp/skidmarks
python
https://github.com/brentp/skidmarks/blob/f63b9f1b822cb47991215b655155b5041e86ea39/skidmarks.py#L102-L129
[ "def", "auto_correlation", "(", "sequence", ")", ":", "if", "isinstance", "(", "sequence", ",", "basestring", ")", ":", "sequence", "=", "map", "(", "int", ",", "sequence", ")", "seq", "=", "np", ".", "array", "(", "list", "(", "sequence", ")", ",", ...
f63b9f1b822cb47991215b655155b5041e86ea39
train
_parse_header_links
Parse the links from a Link: header field. .. todo:: Links with the same relation collide at the moment. :param bytes value: The header value. :rtype: `dict` :return: A dictionary of parsed links, keyed by ``rel`` or ``url``.
src/txacme/client.py
def _parse_header_links(response): """ Parse the links from a Link: header field. .. todo:: Links with the same relation collide at the moment. :param bytes value: The header value. :rtype: `dict` :return: A dictionary of parsed links, keyed by ``rel`` or ``url``. """ values = respon...
def _parse_header_links(response): """ Parse the links from a Link: header field. .. todo:: Links with the same relation collide at the moment. :param bytes value: The header value. :rtype: `dict` :return: A dictionary of parsed links, keyed by ``rel`` or ``url``. """ values = respon...
[ "Parse", "the", "links", "from", "a", "Link", ":", "header", "field", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L37-L69
[ "def", "_parse_header_links", "(", "response", ")", ":", "values", "=", "response", ".", "headers", ".", "getRawHeaders", "(", "b'link'", ",", "[", "b''", "]", ")", "value", "=", "b','", ".", "join", "(", "values", ")", ".", "decode", "(", "'ascii'", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_default_client
Make a client if we didn't get one.
src/txacme/client.py
def _default_client(jws_client, reactor, key, alg): """ Make a client if we didn't get one. """ if jws_client is None: pool = HTTPConnectionPool(reactor) agent = Agent(reactor, pool=pool) jws_client = JWSClient(HTTPClient(agent=agent), key, alg) return jws_client
def _default_client(jws_client, reactor, key, alg): """ Make a client if we didn't get one. """ if jws_client is None: pool = HTTPConnectionPool(reactor) agent = Agent(reactor, pool=pool) jws_client = JWSClient(HTTPClient(agent=agent), key, alg) return jws_client
[ "Make", "a", "client", "if", "we", "didn", "t", "get", "one", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L72-L80
[ "def", "_default_client", "(", "jws_client", ",", "reactor", ",", "key", ",", "alg", ")", ":", "if", "jws_client", "is", "None", ":", "pool", "=", "HTTPConnectionPool", "(", "reactor", ")", "agent", "=", "Agent", "(", "reactor", ",", "pool", "=", "pool",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_find_supported_challenge
Find a challenge combination that consists of a single challenge that the responder can satisfy. :param ~acme.messages.AuthorizationResource auth: The authorization to examine. :type responder: List[`~txacme.interfaces.IResponder`] :param responder: The possible responders to use. :raises...
src/txacme/client.py
def _find_supported_challenge(authzr, responders): """ Find a challenge combination that consists of a single challenge that the responder can satisfy. :param ~acme.messages.AuthorizationResource auth: The authorization to examine. :type responder: List[`~txacme.interfaces.IResponder`] ...
def _find_supported_challenge(authzr, responders): """ Find a challenge combination that consists of a single challenge that the responder can satisfy. :param ~acme.messages.AuthorizationResource auth: The authorization to examine. :type responder: List[`~txacme.interfaces.IResponder`] ...
[ "Find", "a", "challenge", "combination", "that", "consists", "of", "a", "single", "challenge", "that", "the", "responder", "can", "satisfy", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L505-L531
[ "def", "_find_supported_challenge", "(", "authzr", ",", "responders", ")", ":", "matches", "=", "[", "(", "responder", ",", "challbs", "[", "0", "]", ")", "for", "challbs", "in", "authzr", ".", "body", ".", "resolved_combinations", "for", "responder", "in", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
answer_challenge
Complete an authorization using a responder. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param .Client client: The ACME client. :type responders: List[`~txacme.interfaces.IResponder`] :param responders: A list of responders that can be used to complete the...
src/txacme/client.py
def answer_challenge(authzr, client, responders): """ Complete an authorization using a responder. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param .Client client: The ACME client. :type responders: List[`~txacme.interfaces.IResponder`] :param res...
def answer_challenge(authzr, client, responders): """ Complete an authorization using a responder. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param .Client client: The ACME client. :type responders: List[`~txacme.interfaces.IResponder`] :param res...
[ "Complete", "an", "authorization", "using", "a", "responder", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L534-L565
[ "def", "answer_challenge", "(", "authzr", ",", "client", ",", "responders", ")", ":", "responder", ",", "challb", "=", "_find_supported_challenge", "(", "authzr", ",", "responders", ")", "response", "=", "challb", ".", "response", "(", "client", ".", "key", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
poll_until_valid
Poll an authorization until it is in a state other than pending or processing. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param clock: The ``IReactorTime`` implementation to use; usually the reactor, when not testing. :param .Client client: The ACM...
src/txacme/client.py
def poll_until_valid(authzr, clock, client, timeout=300.0): """ Poll an authorization until it is in a state other than pending or processing. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param clock: The ``IReactorTime`` implementation to use; usually t...
def poll_until_valid(authzr, clock, client, timeout=300.0): """ Poll an authorization until it is in a state other than pending or processing. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param clock: The ``IReactorTime`` implementation to use; usually t...
[ "Poll", "an", "authorization", "until", "it", "is", "in", "a", "state", "other", "than", "pending", "or", "processing", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L568-L609
[ "def", "poll_until_valid", "(", "authzr", ",", "clock", ",", "client", ",", "timeout", "=", "300.0", ")", ":", "def", "repoll", "(", "result", ")", ":", "authzr", ",", "retry_after", "=", "result", "if", "authzr", ".", "body", ".", "status", "in", "{",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.from_url
Construct a client from an ACME directory at a given URL. :param url: The ``twisted.python.url.URL`` to fetch the directory from. See `txacme.urls` for constants for various well-known public directories. :param reactor: The Twisted reactor to use. :param ~josepy.jwk.JWK...
src/txacme/client.py
def from_url(cls, reactor, url, key, alg=RS256, jws_client=None): """ Construct a client from an ACME directory at a given URL. :param url: The ``twisted.python.url.URL`` to fetch the directory from. See `txacme.urls` for constants for various well-known public directori...
def from_url(cls, reactor, url, key, alg=RS256, jws_client=None): """ Construct a client from an ACME directory at a given URL. :param url: The ``twisted.python.url.URL`` to fetch the directory from. See `txacme.urls` for constants for various well-known public directori...
[ "Construct", "a", "client", "from", "an", "ACME", "directory", "at", "a", "given", "URL", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L109-L138
[ "def", "from_url", "(", "cls", ",", "reactor", ",", "url", ",", "key", ",", "alg", "=", "RS256", ",", "jws_client", "=", "None", ")", ":", "action", "=", "LOG_ACME_CONSUME_DIRECTORY", "(", "url", "=", "url", ",", "key_type", "=", "key", ".", "typ", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.register
Create a new registration with the ACME server. :param ~acme.messages.NewRegistration new_reg: The registration message to use, or ``None`` to construct one. :return: The registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`]
src/txacme/client.py
def register(self, new_reg=None): """ Create a new registration with the ACME server. :param ~acme.messages.NewRegistration new_reg: The registration message to use, or ``None`` to construct one. :return: The registration resource. :rtype: Deferred[`~acme.messages.R...
def register(self, new_reg=None): """ Create a new registration with the ACME server. :param ~acme.messages.NewRegistration new_reg: The registration message to use, or ``None`` to construct one. :return: The registration resource. :rtype: Deferred[`~acme.messages.R...
[ "Create", "a", "new", "registration", "with", "the", "ACME", "server", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L140-L161
[ "def", "register", "(", "self", ",", "new_reg", "=", "None", ")", ":", "if", "new_reg", "is", "None", ":", "new_reg", "=", "messages", ".", "NewRegistration", "(", ")", "action", "=", "LOG_ACME_REGISTER", "(", "registration", "=", "new_reg", ")", "with", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._maybe_location
Get the Location: if there is one.
src/txacme/client.py
def _maybe_location(cls, response, uri=None): """ Get the Location: if there is one. """ location = response.headers.getRawHeaders(b'location', [None])[0] if location is not None: return location.decode('ascii') return uri
def _maybe_location(cls, response, uri=None): """ Get the Location: if there is one. """ location = response.headers.getRawHeaders(b'location', [None])[0] if location is not None: return location.decode('ascii') return uri
[ "Get", "the", "Location", ":", "if", "there", "is", "one", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L164-L171
[ "def", "_maybe_location", "(", "cls", ",", "response", ",", "uri", "=", "None", ")", ":", "location", "=", "response", ".", "headers", ".", "getRawHeaders", "(", "b'location'", ",", "[", "None", "]", ")", "[", "0", "]", "if", "location", "is", "not", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._maybe_registered
If the registration already exists, we should just load it.
src/txacme/client.py
def _maybe_registered(self, failure, new_reg): """ If the registration already exists, we should just load it. """ failure.trap(ServerError) response = failure.value.response if response.code == http.CONFLICT: reg = new_reg.update( resource=mes...
def _maybe_registered(self, failure, new_reg): """ If the registration already exists, we should just load it. """ failure.trap(ServerError) response = failure.value.response if response.code == http.CONFLICT: reg = new_reg.update( resource=mes...
[ "If", "the", "registration", "already", "exists", "we", "should", "just", "load", "it", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L173-L184
[ "def", "_maybe_registered", "(", "self", ",", "failure", ",", "new_reg", ")", ":", "failure", ".", "trap", "(", "ServerError", ")", "response", "=", "failure", ".", "value", ".", "response", "if", "response", ".", "code", "==", "http", ".", "CONFLICT", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.agree_to_tos
Accept the terms-of-service for a registration. :param ~acme.messages.RegistrationResource regr: The registration to update. :return: The updated registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`]
src/txacme/client.py
def agree_to_tos(self, regr): """ Accept the terms-of-service for a registration. :param ~acme.messages.RegistrationResource regr: The registration to update. :return: The updated registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`] ...
def agree_to_tos(self, regr): """ Accept the terms-of-service for a registration. :param ~acme.messages.RegistrationResource regr: The registration to update. :return: The updated registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`] ...
[ "Accept", "the", "terms", "-", "of", "-", "service", "for", "a", "registration", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L186-L199
[ "def", "agree_to_tos", "(", "self", ",", "regr", ")", ":", "return", "self", ".", "update_registration", "(", "regr", ".", "update", "(", "body", "=", "regr", ".", "body", ".", "update", "(", "agreement", "=", "regr", ".", "terms_of_service", ")", ")", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.update_registration
Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registration. :param str uri: The url to submit to. Must be ...
src/txacme/client.py
def update_registration(self, regr, uri=None): """ Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registrat...
def update_registration(self, regr, uri=None): """ Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registrat...
[ "Submit", "a", "registration", "to", "the", "server", "to", "update", "it", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L201-L228
[ "def", "update_registration", "(", "self", ",", "regr", ",", "uri", "=", "None", ")", ":", "if", "uri", "is", "None", ":", "uri", "=", "regr", ".", "uri", "if", "isinstance", "(", "regr", ",", "messages", ".", "RegistrationResource", ")", ":", "message...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._parse_regr_response
Parse a registration response from the server.
src/txacme/client.py
def _parse_regr_response(self, response, uri=None, new_authzr_uri=None, terms_of_service=None): """ Parse a registration response from the server. """ links = _parse_header_links(response) if u'terms-of-service' in links: terms_of_service ...
def _parse_regr_response(self, response, uri=None, new_authzr_uri=None, terms_of_service=None): """ Parse a registration response from the server. """ links = _parse_header_links(response) if u'terms-of-service' in links: terms_of_service ...
[ "Parse", "a", "registration", "response", "from", "the", "server", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L230-L251
[ "def", "_parse_regr_response", "(", "self", ",", "response", ",", "uri", "=", "None", ",", "new_authzr_uri", "=", "None", ",", "terms_of_service", "=", "None", ")", ":", "links", "=", "_parse_header_links", "(", "response", ")", "if", "u'terms-of-service'", "i...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._check_regr
Check that a registration response contains the registration we were expecting.
src/txacme/client.py
def _check_regr(self, regr, new_reg): """ Check that a registration response contains the registration we were expecting. """ body = getattr(new_reg, 'body', new_reg) for k, v in body.items(): if k == 'resource' or not v: continue i...
def _check_regr(self, regr, new_reg): """ Check that a registration response contains the registration we were expecting. """ body = getattr(new_reg, 'body', new_reg) for k, v in body.items(): if k == 'resource' or not v: continue i...
[ "Check", "that", "a", "registration", "response", "contains", "the", "registration", "we", "were", "expecting", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L253-L266
[ "def", "_check_regr", "(", "self", ",", "regr", ",", "new_reg", ")", ":", "body", "=", "getattr", "(", "new_reg", ",", "'body'", ",", "new_reg", ")", "for", "k", ",", "v", "in", "body", ".", "items", "(", ")", ":", "if", "k", "==", "'resource'", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.request_challenges
Create a new authorization. :param ~acme.messages.Identifier identifier: The identifier to authorize. :return: The new authorization resource. :rtype: Deferred[`~acme.messages.AuthorizationResource`]
src/txacme/client.py
def request_challenges(self, identifier): """ Create a new authorization. :param ~acme.messages.Identifier identifier: The identifier to authorize. :return: The new authorization resource. :rtype: Deferred[`~acme.messages.AuthorizationResource`] """ ...
def request_challenges(self, identifier): """ Create a new authorization. :param ~acme.messages.Identifier identifier: The identifier to authorize. :return: The new authorization resource. :rtype: Deferred[`~acme.messages.AuthorizationResource`] """ ...
[ "Create", "a", "new", "authorization", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L268-L289
[ "def", "request_challenges", "(", "self", ",", "identifier", ")", ":", "action", "=", "LOG_ACME_CREATE_AUTHORIZATION", "(", "identifier", "=", "identifier", ")", "with", "action", ".", "context", "(", ")", ":", "message", "=", "messages", ".", "NewAuthorization"...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._expect_response
Ensure we got the expected response code.
src/txacme/client.py
def _expect_response(cls, response, code): """ Ensure we got the expected response code. """ if response.code != code: raise errors.ClientError( 'Expected {!r} response but got {!r}'.format( code, response.code)) return response
def _expect_response(cls, response, code): """ Ensure we got the expected response code. """ if response.code != code: raise errors.ClientError( 'Expected {!r} response but got {!r}'.format( code, response.code)) return response
[ "Ensure", "we", "got", "the", "expected", "response", "code", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L292-L300
[ "def", "_expect_response", "(", "cls", ",", "response", ",", "code", ")", ":", "if", "response", ".", "code", "!=", "code", ":", "raise", "errors", ".", "ClientError", "(", "'Expected {!r} response but got {!r}'", ".", "format", "(", "code", ",", "response", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._parse_authorization
Parse an authorization resource.
src/txacme/client.py
def _parse_authorization(cls, response, uri=None): """ Parse an authorization resource. """ links = _parse_header_links(response) try: new_cert_uri = links[u'next'][u'url'] except KeyError: raise errors.ClientError('"next" link missing') re...
def _parse_authorization(cls, response, uri=None): """ Parse an authorization resource. """ links = _parse_header_links(response) try: new_cert_uri = links[u'next'][u'url'] except KeyError: raise errors.ClientError('"next" link missing') re...
[ "Parse", "an", "authorization", "resource", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L303-L319
[ "def", "_parse_authorization", "(", "cls", ",", "response", ",", "uri", "=", "None", ")", ":", "links", "=", "_parse_header_links", "(", "response", ")", "try", ":", "new_cert_uri", "=", "links", "[", "u'next'", "]", "[", "u'url'", "]", "except", "KeyError...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._check_authorization
Check that the authorization we got is the one we expected.
src/txacme/client.py
def _check_authorization(cls, authzr, identifier): """ Check that the authorization we got is the one we expected. """ if authzr.body.identifier != identifier: raise errors.UnexpectedUpdate(authzr) return authzr
def _check_authorization(cls, authzr, identifier): """ Check that the authorization we got is the one we expected. """ if authzr.body.identifier != identifier: raise errors.UnexpectedUpdate(authzr) return authzr
[ "Check", "that", "the", "authorization", "we", "got", "is", "the", "one", "we", "expected", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L322-L328
[ "def", "_check_authorization", "(", "cls", ",", "authzr", ",", "identifier", ")", ":", "if", "authzr", ".", "body", ".", "identifier", "!=", "identifier", ":", "raise", "errors", ".", "UnexpectedUpdate", "(", "authzr", ")", "return", "authzr" ]
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.answer_challenge
Respond to an authorization challenge. :param ~acme.messages.ChallengeBody challenge_body: The challenge being responded to. :param ~acme.challenges.ChallengeResponse response: The response to the challenge. :return: The updated challenge resource. :rtype: Defer...
src/txacme/client.py
def answer_challenge(self, challenge_body, response): """ Respond to an authorization challenge. :param ~acme.messages.ChallengeBody challenge_body: The challenge being responded to. :param ~acme.challenges.ChallengeResponse response: The response to the challeng...
def answer_challenge(self, challenge_body, response): """ Respond to an authorization challenge. :param ~acme.messages.ChallengeBody challenge_body: The challenge being responded to. :param ~acme.challenges.ChallengeResponse response: The response to the challeng...
[ "Respond", "to", "an", "authorization", "challenge", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L330-L353
[ "def", "answer_challenge", "(", "self", ",", "challenge_body", ",", "response", ")", ":", "action", "=", "LOG_ACME_ANSWER_CHALLENGE", "(", "challenge_body", "=", "challenge_body", ",", "response", "=", "response", ")", "with", "action", ".", "context", "(", ")",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._parse_challenge
Parse a challenge resource.
src/txacme/client.py
def _parse_challenge(cls, response): """ Parse a challenge resource. """ links = _parse_header_links(response) try: authzr_uri = links['up']['url'] except KeyError: raise errors.ClientError('"up" link missing') return ( response...
def _parse_challenge(cls, response): """ Parse a challenge resource. """ links = _parse_header_links(response) try: authzr_uri = links['up']['url'] except KeyError: raise errors.ClientError('"up" link missing') return ( response...
[ "Parse", "a", "challenge", "resource", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L356-L371
[ "def", "_parse_challenge", "(", "cls", ",", "response", ")", ":", "links", "=", "_parse_header_links", "(", "response", ")", "try", ":", "authzr_uri", "=", "links", "[", "'up'", "]", "[", "'url'", "]", "except", "KeyError", ":", "raise", "errors", ".", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._check_challenge
Check that the challenge resource we got is the one we expected.
src/txacme/client.py
def _check_challenge(cls, challenge, challenge_body): """ Check that the challenge resource we got is the one we expected. """ if challenge.uri != challenge_body.uri: raise errors.UnexpectedUpdate(challenge.uri) return challenge
def _check_challenge(cls, challenge, challenge_body): """ Check that the challenge resource we got is the one we expected. """ if challenge.uri != challenge_body.uri: raise errors.UnexpectedUpdate(challenge.uri) return challenge
[ "Check", "that", "the", "challenge", "resource", "we", "got", "is", "the", "one", "we", "expected", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L374-L380
[ "def", "_check_challenge", "(", "cls", ",", "challenge", ",", "challenge_body", ")", ":", "if", "challenge", ".", "uri", "!=", "challenge_body", ".", "uri", ":", "raise", "errors", ".", "UnexpectedUpdate", "(", "challenge", ".", "uri", ")", "return", "challe...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.poll
Update an authorization from the server (usually to check its status).
src/txacme/client.py
def poll(self, authzr): """ Update an authorization from the server (usually to check its status). """ action = LOG_ACME_POLL_AUTHORIZATION(authorization=authzr) with action.context(): return ( DeferredContext(self._client.get(authzr.uri)) ...
def poll(self, authzr): """ Update an authorization from the server (usually to check its status). """ action = LOG_ACME_POLL_AUTHORIZATION(authorization=authzr) with action.context(): return ( DeferredContext(self._client.get(authzr.uri)) ...
[ "Update", "an", "authorization", "from", "the", "server", "(", "usually", "to", "check", "its", "status", ")", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L382-L406
[ "def", "poll", "(", "self", ",", "authzr", ")", ":", "action", "=", "LOG_ACME_POLL_AUTHORIZATION", "(", "authorization", "=", "authzr", ")", "with", "action", ".", "context", "(", ")", ":", "return", "(", "DeferredContext", "(", "self", ".", "_client", "."...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.retry_after
Parse the Retry-After value from a response.
src/txacme/client.py
def retry_after(cls, response, default=5, _now=time.time): """ Parse the Retry-After value from a response. """ val = response.headers.getRawHeaders(b'retry-after', [default])[0] try: return int(val) except ValueError: return http.stringToDatetime(...
def retry_after(cls, response, default=5, _now=time.time): """ Parse the Retry-After value from a response. """ val = response.headers.getRawHeaders(b'retry-after', [default])[0] try: return int(val) except ValueError: return http.stringToDatetime(...
[ "Parse", "the", "Retry", "-", "After", "value", "from", "a", "response", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L409-L417
[ "def", "retry_after", "(", "cls", ",", "response", ",", "default", "=", "5", ",", "_now", "=", "time", ".", "time", ")", ":", "val", "=", "response", ".", "headers", ".", "getRawHeaders", "(", "b'retry-after'", ",", "[", "default", "]", ")", "[", "0"...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.request_issuance
Request a certificate. Authorizations should have already been completed for all of the names requested in the CSR. Note that unlike `acme.client.Client.request_issuance`, the certificate resource will have the body data as raw bytes. .. seealso:: `txacme.util.csr_for_names` ...
src/txacme/client.py
def request_issuance(self, csr): """ Request a certificate. Authorizations should have already been completed for all of the names requested in the CSR. Note that unlike `acme.client.Client.request_issuance`, the certificate resource will have the body data as raw bytes...
def request_issuance(self, csr): """ Request a certificate. Authorizations should have already been completed for all of the names requested in the CSR. Note that unlike `acme.client.Client.request_issuance`, the certificate resource will have the body data as raw bytes...
[ "Request", "a", "certificate", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L419-L451
[ "def", "request_issuance", "(", "self", ",", "csr", ")", ":", "action", "=", "LOG_ACME_REQUEST_CERTIFICATE", "(", ")", "with", "action", ".", "context", "(", ")", ":", "return", "(", "DeferredContext", "(", "self", ".", "_client", ".", "post", "(", "self",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client._parse_certificate
Parse a response containing a certificate resource.
src/txacme/client.py
def _parse_certificate(cls, response): """ Parse a response containing a certificate resource. """ links = _parse_header_links(response) try: cert_chain_uri = links[u'up'][u'url'] except KeyError: cert_chain_uri = None return ( ...
def _parse_certificate(cls, response): """ Parse a response containing a certificate resource. """ links = _parse_header_links(response) try: cert_chain_uri = links[u'up'][u'url'] except KeyError: cert_chain_uri = None return ( ...
[ "Parse", "a", "response", "containing", "a", "certificate", "resource", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L454-L470
[ "def", "_parse_certificate", "(", "cls", ",", "response", ")", ":", "links", "=", "_parse_header_links", "(", "response", ")", "try", ":", "cert_chain_uri", "=", "links", "[", "u'up'", "]", "[", "u'url'", "]", "except", "KeyError", ":", "cert_chain_uri", "="...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Client.fetch_chain
Fetch the intermediary chain for a certificate. :param acme.messages.CertificateResource certr: The certificate to fetch the chain for. :param int max_length: The maximum length of the chain that will be fetched. :rtype: Deferred[List[`acme.messages.CertificateResource`...
src/txacme/client.py
def fetch_chain(self, certr, max_length=10): """ Fetch the intermediary chain for a certificate. :param acme.messages.CertificateResource certr: The certificate to fetch the chain for. :param int max_length: The maximum length of the chain that will be fetched. ...
def fetch_chain(self, certr, max_length=10): """ Fetch the intermediary chain for a certificate. :param acme.messages.CertificateResource certr: The certificate to fetch the chain for. :param int max_length: The maximum length of the chain that will be fetched. ...
[ "Fetch", "the", "intermediary", "chain", "for", "a", "certificate", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L472-L502
[ "def", "fetch_chain", "(", "self", ",", "certr", ",", "max_length", "=", "10", ")", ":", "action", "=", "LOG_ACME_FETCH_CHAIN", "(", ")", "with", "action", ".", "context", "(", ")", ":", "if", "certr", ".", "cert_chain_uri", "is", "None", ":", "return", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient._wrap_in_jws
Wrap ``JSONDeSerializable`` object in JWS. .. todo:: Implement ``acmePath``. :param ~josepy.interfaces.JSONDeSerializable obj: :param bytes nonce: :rtype: `bytes` :return: JSON-encoded data
src/txacme/client.py
def _wrap_in_jws(self, nonce, obj): """ Wrap ``JSONDeSerializable`` object in JWS. .. todo:: Implement ``acmePath``. :param ~josepy.interfaces.JSONDeSerializable obj: :param bytes nonce: :rtype: `bytes` :return: JSON-encoded data """ with LOG_J...
def _wrap_in_jws(self, nonce, obj): """ Wrap ``JSONDeSerializable`` object in JWS. .. todo:: Implement ``acmePath``. :param ~josepy.interfaces.JSONDeSerializable obj: :param bytes nonce: :rtype: `bytes` :return: JSON-encoded data """ with LOG_J...
[ "Wrap", "JSONDeSerializable", "object", "in", "JWS", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L678-L697
[ "def", "_wrap_in_jws", "(", "self", ",", "nonce", ",", "obj", ")", ":", "with", "LOG_JWS_SIGN", "(", "key_type", "=", "self", ".", "_key", ".", "typ", ",", "alg", "=", "self", ".", "_alg", ".", "name", ",", "nonce", "=", "nonce", ")", ":", "jobj", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient._check_response
Check response content and its type. .. note:: Unlike :mod:`acme.client`, checking is strict. :param bytes content_type: Expected Content-Type response header. If the response Content-Type does not match, :exc:`ClientError` is raised. :raises .ServerErro...
src/txacme/client.py
def _check_response(cls, response, content_type=JSON_CONTENT_TYPE): """ Check response content and its type. .. note:: Unlike :mod:`acme.client`, checking is strict. :param bytes content_type: Expected Content-Type response header. If the response Content-Typ...
def _check_response(cls, response, content_type=JSON_CONTENT_TYPE): """ Check response content and its type. .. note:: Unlike :mod:`acme.client`, checking is strict. :param bytes content_type: Expected Content-Type response header. If the response Content-Typ...
[ "Check", "response", "content", "and", "its", "type", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L700-L748
[ "def", "_check_response", "(", "cls", ",", "response", ",", "content_type", "=", "JSON_CONTENT_TYPE", ")", ":", "def", "_got_failure", "(", "f", ")", ":", "f", ".", "trap", "(", "ValueError", ")", "return", "None", "def", "_got_json", "(", "jobj", ")", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient._send_request
Send HTTP request. :param str method: The HTTP method to use. :param str url: The URL to make the request to. :return: Deferred firing with the HTTP response.
src/txacme/client.py
def _send_request(self, method, url, *args, **kwargs): """ Send HTTP request. :param str method: The HTTP method to use. :param str url: The URL to make the request to. :return: Deferred firing with the HTTP response. """ action = LOG_JWS_REQUEST(url=url) ...
def _send_request(self, method, url, *args, **kwargs): """ Send HTTP request. :param str method: The HTTP method to use. :param str url: The URL to make the request to. :return: Deferred firing with the HTTP response. """ action = LOG_JWS_REQUEST(url=url) ...
[ "Send", "HTTP", "request", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L750-L772
[ "def", "_send_request", "(", "self", ",", "method", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "action", "=", "LOG_JWS_REQUEST", "(", "url", "=", "url", ")", "with", "action", ".", "context", "(", ")", ":", "headers", "=", "kw...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient.head
Send HEAD request without checking the response. Note that ``_check_response`` is not called, as there will be no response body to check. :param str url: The URL to make the request to.
src/txacme/client.py
def head(self, url, *args, **kwargs): """ Send HEAD request without checking the response. Note that ``_check_response`` is not called, as there will be no response body to check. :param str url: The URL to make the request to. """ with LOG_JWS_HEAD().context():...
def head(self, url, *args, **kwargs): """ Send HEAD request without checking the response. Note that ``_check_response`` is not called, as there will be no response body to check. :param str url: The URL to make the request to. """ with LOG_JWS_HEAD().context():...
[ "Send", "HEAD", "request", "without", "checking", "the", "response", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L774-L786
[ "def", "head", "(", "self", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "LOG_JWS_HEAD", "(", ")", ".", "context", "(", ")", ":", "return", "DeferredContext", "(", "self", ".", "_send_request", "(", "u'HEAD'", ",", "url", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient.get
Send GET request and check response. :param str method: The HTTP method to use. :param str url: The URL to make the request to. :raises txacme.client.ServerError: If server response body carries HTTP Problem (draft-ietf-appsawg-http-problem-00). :raises acme.errors.ClientEr...
src/txacme/client.py
def get(self, url, content_type=JSON_CONTENT_TYPE, **kwargs): """ Send GET request and check response. :param str method: The HTTP method to use. :param str url: The URL to make the request to. :raises txacme.client.ServerError: If server response body carries HTTP ...
def get(self, url, content_type=JSON_CONTENT_TYPE, **kwargs): """ Send GET request and check response. :param str method: The HTTP method to use. :param str url: The URL to make the request to. :raises txacme.client.ServerError: If server response body carries HTTP ...
[ "Send", "GET", "request", "and", "check", "response", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L788-L805
[ "def", "get", "(", "self", ",", "url", ",", "content_type", "=", "JSON_CONTENT_TYPE", ",", "*", "*", "kwargs", ")", ":", "with", "LOG_JWS_GET", "(", ")", ".", "context", "(", ")", ":", "return", "(", "DeferredContext", "(", "self", ".", "_send_request", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient._add_nonce
Store a nonce from a response we received. :param twisted.web.iweb.IResponse response: The HTTP response. :return: The response, unmodified.
src/txacme/client.py
def _add_nonce(self, response): """ Store a nonce from a response we received. :param twisted.web.iweb.IResponse response: The HTTP response. :return: The response, unmodified. """ nonce = response.headers.getRawHeaders( REPLAY_NONCE_HEADER, [None])[0] ...
def _add_nonce(self, response): """ Store a nonce from a response we received. :param twisted.web.iweb.IResponse response: The HTTP response. :return: The response, unmodified. """ nonce = response.headers.getRawHeaders( REPLAY_NONCE_HEADER, [None])[0] ...
[ "Store", "a", "nonce", "from", "a", "response", "we", "received", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L807-L829
[ "def", "_add_nonce", "(", "self", ",", "response", ")", ":", "nonce", "=", "response", ".", "headers", ".", "getRawHeaders", "(", "REPLAY_NONCE_HEADER", ",", "[", "None", "]", ")", "[", "0", "]", "with", "LOG_JWS_ADD_NONCE", "(", "raw_nonce", "=", "nonce",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient._get_nonce
Get a nonce to use in a request, removing it from the nonces on hand.
src/txacme/client.py
def _get_nonce(self, url): """ Get a nonce to use in a request, removing it from the nonces on hand. """ action = LOG_JWS_GET_NONCE() if len(self._nonces) > 0: with action: nonce = self._nonces.pop() action.add_success_fields(nonce=nonc...
def _get_nonce(self, url): """ Get a nonce to use in a request, removing it from the nonces on hand. """ action = LOG_JWS_GET_NONCE() if len(self._nonces) > 0: with action: nonce = self._nonces.pop() action.add_success_fields(nonce=nonc...
[ "Get", "a", "nonce", "to", "use", "in", "a", "request", "removing", "it", "from", "the", "nonces", "on", "hand", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L831-L849
[ "def", "_get_nonce", "(", "self", ",", "url", ")", ":", "action", "=", "LOG_JWS_GET_NONCE", "(", ")", "if", "len", "(", "self", ".", "_nonces", ")", ">", "0", ":", "with", "action", ":", "nonce", "=", "self", ".", "_nonces", ".", "pop", "(", ")", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient._post
POST an object and check the response. :param str url: The URL to request. :param ~josepy.interfaces.JSONDeSerializable obj: The serializable payload of the request. :param bytes content_type: The expected content type of the response. :raises txacme.client.ServerError: If ...
src/txacme/client.py
def _post(self, url, obj, content_type, **kwargs): """ POST an object and check the response. :param str url: The URL to request. :param ~josepy.interfaces.JSONDeSerializable obj: The serializable payload of the request. :param bytes content_type: The expected conten...
def _post(self, url, obj, content_type, **kwargs): """ POST an object and check the response. :param str url: The URL to request. :param ~josepy.interfaces.JSONDeSerializable obj: The serializable payload of the request. :param bytes content_type: The expected conten...
[ "POST", "an", "object", "and", "check", "the", "response", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L851-L875
[ "def", "_post", "(", "self", ",", "url", ",", "obj", ",", "content_type", ",", "*", "*", "kwargs", ")", ":", "with", "LOG_JWS_POST", "(", ")", ".", "context", "(", ")", ":", "headers", "=", "kwargs", ".", "setdefault", "(", "'headers'", ",", "Headers...
9478381cc63c6d53d14bf8db8407c923f472989a
train
JWSClient.post
POST an object and check the response. Retry once if a badNonce error is received. :param str url: The URL to request. :param ~josepy.interfaces.JSONDeSerializable obj: The serializable payload of the request. :param bytes content_type: The expected content type of the respo...
src/txacme/client.py
def post(self, url, obj, content_type=JSON_CONTENT_TYPE, **kwargs): """ POST an object and check the response. Retry once if a badNonce error is received. :param str url: The URL to request. :param ~josepy.interfaces.JSONDeSerializable obj: The serializable payload o...
def post(self, url, obj, content_type=JSON_CONTENT_TYPE, **kwargs): """ POST an object and check the response. Retry once if a badNonce error is received. :param str url: The URL to request. :param ~josepy.interfaces.JSONDeSerializable obj: The serializable payload o...
[ "POST", "an", "object", "and", "check", "the", "response", ".", "Retry", "once", "if", "a", "badNonce", "error", "is", "received", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L877-L907
[ "def", "post", "(", "self", ",", "url", ",", "obj", ",", "content_type", "=", "JSON_CONTENT_TYPE", ",", "*", "*", "kwargs", ")", ":", "def", "retry_bad_nonce", "(", "f", ")", ":", "f", ".", "trap", "(", "ServerError", ")", "# The current RFC draft defines ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_daemon_thread
Create a `threading.Thread`, but always set ``daemon``.
src/txacme/challenges/_libcloud.py
def _daemon_thread(*a, **kw): """ Create a `threading.Thread`, but always set ``daemon``. """ thread = Thread(*a, **kw) thread.daemon = True return thread
def _daemon_thread(*a, **kw): """ Create a `threading.Thread`, but always set ``daemon``. """ thread = Thread(*a, **kw) thread.daemon = True return thread
[ "Create", "a", "threading", ".", "Thread", "but", "always", "set", "daemon", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L18-L24
[ "def", "_daemon_thread", "(", "*", "a", ",", "*", "*", "kw", ")", ":", "thread", "=", "Thread", "(", "*", "a", ",", "*", "*", "kw", ")", "thread", ".", "daemon", "=", "True", "return", "thread" ]
9478381cc63c6d53d14bf8db8407c923f472989a
train
_defer_to_worker
Run a task in a worker, delivering the result as a ``Deferred`` in the reactor thread.
src/txacme/challenges/_libcloud.py
def _defer_to_worker(deliver, worker, work, *args, **kwargs): """ Run a task in a worker, delivering the result as a ``Deferred`` in the reactor thread. """ deferred = Deferred() def wrapped_work(): try: result = work(*args, **kwargs) except BaseException: ...
def _defer_to_worker(deliver, worker, work, *args, **kwargs): """ Run a task in a worker, delivering the result as a ``Deferred`` in the reactor thread. """ deferred = Deferred() def wrapped_work(): try: result = work(*args, **kwargs) except BaseException: ...
[ "Run", "a", "task", "in", "a", "worker", "delivering", "the", "result", "as", "a", "Deferred", "in", "the", "reactor", "thread", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L27-L43
[ "def", "_defer_to_worker", "(", "deliver", ",", "worker", ",", "work", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "deferred", "=", "Deferred", "(", ")", "def", "wrapped_work", "(", ")", ":", "try", ":", "result", "=", "work", "(", "*", "a...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_split_zone
Split the zone portion off from a DNS label. :param str server_name: The full DNS label. :param str zone_name: The zone name suffix.
src/txacme/challenges/_libcloud.py
def _split_zone(server_name, zone_name): """ Split the zone portion off from a DNS label. :param str server_name: The full DNS label. :param str zone_name: The zone name suffix. """ server_name = server_name.rstrip(u'.') zone_name = zone_name.rstrip(u'.') if not (server_name == zone_nam...
def _split_zone(server_name, zone_name): """ Split the zone portion off from a DNS label. :param str server_name: The full DNS label. :param str zone_name: The zone name suffix. """ server_name = server_name.rstrip(u'.') zone_name = zone_name.rstrip(u'.') if not (server_name == zone_nam...
[ "Split", "the", "zone", "portion", "off", "from", "a", "DNS", "label", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L46-L58
[ "def", "_split_zone", "(", "server_name", ",", "zone_name", ")", ":", "server_name", "=", "server_name", ".", "rstrip", "(", "u'.'", ")", "zone_name", "=", "zone_name", ".", "rstrip", "(", "u'.'", ")", "if", "not", "(", "server_name", "==", "zone_name", "o...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_get_existing
Get existing validation records.
src/txacme/challenges/_libcloud.py
def _get_existing(driver, zone_name, server_name, validation): """ Get existing validation records. """ if zone_name is None: zones = sorted( (z for z in driver.list_zones() if server_name.rstrip(u'.') .endswith(u'.' + z.domain.rstrip(u'.')))...
def _get_existing(driver, zone_name, server_name, validation): """ Get existing validation records. """ if zone_name is None: zones = sorted( (z for z in driver.list_zones() if server_name.rstrip(u'.') .endswith(u'.' + z.domain.rstrip(u'.')))...
[ "Get", "existing", "validation", "records", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L61-L90
[ "def", "_get_existing", "(", "driver", ",", "zone_name", ",", "server_name", ",", "validation", ")", ":", "if", "zone_name", "is", "None", ":", "zones", "=", "sorted", "(", "(", "z", "for", "z", "in", "driver", ".", "list_zones", "(", ")", "if", "serve...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_validation
Get the validation value for a challenge response.
src/txacme/challenges/_libcloud.py
def _validation(response): """ Get the validation value for a challenge response. """ h = hashlib.sha256(response.key_authorization.encode("utf-8")) return b64encode(h.digest()).decode()
def _validation(response): """ Get the validation value for a challenge response. """ h = hashlib.sha256(response.key_authorization.encode("utf-8")) return b64encode(h.digest()).decode()
[ "Get", "the", "validation", "value", "for", "a", "challenge", "response", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/challenges/_libcloud.py#L93-L98
[ "def", "_validation", "(", "response", ")", ":", "h", "=", "hashlib", ".", "sha256", "(", "response", ".", "key_authorization", ".", "encode", "(", "\"utf-8\"", ")", ")", "return", "b64encode", "(", "h", ".", "digest", "(", ")", ")", ".", "decode", "("...
9478381cc63c6d53d14bf8db8407c923f472989a
train
load_or_create_client_key
Load the client key from a directory, creating it if it does not exist. .. note:: The client key that will be created will be a 2048-bit RSA key. :type pem_path: ``twisted.python.filepath.FilePath`` :param pem_path: The certificate directory to use, as with the endpoint.
src/txacme/endpoint.py
def load_or_create_client_key(pem_path): """ Load the client key from a directory, creating it if it does not exist. .. note:: The client key that will be created will be a 2048-bit RSA key. :type pem_path: ``twisted.python.filepath.FilePath`` :param pem_path: The certificate directory to ...
def load_or_create_client_key(pem_path): """ Load the client key from a directory, creating it if it does not exist. .. note:: The client key that will be created will be a 2048-bit RSA key. :type pem_path: ``twisted.python.filepath.FilePath`` :param pem_path: The certificate directory to ...
[ "Load", "the", "client", "key", "from", "a", "directory", "creating", "it", "if", "it", "does", "not", "exist", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/endpoint.py#L131-L154
[ "def", "load_or_create_client_key", "(", "pem_path", ")", ":", "acme_key_file", "=", "pem_path", ".", "asTextMode", "(", ")", ".", "child", "(", "u'client.key'", ")", "if", "acme_key_file", ".", "exists", "(", ")", ":", "key", "=", "serialization", ".", "loa...
9478381cc63c6d53d14bf8db8407c923f472989a
train
_parse
Parse a txacme endpoint description. :param reactor: The Twisted reactor. :param directory: ``twisted.python.url.URL`` for the ACME directory to use for issuing certs. :param str pemdir: The path to the certificate directory to use.
src/txacme/endpoint.py
def _parse(reactor, directory, pemdir, *args, **kwargs): """ Parse a txacme endpoint description. :param reactor: The Twisted reactor. :param directory: ``twisted.python.url.URL`` for the ACME directory to use for issuing certs. :param str pemdir: The path to the certificate directory to us...
def _parse(reactor, directory, pemdir, *args, **kwargs): """ Parse a txacme endpoint description. :param reactor: The Twisted reactor. :param directory: ``twisted.python.url.URL`` for the ACME directory to use for issuing certs. :param str pemdir: The path to the certificate directory to us...
[ "Parse", "a", "txacme", "endpoint", "description", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/endpoint.py#L157-L177
[ "def", "_parse", "(", "reactor", ",", "directory", ",", "pemdir", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "colon_join", "(", "items", ")", ":", "return", "':'", ".", "join", "(", "[", "item", ".", "replace", "(", "':'", ",", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
lazyread
Generator which continually reads ``f`` to the next instance of ``delimiter``. This allows you to do batch processing on the contents of ``f`` without loading the entire file into memory. :param f: Any file-like object which has a ``.read()`` method. :param delimiter: Delimiter on which to split u...
lazyreader.py
def lazyread(f, delimiter): """ Generator which continually reads ``f`` to the next instance of ``delimiter``. This allows you to do batch processing on the contents of ``f`` without loading the entire file into memory. :param f: Any file-like object which has a ``.read()`` method. :param ...
def lazyread(f, delimiter): """ Generator which continually reads ``f`` to the next instance of ``delimiter``. This allows you to do batch processing on the contents of ``f`` without loading the entire file into memory. :param f: Any file-like object which has a ``.read()`` method. :param ...
[ "Generator", "which", "continually", "reads", "f", "to", "the", "next", "instance", "of", "delimiter", "." ]
alexwlchan/lazyreader
python
https://github.com/alexwlchan/lazyreader/blob/918c408efba015efc1d67b05d1e4b373ac9d1192/lazyreader.py#L3-L44
[ "def", "lazyread", "(", "f", ",", "delimiter", ")", ":", "# Get an empty string to start with. We need to make sure that if the", "# file is opened in binary mode, we're using byte strings, and similar", "# for Unicode. Otherwise trying to update the running string will", "# hit a TypeError....
918c408efba015efc1d67b05d1e4b373ac9d1192
train
generate_private_key
Generate a random private key using sensible parameters. :param str key_type: The type of key to generate. One of: ``rsa``.
src/txacme/util.py
def generate_private_key(key_type): """ Generate a random private key using sensible parameters. :param str key_type: The type of key to generate. One of: ``rsa``. """ if key_type == u'rsa': return rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_b...
def generate_private_key(key_type): """ Generate a random private key using sensible parameters. :param str key_type: The type of key to generate. One of: ``rsa``. """ if key_type == u'rsa': return rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_b...
[ "Generate", "a", "random", "private", "key", "using", "sensible", "parameters", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L20-L29
[ "def", "generate_private_key", "(", "key_type", ")", ":", "if", "key_type", "==", "u'rsa'", ":", "return", "rsa", ".", "generate_private_key", "(", "public_exponent", "=", "65537", ",", "key_size", "=", "2048", ",", "backend", "=", "default_backend", "(", ")",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
generate_tls_sni_01_cert
Generate a certificate/key pair for responding to a tls-sni-01 challenge. :param str server_name: The SAN the certificate should have. :param str key_type: The type of key to generate; usually not necessary. :rtype: ``Tuple[`~cryptography.x509.Certificate`, PrivateKey]`` :return: A tuple of the certif...
src/txacme/util.py
def generate_tls_sni_01_cert(server_name, key_type=u'rsa', _generate_private_key=None): """ Generate a certificate/key pair for responding to a tls-sni-01 challenge. :param str server_name: The SAN the certificate should have. :param str key_type: The type of key to generat...
def generate_tls_sni_01_cert(server_name, key_type=u'rsa', _generate_private_key=None): """ Generate a certificate/key pair for responding to a tls-sni-01 challenge. :param str server_name: The SAN the certificate should have. :param str key_type: The type of key to generat...
[ "Generate", "a", "certificate", "/", "key", "pair", "for", "responding", "to", "a", "tls", "-", "sni", "-", "01", "challenge", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L32-L62
[ "def", "generate_tls_sni_01_cert", "(", "server_name", ",", "key_type", "=", "u'rsa'", ",", "_generate_private_key", "=", "None", ")", ":", "key", "=", "(", "_generate_private_key", "or", "generate_private_key", ")", "(", "key_type", ")", "name", "=", "x509", "....
9478381cc63c6d53d14bf8db8407c923f472989a
train
tap
"Tap" a Deferred callback chain with a function whose return value is ignored.
src/txacme/util.py
def tap(f): """ "Tap" a Deferred callback chain with a function whose return value is ignored. """ @wraps(f) def _cb(res, *a, **kw): d = maybeDeferred(f, res, *a, **kw) d.addCallback(lambda ignored: res) return d return _cb
def tap(f): """ "Tap" a Deferred callback chain with a function whose return value is ignored. """ @wraps(f) def _cb(res, *a, **kw): d = maybeDeferred(f, res, *a, **kw) d.addCallback(lambda ignored: res) return d return _cb
[ "Tap", "a", "Deferred", "callback", "chain", "with", "a", "function", "whose", "return", "value", "is", "ignored", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L65-L75
[ "def", "tap", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "_cb", "(", "res", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "d", "=", "maybeDeferred", "(", "f", ",", "res", ",", "*", "a", ",", "*", "*", "kw", ")", "d", ".", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
decode_csr
Decode JOSE Base-64 DER-encoded CSR. :param str b64der: The encoded CSR. :rtype: `cryptography.x509.CertificateSigningRequest` :return: The decoded CSR.
src/txacme/util.py
def decode_csr(b64der): """ Decode JOSE Base-64 DER-encoded CSR. :param str b64der: The encoded CSR. :rtype: `cryptography.x509.CertificateSigningRequest` :return: The decoded CSR. """ try: return x509.load_der_x509_csr( decode_b64jose(b64der), default_backend()) ex...
def decode_csr(b64der): """ Decode JOSE Base-64 DER-encoded CSR. :param str b64der: The encoded CSR. :rtype: `cryptography.x509.CertificateSigningRequest` :return: The decoded CSR. """ try: return x509.load_der_x509_csr( decode_b64jose(b64der), default_backend()) ex...
[ "Decode", "JOSE", "Base", "-", "64", "DER", "-", "encoded", "CSR", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L89-L102
[ "def", "decode_csr", "(", "b64der", ")", ":", "try", ":", "return", "x509", ".", "load_der_x509_csr", "(", "decode_b64jose", "(", "b64der", ")", ",", "default_backend", "(", ")", ")", "except", "ValueError", "as", "error", ":", "raise", "DeserializationError",...
9478381cc63c6d53d14bf8db8407c923f472989a
train
csr_for_names
Generate a certificate signing request for the given names and private key. .. seealso:: `acme.client.Client.request_issuance` .. seealso:: `generate_private_key` :param ``List[str]``: One or more names (subjectAltName) for which to request a certificate. :param key: A Cryptography private ...
src/txacme/util.py
def csr_for_names(names, key): """ Generate a certificate signing request for the given names and private key. .. seealso:: `acme.client.Client.request_issuance` .. seealso:: `generate_private_key` :param ``List[str]``: One or more names (subjectAltName) for which to request a certifica...
def csr_for_names(names, key): """ Generate a certificate signing request for the given names and private key. .. seealso:: `acme.client.Client.request_issuance` .. seealso:: `generate_private_key` :param ``List[str]``: One or more names (subjectAltName) for which to request a certifica...
[ "Generate", "a", "certificate", "signing", "request", "for", "the", "given", "names", "and", "private", "key", "." ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/util.py#L105-L133
[ "def", "csr_for_names", "(", "names", ",", "key", ")", ":", "if", "len", "(", "names", ")", "==", "0", ":", "raise", "ValueError", "(", "'Must have at least one name'", ")", "if", "len", "(", "names", "[", "0", "]", ")", ">", "64", ":", "common_name", ...
9478381cc63c6d53d14bf8db8407c923f472989a
train
Debug._wrap_parse
async wrapper is required to avoid await calls raising a SyntaxError
devtools/debug.py
def _wrap_parse(code, filename): """ async wrapper is required to avoid await calls raising a SyntaxError """ code = 'async def wrapper():\n' + indent(code, ' ') return ast.parse(code, filename=filename).body[0].body[0].value
def _wrap_parse(code, filename): """ async wrapper is required to avoid await calls raising a SyntaxError """ code = 'async def wrapper():\n' + indent(code, ' ') return ast.parse(code, filename=filename).body[0].body[0].value
[ "async", "wrapper", "is", "required", "to", "avoid", "await", "calls", "raising", "a", "SyntaxError" ]
samuelcolvin/python-devtools
python
https://github.com/samuelcolvin/python-devtools/blob/fb0021b3e6815348a28c1d2bf11b50b8f0bd511a/devtools/debug.py#L274-L279
[ "def", "_wrap_parse", "(", "code", ",", "filename", ")", ":", "code", "=", "'async def wrapper():\\n'", "+", "indent", "(", "code", ",", "' '", ")", "return", "ast", ".", "parse", "(", "code", ",", "filename", "=", "filename", ")", ".", "body", "[", "0...
fb0021b3e6815348a28c1d2bf11b50b8f0bd511a
train
linkcode_resolve
Determine the URL corresponding to Python object
docs/conf.py
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for part ...
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object """ if domain != 'py': return None modname = info['module'] fullname = info['fullname'] submod = sys.modules.get(modname) if submod is None: return None obj = submod for part ...
[ "Determine", "the", "URL", "corresponding", "to", "Python", "object" ]
twisted/txacme
python
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/docs/conf.py#L326-L359
[ "def", "linkcode_resolve", "(", "domain", ",", "info", ")", ":", "if", "domain", "!=", "'py'", ":", "return", "None", "modname", "=", "info", "[", "'module'", "]", "fullname", "=", "info", "[", "'fullname'", "]", "submod", "=", "sys", ".", "modules", "...
9478381cc63c6d53d14bf8db8407c923f472989a
train
SolrHypermap.layers_to_solr
Sync n layers in Solr.
hypermap/aggregator/solr.py
def layers_to_solr(self, layers): """ Sync n layers in Solr. """ layers_dict_list = [] layers_success_ids = [] layers_errors_ids = [] for layer in layers: layer_dict, message = layer2dict(layer) if not layer_dict: layers_e...
def layers_to_solr(self, layers): """ Sync n layers in Solr. """ layers_dict_list = [] layers_success_ids = [] layers_errors_ids = [] for layer in layers: layer_dict, message = layer2dict(layer) if not layer_dict: layers_e...
[ "Sync", "n", "layers", "in", "Solr", "." ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L19-L50
[ "def", "layers_to_solr", "(", "self", ",", "layers", ")", ":", "layers_dict_list", "=", "[", "]", "layers_success_ids", "=", "[", "]", "layers_errors_ids", "=", "[", "]", "for", "layer", "in", "layers", ":", "layer_dict", ",", "message", "=", "layer2dict", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
SolrHypermap.layer_to_solr
Sync a layer in Solr.
hypermap/aggregator/solr.py
def layer_to_solr(self, layer): """ Sync a layer in Solr. """ success = True message = 'Synced layer id %s to Solr' % layer.id layer_dict, message = layer2dict(layer) if not layer_dict: success = False else: layer_json = json.dumps...
def layer_to_solr(self, layer): """ Sync a layer in Solr. """ success = True message = 'Synced layer id %s to Solr' % layer.id layer_dict, message = layer2dict(layer) if not layer_dict: success = False else: layer_json = json.dumps...
[ "Sync", "a", "layer", "in", "Solr", "." ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L52-L81
[ "def", "layer_to_solr", "(", "self", ",", "layer", ")", ":", "success", "=", "True", "message", "=", "'Synced layer id %s to Solr'", "%", "layer", ".", "id", "layer_dict", ",", "message", "=", "layer2dict", "(", "layer", ")", "if", "not", "layer_dict", ":", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
SolrHypermap.clear_solr
Clear all indexes in the solr core
hypermap/aggregator/solr.py
def clear_solr(self, catalog="hypermap"): """Clear all indexes in the solr core""" solr_url = "{0}/solr/{1}".format(SEARCH_URL, catalog) solr = pysolr.Solr(solr_url, timeout=60) solr.delete(q='*:*') LOGGER.debug('Solr core cleared')
def clear_solr(self, catalog="hypermap"): """Clear all indexes in the solr core""" solr_url = "{0}/solr/{1}".format(SEARCH_URL, catalog) solr = pysolr.Solr(solr_url, timeout=60) solr.delete(q='*:*') LOGGER.debug('Solr core cleared')
[ "Clear", "all", "indexes", "in", "the", "solr", "core" ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L83-L88
[ "def", "clear_solr", "(", "self", ",", "catalog", "=", "\"hypermap\"", ")", ":", "solr_url", "=", "\"{0}/solr/{1}\"", ".", "format", "(", "SEARCH_URL", ",", "catalog", ")", "solr", "=", "pysolr", ".", "Solr", "(", "solr_url", ",", "timeout", "=", "60", "...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
SolrHypermap.update_schema
set the mapping in solr. :param catalog: core :return:
hypermap/aggregator/solr.py
def update_schema(self, catalog="hypermap"): """ set the mapping in solr. :param catalog: core :return: """ schema_url = "{0}/solr/{1}/schema".format(SEARCH_URL, catalog) print schema_url # create a special type to draw better heatmaps. location_r...
def update_schema(self, catalog="hypermap"): """ set the mapping in solr. :param catalog: core :return: """ schema_url = "{0}/solr/{1}/schema".format(SEARCH_URL, catalog) print schema_url # create a special type to draw better heatmaps. location_r...
[ "set", "the", "mapping", "in", "solr", ".", ":", "param", "catalog", ":", "core", ":", "return", ":" ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/solr.py#L99-L221
[ "def", "update_schema", "(", "self", ",", "catalog", "=", "\"hypermap\"", ")", ":", "schema_url", "=", "\"{0}/solr/{1}/schema\"", ".", "format", "(", "SEARCH_URL", ",", "catalog", ")", "print", "schema_url", "# create a special type to draw better heatmaps.", "location_...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
create_layer_from_metadata_xml
Create a layer / keyword list from a metadata record if it does not already exist.
hypermap/aggregator/utils.py
def create_layer_from_metadata_xml(resourcetype, xml, monitor=False, service=None, catalog=None): """ Create a layer / keyword list from a metadata record if it does not already exist. """ from models import gen_anytext, Layer if resourcetype == 'http://www.opengis.net/cat/csw/2.0.2': # Dublin cor...
def create_layer_from_metadata_xml(resourcetype, xml, monitor=False, service=None, catalog=None): """ Create a layer / keyword list from a metadata record if it does not already exist. """ from models import gen_anytext, Layer if resourcetype == 'http://www.opengis.net/cat/csw/2.0.2': # Dublin cor...
[ "Create", "a", "layer", "/", "keyword", "list", "from", "a", "metadata", "record", "if", "it", "does", "not", "already", "exist", "." ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L28-L59
[ "def", "create_layer_from_metadata_xml", "(", "resourcetype", ",", "xml", ",", "monitor", "=", "False", ",", "service", "=", "None", ",", "catalog", "=", "None", ")", ":", "from", "models", "import", "gen_anytext", ",", "Layer", "if", "resourcetype", "==", "...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
create_service_from_endpoint
Create a service from an endpoint if it does not already exists.
hypermap/aggregator/utils.py
def create_service_from_endpoint(endpoint, service_type, title=None, abstract=None, catalog=None): """ Create a service from an endpoint if it does not already exists. """ from models import Service if Service.objects.filter(url=endpoint, catalog=catalog).count() == 0: # check if endpoint is...
def create_service_from_endpoint(endpoint, service_type, title=None, abstract=None, catalog=None): """ Create a service from an endpoint if it does not already exists. """ from models import Service if Service.objects.filter(url=endpoint, catalog=catalog).count() == 0: # check if endpoint is...
[ "Create", "a", "service", "from", "an", "endpoint", "if", "it", "does", "not", "already", "exists", "." ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L62-L82
[ "def", "create_service_from_endpoint", "(", "endpoint", ",", "service_type", ",", "title", "=", "None", ",", "abstract", "=", "None", ",", "catalog", "=", "None", ")", ":", "from", "models", "import", "Service", "if", "Service", ".", "objects", ".", "filter"...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
create_services_from_endpoint
Generate service/services from an endpoint. WMS, WMTS, TMS endpoints correspond to a single service. ESRI, CSW endpoints corrispond to many services. :return: imported, message
hypermap/aggregator/utils.py
def create_services_from_endpoint(url, catalog, greedy_opt=True): """ Generate service/services from an endpoint. WMS, WMTS, TMS endpoints correspond to a single service. ESRI, CSW endpoints corrispond to many services. :return: imported, message """ # this variable will collect any excepti...
def create_services_from_endpoint(url, catalog, greedy_opt=True): """ Generate service/services from an endpoint. WMS, WMTS, TMS endpoints correspond to a single service. ESRI, CSW endpoints corrispond to many services. :return: imported, message """ # this variable will collect any excepti...
[ "Generate", "service", "/", "services", "from", "an", "endpoint", ".", "WMS", "WMTS", "TMS", "endpoints", "correspond", "to", "a", "single", "service", ".", "ESRI", "CSW", "endpoints", "corrispond", "to", "many", "services", ".", ":", "return", ":", "importe...
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L85-L332
[ "def", "create_services_from_endpoint", "(", "url", ",", "catalog", ",", "greedy_opt", "=", "True", ")", ":", "# this variable will collect any exception message during the routine.", "# will be used in the last step to send a message if \"detected\" var is False.", "messages", "=", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
service_url_parse
Function that parses from url the service and folder of services.
hypermap/aggregator/utils.py
def service_url_parse(url): """ Function that parses from url the service and folder of services. """ endpoint = get_sanitized_endpoint(url) url_split_list = url.split(endpoint + '/') if len(url_split_list) != 0: url_split_list = url_split_list[1].split('/') else: raise Excep...
def service_url_parse(url): """ Function that parses from url the service and folder of services. """ endpoint = get_sanitized_endpoint(url) url_split_list = url.split(endpoint + '/') if len(url_split_list) != 0: url_split_list = url_split_list[1].split('/') else: raise Excep...
[ "Function", "that", "parses", "from", "url", "the", "service", "and", "folder", "of", "services", "." ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L335-L349
[ "def", "service_url_parse", "(", "url", ")", ":", "endpoint", "=", "get_sanitized_endpoint", "(", "url", ")", "url_split_list", "=", "url", ".", "split", "(", "endpoint", "+", "'/'", ")", "if", "len", "(", "url_split_list", ")", "!=", "0", ":", "url_split_...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
inverse_mercator
Given coordinates in spherical mercator, return a lon,lat tuple.
hypermap/aggregator/utils.py
def inverse_mercator(xy): """ Given coordinates in spherical mercator, return a lon,lat tuple. """ lon = (xy[0] / 20037508.34) * 180 lat = (xy[1] / 20037508.34) * 180 lat = 180 / math.pi * \ (2 * math.atan(math.exp(lat * math.pi / 180)) - math.pi / 2) return (lon, lat)
def inverse_mercator(xy): """ Given coordinates in spherical mercator, return a lon,lat tuple. """ lon = (xy[0] / 20037508.34) * 180 lat = (xy[1] / 20037508.34) * 180 lat = 180 / math.pi * \ (2 * math.atan(math.exp(lat * math.pi / 180)) - math.pi / 2) return (lon, lat)
[ "Given", "coordinates", "in", "spherical", "mercator", "return", "a", "lon", "lat", "tuple", "." ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L404-L412
[ "def", "inverse_mercator", "(", "xy", ")", ":", "lon", "=", "(", "xy", "[", "0", "]", "/", "20037508.34", ")", "*", "180", "lat", "=", "(", "xy", "[", "1", "]", "/", "20037508.34", ")", "*", "180", "lat", "=", "180", "/", "math", ".", "pi", "...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
get_wms_version_negotiate
OWSLib wrapper function to perform version negotiation against owslib.wms.WebMapService
hypermap/aggregator/utils.py
def get_wms_version_negotiate(url, timeout=10): """ OWSLib wrapper function to perform version negotiation against owslib.wms.WebMapService """ try: LOGGER.debug('Trying a WMS 1.3.0 GetCapabilities request') return WebMapService(url, version='1.3.0', timeout=timeout) except Exceptio...
def get_wms_version_negotiate(url, timeout=10): """ OWSLib wrapper function to perform version negotiation against owslib.wms.WebMapService """ try: LOGGER.debug('Trying a WMS 1.3.0 GetCapabilities request') return WebMapService(url, version='1.3.0', timeout=timeout) except Exceptio...
[ "OWSLib", "wrapper", "function", "to", "perform", "version", "negotiation", "against", "owslib", ".", "wms", ".", "WebMapService" ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L415-L426
[ "def", "get_wms_version_negotiate", "(", "url", ",", "timeout", "=", "10", ")", ":", "try", ":", "LOGGER", ".", "debug", "(", "'Trying a WMS 1.3.0 GetCapabilities request'", ")", "return", "WebMapService", "(", "url", ",", "version", "=", "'1.3.0'", ",", "timeou...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
get_sanitized_endpoint
Sanitize an endpoint, as removing unneeded parameters
hypermap/aggregator/utils.py
def get_sanitized_endpoint(url): """ Sanitize an endpoint, as removing unneeded parameters """ # sanitize esri sanitized_url = url.rstrip() esri_string = '/rest/services' if esri_string in url: match = re.search(esri_string, sanitized_url) sanitized_url = url[0:(match.start(0...
def get_sanitized_endpoint(url): """ Sanitize an endpoint, as removing unneeded parameters """ # sanitize esri sanitized_url = url.rstrip() esri_string = '/rest/services' if esri_string in url: match = re.search(esri_string, sanitized_url) sanitized_url = url[0:(match.start(0...
[ "Sanitize", "an", "endpoint", "as", "removing", "unneeded", "parameters" ]
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L435-L445
[ "def", "get_sanitized_endpoint", "(", "url", ")", ":", "# sanitize esri", "sanitized_url", "=", "url", ".", "rstrip", "(", ")", "esri_string", "=", "'/rest/services'", "if", "esri_string", "in", "url", ":", "match", "=", "re", ".", "search", "(", "esri_string"...
899a5385b15af7fba190ab4fae1d41e47d155a1b
train
get_esri_service_name
A method to get a service name from an esri endpoint. For example: http://example.com/arcgis/rest/services/myservice/mylayer/MapServer/?f=json Will return: myservice/mylayer
hypermap/aggregator/utils.py
def get_esri_service_name(url): """ A method to get a service name from an esri endpoint. For example: http://example.com/arcgis/rest/services/myservice/mylayer/MapServer/?f=json Will return: myservice/mylayer """ result = re.search('rest/services/(.*)/[MapServer|ImageServer]', url) if resul...
def get_esri_service_name(url): """ A method to get a service name from an esri endpoint. For example: http://example.com/arcgis/rest/services/myservice/mylayer/MapServer/?f=json Will return: myservice/mylayer """ result = re.search('rest/services/(.*)/[MapServer|ImageServer]', url) if resul...
[ "A", "method", "to", "get", "a", "service", "name", "from", "an", "esri", "endpoint", ".", "For", "example", ":", "http", ":", "//", "example", ".", "com", "/", "arcgis", "/", "rest", "/", "services", "/", "myservice", "/", "mylayer", "/", "MapServer",...
cga-harvard/Hypermap-Registry
python
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/utils.py#L448-L458
[ "def", "get_esri_service_name", "(", "url", ")", ":", "result", "=", "re", ".", "search", "(", "'rest/services/(.*)/[MapServer|ImageServer]'", ",", "url", ")", "if", "result", "is", "None", ":", "return", "url", "else", ":", "return", "result", ".", "group", ...
899a5385b15af7fba190ab4fae1d41e47d155a1b