Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
sequence
start_point
sequence
end_point
sequence
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
member_calldef_t.has_static
(self)
describes, whether "callable" has static modifier or not
describes, whether "callable" has static modifier or not
def has_static(self): """describes, whether "callable" has static modifier or not""" return self._has_static
[ "def", "has_static", "(", "self", ")", ":", "return", "self", ".", "_has_static" ]
[ 96, 4 ]
[ 98, 31 ]
python
en
['en', 'gl', 'en']
True
member_calldef_t.function_type
(self)
returns function type. See :class:`type_t` hierarchy
returns function type. See :class:`type_t` hierarchy
def function_type(self): """returns function type. See :class:`type_t` hierarchy""" if self.has_static: return cpptypes.free_function_type_t( return_type=self.return_type, arguments_types=[arg.decl_type for arg in self.arguments]) else: return cpptypes.member_function_type_t( class_inst=self.parent, return_type=self.return_type, arguments_types=[arg.decl_type for arg in self.arguments], has_const=self.has_const)
[ "def", "function_type", "(", "self", ")", ":", "if", "self", ".", "has_static", ":", "return", "cpptypes", ".", "free_function_type_t", "(", "return_type", "=", "self", ".", "return_type", ",", "arguments_types", "=", "[", "arg", ".", "decl_type", "for", "arg", "in", "self", ".", "arguments", "]", ")", "else", ":", "return", "cpptypes", ".", "member_function_type_t", "(", "class_inst", "=", "self", ".", "parent", ",", "return_type", "=", "self", ".", "return_type", ",", "arguments_types", "=", "[", "arg", ".", "decl_type", "for", "arg", "in", "self", ".", "arguments", "]", ",", "has_const", "=", "self", ".", "has_const", ")" ]
[ 104, 4 ]
[ 115, 41 ]
python
en
['en', 'en', 'en']
True
operator_t.symbol
(self)
operator's symbol. For example: operator+, symbol is equal to '+
operator's symbol. For example: operator+, symbol is equal to '+
def symbol(self): """operator's symbol. For example: operator+, symbol is equal to '+'""" return self.name[operator_t.OPERATOR_WORD_LEN:].strip()
[ "def", "symbol", "(", "self", ")", ":", "return", "self", ".", "name", "[", "operator_t", ".", "OPERATOR_WORD_LEN", ":", "]", ".", "strip", "(", ")" ]
[ 147, 4 ]
[ 149, 63 ]
python
en
['en', 'en', 'en']
True
constructor_t.explicit
(self)
True, if constructor has "explicit" keyword, False otherwise @type: bool
True, if constructor has "explicit" keyword, False otherwise
def explicit(self): """True, if constructor has "explicit" keyword, False otherwise @type: bool""" return self._explicit
[ "def", "explicit", "(", "self", ")", ":", "return", "self", ".", "_explicit" ]
[ 170, 4 ]
[ 173, 29 ]
python
en
['en', 'en', 'en']
True
FilterSelect._filter_F_one_feature
(data, treatment_indicator, feature_name, y_name)
Conduct F-test of the interaction between treatment and one feature. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics
Conduct F-test of the interaction between treatment and one feature.
def _filter_F_one_feature(data, treatment_indicator, feature_name, y_name): """ Conduct F-test of the interaction between treatment and one feature. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics """ Y = data[y_name] X = data[[treatment_indicator, feature_name]] X = sm.add_constant(X) X['{}-{}'.format(treatment_indicator, feature_name)] = X[[treatment_indicator, feature_name]].product(axis=1) model = sm.OLS(Y, X) result = model.fit() F_test = result.f_test(np.array([0, 0, 0, 1])) F_test_result = pd.DataFrame({ 'feature': feature_name, # for the interaction, not the main effect 'method': 'F-statistic', 'score': F_test.fvalue[0][0], 'p_value': F_test.pvalue, 'misc': 'df_num: {}, df_denom: {}'.format(F_test.df_num, F_test.df_denom), }, index=[0]).reset_index(drop=True) return F_test_result
[ "def", "_filter_F_one_feature", "(", "data", ",", "treatment_indicator", ",", "feature_name", ",", "y_name", ")", ":", "Y", "=", "data", "[", "y_name", "]", "X", "=", "data", "[", "[", "treatment_indicator", ",", "feature_name", "]", "]", "X", "=", "sm", ".", "add_constant", "(", "X", ")", "X", "[", "'{}-{}'", ".", "format", "(", "treatment_indicator", ",", "feature_name", ")", "]", "=", "X", "[", "[", "treatment_indicator", ",", "feature_name", "]", "]", ".", "product", "(", "axis", "=", "1", ")", "model", "=", "sm", ".", "OLS", "(", "Y", ",", "X", ")", "result", "=", "model", ".", "fit", "(", ")", "F_test", "=", "result", ".", "f_test", "(", "np", ".", "array", "(", "[", "0", ",", "0", ",", "0", ",", "1", "]", ")", ")", "F_test_result", "=", "pd", ".", "DataFrame", "(", "{", "'feature'", ":", "feature_name", ",", "# for the interaction, not the main effect", "'method'", ":", "'F-statistic'", ",", "'score'", ":", "F_test", ".", "fvalue", "[", "0", "]", "[", "0", "]", ",", "'p_value'", ":", "F_test", ".", "pvalue", ",", "'misc'", ":", "'df_num: {}, df_denom: {}'", ".", "format", "(", "F_test", ".", "df_num", ",", "F_test", ".", "df_denom", ")", ",", "}", ",", "index", "=", "[", "0", "]", ")", ".", "reset_index", "(", "drop", "=", "True", ")", "return", "F_test_result" ]
[ 20, 4 ]
[ 52, 28 ]
python
en
['en', 'error', 'th']
False
FilterSelect.filter_F
(self, data, treatment_indicator, features, y_name)
Rank features based on the F-statistics of the interaction. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) features (list of string): list of feature names, that are columns in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics
Rank features based on the F-statistics of the interaction.
def filter_F(self, data, treatment_indicator, features, y_name): """ Rank features based on the F-statistics of the interaction. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) features (list of string): list of feature names, that are columns in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics """ all_result = pd.DataFrame() for x_name_i in features: one_result = self._filter_F_one_feature(data=data, treatment_indicator=treatment_indicator, feature_name=x_name_i, y_name=y_name ) all_result = pd.concat([all_result, one_result]) all_result = all_result.sort_values(by='score', ascending=False) all_result['rank'] = all_result['score'].rank(ascending=False) return all_result
[ "def", "filter_F", "(", "self", ",", "data", ",", "treatment_indicator", ",", "features", ",", "y_name", ")", ":", "all_result", "=", "pd", ".", "DataFrame", "(", ")", "for", "x_name_i", "in", "features", ":", "one_result", "=", "self", ".", "_filter_F_one_feature", "(", "data", "=", "data", ",", "treatment_indicator", "=", "treatment_indicator", ",", "feature_name", "=", "x_name_i", ",", "y_name", "=", "y_name", ")", "all_result", "=", "pd", ".", "concat", "(", "[", "all_result", ",", "one_result", "]", ")", "all_result", "=", "all_result", ".", "sort_values", "(", "by", "=", "'score'", ",", "ascending", "=", "False", ")", "all_result", "[", "'rank'", "]", "=", "all_result", "[", "'score'", "]", ".", "rank", "(", "ascending", "=", "False", ")", "return", "all_result" ]
[ 55, 4 ]
[ 80, 25 ]
python
en
['en', 'error', 'th']
False
FilterSelect._filter_LR_one_feature
(data, treatment_indicator, feature_name, y_name, disp=True)
Conduct LR (Likelihood Ratio) test of the interaction between treatment and one feature. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics
Conduct LR (Likelihood Ratio) test of the interaction between treatment and one feature.
def _filter_LR_one_feature(data, treatment_indicator, feature_name, y_name, disp=True): """ Conduct LR (Likelihood Ratio) test of the interaction between treatment and one feature. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics """ Y = data[y_name] # Restricted model X_r = data[[treatment_indicator, feature_name]] X_r = sm.add_constant(X_r) model_r = sm.Logit(Y, X_r) result_r = model_r.fit(disp=disp) # Full model (with interaction) X_f = X_r.copy() X_f['{}-{}'.format(treatment_indicator, feature_name)] = X_f[[treatment_indicator, feature_name]].product(axis=1) model_f = sm.Logit(Y, X_f) result_f = model_f.fit(disp=disp) LR_stat = -2 * (result_r.llf - result_f.llf) LR_df = len(result_f.params) - len(result_r.params) LR_pvalue = 1 - stats.chi2.cdf(LR_stat, df=LR_df) LR_test_result = pd.DataFrame({ 'feature': feature_name, # for the interaction, not the main effect 'method': 'LRT-statistic', 'score': LR_stat, 'p_value': LR_pvalue, 'misc': 'df: {}'.format(LR_df), }, index=[0]).reset_index(drop=True) return LR_test_result
[ "def", "_filter_LR_one_feature", "(", "data", ",", "treatment_indicator", ",", "feature_name", ",", "y_name", ",", "disp", "=", "True", ")", ":", "Y", "=", "data", "[", "y_name", "]", "# Restricted model", "X_r", "=", "data", "[", "[", "treatment_indicator", ",", "feature_name", "]", "]", "X_r", "=", "sm", ".", "add_constant", "(", "X_r", ")", "model_r", "=", "sm", ".", "Logit", "(", "Y", ",", "X_r", ")", "result_r", "=", "model_r", ".", "fit", "(", "disp", "=", "disp", ")", "# Full model (with interaction)", "X_f", "=", "X_r", ".", "copy", "(", ")", "X_f", "[", "'{}-{}'", ".", "format", "(", "treatment_indicator", ",", "feature_name", ")", "]", "=", "X_f", "[", "[", "treatment_indicator", ",", "feature_name", "]", "]", ".", "product", "(", "axis", "=", "1", ")", "model_f", "=", "sm", ".", "Logit", "(", "Y", ",", "X_f", ")", "result_f", "=", "model_f", ".", "fit", "(", "disp", "=", "disp", ")", "LR_stat", "=", "-", "2", "*", "(", "result_r", ".", "llf", "-", "result_f", ".", "llf", ")", "LR_df", "=", "len", "(", "result_f", ".", "params", ")", "-", "len", "(", "result_r", ".", "params", ")", "LR_pvalue", "=", "1", "-", "stats", ".", "chi2", ".", "cdf", "(", "LR_stat", ",", "df", "=", "LR_df", ")", "LR_test_result", "=", "pd", ".", "DataFrame", "(", "{", "'feature'", ":", "feature_name", ",", "# for the interaction, not the main effect", "'method'", ":", "'LRT-statistic'", ",", "'score'", ":", "LR_stat", ",", "'p_value'", ":", "LR_pvalue", ",", "'misc'", ":", "'df: {}'", ".", "format", "(", "LR_df", ")", ",", "}", ",", "index", "=", "[", "0", "]", ")", ".", "reset_index", "(", "drop", "=", "True", ")", "return", "LR_test_result" ]
[ 84, 4 ]
[ 125, 29 ]
python
en
['en', 'error', 'th']
False
FilterSelect.filter_LR
(self, data, treatment_indicator, features, y_name, disp=True)
Rank features based on the LRT-statistics of the interaction. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics
Rank features based on the LRT-statistics of the interaction.
def filter_LR(self, data, treatment_indicator, features, y_name, disp=True): """ Rank features based on the LRT-statistics of the interaction. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics """ all_result = pd.DataFrame() for x_name_i in features: one_result = self._filter_LR_one_feature(data=data, treatment_indicator=treatment_indicator, feature_name=x_name_i, y_name=y_name, disp=disp ) all_result = pd.concat([all_result, one_result]) all_result = all_result.sort_values(by='score', ascending=False) all_result['rank'] = all_result['score'].rank(ascending=False) return all_result
[ "def", "filter_LR", "(", "self", ",", "data", ",", "treatment_indicator", ",", "features", ",", "y_name", ",", "disp", "=", "True", ")", ":", "all_result", "=", "pd", ".", "DataFrame", "(", ")", "for", "x_name_i", "in", "features", ":", "one_result", "=", "self", ".", "_filter_LR_one_feature", "(", "data", "=", "data", ",", "treatment_indicator", "=", "treatment_indicator", ",", "feature_name", "=", "x_name_i", ",", "y_name", "=", "y_name", ",", "disp", "=", "disp", ")", "all_result", "=", "pd", ".", "concat", "(", "[", "all_result", ",", "one_result", "]", ")", "all_result", "=", "all_result", ".", "sort_values", "(", "by", "=", "'score'", ",", "ascending", "=", "False", ")", "all_result", "[", "'rank'", "]", "=", "all_result", "[", "'score'", "]", ".", "rank", "(", "ascending", "=", "False", ")", "return", "all_result" ]
[ 128, 4 ]
[ 153, 25 ]
python
en
['en', 'error', 'th']
False
FilterSelect._GetNodeSummary
(data, experiment_group_column='treatment_group_key', y_name='conversion', smooth=True)
To count the conversions and get the probabilities by treatment groups. This function comes from the uplift tree algorithm, that is used for tree node split evaluation. Parameters ---------- data : DataFrame The DataFrame that contains all the data (in the current "node"). experiment_group_column : str Treatment indicator column name. y_name : str Label indicator column name. smooth : bool Smooth label count by adding 1 in case certain labels do not occur naturally with a treatment. Prevents zero divisions. Returns ------- results : dict Counts of conversions by treatment groups, of the form: {'control': {0: 10, 1: 8}, 'treatment1': {0: 5, 1: 15}} nodeSummary: dict Probability of conversion and group size by treatment groups, of the form: {'control': [0.490, 500], 'treatment1': [0.584, 500]}
To count the conversions and get the probabilities by treatment groups. This function comes from the uplift tree algorithm, that is used for tree node split evaluation.
def _GetNodeSummary(data, experiment_group_column='treatment_group_key', y_name='conversion', smooth=True): """ To count the conversions and get the probabilities by treatment groups. This function comes from the uplift tree algorithm, that is used for tree node split evaluation. Parameters ---------- data : DataFrame The DataFrame that contains all the data (in the current "node"). experiment_group_column : str Treatment indicator column name. y_name : str Label indicator column name. smooth : bool Smooth label count by adding 1 in case certain labels do not occur naturally with a treatment. Prevents zero divisions. Returns ------- results : dict Counts of conversions by treatment groups, of the form: {'control': {0: 10, 1: 8}, 'treatment1': {0: 5, 1: 15}} nodeSummary: dict Probability of conversion and group size by treatment groups, of the form: {'control': [0.490, 500], 'treatment1': [0.584, 500]} """ # Note: results and nodeSummary are both dict with treatment_group_key # as the key. So we can compute the treatment effect and/or # divergence easily. # Counts of conversions by treatment group results_series = data.groupby([experiment_group_column, y_name]).size() treatment_group_keys = results_series.index.levels[0].tolist() y_name_keys = results_series.index.levels[1].tolist() results = {} for ti in treatment_group_keys: results.update({ti: {}}) for ci in y_name_keys: if smooth: results[ti].update({ci: results_series[ti, ci] if results_series.index.isin([(ti, ci)]).any() else 1}) else: results[ti].update({ci: results_series[ti, ci]}) # Probability of conversion and group size by treatment group nodeSummary = {} for treatment_group_key in results: n_1 = results[treatment_group_key].get(1, 0) n_total = (results[treatment_group_key].get(1, 0) + results[treatment_group_key].get(0, 0)) y_mean = 1.0 * n_1 / n_total nodeSummary[treatment_group_key] = [y_mean, n_total] return results, nodeSummary
[ "def", "_GetNodeSummary", "(", "data", ",", "experiment_group_column", "=", "'treatment_group_key'", ",", "y_name", "=", "'conversion'", ",", "smooth", "=", "True", ")", ":", "# Note: results and nodeSummary are both dict with treatment_group_key", "# as the key. So we can compute the treatment effect and/or ", "# divergence easily.", "# Counts of conversions by treatment group", "results_series", "=", "data", ".", "groupby", "(", "[", "experiment_group_column", ",", "y_name", "]", ")", ".", "size", "(", ")", "treatment_group_keys", "=", "results_series", ".", "index", ".", "levels", "[", "0", "]", ".", "tolist", "(", ")", "y_name_keys", "=", "results_series", ".", "index", ".", "levels", "[", "1", "]", ".", "tolist", "(", ")", "results", "=", "{", "}", "for", "ti", "in", "treatment_group_keys", ":", "results", ".", "update", "(", "{", "ti", ":", "{", "}", "}", ")", "for", "ci", "in", "y_name_keys", ":", "if", "smooth", ":", "results", "[", "ti", "]", ".", "update", "(", "{", "ci", ":", "results_series", "[", "ti", ",", "ci", "]", "if", "results_series", ".", "index", ".", "isin", "(", "[", "(", "ti", ",", "ci", ")", "]", ")", ".", "any", "(", ")", "else", "1", "}", ")", "else", ":", "results", "[", "ti", "]", ".", "update", "(", "{", "ci", ":", "results_series", "[", "ti", ",", "ci", "]", "}", ")", "# Probability of conversion and group size by treatment group", "nodeSummary", "=", "{", "}", "for", "treatment_group_key", "in", "results", ":", "n_1", "=", "results", "[", "treatment_group_key", "]", ".", "get", "(", "1", ",", "0", ")", "n_total", "=", "(", "results", "[", "treatment_group_key", "]", ".", "get", "(", "1", ",", "0", ")", "+", "results", "[", "treatment_group_key", "]", ".", "get", "(", "0", ",", "0", ")", ")", "y_mean", "=", "1.0", "*", "n_1", "/", "n_total", "nodeSummary", "[", "treatment_group_key", "]", "=", "[", "y_mean", ",", "n_total", "]", "return", "results", ",", "nodeSummary" ]
[ 158, 4 ]
[ 217, 35 ]
python
en
['en', 'error', 'th']
False
FilterSelect._kl_divergence
(pk, qk)
Calculate KL Divergence for binary classification. Parameters ---------- pk (float): Probability of class 1 in treatment group qk (float): Probability of class 1 in control group
Calculate KL Divergence for binary classification.
def _kl_divergence(pk, qk): """ Calculate KL Divergence for binary classification. Parameters ---------- pk (float): Probability of class 1 in treatment group qk (float): Probability of class 1 in control group """ if qk < 0.1**6: qk = 0.1**6 elif qk > 1 - 0.1**6: qk = 1 - 0.1**6 S = pk * np.log(pk / qk) + (1-pk) * np.log((1-pk) / (1-qk)) return S
[ "def", "_kl_divergence", "(", "pk", ",", "qk", ")", ":", "if", "qk", "<", "0.1", "**", "6", ":", "qk", "=", "0.1", "**", "6", "elif", "qk", ">", "1", "-", "0.1", "**", "6", ":", "qk", "=", "1", "-", "0.1", "**", "6", "S", "=", "pk", "*", "np", ".", "log", "(", "pk", "/", "qk", ")", "+", "(", "1", "-", "pk", ")", "*", "np", ".", "log", "(", "(", "1", "-", "pk", ")", "/", "(", "1", "-", "qk", ")", ")", "return", "S" ]
[ 221, 4 ]
[ 235, 16 ]
python
en
['en', 'error', 'th']
False
FilterSelect._evaluate_KL
(self, nodeSummary, control_group='control')
Calculate the multi-treatment unconditional D (one node) with KL Divergence as split Evaluation function. Parameters ---------- nodeSummary (dict): a dictionary containing the statistics for a tree node sample control_group (string, optional, default='control'): the name for control group Notes ----- The function works for more than one non-control treatment groups.
Calculate the multi-treatment unconditional D (one node) with KL Divergence as split Evaluation function.
def _evaluate_KL(self, nodeSummary, control_group='control'): """ Calculate the multi-treatment unconditional D (one node) with KL Divergence as split Evaluation function. Parameters ---------- nodeSummary (dict): a dictionary containing the statistics for a tree node sample control_group (string, optional, default='control'): the name for control group Notes ----- The function works for more than one non-control treatment groups. """ if control_group not in nodeSummary: return 0 pc = nodeSummary[control_group][0] d_res = 0 for treatment_group in nodeSummary: if treatment_group != control_group: d_res += self._kl_divergence(nodeSummary[treatment_group][0], pc) return d_res
[ "def", "_evaluate_KL", "(", "self", ",", "nodeSummary", ",", "control_group", "=", "'control'", ")", ":", "if", "control_group", "not", "in", "nodeSummary", ":", "return", "0", "pc", "=", "nodeSummary", "[", "control_group", "]", "[", "0", "]", "d_res", "=", "0", "for", "treatment_group", "in", "nodeSummary", ":", "if", "treatment_group", "!=", "control_group", ":", "d_res", "+=", "self", ".", "_kl_divergence", "(", "nodeSummary", "[", "treatment_group", "]", "[", "0", "]", ",", "pc", ")", "return", "d_res" ]
[ 237, 4 ]
[ 258, 20 ]
python
en
['en', 'error', 'th']
False
FilterSelect._evaluate_ED
(nodeSummary, control_group='control')
Calculate the multi-treatment unconditional D (one node) with Euclidean Distance as split Evaluation function. Parameters ---------- nodeSummary (dict): a dictionary containing the statistics for a tree node sample control_group (string, optional, default='control'): the name for control group
Calculate the multi-treatment unconditional D (one node) with Euclidean Distance as split Evaluation function.
def _evaluate_ED(nodeSummary, control_group='control'): """ Calculate the multi-treatment unconditional D (one node) with Euclidean Distance as split Evaluation function. Parameters ---------- nodeSummary (dict): a dictionary containing the statistics for a tree node sample control_group (string, optional, default='control'): the name for control group """ if control_group not in nodeSummary: return 0 pc = nodeSummary[control_group][0] d_res = 0 for treatment_group in nodeSummary: if treatment_group != control_group: d_res += 2 * (nodeSummary[treatment_group][0] - pc)**2 return d_res
[ "def", "_evaluate_ED", "(", "nodeSummary", ",", "control_group", "=", "'control'", ")", ":", "if", "control_group", "not", "in", "nodeSummary", ":", "return", "0", "pc", "=", "nodeSummary", "[", "control_group", "]", "[", "0", "]", "d_res", "=", "0", "for", "treatment_group", "in", "nodeSummary", ":", "if", "treatment_group", "!=", "control_group", ":", "d_res", "+=", "2", "*", "(", "nodeSummary", "[", "treatment_group", "]", "[", "0", "]", "-", "pc", ")", "**", "2", "return", "d_res" ]
[ 261, 4 ]
[ 278, 20 ]
python
en
['en', 'error', 'th']
False
FilterSelect._evaluate_Chi
(nodeSummary, control_group='control')
Calculate the multi-treatment unconditional D (one node) with Chi-Square as split Evaluation function. Parameters ---------- nodeSummary (dict): a dictionary containing the statistics for a tree node sample control_group (string, optional, default='control'): the name for control group
Calculate the multi-treatment unconditional D (one node) with Chi-Square as split Evaluation function.
def _evaluate_Chi(nodeSummary, control_group='control'): """ Calculate the multi-treatment unconditional D (one node) with Chi-Square as split Evaluation function. Parameters ---------- nodeSummary (dict): a dictionary containing the statistics for a tree node sample control_group (string, optional, default='control'): the name for control group """ if control_group not in nodeSummary: return 0 pc = nodeSummary[control_group][0] d_res = 0 for treatment_group in nodeSummary: if treatment_group != control_group: d_res += ( (nodeSummary[treatment_group][0] - pc)**2 / max(0.1**6, pc) + (nodeSummary[treatment_group][0] - pc)**2 / max(0.1**6, 1-pc) ) return d_res
[ "def", "_evaluate_Chi", "(", "nodeSummary", ",", "control_group", "=", "'control'", ")", ":", "if", "control_group", "not", "in", "nodeSummary", ":", "return", "0", "pc", "=", "nodeSummary", "[", "control_group", "]", "[", "0", "]", "d_res", "=", "0", "for", "treatment_group", "in", "nodeSummary", ":", "if", "treatment_group", "!=", "control_group", ":", "d_res", "+=", "(", "(", "nodeSummary", "[", "treatment_group", "]", "[", "0", "]", "-", "pc", ")", "**", "2", "/", "max", "(", "0.1", "**", "6", ",", "pc", ")", "+", "(", "nodeSummary", "[", "treatment_group", "]", "[", "0", "]", "-", "pc", ")", "**", "2", "/", "max", "(", "0.1", "**", "6", ",", "1", "-", "pc", ")", ")", "return", "d_res" ]
[ 281, 4 ]
[ 302, 20 ]
python
en
['en', 'error', 'th']
False
FilterSelect._filter_D_one_feature
(self, data, feature_name, y_name, n_bins=10, method='KL', control_group='control', experiment_group_column='treatment_group_key', null_impute=None)
Calculate the chosen divergence measure for one feature. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'} The feature selection method to be used to rank the features. 'F' for F-test 'LR' for likelihood ratio test 'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively experiment_group_column (string, optional, default = 'treatment_group_key'): the experiment column name in the DataFrame, which contains the treatment and control assignment label control_group (string, optional, default = 'control'): name for control group, value in the experiment group column n_bins (int, optional, default = 10): number of bins to be used for bin-based uplift filter methods null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If Value is None and null is present then exception will be raised Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics
Calculate the chosen divergence measure for one feature.
def _filter_D_one_feature(self, data, feature_name, y_name, n_bins=10, method='KL', control_group='control', experiment_group_column='treatment_group_key', null_impute=None): """ Calculate the chosen divergence measure for one feature. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) feature_name (string): feature name, as one column in the data DataFrame y_name (string): name of the outcome variable method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'} The feature selection method to be used to rank the features. 'F' for F-test 'LR' for likelihood ratio test 'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively experiment_group_column (string, optional, default = 'treatment_group_key'): the experiment column name in the DataFrame, which contains the treatment and control assignment label control_group (string, optional, default = 'control'): name for control group, value in the experiment group column n_bins (int, optional, default = 10): number of bins to be used for bin-based uplift filter methods null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If Value is None and null is present then exception will be raised Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics """ # [TODO] Application to categorical features if method == 'KL': evaluationFunction = self._evaluate_KL elif method == 'ED': evaluationFunction = self._evaluate_ED elif method == 'Chi': evaluationFunction = self._evaluate_Chi totalSize = len(data.index) # impute null if enabled if null_impute is not None: data[feature_name] = SimpleImputer(missing_values=np.nan, strategy=null_impute).fit_transform(data[feature_name].values.reshape(-1, 1)) elif data[feature_name].isna().any(): raise Exception("Null value(s) present in column '{}'. Please impute the null value or use null_impute parameter provided!!!".format(feature_name)) # drop duplicate edges in pq.cut result to avoid issues x_bin = pd.qcut(data[feature_name].values, n_bins, labels=False, duplicates='drop') d_children = 0 for i_bin in range(np.nanmax(x_bin).astype(int) + 1): # range(n_bins): nodeSummary = self._GetNodeSummary( data=data.loc[x_bin == i_bin], experiment_group_column=experiment_group_column, y_name=y_name )[1] nodeScore = evaluationFunction(nodeSummary, control_group=control_group) nodeSize = sum([x[1] for x in list(nodeSummary.values())]) d_children += nodeScore * nodeSize / totalSize parentNodeSummary = self._GetNodeSummary( data=data, experiment_group_column=experiment_group_column, y_name=y_name )[1] d_parent = evaluationFunction(parentNodeSummary, control_group=control_group) d_res = d_children - d_parent D_result = pd.DataFrame({ 'feature': feature_name, 'method': method, 'score': d_res, 'p_value': None, 'misc': 'number_of_bins: {}'.format(min(n_bins, np.nanmax(x_bin).astype(int) + 1)),# format(n_bins), }, index=[0]).reset_index(drop=True) return(D_result)
[ "def", "_filter_D_one_feature", "(", "self", ",", "data", ",", "feature_name", ",", "y_name", ",", "n_bins", "=", "10", ",", "method", "=", "'KL'", ",", "control_group", "=", "'control'", ",", "experiment_group_column", "=", "'treatment_group_key'", ",", "null_impute", "=", "None", ")", ":", "# [TODO] Application to categorical features", "if", "method", "==", "'KL'", ":", "evaluationFunction", "=", "self", ".", "_evaluate_KL", "elif", "method", "==", "'ED'", ":", "evaluationFunction", "=", "self", ".", "_evaluate_ED", "elif", "method", "==", "'Chi'", ":", "evaluationFunction", "=", "self", ".", "_evaluate_Chi", "totalSize", "=", "len", "(", "data", ".", "index", ")", "# impute null if enabled", "if", "null_impute", "is", "not", "None", ":", "data", "[", "feature_name", "]", "=", "SimpleImputer", "(", "missing_values", "=", "np", ".", "nan", ",", "strategy", "=", "null_impute", ")", ".", "fit_transform", "(", "data", "[", "feature_name", "]", ".", "values", ".", "reshape", "(", "-", "1", ",", "1", ")", ")", "elif", "data", "[", "feature_name", "]", ".", "isna", "(", ")", ".", "any", "(", ")", ":", "raise", "Exception", "(", "\"Null value(s) present in column '{}'. Please impute the null value or use null_impute parameter provided!!!\"", ".", "format", "(", "feature_name", ")", ")", "# drop duplicate edges in pq.cut result to avoid issues", "x_bin", "=", "pd", ".", "qcut", "(", "data", "[", "feature_name", "]", ".", "values", ",", "n_bins", ",", "labels", "=", "False", ",", "duplicates", "=", "'drop'", ")", "d_children", "=", "0", "for", "i_bin", "in", "range", "(", "np", ".", "nanmax", "(", "x_bin", ")", ".", "astype", "(", "int", ")", "+", "1", ")", ":", "# range(n_bins):", "nodeSummary", "=", "self", ".", "_GetNodeSummary", "(", "data", "=", "data", ".", "loc", "[", "x_bin", "==", "i_bin", "]", ",", "experiment_group_column", "=", "experiment_group_column", ",", "y_name", "=", "y_name", ")", "[", "1", "]", "nodeScore", "=", "evaluationFunction", "(", "nodeSummary", ",", "control_group", "=", "control_group", ")", "nodeSize", "=", "sum", "(", "[", "x", "[", "1", "]", "for", "x", "in", "list", "(", "nodeSummary", ".", "values", "(", ")", ")", "]", ")", "d_children", "+=", "nodeScore", "*", "nodeSize", "/", "totalSize", "parentNodeSummary", "=", "self", ".", "_GetNodeSummary", "(", "data", "=", "data", ",", "experiment_group_column", "=", "experiment_group_column", ",", "y_name", "=", "y_name", ")", "[", "1", "]", "d_parent", "=", "evaluationFunction", "(", "parentNodeSummary", ",", "control_group", "=", "control_group", ")", "d_res", "=", "d_children", "-", "d_parent", "D_result", "=", "pd", ".", "DataFrame", "(", "{", "'feature'", ":", "feature_name", ",", "'method'", ":", "method", ",", "'score'", ":", "d_res", ",", "'p_value'", ":", "None", ",", "'misc'", ":", "'number_of_bins: {}'", ".", "format", "(", "min", "(", "n_bins", ",", "np", ".", "nanmax", "(", "x_bin", ")", ".", "astype", "(", "int", ")", "+", "1", ")", ")", ",", "# format(n_bins),", "}", ",", "index", "=", "[", "0", "]", ")", ".", "reset_index", "(", "drop", "=", "True", ")", "return", "(", "D_result", ")" ]
[ 305, 4 ]
[ 380, 24 ]
python
en
['en', 'error', 'th']
False
FilterSelect.filter_D
(self, data, features, y_name, n_bins=10, method='KL', control_group='control', experiment_group_column='treatment_group_key', null_impute=None)
Rank features based on the chosen divergence measure. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) features (list of string): list of feature names, that are columns in the data DataFrame y_name (string): name of the outcome variable method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'} The feature selection method to be used to rank the features. 'F' for F-test 'LR' for likelihood ratio test 'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively experiment_group_column (string, optional, default = 'treatment_group_key'): the experiment column name in the DataFrame, which contains the treatment and control assignment label control_group (string, optional, default = 'control'): name for control group, value in the experiment group column n_bins (int, optional, default = 10): number of bins to be used for bin-based uplift filter methods null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If Value is None and null is present then exception will be raised Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics
Rank features based on the chosen divergence measure.
def filter_D(self, data, features, y_name, n_bins=10, method='KL', control_group='control', experiment_group_column='treatment_group_key', null_impute=None): """ Rank features based on the chosen divergence measure. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0) features (list of string): list of feature names, that are columns in the data DataFrame y_name (string): name of the outcome variable method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'} The feature selection method to be used to rank the features. 'F' for F-test 'LR' for likelihood ratio test 'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively experiment_group_column (string, optional, default = 'treatment_group_key'): the experiment column name in the DataFrame, which contains the treatment and control assignment label control_group (string, optional, default = 'control'): name for control group, value in the experiment group column n_bins (int, optional, default = 10): number of bins to be used for bin-based uplift filter methods null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If Value is None and null is present then exception will be raised Returns ---------- (pd.DataFrame): a data frame containing the feature importance statistics """ all_result = pd.DataFrame() for x_name_i in features: one_result = self._filter_D_one_feature( data=data, feature_name=x_name_i, y_name=y_name, n_bins=n_bins, method=method, control_group=control_group, experiment_group_column=experiment_group_column, null_impute=null_impute ) all_result = pd.concat([all_result, one_result]) all_result = all_result.sort_values(by='score', ascending=False) all_result['rank'] = all_result['score'].rank(ascending=False) return all_result
[ "def", "filter_D", "(", "self", ",", "data", ",", "features", ",", "y_name", ",", "n_bins", "=", "10", ",", "method", "=", "'KL'", ",", "control_group", "=", "'control'", ",", "experiment_group_column", "=", "'treatment_group_key'", ",", "null_impute", "=", "None", ")", ":", "all_result", "=", "pd", ".", "DataFrame", "(", ")", "for", "x_name_i", "in", "features", ":", "one_result", "=", "self", ".", "_filter_D_one_feature", "(", "data", "=", "data", ",", "feature_name", "=", "x_name_i", ",", "y_name", "=", "y_name", ",", "n_bins", "=", "n_bins", ",", "method", "=", "method", ",", "control_group", "=", "control_group", ",", "experiment_group_column", "=", "experiment_group_column", ",", "null_impute", "=", "null_impute", ")", "all_result", "=", "pd", ".", "concat", "(", "[", "all_result", ",", "one_result", "]", ")", "all_result", "=", "all_result", ".", "sort_values", "(", "by", "=", "'score'", ",", "ascending", "=", "False", ")", "all_result", "[", "'rank'", "]", "=", "all_result", "[", "'score'", "]", ".", "rank", "(", "ascending", "=", "False", ")", "return", "all_result" ]
[ 382, 4 ]
[ 424, 25 ]
python
en
['en', 'error', 'th']
False
FilterSelect.get_importance
(self, data, features, y_name, method, experiment_group_column='treatment_group_key', control_group = 'control', treatment_group = 'treatment', n_bins=5, null_impute=None )
Rank features based on the chosen statistic of the interaction. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group features (list of string): list of feature names, that are columns in the data DataFrame y_name (string): name of the outcome variable method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'} The feature selection method to be used to rank the features. 'F' for F-test 'LR' for likelihood ratio test 'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively experiment_group_column (string): the experiment column name in the DataFrame, which contains the treatment and control assignment label control_group (string): name for control group, value in the experiment group column treatment_group (string): name for treatment group, value in the experiment group column n_bins (int, optional): number of bins to be used for bin-based uplift filter methods null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If value is None and null is present then exception will be raised Returns ---------- (pd.DataFrame): a data frame with following columns: ['method', 'feature', 'rank', 'score', 'p_value', 'misc']
Rank features based on the chosen statistic of the interaction.
def get_importance(self, data, features, y_name, method, experiment_group_column='treatment_group_key', control_group = 'control', treatment_group = 'treatment', n_bins=5, null_impute=None ): """ Rank features based on the chosen statistic of the interaction. Parameters ---------- data (pd.Dataframe): DataFrame containing outcome, features, and experiment group features (list of string): list of feature names, that are columns in the data DataFrame y_name (string): name of the outcome variable method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'} The feature selection method to be used to rank the features. 'F' for F-test 'LR' for likelihood ratio test 'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively experiment_group_column (string): the experiment column name in the DataFrame, which contains the treatment and control assignment label control_group (string): name for control group, value in the experiment group column treatment_group (string): name for treatment group, value in the experiment group column n_bins (int, optional): number of bins to be used for bin-based uplift filter methods null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If value is None and null is present then exception will be raised Returns ---------- (pd.DataFrame): a data frame with following columns: ['method', 'feature', 'rank', 'score', 'p_value', 'misc'] """ if method == 'F': data = data[data[experiment_group_column].isin([control_group, treatment_group])] data['treatment_indicator'] = 0 data.loc[data[experiment_group_column]==treatment_group,'treatment_indicator'] = 1 all_result = self.filter_F(data=data, treatment_indicator='treatment_indicator', features=features, y_name=y_name ) elif method == 'LR': data = data[data[experiment_group_column].isin([control_group, treatment_group])] data['treatment_indicator'] = 0 data.loc[data[experiment_group_column]==treatment_group,'treatment_indicator'] = 1 all_result = self.filter_LR(data=data, disp=True, treatment_indicator='treatment_indicator', features=features, y_name=y_name ) else: all_result = self.filter_D(data=data, method=method, features=features, y_name=y_name, n_bins=n_bins, control_group=control_group, experiment_group_column=experiment_group_column, null_impute=null_impute ) all_result['method'] = method + ' filter' return all_result[['method', 'feature', 'rank', 'score', 'p_value', 'misc']]
[ "def", "get_importance", "(", "self", ",", "data", ",", "features", ",", "y_name", ",", "method", ",", "experiment_group_column", "=", "'treatment_group_key'", ",", "control_group", "=", "'control'", ",", "treatment_group", "=", "'treatment'", ",", "n_bins", "=", "5", ",", "null_impute", "=", "None", ")", ":", "if", "method", "==", "'F'", ":", "data", "=", "data", "[", "data", "[", "experiment_group_column", "]", ".", "isin", "(", "[", "control_group", ",", "treatment_group", "]", ")", "]", "data", "[", "'treatment_indicator'", "]", "=", "0", "data", ".", "loc", "[", "data", "[", "experiment_group_column", "]", "==", "treatment_group", ",", "'treatment_indicator'", "]", "=", "1", "all_result", "=", "self", ".", "filter_F", "(", "data", "=", "data", ",", "treatment_indicator", "=", "'treatment_indicator'", ",", "features", "=", "features", ",", "y_name", "=", "y_name", ")", "elif", "method", "==", "'LR'", ":", "data", "=", "data", "[", "data", "[", "experiment_group_column", "]", ".", "isin", "(", "[", "control_group", ",", "treatment_group", "]", ")", "]", "data", "[", "'treatment_indicator'", "]", "=", "0", "data", ".", "loc", "[", "data", "[", "experiment_group_column", "]", "==", "treatment_group", ",", "'treatment_indicator'", "]", "=", "1", "all_result", "=", "self", ".", "filter_LR", "(", "data", "=", "data", ",", "disp", "=", "True", ",", "treatment_indicator", "=", "'treatment_indicator'", ",", "features", "=", "features", ",", "y_name", "=", "y_name", ")", "else", ":", "all_result", "=", "self", ".", "filter_D", "(", "data", "=", "data", ",", "method", "=", "method", ",", "features", "=", "features", ",", "y_name", "=", "y_name", ",", "n_bins", "=", "n_bins", ",", "control_group", "=", "control_group", ",", "experiment_group_column", "=", "experiment_group_column", ",", "null_impute", "=", "null_impute", ")", "all_result", "[", "'method'", "]", "=", "method", "+", "' filter'", "return", "all_result", "[", "[", "'method'", ",", "'feature'", ",", "'rank'", ",", "'score'", ",", "'p_value'", ",", "'misc'", "]", "]" ]
[ 426, 4 ]
[ 480, 84 ]
python
en
['en', 'error', 'th']
False
calibrate
(ps, treatment)
Calibrate propensity scores with logistic GAM. Ref: https://pygam.readthedocs.io/en/latest/api/logisticgam.html Args: ps (numpy.array): a propensity score vector treatment (numpy.array): a binary treatment vector (0: control, 1: treated) Returns: (numpy.array): a calibrated propensity score vector
Calibrate propensity scores with logistic GAM.
def calibrate(ps, treatment): """Calibrate propensity scores with logistic GAM. Ref: https://pygam.readthedocs.io/en/latest/api/logisticgam.html Args: ps (numpy.array): a propensity score vector treatment (numpy.array): a binary treatment vector (0: control, 1: treated) Returns: (numpy.array): a calibrated propensity score vector """ gam = LogisticGAM(s(0)).fit(ps, treatment) return gam.predict_proba(ps)
[ "def", "calibrate", "(", "ps", ",", "treatment", ")", ":", "gam", "=", "LogisticGAM", "(", "s", "(", "0", ")", ")", ".", "fit", "(", "ps", ",", "treatment", ")", "return", "gam", ".", "predict_proba", "(", "ps", ")" ]
[ 181, 0 ]
[ 196, 32 ]
python
en
['en', 'en', 'en']
True
compute_propensity_score
(X, treatment, p_model=None, X_pred=None, treatment_pred=None, calibrate_p=True)
Generate propensity score if user didn't provide Args: X (np.matrix): features for training treatment (np.array or pd.Series): a treatment vector for training p_model (propensity model object, optional): ElasticNetPropensityModel (default) / GradientBoostedPropensityModel X_pred (np.matrix, optional): features for prediction treatment_pred (np.array or pd.Series, optional): a treatment vector for prediciton calibrate_p (bool, optional): whether calibrate the propensity score Returns: (tuple) - p (numpy.ndarray): propensity score - p_model (PropensityModel): a trained PropensityModel object
Generate propensity score if user didn't provide
def compute_propensity_score(X, treatment, p_model=None, X_pred=None, treatment_pred=None, calibrate_p=True): """Generate propensity score if user didn't provide Args: X (np.matrix): features for training treatment (np.array or pd.Series): a treatment vector for training p_model (propensity model object, optional): ElasticNetPropensityModel (default) / GradientBoostedPropensityModel X_pred (np.matrix, optional): features for prediction treatment_pred (np.array or pd.Series, optional): a treatment vector for prediciton calibrate_p (bool, optional): whether calibrate the propensity score Returns: (tuple) - p (numpy.ndarray): propensity score - p_model (PropensityModel): a trained PropensityModel object """ if treatment_pred is None: treatment_pred = treatment.copy() if p_model is None: p_model = ElasticNetPropensityModel() p_model.fit(X, treatment) if X_pred is None: p = p_model.predict(X) else: p = p_model.predict(X_pred) if calibrate_p: logger.info('Calibrating propensity scores.') p = calibrate(p, treatment_pred) # force the p values within the range eps = np.finfo(float).eps p = np.where(p < 0 + eps, 0 + eps*1.001, p) p = np.where(p > 1 - eps, 1 - eps*1.001, p) return p, p_model
[ "def", "compute_propensity_score", "(", "X", ",", "treatment", ",", "p_model", "=", "None", ",", "X_pred", "=", "None", ",", "treatment_pred", "=", "None", ",", "calibrate_p", "=", "True", ")", ":", "if", "treatment_pred", "is", "None", ":", "treatment_pred", "=", "treatment", ".", "copy", "(", ")", "if", "p_model", "is", "None", ":", "p_model", "=", "ElasticNetPropensityModel", "(", ")", "p_model", ".", "fit", "(", "X", ",", "treatment", ")", "if", "X_pred", "is", "None", ":", "p", "=", "p_model", ".", "predict", "(", "X", ")", "else", ":", "p", "=", "p_model", ".", "predict", "(", "X_pred", ")", "if", "calibrate_p", ":", "logger", ".", "info", "(", "'Calibrating propensity scores.'", ")", "p", "=", "calibrate", "(", "p", ",", "treatment_pred", ")", "# force the p values within the range", "eps", "=", "np", ".", "finfo", "(", "float", ")", ".", "eps", "p", "=", "np", ".", "where", "(", "p", "<", "0", "+", "eps", ",", "0", "+", "eps", "*", "1.001", ",", "p", ")", "p", "=", "np", ".", "where", "(", "p", ">", "1", "-", "eps", ",", "1", "-", "eps", "*", "1.001", ",", "p", ")", "return", "p", ",", "p_model" ]
[ 199, 0 ]
[ 237, 21 ]
python
en
['en', 'en', 'en']
True
PropensityModel.__init__
(self, clip_bounds=(1e-3, 1 - 1e-3), **model_kwargs)
Args: clip_bounds (tuple): lower and upper bounds for clipping propensity scores. Bounds should be implemented such that: 0 < lower < upper < 1, to avoid division by zero in BaseRLearner.fit_predict() step. model_kwargs: Keyword arguments to be passed to the underlying classification model.
Args: clip_bounds (tuple): lower and upper bounds for clipping propensity scores. Bounds should be implemented such that: 0 < lower < upper < 1, to avoid division by zero in BaseRLearner.fit_predict() step. model_kwargs: Keyword arguments to be passed to the underlying classification model.
def __init__(self, clip_bounds=(1e-3, 1 - 1e-3), **model_kwargs): """ Args: clip_bounds (tuple): lower and upper bounds for clipping propensity scores. Bounds should be implemented such that: 0 < lower < upper < 1, to avoid division by zero in BaseRLearner.fit_predict() step. model_kwargs: Keyword arguments to be passed to the underlying classification model. """ self.clip_bounds = clip_bounds self.model_kwargs = model_kwargs self.model = self._model
[ "def", "__init__", "(", "self", ",", "clip_bounds", "=", "(", "1e-3", ",", "1", "-", "1e-3", ")", ",", "*", "*", "model_kwargs", ")", ":", "self", ".", "clip_bounds", "=", "clip_bounds", "self", ".", "model_kwargs", "=", "model_kwargs", "self", ".", "model", "=", "self", ".", "_model" ]
[ 14, 4 ]
[ 23, 32 ]
python
en
['en', 'error', 'th']
False
PropensityModel.fit
(self, X, y)
Fit a propensity model. Args: X (numpy.ndarray): a feature matrix y (numpy.ndarray): a binary target vector
Fit a propensity model.
def fit(self, X, y): """ Fit a propensity model. Args: X (numpy.ndarray): a feature matrix y (numpy.ndarray): a binary target vector """ self.model.fit(X, y)
[ "def", "fit", "(", "self", ",", "X", ",", "y", ")", ":", "self", ".", "model", ".", "fit", "(", "X", ",", "y", ")" ]
[ 33, 4 ]
[ 41, 28 ]
python
en
['en', 'error', 'th']
False
PropensityModel.predict
(self, X)
Predict propensity scores. Args: X (numpy.ndarray): a feature matrix Returns: (numpy.ndarray): Propensity scores between 0 and 1.
Predict propensity scores.
def predict(self, X): """ Predict propensity scores. Args: X (numpy.ndarray): a feature matrix Returns: (numpy.ndarray): Propensity scores between 0 and 1. """ return np.clip( self.model.predict_proba(X)[:, 1], *self.clip_bounds )
[ "def", "predict", "(", "self", ",", "X", ")", ":", "return", "np", ".", "clip", "(", "self", ".", "model", ".", "predict_proba", "(", "X", ")", "[", ":", ",", "1", "]", ",", "*", "self", ".", "clip_bounds", ")" ]
[ 43, 4 ]
[ 55, 9 ]
python
en
['en', 'error', 'th']
False
PropensityModel.fit_predict
(self, X, y)
Fit a propensity model and predict propensity scores. Args: X (numpy.ndarray): a feature matrix y (numpy.ndarray): a binary target vector Returns: (numpy.ndarray): Propensity scores between 0 and 1.
Fit a propensity model and predict propensity scores.
def fit_predict(self, X, y): """ Fit a propensity model and predict propensity scores. Args: X (numpy.ndarray): a feature matrix y (numpy.ndarray): a binary target vector Returns: (numpy.ndarray): Propensity scores between 0 and 1. """ self.fit(X, y) propensity_scores = self.predict(X) logger.info('AUC score: {:.6f}'.format(auc(y, propensity_scores))) return propensity_scores
[ "def", "fit_predict", "(", "self", ",", "X", ",", "y", ")", ":", "self", ".", "fit", "(", "X", ",", "y", ")", "propensity_scores", "=", "self", ".", "predict", "(", "X", ")", "logger", ".", "info", "(", "'AUC score: {:.6f}'", ".", "format", "(", "auc", "(", "y", ",", "propensity_scores", ")", ")", ")", "return", "propensity_scores" ]
[ 57, 4 ]
[ 71, 32 ]
python
en
['en', 'error', 'th']
False
GradientBoostedPropensityModel.fit
(self, X, y, early_stopping_rounds=10, stop_val_size=0.2)
Fit a propensity model. Args: X (numpy.ndarray): a feature matrix y (numpy.ndarray): a binary target vector
Fit a propensity model.
def fit(self, X, y, early_stopping_rounds=10, stop_val_size=0.2): """ Fit a propensity model. Args: X (numpy.ndarray): a feature matrix y (numpy.ndarray): a binary target vector """ if self.early_stop: X_train, X_val, y_train, y_val = train_test_split( X, y, test_size=stop_val_size ) self.model.fit( X_train, y_train, eval_set=[(X_val, y_val)], early_stopping_rounds=early_stopping_rounds ) else: super(GradientBoostedPropensityModel, self).fit(X, y)
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "early_stopping_rounds", "=", "10", ",", "stop_val_size", "=", "0.2", ")", ":", "if", "self", ".", "early_stop", ":", "X_train", ",", "X_val", ",", "y_train", ",", "y_val", "=", "train_test_split", "(", "X", ",", "y", ",", "test_size", "=", "stop_val_size", ")", "self", ".", "model", ".", "fit", "(", "X_train", ",", "y_train", ",", "eval_set", "=", "[", "(", "X_val", ",", "y_val", ")", "]", ",", "early_stopping_rounds", "=", "early_stopping_rounds", ")", "else", ":", "super", "(", "GradientBoostedPropensityModel", ",", "self", ")", ".", "fit", "(", "X", ",", "y", ")" ]
[ 136, 4 ]
[ 157, 65 ]
python
en
['en', 'error', 'th']
False
GradientBoostedPropensityModel.predict
(self, X)
Predict propensity scores. Args: X (numpy.ndarray): a feature matrix Returns: (numpy.ndarray): Propensity scores between 0 and 1.
Predict propensity scores.
def predict(self, X): """ Predict propensity scores. Args: X (numpy.ndarray): a feature matrix Returns: (numpy.ndarray): Propensity scores between 0 and 1. """ if self.early_stop: return np.clip( self.model.predict_proba( X, ntree_limit=self.model.best_ntree_limit )[:, 1], *self.clip_bounds ) else: return super(GradientBoostedPropensityModel, self).predict(X)
[ "def", "predict", "(", "self", ",", "X", ")", ":", "if", "self", ".", "early_stop", ":", "return", "np", ".", "clip", "(", "self", ".", "model", ".", "predict_proba", "(", "X", ",", "ntree_limit", "=", "self", ".", "model", ".", "best_ntree_limit", ")", "[", ":", ",", "1", "]", ",", "*", "self", ".", "clip_bounds", ")", "else", ":", "return", "super", "(", "GradientBoostedPropensityModel", ",", "self", ")", ".", "predict", "(", "X", ")" ]
[ 159, 4 ]
[ 178, 73 ]
python
en
['en', 'error', 'th']
False
get_root
()
Get the project root directory. We require that all commands are run from the project root, i.e. the directory that contains setup.py, setup.cfg, and versioneer.py .
Get the project root directory.
def get_root(): """Get the project root directory. We require that all commands are run from the project root, i.e. the directory that contains setup.py, setup.cfg, and versioneer.py . """ root = os.path.realpath(os.path.abspath(os.getcwd())) setup_py = os.path.join(root, "setup.py") versioneer_py = os.path.join(root, "versioneer.py") if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): # allow 'python path/to/setup.py COMMAND' root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) setup_py = os.path.join(root, "setup.py") versioneer_py = os.path.join(root, "versioneer.py") if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): err = ( "Versioneer was unable to run the project root directory. " "Versioneer requires setup.py to be executed from " "its immediate directory (like 'python setup.py COMMAND'), " "or in a way that lets it use sys.argv[0] to find the root " "(like 'python path/to/setup.py COMMAND')." ) raise VersioneerBadRootError(err) try: # Certain runtime workflows (setup.py install/develop in a setuptools # tree) execute all dependencies in a single python process, so # "versioneer" may be imported multiple times, and python's shared # module-import table will cache the first one. So we can't use # os.path.dirname(__file__), as that will find whichever # versioneer.py was first imported, even in later projects. me = os.path.realpath(os.path.abspath(__file__)) me_dir = os.path.normcase(os.path.splitext(me)[0]) vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) if me_dir != vsr_dir: print( "Warning: build in %s is using versioneer.py from %s" % (os.path.dirname(me), versioneer_py) ) except NameError: pass return root
[ "def", "get_root", "(", ")", ":", "root", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "getcwd", "(", ")", ")", ")", "setup_py", "=", "os", ".", "path", ".", "join", "(", "root", ",", "\"setup.py\"", ")", "versioneer_py", "=", "os", ".", "path", ".", "join", "(", "root", ",", "\"versioneer.py\"", ")", "if", "not", "(", "os", ".", "path", ".", "exists", "(", "setup_py", ")", "or", "os", ".", "path", ".", "exists", "(", "versioneer_py", ")", ")", ":", "# allow 'python path/to/setup.py COMMAND'", "root", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "abspath", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", ")", "setup_py", "=", "os", ".", "path", ".", "join", "(", "root", ",", "\"setup.py\"", ")", "versioneer_py", "=", "os", ".", "path", ".", "join", "(", "root", ",", "\"versioneer.py\"", ")", "if", "not", "(", "os", ".", "path", ".", "exists", "(", "setup_py", ")", "or", "os", ".", "path", ".", "exists", "(", "versioneer_py", ")", ")", ":", "err", "=", "(", "\"Versioneer was unable to run the project root directory. \"", "\"Versioneer requires setup.py to be executed from \"", "\"its immediate directory (like 'python setup.py COMMAND'), \"", "\"or in a way that lets it use sys.argv[0] to find the root \"", "\"(like 'python path/to/setup.py COMMAND').\"", ")", "raise", "VersioneerBadRootError", "(", "err", ")", "try", ":", "# Certain runtime workflows (setup.py install/develop in a setuptools", "# tree) execute all dependencies in a single python process, so", "# \"versioneer\" may be imported multiple times, and python's shared", "# module-import table will cache the first one. So we can't use", "# os.path.dirname(__file__), as that will find whichever", "# versioneer.py was first imported, even in later projects.", "me", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", "me_dir", "=", "os", ".", "path", ".", "normcase", "(", "os", ".", "path", ".", "splitext", "(", "me", ")", "[", "0", "]", ")", "vsr_dir", "=", "os", ".", "path", ".", "normcase", "(", "os", ".", "path", ".", "splitext", "(", "versioneer_py", ")", "[", "0", "]", ")", "if", "me_dir", "!=", "vsr_dir", ":", "print", "(", "\"Warning: build in %s is using versioneer.py from %s\"", "%", "(", "os", ".", "path", ".", "dirname", "(", "me", ")", ",", "versioneer_py", ")", ")", "except", "NameError", ":", "pass", "return", "root" ]
[ 293, 0 ]
[ 333, 15 ]
python
en
['en', 'en', 'en']
True
get_config_from_root
(root)
Read the project setup.cfg file to determine Versioneer config.
Read the project setup.cfg file to determine Versioneer config.
def get_config_from_root(root): """Read the project setup.cfg file to determine Versioneer config.""" # This might raise EnvironmentError (if setup.cfg is missing), or # configparser.NoSectionError (if it lacks a [versioneer] section), or # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") parser = configparser.SafeConfigParser() with open(setup_cfg) as f: parser.readfp(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): if parser.has_option("versioneer", name): return parser.get("versioneer", name) return None cfg = VersioneerConfig() cfg.VCS = VCS cfg.style = get(parser, "style") or "" cfg.versionfile_source = get(parser, "versionfile_source") cfg.versionfile_build = get(parser, "versionfile_build") cfg.tag_prefix = get(parser, "tag_prefix") if cfg.tag_prefix in ("''", '""'): cfg.tag_prefix = "" cfg.parentdir_prefix = get(parser, "parentdir_prefix") cfg.verbose = get(parser, "verbose") return cfg
[ "def", "get_config_from_root", "(", "root", ")", ":", "# This might raise EnvironmentError (if setup.cfg is missing), or", "# configparser.NoSectionError (if it lacks a [versioneer] section), or", "# configparser.NoOptionError (if it lacks \"VCS=\"). See the docstring at", "# the top of versioneer.py for instructions on writing your setup.cfg .", "setup_cfg", "=", "os", ".", "path", ".", "join", "(", "root", ",", "\"setup.cfg\"", ")", "parser", "=", "configparser", ".", "SafeConfigParser", "(", ")", "with", "open", "(", "setup_cfg", ")", "as", "f", ":", "parser", ".", "readfp", "(", "f", ")", "VCS", "=", "parser", ".", "get", "(", "\"versioneer\"", ",", "\"VCS\"", ")", "# mandatory", "def", "get", "(", "parser", ",", "name", ")", ":", "if", "parser", ".", "has_option", "(", "\"versioneer\"", ",", "name", ")", ":", "return", "parser", ".", "get", "(", "\"versioneer\"", ",", "name", ")", "return", "None", "cfg", "=", "VersioneerConfig", "(", ")", "cfg", ".", "VCS", "=", "VCS", "cfg", ".", "style", "=", "get", "(", "parser", ",", "\"style\"", ")", "or", "\"\"", "cfg", ".", "versionfile_source", "=", "get", "(", "parser", ",", "\"versionfile_source\"", ")", "cfg", ".", "versionfile_build", "=", "get", "(", "parser", ",", "\"versionfile_build\"", ")", "cfg", ".", "tag_prefix", "=", "get", "(", "parser", ",", "\"tag_prefix\"", ")", "if", "cfg", ".", "tag_prefix", "in", "(", "\"''\"", ",", "'\"\"'", ")", ":", "cfg", ".", "tag_prefix", "=", "\"\"", "cfg", ".", "parentdir_prefix", "=", "get", "(", "parser", ",", "\"parentdir_prefix\"", ")", "cfg", ".", "verbose", "=", "get", "(", "parser", ",", "\"verbose\"", ")", "return", "cfg" ]
[ 336, 0 ]
[ 363, 14 ]
python
en
['en', 'en', 'en']
True
register_vcs_handler
(vcs, method)
Decorator to mark a method as the handler for a particular VCS.
Decorator to mark a method as the handler for a particular VCS.
def register_vcs_handler(vcs, method): # decorator """Decorator to mark a method as the handler for a particular VCS.""" def decorate(f): """Store f in HANDLERS[vcs][method].""" if vcs not in HANDLERS: HANDLERS[vcs] = {} HANDLERS[vcs][method] = f return f return decorate
[ "def", "register_vcs_handler", "(", "vcs", ",", "method", ")", ":", "# decorator", "def", "decorate", "(", "f", ")", ":", "\"\"\"Store f in HANDLERS[vcs][method].\"\"\"", "if", "vcs", "not", "in", "HANDLERS", ":", "HANDLERS", "[", "vcs", "]", "=", "{", "}", "HANDLERS", "[", "vcs", "]", "[", "method", "]", "=", "f", "return", "f", "return", "decorate" ]
[ 375, 0 ]
[ 385, 19 ]
python
en
['en', 'en', 'en']
True
run_command
(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None)
Call the given command(s).
Call the given command(s).
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): """Call the given command(s).""" assert isinstance(commands, list) p = None for c in commands: try: dispcmd = str([c] + args) # remember shell=False, so use git.cmd on windows, not just git p = subprocess.Popen( [c] + args, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=(subprocess.PIPE if hide_stderr else None), ) break except OSError: e = sys.exc_info()[1] if e.errno == errno.ENOENT: continue if verbose: print("unable to run %s" % dispcmd) print(e) return None, None else: if verbose: print("unable to find command, tried {}".format(commands)) return None, None stdout = p.communicate()[0].strip() if sys.version_info[0] >= 3: stdout = stdout.decode() if p.returncode != 0: if verbose: print("unable to run %s (error)" % dispcmd) print("stdout was %s" % stdout) return None, p.returncode return stdout, p.returncode
[ "def", "run_command", "(", "commands", ",", "args", ",", "cwd", "=", "None", ",", "verbose", "=", "False", ",", "hide_stderr", "=", "False", ",", "env", "=", "None", ")", ":", "assert", "isinstance", "(", "commands", ",", "list", ")", "p", "=", "None", "for", "c", "in", "commands", ":", "try", ":", "dispcmd", "=", "str", "(", "[", "c", "]", "+", "args", ")", "# remember shell=False, so use git.cmd on windows, not just git", "p", "=", "subprocess", ".", "Popen", "(", "[", "c", "]", "+", "args", ",", "cwd", "=", "cwd", ",", "env", "=", "env", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "(", "subprocess", ".", "PIPE", "if", "hide_stderr", "else", "None", ")", ",", ")", "break", "except", "OSError", ":", "e", "=", "sys", ".", "exc_info", "(", ")", "[", "1", "]", "if", "e", ".", "errno", "==", "errno", ".", "ENOENT", ":", "continue", "if", "verbose", ":", "print", "(", "\"unable to run %s\"", "%", "dispcmd", ")", "print", "(", "e", ")", "return", "None", ",", "None", "else", ":", "if", "verbose", ":", "print", "(", "\"unable to find command, tried {}\"", ".", "format", "(", "commands", ")", ")", "return", "None", ",", "None", "stdout", "=", "p", ".", "communicate", "(", ")", "[", "0", "]", ".", "strip", "(", ")", "if", "sys", ".", "version_info", "[", "0", "]", ">=", "3", ":", "stdout", "=", "stdout", ".", "decode", "(", ")", "if", "p", ".", "returncode", "!=", "0", ":", "if", "verbose", ":", "print", "(", "\"unable to run %s (error)\"", "%", "dispcmd", ")", "print", "(", "\"stdout was %s\"", "%", "stdout", ")", "return", "None", ",", "p", ".", "returncode", "return", "stdout", ",", "p", ".", "returncode" ]
[ 388, 0 ]
[ 424, 31 ]
python
en
['en', 'en', 'en']
True
git_get_keywords
(versionfile_abs)
Extract version information from the given file.
Extract version information from the given file.
def git_get_keywords(versionfile_abs): """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. keywords = {} try: f = open(versionfile_abs) for line in f.readlines(): if line.strip().startswith("git_refnames ="): mo = re.search(r'=\s*"(.*)"', line) if mo: keywords["refnames"] = mo.group(1) if line.strip().startswith("git_full ="): mo = re.search(r'=\s*"(.*)"', line) if mo: keywords["full"] = mo.group(1) if line.strip().startswith("git_date ="): mo = re.search(r'=\s*"(.*)"', line) if mo: keywords["date"] = mo.group(1) f.close() except OSError: pass return keywords
[ "def", "git_get_keywords", "(", "versionfile_abs", ")", ":", "# the code embedded in _version.py can just fetch the value of these", "# keywords. When used from setup.py, we don't want to import _version.py,", "# so we do it with a regexp instead. This function is not used from", "# _version.py.", "keywords", "=", "{", "}", "try", ":", "f", "=", "open", "(", "versionfile_abs", ")", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"git_refnames =\"", ")", ":", "mo", "=", "re", ".", "search", "(", "r'=\\s*\"(.*)\"'", ",", "line", ")", "if", "mo", ":", "keywords", "[", "\"refnames\"", "]", "=", "mo", ".", "group", "(", "1", ")", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"git_full =\"", ")", ":", "mo", "=", "re", ".", "search", "(", "r'=\\s*\"(.*)\"'", ",", "line", ")", "if", "mo", ":", "keywords", "[", "\"full\"", "]", "=", "mo", ".", "group", "(", "1", ")", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"git_date =\"", ")", ":", "mo", "=", "re", ".", "search", "(", "r'=\\s*\"(.*)\"'", ",", "line", ")", "if", "mo", ":", "keywords", "[", "\"date\"", "]", "=", "mo", ".", "group", "(", "1", ")", "f", ".", "close", "(", ")", "except", "OSError", ":", "pass", "return", "keywords" ]
[ 953, 0 ]
[ 978, 19 ]
python
en
['en', 'en', 'en']
True
git_versions_from_keywords
(keywords, tag_prefix, verbose)
Get version information from git keywords.
Get version information from git keywords.
def git_versions_from_keywords(keywords, tag_prefix, verbose): """Get version information from git keywords.""" if not keywords: raise NotThisMethod("no keywords at all, weird") date = keywords.get("date") if date is not None: # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 # -like" string, which we must then edit to make compliant), because # it's been around since git-1.5.3, and it's too difficult to # discover which version we're using, or to work around using an # older one. date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) refnames = keywords["refnames"].strip() if refnames.startswith("$Format"): if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") refs = {r.strip() for r in refnames.strip("()").split(",")} # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d # expansion behaves like git log --decorate=short and strips out the # refs/heads/ and refs/tags/ prefixes that would let us distinguish # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". tags = {r for r in refs if re.search(r"\d", r)} if verbose: print("discarding '%s', no digits" % ",".join(refs - tags)) if verbose: print("likely tags: %s" % ",".join(sorted(tags))) for ref in sorted(tags): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix) :] if verbose: print("picking %s" % r) return { "version": r, "full-revisionid": keywords["full"].strip(), "dirty": False, "error": None, "date": date, } # no suitable tags, so version is "0+unknown", but full hex is still there if verbose: print("no suitable tags, using unknown + full revision id") return { "version": "0+unknown", "full-revisionid": keywords["full"].strip(), "dirty": False, "error": "no suitable tags", "date": None, }
[ "def", "git_versions_from_keywords", "(", "keywords", ",", "tag_prefix", ",", "verbose", ")", ":", "if", "not", "keywords", ":", "raise", "NotThisMethod", "(", "\"no keywords at all, weird\"", ")", "date", "=", "keywords", ".", "get", "(", "\"date\"", ")", "if", "date", "is", "not", "None", ":", "# git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant", "# datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601", "# -like\" string, which we must then edit to make compliant), because", "# it's been around since git-1.5.3, and it's too difficult to", "# discover which version we're using, or to work around using an", "# older one.", "date", "=", "date", ".", "strip", "(", ")", ".", "replace", "(", "\" \"", ",", "\"T\"", ",", "1", ")", ".", "replace", "(", "\" \"", ",", "\"\"", ",", "1", ")", "refnames", "=", "keywords", "[", "\"refnames\"", "]", ".", "strip", "(", ")", "if", "refnames", ".", "startswith", "(", "\"$Format\"", ")", ":", "if", "verbose", ":", "print", "(", "\"keywords are unexpanded, not using\"", ")", "raise", "NotThisMethod", "(", "\"unexpanded keywords, not a git-archive tarball\"", ")", "refs", "=", "{", "r", ".", "strip", "(", ")", "for", "r", "in", "refnames", ".", "strip", "(", "\"()\"", ")", ".", "split", "(", "\",\"", ")", "}", "# starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of", "# just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.", "TAG", "=", "\"tag: \"", "tags", "=", "{", "r", "[", "len", "(", "TAG", ")", ":", "]", "for", "r", "in", "refs", "if", "r", ".", "startswith", "(", "TAG", ")", "}", "if", "not", "tags", ":", "# Either we're using git < 1.8.3, or there really are no tags. We use", "# a heuristic: assume all version tags have a digit. The old git %d", "# expansion behaves like git log --decorate=short and strips out the", "# refs/heads/ and refs/tags/ prefixes that would let us distinguish", "# between branches and tags. By ignoring refnames without digits, we", "# filter out many common branch names like \"release\" and", "# \"stabilization\", as well as \"HEAD\" and \"master\".", "tags", "=", "{", "r", "for", "r", "in", "refs", "if", "re", ".", "search", "(", "r\"\\d\"", ",", "r", ")", "}", "if", "verbose", ":", "print", "(", "\"discarding '%s', no digits\"", "%", "\",\"", ".", "join", "(", "refs", "-", "tags", ")", ")", "if", "verbose", ":", "print", "(", "\"likely tags: %s\"", "%", "\",\"", ".", "join", "(", "sorted", "(", "tags", ")", ")", ")", "for", "ref", "in", "sorted", "(", "tags", ")", ":", "# sorting will prefer e.g. \"2.0\" over \"2.0rc1\"", "if", "ref", ".", "startswith", "(", "tag_prefix", ")", ":", "r", "=", "ref", "[", "len", "(", "tag_prefix", ")", ":", "]", "if", "verbose", ":", "print", "(", "\"picking %s\"", "%", "r", ")", "return", "{", "\"version\"", ":", "r", ",", "\"full-revisionid\"", ":", "keywords", "[", "\"full\"", "]", ".", "strip", "(", ")", ",", "\"dirty\"", ":", "False", ",", "\"error\"", ":", "None", ",", "\"date\"", ":", "date", ",", "}", "# no suitable tags, so version is \"0+unknown\", but full hex is still there", "if", "verbose", ":", "print", "(", "\"no suitable tags, using unknown + full revision id\"", ")", "return", "{", "\"version\"", ":", "\"0+unknown\"", ",", "\"full-revisionid\"", ":", "keywords", "[", "\"full\"", "]", ".", "strip", "(", ")", ",", "\"dirty\"", ":", "False", ",", "\"error\"", ":", "\"no suitable tags\"", ",", "\"date\"", ":", "None", ",", "}" ]
[ 982, 0 ]
[ 1040, 5 ]
python
en
['en', 'da', 'en']
True
git_pieces_from_vcs
(tag_prefix, root, verbose, run_command=run_command)
Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* expanded, and _version.py hasn't already been rewritten with a short version string, meaning we're inside a checked out source tree.
Get version from 'git describe' in the root of the source tree.
def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* expanded, and _version.py hasn't already been rewritten with a short version string, meaning we're inside a checked out source tree. """ GITS = ["git"] if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) if rc != 0: if verbose: print("Directory %s not under git control" % root) raise NotThisMethod("'git rev-parse --git-dir' returned error") # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] # if there isn't one, this yields HEX[-dirty] (no NUM) describe_out, rc = run_command( GITS, [ "describe", "--tags", "--dirty", "--always", "--long", "--match", "%s*" % tag_prefix, ], cwd=root, ) # --long was added in git-1.5.5 if describe_out is None: raise NotThisMethod("'git describe' failed") describe_out = describe_out.strip() full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) if full_out is None: raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() pieces = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] # TAG might have hyphens. git_describe = describe_out # look for -dirty suffix dirty = git_describe.endswith("-dirty") pieces["dirty"] = dirty if dirty: git_describe = git_describe[: git_describe.rindex("-dirty")] # now we have TAG-NUM-gHEX or HEX if "-" in git_describe: # TAG-NUM-gHEX mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) if not mo: # unparsable. Maybe git-describe is misbehaving? pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out return pieces # tag full_tag = mo.group(1) if not full_tag.startswith(tag_prefix): if verbose: fmt = "tag '%s' doesn't start with prefix '%s'" print(fmt % (full_tag, tag_prefix)) pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format( full_tag, tag_prefix, ) return pieces pieces["closest-tag"] = full_tag[len(tag_prefix) :] # distance: number of commits since tag pieces["distance"] = int(mo.group(2)) # commit: short hex revision ID pieces["short"] = mo.group(3) else: # HEX: no tags pieces["closest-tag"] = None count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root) pieces["distance"] = int(count_out) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ 0 ].strip() pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) return pieces
[ "def", "git_pieces_from_vcs", "(", "tag_prefix", ",", "root", ",", "verbose", ",", "run_command", "=", "run_command", ")", ":", "GITS", "=", "[", "\"git\"", "]", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "GITS", "=", "[", "\"git.cmd\"", ",", "\"git.exe\"", "]", "out", ",", "rc", "=", "run_command", "(", "GITS", ",", "[", "\"rev-parse\"", ",", "\"--git-dir\"", "]", ",", "cwd", "=", "root", ",", "hide_stderr", "=", "True", ")", "if", "rc", "!=", "0", ":", "if", "verbose", ":", "print", "(", "\"Directory %s not under git control\"", "%", "root", ")", "raise", "NotThisMethod", "(", "\"'git rev-parse --git-dir' returned error\"", ")", "# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]", "# if there isn't one, this yields HEX[-dirty] (no NUM)", "describe_out", ",", "rc", "=", "run_command", "(", "GITS", ",", "[", "\"describe\"", ",", "\"--tags\"", ",", "\"--dirty\"", ",", "\"--always\"", ",", "\"--long\"", ",", "\"--match\"", ",", "\"%s*\"", "%", "tag_prefix", ",", "]", ",", "cwd", "=", "root", ",", ")", "# --long was added in git-1.5.5", "if", "describe_out", "is", "None", ":", "raise", "NotThisMethod", "(", "\"'git describe' failed\"", ")", "describe_out", "=", "describe_out", ".", "strip", "(", ")", "full_out", ",", "rc", "=", "run_command", "(", "GITS", ",", "[", "\"rev-parse\"", ",", "\"HEAD\"", "]", ",", "cwd", "=", "root", ")", "if", "full_out", "is", "None", ":", "raise", "NotThisMethod", "(", "\"'git rev-parse' failed\"", ")", "full_out", "=", "full_out", ".", "strip", "(", ")", "pieces", "=", "{", "}", "pieces", "[", "\"long\"", "]", "=", "full_out", "pieces", "[", "\"short\"", "]", "=", "full_out", "[", ":", "7", "]", "# maybe improved later", "pieces", "[", "\"error\"", "]", "=", "None", "# parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]", "# TAG might have hyphens.", "git_describe", "=", "describe_out", "# look for -dirty suffix", "dirty", "=", "git_describe", ".", "endswith", "(", "\"-dirty\"", ")", "pieces", "[", "\"dirty\"", "]", "=", "dirty", "if", "dirty", ":", "git_describe", "=", "git_describe", "[", ":", "git_describe", ".", "rindex", "(", "\"-dirty\"", ")", "]", "# now we have TAG-NUM-gHEX or HEX", "if", "\"-\"", "in", "git_describe", ":", "# TAG-NUM-gHEX", "mo", "=", "re", ".", "search", "(", "r\"^(.+)-(\\d+)-g([0-9a-f]+)$\"", ",", "git_describe", ")", "if", "not", "mo", ":", "# unparsable. Maybe git-describe is misbehaving?", "pieces", "[", "\"error\"", "]", "=", "\"unable to parse git-describe output: '%s'\"", "%", "describe_out", "return", "pieces", "# tag", "full_tag", "=", "mo", ".", "group", "(", "1", ")", "if", "not", "full_tag", ".", "startswith", "(", "tag_prefix", ")", ":", "if", "verbose", ":", "fmt", "=", "\"tag '%s' doesn't start with prefix '%s'\"", "print", "(", "fmt", "%", "(", "full_tag", ",", "tag_prefix", ")", ")", "pieces", "[", "\"error\"", "]", "=", "\"tag '{}' doesn't start with prefix '{}'\"", ".", "format", "(", "full_tag", ",", "tag_prefix", ",", ")", "return", "pieces", "pieces", "[", "\"closest-tag\"", "]", "=", "full_tag", "[", "len", "(", "tag_prefix", ")", ":", "]", "# distance: number of commits since tag", "pieces", "[", "\"distance\"", "]", "=", "int", "(", "mo", ".", "group", "(", "2", ")", ")", "# commit: short hex revision ID", "pieces", "[", "\"short\"", "]", "=", "mo", ".", "group", "(", "3", ")", "else", ":", "# HEX: no tags", "pieces", "[", "\"closest-tag\"", "]", "=", "None", "count_out", ",", "rc", "=", "run_command", "(", "GITS", ",", "[", "\"rev-list\"", ",", "\"HEAD\"", ",", "\"--count\"", "]", ",", "cwd", "=", "root", ")", "pieces", "[", "\"distance\"", "]", "=", "int", "(", "count_out", ")", "# total number of commits", "# commit date: see ISO-8601 comment in git_versions_from_keywords()", "date", "=", "run_command", "(", "GITS", ",", "[", "\"show\"", ",", "\"-s\"", ",", "\"--format=%ci\"", ",", "\"HEAD\"", "]", ",", "cwd", "=", "root", ")", "[", "0", "]", ".", "strip", "(", ")", "pieces", "[", "\"date\"", "]", "=", "date", ".", "strip", "(", ")", ".", "replace", "(", "\" \"", ",", "\"T\"", ",", "1", ")", ".", "replace", "(", "\" \"", ",", "\"\"", ",", "1", ")", "return", "pieces" ]
[ 1044, 0 ]
[ 1141, 17 ]
python
en
['en', 'en', 'en']
True
do_vcs_install
(manifest_in, versionfile_source, ipy)
Git-specific installation logic for Versioneer. For Git, this means creating/changing .gitattributes to mark _version.py for export-subst keyword substitution.
Git-specific installation logic for Versioneer.
def do_vcs_install(manifest_in, versionfile_source, ipy): """Git-specific installation logic for Versioneer. For Git, this means creating/changing .gitattributes to mark _version.py for export-subst keyword substitution. """ GITS = ["git"] if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] files = [manifest_in, versionfile_source] if ipy: files.append(ipy) try: me = __file__ if me.endswith(".pyc") or me.endswith(".pyo"): me = os.path.splitext(me)[0] + ".py" versioneer_file = os.path.relpath(me) except NameError: versioneer_file = "versioneer.py" files.append(versioneer_file) present = False try: f = open(".gitattributes") for line in f.readlines(): if line.strip().startswith(versionfile_source): if "export-subst" in line.strip().split()[1:]: present = True f.close() except OSError: pass if not present: f = open(".gitattributes", "a+") f.write("%s export-subst\n" % versionfile_source) f.close() files.append(".gitattributes") run_command(GITS, ["add", "--"] + files)
[ "def", "do_vcs_install", "(", "manifest_in", ",", "versionfile_source", ",", "ipy", ")", ":", "GITS", "=", "[", "\"git\"", "]", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "GITS", "=", "[", "\"git.cmd\"", ",", "\"git.exe\"", "]", "files", "=", "[", "manifest_in", ",", "versionfile_source", "]", "if", "ipy", ":", "files", ".", "append", "(", "ipy", ")", "try", ":", "me", "=", "__file__", "if", "me", ".", "endswith", "(", "\".pyc\"", ")", "or", "me", ".", "endswith", "(", "\".pyo\"", ")", ":", "me", "=", "os", ".", "path", ".", "splitext", "(", "me", ")", "[", "0", "]", "+", "\".py\"", "versioneer_file", "=", "os", ".", "path", ".", "relpath", "(", "me", ")", "except", "NameError", ":", "versioneer_file", "=", "\"versioneer.py\"", "files", ".", "append", "(", "versioneer_file", ")", "present", "=", "False", "try", ":", "f", "=", "open", "(", "\".gitattributes\"", ")", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "versionfile_source", ")", ":", "if", "\"export-subst\"", "in", "line", ".", "strip", "(", ")", ".", "split", "(", ")", "[", "1", ":", "]", ":", "present", "=", "True", "f", ".", "close", "(", ")", "except", "OSError", ":", "pass", "if", "not", "present", ":", "f", "=", "open", "(", "\".gitattributes\"", ",", "\"a+\"", ")", "f", ".", "write", "(", "\"%s export-subst\\n\"", "%", "versionfile_source", ")", "f", ".", "close", "(", ")", "files", ".", "append", "(", "\".gitattributes\"", ")", "run_command", "(", "GITS", ",", "[", "\"add\"", ",", "\"--\"", "]", "+", "files", ")" ]
[ 1144, 0 ]
[ 1179, 44 ]
python
en
['en', 'en', 'en']
True
versions_from_parentdir
(parentdir_prefix, root, verbose)
Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both the project name and a version string. We will also support searching up two directory levels for an appropriately named parent directory
Try to determine the version from the parent directory name.
def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both the project name and a version string. We will also support searching up two directory levels for an appropriately named parent directory """ rootdirs = [] for i in range(3): dirname = os.path.basename(root) if dirname.startswith(parentdir_prefix): return { "version": dirname[len(parentdir_prefix) :], "full-revisionid": None, "dirty": False, "error": None, "date": None, } else: rootdirs.append(root) root = os.path.dirname(root) # up a level if verbose: print( "Tried directories %s but none started with prefix %s" % (str(rootdirs), parentdir_prefix) ) raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
[ "def", "versions_from_parentdir", "(", "parentdir_prefix", ",", "root", ",", "verbose", ")", ":", "rootdirs", "=", "[", "]", "for", "i", "in", "range", "(", "3", ")", ":", "dirname", "=", "os", ".", "path", ".", "basename", "(", "root", ")", "if", "dirname", ".", "startswith", "(", "parentdir_prefix", ")", ":", "return", "{", "\"version\"", ":", "dirname", "[", "len", "(", "parentdir_prefix", ")", ":", "]", ",", "\"full-revisionid\"", ":", "None", ",", "\"dirty\"", ":", "False", ",", "\"error\"", ":", "None", ",", "\"date\"", ":", "None", ",", "}", "else", ":", "rootdirs", ".", "append", "(", "root", ")", "root", "=", "os", ".", "path", ".", "dirname", "(", "root", ")", "# up a level", "if", "verbose", ":", "print", "(", "\"Tried directories %s but none started with prefix %s\"", "%", "(", "str", "(", "rootdirs", ")", ",", "parentdir_prefix", ")", ")", "raise", "NotThisMethod", "(", "\"rootdir doesn't start with parentdir_prefix\"", ")" ]
[ 1182, 0 ]
[ 1210, 70 ]
python
en
['en', 'en', 'en']
True
versions_from_file
(filename)
Try to determine the version from _version.py if present.
Try to determine the version from _version.py if present.
def versions_from_file(filename): """Try to determine the version from _version.py if present.""" try: with open(filename) as f: contents = f.read() except OSError: raise NotThisMethod("unable to read _version.py") mo = re.search( r"version_json = '''\n(.*)''' # END VERSION_JSON", contents, re.M | re.S ) if not mo: mo = re.search( r"version_json = '''\r\n(.*)''' # END VERSION_JSON", contents, re.M | re.S ) if not mo: raise NotThisMethod("no version_json in _version.py") return json.loads(mo.group(1))
[ "def", "versions_from_file", "(", "filename", ")", ":", "try", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "contents", "=", "f", ".", "read", "(", ")", "except", "OSError", ":", "raise", "NotThisMethod", "(", "\"unable to read _version.py\"", ")", "mo", "=", "re", ".", "search", "(", "r\"version_json = '''\\n(.*)''' # END VERSION_JSON\"", ",", "contents", ",", "re", ".", "M", "|", "re", ".", "S", ")", "if", "not", "mo", ":", "mo", "=", "re", ".", "search", "(", "r\"version_json = '''\\r\\n(.*)''' # END VERSION_JSON\"", ",", "contents", ",", "re", ".", "M", "|", "re", ".", "S", ")", "if", "not", "mo", ":", "raise", "NotThisMethod", "(", "\"no version_json in _version.py\"", ")", "return", "json", ".", "loads", "(", "mo", ".", "group", "(", "1", ")", ")" ]
[ 1231, 0 ]
[ 1247, 34 ]
python
en
['en', 'en', 'en']
True
write_to_version_file
(filename, versions)
Write the given version number to the given _version.py file.
Write the given version number to the given _version.py file.
def write_to_version_file(filename, versions): """Write the given version number to the given _version.py file.""" os.unlink(filename) contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) with open(filename, "w") as f: f.write(SHORT_VERSION_PY % contents) print("set {} to '{}'".format(filename, versions["version"]))
[ "def", "write_to_version_file", "(", "filename", ",", "versions", ")", ":", "os", ".", "unlink", "(", "filename", ")", "contents", "=", "json", ".", "dumps", "(", "versions", ",", "sort_keys", "=", "True", ",", "indent", "=", "1", ",", "separators", "=", "(", "\",\"", ",", "\": \"", ")", ")", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "f", ".", "write", "(", "SHORT_VERSION_PY", "%", "contents", ")", "print", "(", "\"set {} to '{}'\"", ".", "format", "(", "filename", ",", "versions", "[", "\"version\"", "]", ")", ")" ]
[ 1250, 0 ]
[ 1257, 65 ]
python
en
['en', 'en', 'en']
True
plus_or_dot
(pieces)
Return a + if we don't already have one, else return a .
Return a + if we don't already have one, else return a .
def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+"
[ "def", "plus_or_dot", "(", "pieces", ")", ":", "if", "\"+\"", "in", "pieces", ".", "get", "(", "\"closest-tag\"", ",", "\"\"", ")", ":", "return", "\".\"", "return", "\"+\"" ]
[ 1260, 0 ]
[ 1264, 14 ]
python
en
['en', 'en', 'en']
True
render_pep440
(pieces)
Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty Exceptions: 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
Build up version string, with post-release "local version identifier".
def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty Exceptions: 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += plus_or_dot(pieces) rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) if pieces["dirty"]: rendered += ".dirty" else: # exception #1 rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) if pieces["dirty"]: rendered += ".dirty" return rendered
[ "def", "render_pep440", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", "or", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "plus_or_dot", "(", "pieces", ")", "rendered", "+=", "\"%d.g%s\"", "%", "(", "pieces", "[", "\"distance\"", "]", ",", "pieces", "[", "\"short\"", "]", ")", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".dirty\"", "else", ":", "# exception #1", "rendered", "=", "\"0+untagged.%d.g%s\"", "%", "(", "pieces", "[", "\"distance\"", "]", ",", "pieces", "[", "\"short\"", "]", ")", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".dirty\"", "return", "rendered" ]
[ 1267, 0 ]
[ 1288, 19 ]
python
en
['en', 'en', 'en']
True
render_pep440_pre
(pieces)
TAG[.post.devDISTANCE] -- No -dirty. Exceptions: 1: no tags. 0.post.devDISTANCE
TAG[.post.devDISTANCE] -- No -dirty.
def render_pep440_pre(pieces): """TAG[.post.devDISTANCE] -- No -dirty. Exceptions: 1: no tags. 0.post.devDISTANCE """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered += ".post.dev%d" % pieces["distance"] else: # exception #1 rendered = "0.post.dev%d" % pieces["distance"] return rendered
[ "def", "render_pep440_pre", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", ":", "rendered", "+=", "\".post.dev%d\"", "%", "pieces", "[", "\"distance\"", "]", "else", ":", "# exception #1", "rendered", "=", "\"0.post.dev%d\"", "%", "pieces", "[", "\"distance\"", "]", "return", "rendered" ]
[ 1291, 0 ]
[ 1304, 19 ]
python
en
['en', 'en', 'pt']
True
render_pep440_post
(pieces)
TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards (a dirty tree will appear "older" than the corresponding clean one), but you shouldn't be releasing software with -dirty anyways. Exceptions: 1: no tags. 0.postDISTANCE[.dev0]
TAG[.postDISTANCE[.dev0]+gHEX] .
def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards (a dirty tree will appear "older" than the corresponding clean one), but you shouldn't be releasing software with -dirty anyways. Exceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" rendered += plus_or_dot(pieces) rendered += "g%s" % pieces["short"] else: # exception #1 rendered = "0.post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" rendered += "+g%s" % pieces["short"] return rendered
[ "def", "render_pep440_post", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", "or", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".post%d\"", "%", "pieces", "[", "\"distance\"", "]", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".dev0\"", "rendered", "+=", "plus_or_dot", "(", "pieces", ")", "rendered", "+=", "\"g%s\"", "%", "pieces", "[", "\"short\"", "]", "else", ":", "# exception #1", "rendered", "=", "\"0.post%d\"", "%", "pieces", "[", "\"distance\"", "]", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".dev0\"", "rendered", "+=", "\"+g%s\"", "%", "pieces", "[", "\"short\"", "]", "return", "rendered" ]
[ 1307, 0 ]
[ 1331, 19 ]
python
cy
['en', 'cy', 'hi']
False
render_pep440_old
(pieces)
TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. Eexceptions: 1: no tags. 0.postDISTANCE[.dev0]
TAG[.postDISTANCE[.dev0]] .
def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. Eexceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" else: # exception #1 rendered = "0.post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" return rendered
[ "def", "render_pep440_old", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", "or", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".post%d\"", "%", "pieces", "[", "\"distance\"", "]", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".dev0\"", "else", ":", "# exception #1", "rendered", "=", "\"0.post%d\"", "%", "pieces", "[", "\"distance\"", "]", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\".dev0\"", "return", "rendered" ]
[ 1334, 0 ]
[ 1353, 19 ]
python
en
['en', 'mt', 'hi']
False
render_git_describe
(pieces)
TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix)
TAG[-DISTANCE-gHEX][-dirty].
def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) else: # exception #1 rendered = pieces["short"] if pieces["dirty"]: rendered += "-dirty" return rendered
[ "def", "render_git_describe", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "if", "pieces", "[", "\"distance\"", "]", ":", "rendered", "+=", "\"-%d-g%s\"", "%", "(", "pieces", "[", "\"distance\"", "]", ",", "pieces", "[", "\"short\"", "]", ")", "else", ":", "# exception #1", "rendered", "=", "pieces", "[", "\"short\"", "]", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\"-dirty\"", "return", "rendered" ]
[ 1356, 0 ]
[ 1373, 19 ]
python
en
['en', 'en', 'en']
False
render_git_describe_long
(pieces)
TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix)
TAG-DISTANCE-gHEX[-dirty].
def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) else: # exception #1 rendered = pieces["short"] if pieces["dirty"]: rendered += "-dirty" return rendered
[ "def", "render_git_describe_long", "(", "pieces", ")", ":", "if", "pieces", "[", "\"closest-tag\"", "]", ":", "rendered", "=", "pieces", "[", "\"closest-tag\"", "]", "rendered", "+=", "\"-%d-g%s\"", "%", "(", "pieces", "[", "\"distance\"", "]", ",", "pieces", "[", "\"short\"", "]", ")", "else", ":", "# exception #1", "rendered", "=", "pieces", "[", "\"short\"", "]", "if", "pieces", "[", "\"dirty\"", "]", ":", "rendered", "+=", "\"-dirty\"", "return", "rendered" ]
[ 1376, 0 ]
[ 1393, 19 ]
python
en
['en', 'en', 'pt']
False
render
(pieces, style)
Render the given version pieces into the requested style.
Render the given version pieces into the requested style.
def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return { "version": "unknown", "full-revisionid": pieces.get("long"), "dirty": None, "error": pieces["error"], "date": None, } if not style or style == "default": style = "pep440" # the default if style == "pep440": rendered = render_pep440(pieces) elif style == "pep440-pre": rendered = render_pep440_pre(pieces) elif style == "pep440-post": rendered = render_pep440_post(pieces) elif style == "pep440-old": rendered = render_pep440_old(pieces) elif style == "git-describe": rendered = render_git_describe(pieces) elif style == "git-describe-long": rendered = render_git_describe_long(pieces) else: raise ValueError("unknown style '%s'" % style) return { "version": rendered, "full-revisionid": pieces["long"], "dirty": pieces["dirty"], "error": None, "date": pieces.get("date"), }
[ "def", "render", "(", "pieces", ",", "style", ")", ":", "if", "pieces", "[", "\"error\"", "]", ":", "return", "{", "\"version\"", ":", "\"unknown\"", ",", "\"full-revisionid\"", ":", "pieces", ".", "get", "(", "\"long\"", ")", ",", "\"dirty\"", ":", "None", ",", "\"error\"", ":", "pieces", "[", "\"error\"", "]", ",", "\"date\"", ":", "None", ",", "}", "if", "not", "style", "or", "style", "==", "\"default\"", ":", "style", "=", "\"pep440\"", "# the default", "if", "style", "==", "\"pep440\"", ":", "rendered", "=", "render_pep440", "(", "pieces", ")", "elif", "style", "==", "\"pep440-pre\"", ":", "rendered", "=", "render_pep440_pre", "(", "pieces", ")", "elif", "style", "==", "\"pep440-post\"", ":", "rendered", "=", "render_pep440_post", "(", "pieces", ")", "elif", "style", "==", "\"pep440-old\"", ":", "rendered", "=", "render_pep440_old", "(", "pieces", ")", "elif", "style", "==", "\"git-describe\"", ":", "rendered", "=", "render_git_describe", "(", "pieces", ")", "elif", "style", "==", "\"git-describe-long\"", ":", "rendered", "=", "render_git_describe_long", "(", "pieces", ")", "else", ":", "raise", "ValueError", "(", "\"unknown style '%s'\"", "%", "style", ")", "return", "{", "\"version\"", ":", "rendered", ",", "\"full-revisionid\"", ":", "pieces", "[", "\"long\"", "]", ",", "\"dirty\"", ":", "pieces", "[", "\"dirty\"", "]", ",", "\"error\"", ":", "None", ",", "\"date\"", ":", "pieces", ".", "get", "(", "\"date\"", ")", ",", "}" ]
[ 1396, 0 ]
[ 1431, 5 ]
python
en
['en', 'en', 'en']
True
get_versions
(verbose=False)
Get the project version from whatever source is available. Returns dict with two keys: 'version' and 'full'.
Get the project version from whatever source is available.
def get_versions(verbose=False): """Get the project version from whatever source is available. Returns dict with two keys: 'version' and 'full'. """ if "versioneer" in sys.modules: # see the discussion in cmdclass.py:get_cmdclass() del sys.modules["versioneer"] root = get_root() cfg = get_config_from_root(root) assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" handlers = HANDLERS.get(cfg.VCS) assert handlers, "unrecognized VCS '%s'" % cfg.VCS verbose = verbose or cfg.verbose assert ( cfg.versionfile_source is not None ), "please set versioneer.versionfile_source" assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" versionfile_abs = os.path.join(root, cfg.versionfile_source) # extract version from first of: _version.py, VCS command (e.g. 'git # describe'), parentdir. This is meant to work for developers using a # source checkout, for users of a tarball created by 'setup.py sdist', # and for users of a tarball/zipball created by 'git archive' or github's # download-from-tag feature or the equivalent in other VCSes. get_keywords_f = handlers.get("get_keywords") from_keywords_f = handlers.get("keywords") if get_keywords_f and from_keywords_f: try: keywords = get_keywords_f(versionfile_abs) ver = from_keywords_f(keywords, cfg.tag_prefix, verbose) if verbose: print("got version from expanded keyword %s" % ver) return ver except NotThisMethod: pass try: ver = versions_from_file(versionfile_abs) if verbose: print("got version from file {} {}".format(versionfile_abs, ver)) return ver except NotThisMethod: pass from_vcs_f = handlers.get("pieces_from_vcs") if from_vcs_f: try: pieces = from_vcs_f(cfg.tag_prefix, root, verbose) ver = render(pieces, cfg.style) if verbose: print("got version from VCS %s" % ver) return ver except NotThisMethod: pass try: if cfg.parentdir_prefix: ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose) if verbose: print("got version from parentdir %s" % ver) return ver except NotThisMethod: pass if verbose: print("unable to compute version") return { "version": "0+unknown", "full-revisionid": None, "dirty": None, "error": "unable to compute version", "date": None, }
[ "def", "get_versions", "(", "verbose", "=", "False", ")", ":", "if", "\"versioneer\"", "in", "sys", ".", "modules", ":", "# see the discussion in cmdclass.py:get_cmdclass()", "del", "sys", ".", "modules", "[", "\"versioneer\"", "]", "root", "=", "get_root", "(", ")", "cfg", "=", "get_config_from_root", "(", "root", ")", "assert", "cfg", ".", "VCS", "is", "not", "None", ",", "\"please set [versioneer]VCS= in setup.cfg\"", "handlers", "=", "HANDLERS", ".", "get", "(", "cfg", ".", "VCS", ")", "assert", "handlers", ",", "\"unrecognized VCS '%s'\"", "%", "cfg", ".", "VCS", "verbose", "=", "verbose", "or", "cfg", ".", "verbose", "assert", "(", "cfg", ".", "versionfile_source", "is", "not", "None", ")", ",", "\"please set versioneer.versionfile_source\"", "assert", "cfg", ".", "tag_prefix", "is", "not", "None", ",", "\"please set versioneer.tag_prefix\"", "versionfile_abs", "=", "os", ".", "path", ".", "join", "(", "root", ",", "cfg", ".", "versionfile_source", ")", "# extract version from first of: _version.py, VCS command (e.g. 'git", "# describe'), parentdir. This is meant to work for developers using a", "# source checkout, for users of a tarball created by 'setup.py sdist',", "# and for users of a tarball/zipball created by 'git archive' or github's", "# download-from-tag feature or the equivalent in other VCSes.", "get_keywords_f", "=", "handlers", ".", "get", "(", "\"get_keywords\"", ")", "from_keywords_f", "=", "handlers", ".", "get", "(", "\"keywords\"", ")", "if", "get_keywords_f", "and", "from_keywords_f", ":", "try", ":", "keywords", "=", "get_keywords_f", "(", "versionfile_abs", ")", "ver", "=", "from_keywords_f", "(", "keywords", ",", "cfg", ".", "tag_prefix", ",", "verbose", ")", "if", "verbose", ":", "print", "(", "\"got version from expanded keyword %s\"", "%", "ver", ")", "return", "ver", "except", "NotThisMethod", ":", "pass", "try", ":", "ver", "=", "versions_from_file", "(", "versionfile_abs", ")", "if", "verbose", ":", "print", "(", "\"got version from file {} {}\"", ".", "format", "(", "versionfile_abs", ",", "ver", ")", ")", "return", "ver", "except", "NotThisMethod", ":", "pass", "from_vcs_f", "=", "handlers", ".", "get", "(", "\"pieces_from_vcs\"", ")", "if", "from_vcs_f", ":", "try", ":", "pieces", "=", "from_vcs_f", "(", "cfg", ".", "tag_prefix", ",", "root", ",", "verbose", ")", "ver", "=", "render", "(", "pieces", ",", "cfg", ".", "style", ")", "if", "verbose", ":", "print", "(", "\"got version from VCS %s\"", "%", "ver", ")", "return", "ver", "except", "NotThisMethod", ":", "pass", "try", ":", "if", "cfg", ".", "parentdir_prefix", ":", "ver", "=", "versions_from_parentdir", "(", "cfg", ".", "parentdir_prefix", ",", "root", ",", "verbose", ")", "if", "verbose", ":", "print", "(", "\"got version from parentdir %s\"", "%", "ver", ")", "return", "ver", "except", "NotThisMethod", ":", "pass", "if", "verbose", ":", "print", "(", "\"unable to compute version\"", ")", "return", "{", "\"version\"", ":", "\"0+unknown\"", ",", "\"full-revisionid\"", ":", "None", ",", "\"dirty\"", ":", "None", ",", "\"error\"", ":", "\"unable to compute version\"", ",", "\"date\"", ":", "None", ",", "}" ]
[ 1438, 0 ]
[ 1516, 5 ]
python
en
['en', 'en', 'en']
True
get_version
()
Get the short version string for this project.
Get the short version string for this project.
def get_version(): """Get the short version string for this project.""" return get_versions()["version"]
[ "def", "get_version", "(", ")", ":", "return", "get_versions", "(", ")", "[", "\"version\"", "]" ]
[ 1519, 0 ]
[ 1521, 36 ]
python
en
['en', 'en', 'en']
True
get_cmdclass
()
Get the custom setuptools/distutils subclasses used by Versioneer.
Get the custom setuptools/distutils subclasses used by Versioneer.
def get_cmdclass(): """Get the custom setuptools/distutils subclasses used by Versioneer.""" if "versioneer" in sys.modules: del sys.modules["versioneer"] # this fixes the "python setup.py develop" case (also 'install' and # 'easy_install .'), in which subdependencies of the main project are # built (using setup.py bdist_egg) in the same python process. Assume # a main project A and a dependency B, which use different versions # of Versioneer. A's setup.py imports A's Versioneer, leaving it in # sys.modules by the time B's setup.py is executed, causing B to run # with the wrong versioneer. Setuptools wraps the sub-dep builds in a # sandbox that restores sys.modules to it's pre-build state, so the # parent is protected against the child's "import versioneer". By # removing ourselves from sys.modules here, before the child build # happens, we protect the child from the parent's versioneer too. # Also see https://github.com/warner/python-versioneer/issues/52 cmds = {} # we add "version" to both distutils and setuptools from distutils.core import Command class cmd_version(Command): description = "report generated version string" user_options = [] boolean_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): vers = get_versions(verbose=True) print("Version: %s" % vers["version"]) print(" full-revisionid: %s" % vers.get("full-revisionid")) print(" dirty: %s" % vers.get("dirty")) print(" date: %s" % vers.get("date")) if vers["error"]: print(" error: %s" % vers["error"]) cmds["version"] = cmd_version # we override "build_py" in both distutils and setuptools # # most invocation pathways end up running build_py: # distutils/build -> build_py # distutils/install -> distutils/build ->.. # setuptools/bdist_wheel -> distutils/install ->.. # setuptools/bdist_egg -> distutils/install_lib -> build_py # setuptools/install -> bdist_egg ->.. # setuptools/develop -> ? # pip install: # copies source tree to a tempdir before running egg_info/etc # if .git isn't copied too, 'git describe' will fail # then does setup.py bdist_wheel, or sometimes setup.py install # setup.py egg_info -> ? # we override different "build_py" commands for both environments if "setuptools" in sys.modules: from setuptools.command.build_py import build_py as _build_py else: from distutils.command.build_py import build_py as _build_py class cmd_build_py(_build_py): def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() _build_py.run(self) # now locate _version.py in the new build/ directory and replace # it with an updated value if cfg.versionfile_build: target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build) print("UPDATING %s" % target_versionfile) write_to_version_file(target_versionfile, versions) cmds["build_py"] = cmd_build_py if "cx_Freeze" in sys.modules: # cx_freeze enabled? from cx_Freeze.dist import build_exe as _build_exe # nczeczulin reports that py2exe won't like the pep440-style string # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. # setup(console=[{ # "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION # "product_version": versioneer.get_version(), # ... class cmd_build_exe(_build_exe): def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() target_versionfile = cfg.versionfile_source print("UPDATING %s" % target_versionfile) write_to_version_file(target_versionfile, versions) _build_exe.run(self) os.unlink(target_versionfile) with open(cfg.versionfile_source, "w") as f: LONG = LONG_VERSION_PY[cfg.VCS] f.write( LONG % { "DOLLAR": "$", "STYLE": cfg.style, "TAG_PREFIX": cfg.tag_prefix, "PARENTDIR_PREFIX": cfg.parentdir_prefix, "VERSIONFILE_SOURCE": cfg.versionfile_source, } ) cmds["build_exe"] = cmd_build_exe del cmds["build_py"] if "py2exe" in sys.modules: # py2exe enabled? from py2exe.distutils_buildexe import py2exe as _py2exe # py3 class cmd_py2exe(_py2exe): def run(self): root = get_root() cfg = get_config_from_root(root) versions = get_versions() target_versionfile = cfg.versionfile_source print("UPDATING %s" % target_versionfile) write_to_version_file(target_versionfile, versions) _py2exe.run(self) os.unlink(target_versionfile) with open(cfg.versionfile_source, "w") as f: LONG = LONG_VERSION_PY[cfg.VCS] f.write( LONG % { "DOLLAR": "$", "STYLE": cfg.style, "TAG_PREFIX": cfg.tag_prefix, "PARENTDIR_PREFIX": cfg.parentdir_prefix, "VERSIONFILE_SOURCE": cfg.versionfile_source, } ) cmds["py2exe"] = cmd_py2exe # we override different "sdist" commands for both environments if "setuptools" in sys.modules: from setuptools.command.sdist import sdist as _sdist else: from distutils.command.sdist import sdist as _sdist class cmd_sdist(_sdist): def run(self): versions = get_versions() self._versioneer_generated_versions = versions # unless we update this, the command will keep using the old # version self.distribution.metadata.version = versions["version"] return _sdist.run(self) def make_release_tree(self, base_dir, files): root = get_root() cfg = get_config_from_root(root) _sdist.make_release_tree(self, base_dir, files) # now locate _version.py in the new base_dir directory # (remembering that it may be a hardlink) and replace it with an # updated value target_versionfile = os.path.join(base_dir, cfg.versionfile_source) print("UPDATING %s" % target_versionfile) write_to_version_file( target_versionfile, self._versioneer_generated_versions ) cmds["sdist"] = cmd_sdist return cmds
[ "def", "get_cmdclass", "(", ")", ":", "if", "\"versioneer\"", "in", "sys", ".", "modules", ":", "del", "sys", ".", "modules", "[", "\"versioneer\"", "]", "# this fixes the \"python setup.py develop\" case (also 'install' and", "# 'easy_install .'), in which subdependencies of the main project are", "# built (using setup.py bdist_egg) in the same python process. Assume", "# a main project A and a dependency B, which use different versions", "# of Versioneer. A's setup.py imports A's Versioneer, leaving it in", "# sys.modules by the time B's setup.py is executed, causing B to run", "# with the wrong versioneer. Setuptools wraps the sub-dep builds in a", "# sandbox that restores sys.modules to it's pre-build state, so the", "# parent is protected against the child's \"import versioneer\". By", "# removing ourselves from sys.modules here, before the child build", "# happens, we protect the child from the parent's versioneer too.", "# Also see https://github.com/warner/python-versioneer/issues/52", "cmds", "=", "{", "}", "# we add \"version\" to both distutils and setuptools", "from", "distutils", ".", "core", "import", "Command", "class", "cmd_version", "(", "Command", ")", ":", "description", "=", "\"report generated version string\"", "user_options", "=", "[", "]", "boolean_options", "=", "[", "]", "def", "initialize_options", "(", "self", ")", ":", "pass", "def", "finalize_options", "(", "self", ")", ":", "pass", "def", "run", "(", "self", ")", ":", "vers", "=", "get_versions", "(", "verbose", "=", "True", ")", "print", "(", "\"Version: %s\"", "%", "vers", "[", "\"version\"", "]", ")", "print", "(", "\" full-revisionid: %s\"", "%", "vers", ".", "get", "(", "\"full-revisionid\"", ")", ")", "print", "(", "\" dirty: %s\"", "%", "vers", ".", "get", "(", "\"dirty\"", ")", ")", "print", "(", "\" date: %s\"", "%", "vers", ".", "get", "(", "\"date\"", ")", ")", "if", "vers", "[", "\"error\"", "]", ":", "print", "(", "\" error: %s\"", "%", "vers", "[", "\"error\"", "]", ")", "cmds", "[", "\"version\"", "]", "=", "cmd_version", "# we override \"build_py\" in both distutils and setuptools", "#", "# most invocation pathways end up running build_py:", "# distutils/build -> build_py", "# distutils/install -> distutils/build ->..", "# setuptools/bdist_wheel -> distutils/install ->..", "# setuptools/bdist_egg -> distutils/install_lib -> build_py", "# setuptools/install -> bdist_egg ->..", "# setuptools/develop -> ?", "# pip install:", "# copies source tree to a tempdir before running egg_info/etc", "# if .git isn't copied too, 'git describe' will fail", "# then does setup.py bdist_wheel, or sometimes setup.py install", "# setup.py egg_info -> ?", "# we override different \"build_py\" commands for both environments", "if", "\"setuptools\"", "in", "sys", ".", "modules", ":", "from", "setuptools", ".", "command", ".", "build_py", "import", "build_py", "as", "_build_py", "else", ":", "from", "distutils", ".", "command", ".", "build_py", "import", "build_py", "as", "_build_py", "class", "cmd_build_py", "(", "_build_py", ")", ":", "def", "run", "(", "self", ")", ":", "root", "=", "get_root", "(", ")", "cfg", "=", "get_config_from_root", "(", "root", ")", "versions", "=", "get_versions", "(", ")", "_build_py", ".", "run", "(", "self", ")", "# now locate _version.py in the new build/ directory and replace", "# it with an updated value", "if", "cfg", ".", "versionfile_build", ":", "target_versionfile", "=", "os", ".", "path", ".", "join", "(", "self", ".", "build_lib", ",", "cfg", ".", "versionfile_build", ")", "print", "(", "\"UPDATING %s\"", "%", "target_versionfile", ")", "write_to_version_file", "(", "target_versionfile", ",", "versions", ")", "cmds", "[", "\"build_py\"", "]", "=", "cmd_build_py", "if", "\"cx_Freeze\"", "in", "sys", ".", "modules", ":", "# cx_freeze enabled?", "from", "cx_Freeze", ".", "dist", "import", "build_exe", "as", "_build_exe", "# nczeczulin reports that py2exe won't like the pep440-style string", "# as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.", "# setup(console=[{", "# \"version\": versioneer.get_version().split(\"+\", 1)[0], # FILEVERSION", "# \"product_version\": versioneer.get_version(),", "# ...", "class", "cmd_build_exe", "(", "_build_exe", ")", ":", "def", "run", "(", "self", ")", ":", "root", "=", "get_root", "(", ")", "cfg", "=", "get_config_from_root", "(", "root", ")", "versions", "=", "get_versions", "(", ")", "target_versionfile", "=", "cfg", ".", "versionfile_source", "print", "(", "\"UPDATING %s\"", "%", "target_versionfile", ")", "write_to_version_file", "(", "target_versionfile", ",", "versions", ")", "_build_exe", ".", "run", "(", "self", ")", "os", ".", "unlink", "(", "target_versionfile", ")", "with", "open", "(", "cfg", ".", "versionfile_source", ",", "\"w\"", ")", "as", "f", ":", "LONG", "=", "LONG_VERSION_PY", "[", "cfg", ".", "VCS", "]", "f", ".", "write", "(", "LONG", "%", "{", "\"DOLLAR\"", ":", "\"$\"", ",", "\"STYLE\"", ":", "cfg", ".", "style", ",", "\"TAG_PREFIX\"", ":", "cfg", ".", "tag_prefix", ",", "\"PARENTDIR_PREFIX\"", ":", "cfg", ".", "parentdir_prefix", ",", "\"VERSIONFILE_SOURCE\"", ":", "cfg", ".", "versionfile_source", ",", "}", ")", "cmds", "[", "\"build_exe\"", "]", "=", "cmd_build_exe", "del", "cmds", "[", "\"build_py\"", "]", "if", "\"py2exe\"", "in", "sys", ".", "modules", ":", "# py2exe enabled?", "from", "py2exe", ".", "distutils_buildexe", "import", "py2exe", "as", "_py2exe", "# py3", "class", "cmd_py2exe", "(", "_py2exe", ")", ":", "def", "run", "(", "self", ")", ":", "root", "=", "get_root", "(", ")", "cfg", "=", "get_config_from_root", "(", "root", ")", "versions", "=", "get_versions", "(", ")", "target_versionfile", "=", "cfg", ".", "versionfile_source", "print", "(", "\"UPDATING %s\"", "%", "target_versionfile", ")", "write_to_version_file", "(", "target_versionfile", ",", "versions", ")", "_py2exe", ".", "run", "(", "self", ")", "os", ".", "unlink", "(", "target_versionfile", ")", "with", "open", "(", "cfg", ".", "versionfile_source", ",", "\"w\"", ")", "as", "f", ":", "LONG", "=", "LONG_VERSION_PY", "[", "cfg", ".", "VCS", "]", "f", ".", "write", "(", "LONG", "%", "{", "\"DOLLAR\"", ":", "\"$\"", ",", "\"STYLE\"", ":", "cfg", ".", "style", ",", "\"TAG_PREFIX\"", ":", "cfg", ".", "tag_prefix", ",", "\"PARENTDIR_PREFIX\"", ":", "cfg", ".", "parentdir_prefix", ",", "\"VERSIONFILE_SOURCE\"", ":", "cfg", ".", "versionfile_source", ",", "}", ")", "cmds", "[", "\"py2exe\"", "]", "=", "cmd_py2exe", "# we override different \"sdist\" commands for both environments", "if", "\"setuptools\"", "in", "sys", ".", "modules", ":", "from", "setuptools", ".", "command", ".", "sdist", "import", "sdist", "as", "_sdist", "else", ":", "from", "distutils", ".", "command", ".", "sdist", "import", "sdist", "as", "_sdist", "class", "cmd_sdist", "(", "_sdist", ")", ":", "def", "run", "(", "self", ")", ":", "versions", "=", "get_versions", "(", ")", "self", ".", "_versioneer_generated_versions", "=", "versions", "# unless we update this, the command will keep using the old", "# version", "self", ".", "distribution", ".", "metadata", ".", "version", "=", "versions", "[", "\"version\"", "]", "return", "_sdist", ".", "run", "(", "self", ")", "def", "make_release_tree", "(", "self", ",", "base_dir", ",", "files", ")", ":", "root", "=", "get_root", "(", ")", "cfg", "=", "get_config_from_root", "(", "root", ")", "_sdist", ".", "make_release_tree", "(", "self", ",", "base_dir", ",", "files", ")", "# now locate _version.py in the new base_dir directory", "# (remembering that it may be a hardlink) and replace it with an", "# updated value", "target_versionfile", "=", "os", ".", "path", ".", "join", "(", "base_dir", ",", "cfg", ".", "versionfile_source", ")", "print", "(", "\"UPDATING %s\"", "%", "target_versionfile", ")", "write_to_version_file", "(", "target_versionfile", ",", "self", ".", "_versioneer_generated_versions", ")", "cmds", "[", "\"sdist\"", "]", "=", "cmd_sdist", "return", "cmds" ]
[ 1524, 0 ]
[ 1700, 15 ]
python
en
['en', 'et', 'en']
True
do_setup
()
Main VCS-independent setup function for installing Versioneer.
Main VCS-independent setup function for installing Versioneer.
def do_setup(): """Main VCS-independent setup function for installing Versioneer.""" root = get_root() try: cfg = get_config_from_root(root) except (OSError, configparser.NoSectionError, configparser.NoOptionError) as e: if isinstance(e, (EnvironmentError, configparser.NoSectionError)): print("Adding sample versioneer config to setup.cfg", file=sys.stderr) with open(os.path.join(root, "setup.cfg"), "a") as f: f.write(SAMPLE_CONFIG) print(CONFIG_ERROR, file=sys.stderr) return 1 print(" creating %s" % cfg.versionfile_source) with open(cfg.versionfile_source, "w") as f: LONG = LONG_VERSION_PY[cfg.VCS] f.write( LONG % { "DOLLAR": "$", "STYLE": cfg.style, "TAG_PREFIX": cfg.tag_prefix, "PARENTDIR_PREFIX": cfg.parentdir_prefix, "VERSIONFILE_SOURCE": cfg.versionfile_source, } ) ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") if os.path.exists(ipy): try: with open(ipy) as f: old = f.read() except OSError: old = "" if INIT_PY_SNIPPET not in old: print(" appending to %s" % ipy) with open(ipy, "a") as f: f.write(INIT_PY_SNIPPET) else: print(" %s unmodified" % ipy) else: print(" %s doesn't exist, ok" % ipy) ipy = None # Make sure both the top-level "versioneer.py" and versionfile_source # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so # they'll be copied into source distributions. Pip won't be able to # install the package without this. manifest_in = os.path.join(root, "MANIFEST.in") simple_includes = set() try: with open(manifest_in) as f: for line in f: if line.startswith("include "): for include in line.split()[1:]: simple_includes.add(include) except OSError: pass # That doesn't cover everything MANIFEST.in can do # (http://docs.python.org/2/distutils/sourcedist.html#commands), so # it might give some false negatives. Appending redundant 'include' # lines is safe, though. if "versioneer.py" not in simple_includes: print(" appending 'versioneer.py' to MANIFEST.in") with open(manifest_in, "a") as f: f.write("include versioneer.py\n") else: print(" 'versioneer.py' already in MANIFEST.in") if cfg.versionfile_source not in simple_includes: print( " appending versionfile_source ('%s') to MANIFEST.in" % cfg.versionfile_source ) with open(manifest_in, "a") as f: f.write("include %s\n" % cfg.versionfile_source) else: print(" versionfile_source already in MANIFEST.in") # Make VCS-specific changes. For git, this means creating/changing # .gitattributes to mark _version.py for export-subst keyword # substitution. do_vcs_install(manifest_in, cfg.versionfile_source, ipy) return 0
[ "def", "do_setup", "(", ")", ":", "root", "=", "get_root", "(", ")", "try", ":", "cfg", "=", "get_config_from_root", "(", "root", ")", "except", "(", "OSError", ",", "configparser", ".", "NoSectionError", ",", "configparser", ".", "NoOptionError", ")", "as", "e", ":", "if", "isinstance", "(", "e", ",", "(", "EnvironmentError", ",", "configparser", ".", "NoSectionError", ")", ")", ":", "print", "(", "\"Adding sample versioneer config to setup.cfg\"", ",", "file", "=", "sys", ".", "stderr", ")", "with", "open", "(", "os", ".", "path", ".", "join", "(", "root", ",", "\"setup.cfg\"", ")", ",", "\"a\"", ")", "as", "f", ":", "f", ".", "write", "(", "SAMPLE_CONFIG", ")", "print", "(", "CONFIG_ERROR", ",", "file", "=", "sys", ".", "stderr", ")", "return", "1", "print", "(", "\" creating %s\"", "%", "cfg", ".", "versionfile_source", ")", "with", "open", "(", "cfg", ".", "versionfile_source", ",", "\"w\"", ")", "as", "f", ":", "LONG", "=", "LONG_VERSION_PY", "[", "cfg", ".", "VCS", "]", "f", ".", "write", "(", "LONG", "%", "{", "\"DOLLAR\"", ":", "\"$\"", ",", "\"STYLE\"", ":", "cfg", ".", "style", ",", "\"TAG_PREFIX\"", ":", "cfg", ".", "tag_prefix", ",", "\"PARENTDIR_PREFIX\"", ":", "cfg", ".", "parentdir_prefix", ",", "\"VERSIONFILE_SOURCE\"", ":", "cfg", ".", "versionfile_source", ",", "}", ")", "ipy", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "cfg", ".", "versionfile_source", ")", ",", "\"__init__.py\"", ")", "if", "os", ".", "path", ".", "exists", "(", "ipy", ")", ":", "try", ":", "with", "open", "(", "ipy", ")", "as", "f", ":", "old", "=", "f", ".", "read", "(", ")", "except", "OSError", ":", "old", "=", "\"\"", "if", "INIT_PY_SNIPPET", "not", "in", "old", ":", "print", "(", "\" appending to %s\"", "%", "ipy", ")", "with", "open", "(", "ipy", ",", "\"a\"", ")", "as", "f", ":", "f", ".", "write", "(", "INIT_PY_SNIPPET", ")", "else", ":", "print", "(", "\" %s unmodified\"", "%", "ipy", ")", "else", ":", "print", "(", "\" %s doesn't exist, ok\"", "%", "ipy", ")", "ipy", "=", "None", "# Make sure both the top-level \"versioneer.py\" and versionfile_source", "# (PKG/_version.py, used by runtime code) are in MANIFEST.in, so", "# they'll be copied into source distributions. Pip won't be able to", "# install the package without this.", "manifest_in", "=", "os", ".", "path", ".", "join", "(", "root", ",", "\"MANIFEST.in\"", ")", "simple_includes", "=", "set", "(", ")", "try", ":", "with", "open", "(", "manifest_in", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if", "line", ".", "startswith", "(", "\"include \"", ")", ":", "for", "include", "in", "line", ".", "split", "(", ")", "[", "1", ":", "]", ":", "simple_includes", ".", "add", "(", "include", ")", "except", "OSError", ":", "pass", "# That doesn't cover everything MANIFEST.in can do", "# (http://docs.python.org/2/distutils/sourcedist.html#commands), so", "# it might give some false negatives. Appending redundant 'include'", "# lines is safe, though.", "if", "\"versioneer.py\"", "not", "in", "simple_includes", ":", "print", "(", "\" appending 'versioneer.py' to MANIFEST.in\"", ")", "with", "open", "(", "manifest_in", ",", "\"a\"", ")", "as", "f", ":", "f", ".", "write", "(", "\"include versioneer.py\\n\"", ")", "else", ":", "print", "(", "\" 'versioneer.py' already in MANIFEST.in\"", ")", "if", "cfg", ".", "versionfile_source", "not", "in", "simple_includes", ":", "print", "(", "\" appending versionfile_source ('%s') to MANIFEST.in\"", "%", "cfg", ".", "versionfile_source", ")", "with", "open", "(", "manifest_in", ",", "\"a\"", ")", "as", "f", ":", "f", ".", "write", "(", "\"include %s\\n\"", "%", "cfg", ".", "versionfile_source", ")", "else", ":", "print", "(", "\" versionfile_source already in MANIFEST.in\"", ")", "# Make VCS-specific changes. For git, this means creating/changing", "# .gitattributes to mark _version.py for export-subst keyword", "# substitution.", "do_vcs_install", "(", "manifest_in", ",", "cfg", ".", "versionfile_source", ",", "ipy", ")", "return", "0" ]
[ 1747, 0 ]
[ 1829, 12 ]
python
en
['en', 'en', 'en']
True
scan_setup_py
()
Validate the contents of setup.py against Versioneer's expectations.
Validate the contents of setup.py against Versioneer's expectations.
def scan_setup_py(): """Validate the contents of setup.py against Versioneer's expectations.""" found = set() setters = False errors = 0 with open("setup.py") as f: for line in f.readlines(): if "import versioneer" in line: found.add("import") if "versioneer.get_cmdclass()" in line: found.add("cmdclass") if "versioneer.get_version()" in line: found.add("get_version") if "versioneer.VCS" in line: setters = True if "versioneer.versionfile_source" in line: setters = True if len(found) != 3: print("") print("Your setup.py appears to be missing some important items") print("(but I might be wrong). Please make sure it has something") print("roughly like the following:") print("") print(" import versioneer") print(" setup( version=versioneer.get_version(),") print(" cmdclass=versioneer.get_cmdclass(), ...)") print("") errors += 1 if setters: print("You should remove lines like 'versioneer.VCS = ' and") print("'versioneer.versionfile_source = ' . This configuration") print("now lives in setup.cfg, and should be removed from setup.py") print("") errors += 1 return errors
[ "def", "scan_setup_py", "(", ")", ":", "found", "=", "set", "(", ")", "setters", "=", "False", "errors", "=", "0", "with", "open", "(", "\"setup.py\"", ")", "as", "f", ":", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", "if", "\"import versioneer\"", "in", "line", ":", "found", ".", "add", "(", "\"import\"", ")", "if", "\"versioneer.get_cmdclass()\"", "in", "line", ":", "found", ".", "add", "(", "\"cmdclass\"", ")", "if", "\"versioneer.get_version()\"", "in", "line", ":", "found", ".", "add", "(", "\"get_version\"", ")", "if", "\"versioneer.VCS\"", "in", "line", ":", "setters", "=", "True", "if", "\"versioneer.versionfile_source\"", "in", "line", ":", "setters", "=", "True", "if", "len", "(", "found", ")", "!=", "3", ":", "print", "(", "\"\"", ")", "print", "(", "\"Your setup.py appears to be missing some important items\"", ")", "print", "(", "\"(but I might be wrong). Please make sure it has something\"", ")", "print", "(", "\"roughly like the following:\"", ")", "print", "(", "\"\"", ")", "print", "(", "\" import versioneer\"", ")", "print", "(", "\" setup( version=versioneer.get_version(),\"", ")", "print", "(", "\" cmdclass=versioneer.get_cmdclass(), ...)\"", ")", "print", "(", "\"\"", ")", "errors", "+=", "1", "if", "setters", ":", "print", "(", "\"You should remove lines like 'versioneer.VCS = ' and\"", ")", "print", "(", "\"'versioneer.versionfile_source = ' . This configuration\"", ")", "print", "(", "\"now lives in setup.cfg, and should be removed from setup.py\"", ")", "print", "(", "\"\"", ")", "errors", "+=", "1", "return", "errors" ]
[ 1832, 0 ]
[ 1866, 17 ]
python
en
['en', 'en', 'en']
True
make_flatten
(decl_or_decls)
Converts tree representation of declarations to flatten one. :param decl_or_decls: reference to list of declaration's or single declaration :type decl_or_decls: :class:`declaration_t` or [ :class:`declaration_t` ] :rtype: [ all internal declarations ]
Converts tree representation of declarations to flatten one.
def make_flatten(decl_or_decls): """ Converts tree representation of declarations to flatten one. :param decl_or_decls: reference to list of declaration's or single declaration :type decl_or_decls: :class:`declaration_t` or [ :class:`declaration_t` ] :rtype: [ all internal declarations ] """ def proceed_single(decl): answer = [decl] if not isinstance(decl, scopedef_t): return answer for elem in decl.declarations: if isinstance(elem, scopedef_t): answer.extend(proceed_single(elem)) else: answer.append(elem) return answer decls = [] if isinstance(decl_or_decls, list): decls.extend(decl_or_decls) else: decls.append(decl_or_decls) answer = [] for decl in decls: answer.extend(proceed_single(decl)) return answer
[ "def", "make_flatten", "(", "decl_or_decls", ")", ":", "def", "proceed_single", "(", "decl", ")", ":", "answer", "=", "[", "decl", "]", "if", "not", "isinstance", "(", "decl", ",", "scopedef_t", ")", ":", "return", "answer", "for", "elem", "in", "decl", ".", "declarations", ":", "if", "isinstance", "(", "elem", ",", "scopedef_t", ")", ":", "answer", ".", "extend", "(", "proceed_single", "(", "elem", ")", ")", "else", ":", "answer", ".", "append", "(", "elem", ")", "return", "answer", "decls", "=", "[", "]", "if", "isinstance", "(", "decl_or_decls", ",", "list", ")", ":", "decls", ".", "extend", "(", "decl_or_decls", ")", "else", ":", "decls", ".", "append", "(", "decl_or_decls", ")", "answer", "=", "[", "]", "for", "decl", "in", "decls", ":", "answer", ".", "extend", "(", "proceed_single", "(", "decl", ")", ")", "return", "answer" ]
[ 1221, 0 ]
[ 1251, 17 ]
python
en
['en', 'error', 'th']
False
find_all_declarations
( declarations, decl_type=None, name=None, parent=None, recursive=True, fullname=None)
Returns a list of all declarations that match criteria, defined by developer. For more information about arguments see :class:`match_declaration_t` class. :rtype: [ matched declarations ]
Returns a list of all declarations that match criteria, defined by developer.
def find_all_declarations( declarations, decl_type=None, name=None, parent=None, recursive=True, fullname=None): """ Returns a list of all declarations that match criteria, defined by developer. For more information about arguments see :class:`match_declaration_t` class. :rtype: [ matched declarations ] """ if recursive: decls = make_flatten(declarations) else: decls = declarations return list( filter( algorithm.match_declaration_t( decl_type=decl_type, name=name, fullname=fullname, parent=parent), decls))
[ "def", "find_all_declarations", "(", "declarations", ",", "decl_type", "=", "None", ",", "name", "=", "None", ",", "parent", "=", "None", ",", "recursive", "=", "True", ",", "fullname", "=", "None", ")", ":", "if", "recursive", ":", "decls", "=", "make_flatten", "(", "declarations", ")", "else", ":", "decls", "=", "declarations", "return", "list", "(", "filter", "(", "algorithm", ".", "match_declaration_t", "(", "decl_type", "=", "decl_type", ",", "name", "=", "name", ",", "fullname", "=", "fullname", ",", "parent", "=", "parent", ")", ",", "decls", ")", ")" ]
[ 1254, 0 ]
[ 1284, 19 ]
python
en
['en', 'error', 'th']
False
find_declaration
( declarations, decl_type=None, name=None, parent=None, recursive=True, fullname=None)
Returns single declaration that match criteria, defined by developer. If more the one declaration was found None will be returned. For more information about arguments see :class:`match_declaration_t` class. :rtype: matched declaration :class:`declaration_t` or None
Returns single declaration that match criteria, defined by developer. If more the one declaration was found None will be returned.
def find_declaration( declarations, decl_type=None, name=None, parent=None, recursive=True, fullname=None): """ Returns single declaration that match criteria, defined by developer. If more the one declaration was found None will be returned. For more information about arguments see :class:`match_declaration_t` class. :rtype: matched declaration :class:`declaration_t` or None """ decl = find_all_declarations( declarations, decl_type=decl_type, name=name, parent=parent, recursive=recursive, fullname=fullname) if len(decl) == 1: return decl[0]
[ "def", "find_declaration", "(", "declarations", ",", "decl_type", "=", "None", ",", "name", "=", "None", ",", "parent", "=", "None", ",", "recursive", "=", "True", ",", "fullname", "=", "None", ")", ":", "decl", "=", "find_all_declarations", "(", "declarations", ",", "decl_type", "=", "decl_type", ",", "name", "=", "name", ",", "parent", "=", "parent", ",", "recursive", "=", "recursive", ",", "fullname", "=", "fullname", ")", "if", "len", "(", "decl", ")", "==", "1", ":", "return", "decl", "[", "0", "]" ]
[ 1287, 0 ]
[ 1313, 22 ]
python
en
['en', 'error', 'th']
False
find_first_declaration
( declarations, decl_type=None, name=None, parent=None, recursive=True, fullname=None)
Returns first declaration that match criteria, defined by developer. For more information about arguments see :class:`match_declaration_t` class. :rtype: matched declaration :class:`declaration_t` or None
Returns first declaration that match criteria, defined by developer.
def find_first_declaration( declarations, decl_type=None, name=None, parent=None, recursive=True, fullname=None): """ Returns first declaration that match criteria, defined by developer. For more information about arguments see :class:`match_declaration_t` class. :rtype: matched declaration :class:`declaration_t` or None """ decl_matcher = algorithm.match_declaration_t( decl_type=decl_type, name=name, fullname=fullname, parent=parent) if recursive: decls = make_flatten(declarations) else: decls = declarations for decl in decls: if decl_matcher(decl): return decl return None
[ "def", "find_first_declaration", "(", "declarations", ",", "decl_type", "=", "None", ",", "name", "=", "None", ",", "parent", "=", "None", ",", "recursive", "=", "True", ",", "fullname", "=", "None", ")", ":", "decl_matcher", "=", "algorithm", ".", "match_declaration_t", "(", "decl_type", "=", "decl_type", ",", "name", "=", "name", ",", "fullname", "=", "fullname", ",", "parent", "=", "parent", ")", "if", "recursive", ":", "decls", "=", "make_flatten", "(", "declarations", ")", "else", ":", "decls", "=", "declarations", "for", "decl", "in", "decls", ":", "if", "decl_matcher", "(", "decl", ")", ":", "return", "decl", "return", "None" ]
[ 1316, 0 ]
[ 1345, 15 ]
python
en
['en', 'error', 'th']
False
declaration_files
(decl_or_decls)
Returns set of files Every declaration is declared in some file. This function returns set, that contains all file names of declarations. :param decl_or_decls: reference to list of declaration's or single declaration :type decl_or_decls: :class:`declaration_t` or [:class:`declaration_t`] :rtype: set(declaration file names)
Returns set of files
def declaration_files(decl_or_decls): """ Returns set of files Every declaration is declared in some file. This function returns set, that contains all file names of declarations. :param decl_or_decls: reference to list of declaration's or single declaration :type decl_or_decls: :class:`declaration_t` or [:class:`declaration_t`] :rtype: set(declaration file names) """ files = set() decls = make_flatten(decl_or_decls) for decl in decls: if decl.location: files.add(decl.location.file_name) return files
[ "def", "declaration_files", "(", "decl_or_decls", ")", ":", "files", "=", "set", "(", ")", "decls", "=", "make_flatten", "(", "decl_or_decls", ")", "for", "decl", "in", "decls", ":", "if", "decl", ".", "location", ":", "files", ".", "add", "(", "decl", ".", "location", ".", "file_name", ")", "return", "files" ]
[ 1348, 0 ]
[ 1367, 16 ]
python
en
['en', 'error', 'th']
False
matcher.find
(decl_matcher, decls, recursive=True)
Returns a list of declarations that match `decl_matcher` defined criteria or None :param decl_matcher: Python callable object, that takes one argument - reference to a declaration :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too
Returns a list of declarations that match `decl_matcher` defined criteria or None
def find(decl_matcher, decls, recursive=True): """ Returns a list of declarations that match `decl_matcher` defined criteria or None :param decl_matcher: Python callable object, that takes one argument - reference to a declaration :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ where = [] if isinstance(decls, list): where.extend(decls) else: where.append(decls) if recursive: where = make_flatten(where) return list(filter(decl_matcher, where))
[ "def", "find", "(", "decl_matcher", ",", "decls", ",", "recursive", "=", "True", ")", ":", "where", "=", "[", "]", "if", "isinstance", "(", "decls", ",", "list", ")", ":", "where", ".", "extend", "(", "decls", ")", "else", ":", "where", ".", "append", "(", "decls", ")", "if", "recursive", ":", "where", "=", "make_flatten", "(", "where", ")", "return", "list", "(", "filter", "(", "decl_matcher", ",", "where", ")", ")" ]
[ 25, 4 ]
[ 45, 48 ]
python
en
['en', 'error', 'th']
False
matcher.find_single
(decl_matcher, decls, recursive=True)
Returns a reference to the declaration, that match `decl_matcher` defined criteria. if a unique declaration could not be found the method will return None. :param decl_matcher: Python callable object, that takes one argument - reference to a declaration :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too
Returns a reference to the declaration, that match `decl_matcher` defined criteria.
def find_single(decl_matcher, decls, recursive=True): """ Returns a reference to the declaration, that match `decl_matcher` defined criteria. if a unique declaration could not be found the method will return None. :param decl_matcher: Python callable object, that takes one argument - reference to a declaration :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ answer = matcher.find(decl_matcher, decls, recursive) if len(answer) == 1: return answer[0]
[ "def", "find_single", "(", "decl_matcher", ",", "decls", ",", "recursive", "=", "True", ")", ":", "answer", "=", "matcher", ".", "find", "(", "decl_matcher", ",", "decls", ",", "recursive", ")", "if", "len", "(", "answer", ")", "==", "1", ":", "return", "answer", "[", "0", "]" ]
[ 48, 4 ]
[ 64, 28 ]
python
en
['en', 'error', 'th']
False
matcher.get_single
(decl_matcher, decls, recursive=True)
Returns a reference to declaration, that match `decl_matcher` defined criteria. If a unique declaration could not be found, an appropriate exception will be raised. :param decl_matcher: Python callable object, that takes one argument - reference to a declaration :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too
Returns a reference to declaration, that match `decl_matcher` defined criteria.
def get_single(decl_matcher, decls, recursive=True): """ Returns a reference to declaration, that match `decl_matcher` defined criteria. If a unique declaration could not be found, an appropriate exception will be raised. :param decl_matcher: Python callable object, that takes one argument - reference to a declaration :param decls: the search scope, :class:declaration_t object or :class:declaration_t objects list t :param recursive: boolean, if True, the method will run `decl_matcher` on the internal declarations too """ answer = matcher.find(decl_matcher, decls, recursive) if len(answer) == 1: return answer[0] elif not answer: raise runtime_errors.declaration_not_found_t(decl_matcher) else: raise runtime_errors.multiple_declarations_found_t(decl_matcher)
[ "def", "get_single", "(", "decl_matcher", ",", "decls", ",", "recursive", "=", "True", ")", ":", "answer", "=", "matcher", ".", "find", "(", "decl_matcher", ",", "decls", ",", "recursive", ")", "if", "len", "(", "answer", ")", "==", "1", ":", "return", "answer", "[", "0", "]", "elif", "not", "answer", ":", "raise", "runtime_errors", ".", "declaration_not_found_t", "(", "decl_matcher", ")", "else", ":", "raise", "runtime_errors", ".", "multiple_declarations_found_t", "(", "decl_matcher", ")" ]
[ 67, 4 ]
[ 88, 76 ]
python
en
['en', 'error', 'th']
False
scopedef_t._logger
(self)
reference to :attr:`pygccxml.utils.loggers.queries_engine` logger
reference to :attr:`pygccxml.utils.loggers.queries_engine` logger
def _logger(self): """reference to :attr:`pygccxml.utils.loggers.queries_engine` logger""" return utils.loggers.queries_engine
[ "def", "_logger", "(", "self", ")", ":", "return", "utils", ".", "loggers", ".", "queries_engine" ]
[ 183, 4 ]
[ 185, 43 ]
python
en
['en', 'en', 'en']
True
scopedef_t._get__cmp__scope_items
(self)
implementation details
implementation details
def _get__cmp__scope_items(self): """implementation details""" raise NotImplementedError()
[ "def", "_get__cmp__scope_items", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 187, 4 ]
[ 189, 35 ]
python
da
['eo', 'da', 'en']
False
scopedef_t._get__cmp__items
(self)
implementation details
implementation details
def _get__cmp__items(self): """implementation details""" items = [] if self._optimized: # in this case we don't need to build class internal declarations # list items.append(self._all_decls_not_recursive.sort()) else: items.append(self.declarations.sort()) items.extend(self._get__cmp__scope_items()) return items
[ "def", "_get__cmp__items", "(", "self", ")", ":", "items", "=", "[", "]", "if", "self", ".", "_optimized", ":", "# in this case we don't need to build class internal declarations", "# list", "items", ".", "append", "(", "self", ".", "_all_decls_not_recursive", ".", "sort", "(", ")", ")", "else", ":", "items", ".", "append", "(", "self", ".", "declarations", ".", "sort", "(", ")", ")", "items", ".", "extend", "(", "self", ".", "_get__cmp__scope_items", "(", ")", ")", "return", "items" ]
[ 191, 4 ]
[ 201, 20 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.declarations
(self)
List of children declarations. Returns: List[declarations.declaration_t]
List of children declarations.
def declarations(self): """ List of children declarations. Returns: List[declarations.declaration_t] """ if self._optimized: return self._all_decls_not_recursive else: return self._get_declarations_impl()
[ "def", "declarations", "(", "self", ")", ":", "if", "self", ".", "_optimized", ":", "return", "self", ".", "_all_decls_not_recursive", "else", ":", "return", "self", ".", "_get_declarations_impl", "(", ")" ]
[ 215, 4 ]
[ 225, 48 ]
python
en
['en', 'error', 'th']
False
scopedef_t.declarations
(self, declarations)
Set list of all declarations defined in the namespace. Args: List[declarations.declaration_t]: list of declarations Not implemented.
Set list of all declarations defined in the namespace.
def declarations(self, declarations): """ Set list of all declarations defined in the namespace. Args: List[declarations.declaration_t]: list of declarations Not implemented. """ raise NotImplementedError()
[ "def", "declarations", "(", "self", ",", "declarations", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 228, 4 ]
[ 238, 35 ]
python
en
['en', 'error', 'th']
False
scopedef_t.__decl_types
(decl)
implementation details
implementation details
def __decl_types(decl): """implementation details""" types = [] bases = list(decl.__class__.__bases__) if 'pygccxml' in decl.__class__.__module__: types.append(decl.__class__) while bases: base = bases.pop() if base is declaration.declaration_t: continue if base is byte_info.byte_info: continue if base is elaborated_info.elaborated_info: continue if 'pygccxml' not in base.__module__: continue types.append(base) bases.extend(base.__bases__) return types
[ "def", "__decl_types", "(", "decl", ")", ":", "types", "=", "[", "]", "bases", "=", "list", "(", "decl", ".", "__class__", ".", "__bases__", ")", "if", "'pygccxml'", "in", "decl", ".", "__class__", ".", "__module__", ":", "types", ".", "append", "(", "decl", ".", "__class__", ")", "while", "bases", ":", "base", "=", "bases", ".", "pop", "(", ")", "if", "base", "is", "declaration", ".", "declaration_t", ":", "continue", "if", "base", "is", "byte_info", ".", "byte_info", ":", "continue", "if", "base", "is", "elaborated_info", ".", "elaborated_info", ":", "continue", "if", "'pygccxml'", "not", "in", "base", ".", "__module__", ":", "continue", "types", ".", "append", "(", "base", ")", "bases", ".", "extend", "(", "base", ".", "__bases__", ")", "return", "types" ]
[ 244, 4 ]
[ 262, 20 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.clear_optimizer
(self)
Cleans query optimizer state
Cleans query optimizer state
def clear_optimizer(self): """Cleans query optimizer state""" self._optimized = False self._type2decls = {} self._type2name2decls = {} self._type2decls_nr = {} self._type2name2decls_nr = {} self._all_decls = None self._all_decls_not_recursive = None for decl in self.declarations: if isinstance(decl, scopedef_t): decl.clear_optimizer()
[ "def", "clear_optimizer", "(", "self", ")", ":", "self", ".", "_optimized", "=", "False", "self", ".", "_type2decls", "=", "{", "}", "self", ".", "_type2name2decls", "=", "{", "}", "self", ".", "_type2decls_nr", "=", "{", "}", "self", ".", "_type2name2decls_nr", "=", "{", "}", "self", ".", "_all_decls", "=", "None", "self", ".", "_all_decls_not_recursive", "=", "None", "for", "decl", "in", "self", ".", "declarations", ":", "if", "isinstance", "(", "decl", ",", "scopedef_t", ")", ":", "decl", ".", "clear_optimizer", "(", ")" ]
[ 264, 4 ]
[ 276, 38 ]
python
en
['fr', 'en', 'en']
True
scopedef_t.init_optimizer
(self)
Initializes query optimizer state. There are 4 internals hash tables: 1. from type to declarations 2. from type to declarations for non-recursive queries 3. from type to name to declarations 4. from type to name to declarations for non-recursive queries Almost every query includes declaration type information. Also very common query is to search some declaration(s) by name or full name. Those hash tables allows to search declaration very quick.
Initializes query optimizer state.
def init_optimizer(self): """ Initializes query optimizer state. There are 4 internals hash tables: 1. from type to declarations 2. from type to declarations for non-recursive queries 3. from type to name to declarations 4. from type to name to declarations for non-recursive queries Almost every query includes declaration type information. Also very common query is to search some declaration(s) by name or full name. Those hash tables allows to search declaration very quick. """ if self.name == '::': self._logger.debug( "preparing data structures for query optimizer - started") start_time = time.clock() self.clear_optimizer() for dtype in scopedef_t._impl_all_decl_types: self._type2decls[dtype] = [] self._type2decls_nr[dtype] = [] self._type2name2decls[dtype] = {} self._type2name2decls_nr[dtype] = {} self._all_decls_not_recursive = self.declarations self._all_decls = make_flatten( self._all_decls_not_recursive) for decl in self._all_decls: types = self.__decl_types(decl) for type_ in types: self._type2decls[type_].append(decl) name2decls = self._type2name2decls[type_] if decl.name not in name2decls: name2decls[decl.name] = [] name2decls[decl.name].append(decl) if self is decl.parent: self._type2decls_nr[type_].append(decl) name2decls_nr = self._type2name2decls_nr[type_] if decl.name not in name2decls_nr: name2decls_nr[decl.name] = [] name2decls_nr[decl.name].append(decl) for decl in self._all_decls_not_recursive: if isinstance(decl, scopedef_t): decl.init_optimizer() if self.name == '::': self._logger.debug(( "preparing data structures for query optimizer - " + "done( %f seconds ). "), (time.clock() - start_time)) self._optimized = True
[ "def", "init_optimizer", "(", "self", ")", ":", "if", "self", ".", "name", "==", "'::'", ":", "self", ".", "_logger", ".", "debug", "(", "\"preparing data structures for query optimizer - started\"", ")", "start_time", "=", "time", ".", "clock", "(", ")", "self", ".", "clear_optimizer", "(", ")", "for", "dtype", "in", "scopedef_t", ".", "_impl_all_decl_types", ":", "self", ".", "_type2decls", "[", "dtype", "]", "=", "[", "]", "self", ".", "_type2decls_nr", "[", "dtype", "]", "=", "[", "]", "self", ".", "_type2name2decls", "[", "dtype", "]", "=", "{", "}", "self", ".", "_type2name2decls_nr", "[", "dtype", "]", "=", "{", "}", "self", ".", "_all_decls_not_recursive", "=", "self", ".", "declarations", "self", ".", "_all_decls", "=", "make_flatten", "(", "self", ".", "_all_decls_not_recursive", ")", "for", "decl", "in", "self", ".", "_all_decls", ":", "types", "=", "self", ".", "__decl_types", "(", "decl", ")", "for", "type_", "in", "types", ":", "self", ".", "_type2decls", "[", "type_", "]", ".", "append", "(", "decl", ")", "name2decls", "=", "self", ".", "_type2name2decls", "[", "type_", "]", "if", "decl", ".", "name", "not", "in", "name2decls", ":", "name2decls", "[", "decl", ".", "name", "]", "=", "[", "]", "name2decls", "[", "decl", ".", "name", "]", ".", "append", "(", "decl", ")", "if", "self", "is", "decl", ".", "parent", ":", "self", ".", "_type2decls_nr", "[", "type_", "]", ".", "append", "(", "decl", ")", "name2decls_nr", "=", "self", ".", "_type2name2decls_nr", "[", "type_", "]", "if", "decl", ".", "name", "not", "in", "name2decls_nr", ":", "name2decls_nr", "[", "decl", ".", "name", "]", "=", "[", "]", "name2decls_nr", "[", "decl", ".", "name", "]", ".", "append", "(", "decl", ")", "for", "decl", "in", "self", ".", "_all_decls_not_recursive", ":", "if", "isinstance", "(", "decl", ",", "scopedef_t", ")", ":", "decl", ".", "init_optimizer", "(", ")", "if", "self", ".", "name", "==", "'::'", ":", "self", ".", "_logger", ".", "debug", "(", "(", "\"preparing data structures for query optimizer - \"", "+", "\"done( %f seconds ). \"", ")", ",", "(", "time", ".", "clock", "(", ")", "-", "start_time", ")", ")", "self", ".", "_optimized", "=", "True" ]
[ 278, 4 ]
[ 330, 30 ]
python
en
['en', 'error', 'th']
False
scopedef_t._build_operator_name
(name, function, symbol)
implementation details
implementation details
def _build_operator_name(name, function, symbol): """implementation details""" def add_operator(sym): if 'new' in sym or 'delete' in sym: return 'operator ' + sym else: return 'operator' + sym if isinstance(name, collections.Callable) and None is function: name = None if name: if 'operator' not in name: name = add_operator(name) return name elif symbol: return add_operator(symbol) return name
[ "def", "_build_operator_name", "(", "name", ",", "function", ",", "symbol", ")", ":", "def", "add_operator", "(", "sym", ")", ":", "if", "'new'", "in", "sym", "or", "'delete'", "in", "sym", ":", "return", "'operator '", "+", "sym", "else", ":", "return", "'operator'", "+", "sym", "if", "isinstance", "(", "name", ",", "collections", ".", "Callable", ")", "and", "None", "is", "function", ":", "name", "=", "None", "if", "name", ":", "if", "'operator'", "not", "in", "name", ":", "name", "=", "add_operator", "(", "name", ")", "return", "name", "elif", "symbol", ":", "return", "add_operator", "(", "symbol", ")", "return", "name" ]
[ 340, 4 ]
[ 355, 19 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.__normalize_args
(**keywds)
implementation details
implementation details
def __normalize_args(**keywds): """implementation details""" if isinstance(keywds['name'], collections.Callable) and \ None is keywds['function']: keywds['function'] = keywds['name'] keywds['name'] = None return keywds
[ "def", "__normalize_args", "(", "*", "*", "keywds", ")", ":", "if", "isinstance", "(", "keywds", "[", "'name'", "]", ",", "collections", ".", "Callable", ")", "and", "None", "is", "keywds", "[", "'function'", "]", ":", "keywds", "[", "'function'", "]", "=", "keywds", "[", "'name'", "]", "keywds", "[", "'name'", "]", "=", "None", "return", "keywds" ]
[ 368, 4 ]
[ 374, 21 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.__findout_recursive
(self, **keywds)
implementation details
implementation details
def __findout_recursive(self, **keywds): """implementation details""" if None is keywds['recursive']: return self.RECURSIVE_DEFAULT else: return keywds['recursive']
[ "def", "__findout_recursive", "(", "self", ",", "*", "*", "keywds", ")", ":", "if", "None", "is", "keywds", "[", "'recursive'", "]", ":", "return", "self", ".", "RECURSIVE_DEFAULT", "else", ":", "return", "keywds", "[", "'recursive'", "]" ]
[ 376, 4 ]
[ 381, 38 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.__findout_allow_empty
(self, **keywds)
implementation details
implementation details
def __findout_allow_empty(self, **keywds): """implementation details""" if None is keywds['allow_empty']: return self.ALLOW_EMPTY_MDECL_WRAPPER else: return keywds['allow_empty']
[ "def", "__findout_allow_empty", "(", "self", ",", "*", "*", "keywds", ")", ":", "if", "None", "is", "keywds", "[", "'allow_empty'", "]", ":", "return", "self", ".", "ALLOW_EMPTY_MDECL_WRAPPER", "else", ":", "return", "keywds", "[", "'allow_empty'", "]" ]
[ 383, 4 ]
[ 388, 40 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.__findout_decl_type
(match_class, **keywds)
implementation details
implementation details
def __findout_decl_type(match_class, **keywds): """implementation details""" if 'decl_type' in keywds: return keywds['decl_type'] matcher_args = keywds.copy() del matcher_args['function'] del matcher_args['recursive'] if 'allow_empty' in matcher_args: del matcher_args['allow_empty'] decl_matcher = match_class(**matcher_args) if decl_matcher.decl_type: return decl_matcher.decl_type return None
[ "def", "__findout_decl_type", "(", "match_class", ",", "*", "*", "keywds", ")", ":", "if", "'decl_type'", "in", "keywds", ":", "return", "keywds", "[", "'decl_type'", "]", "matcher_args", "=", "keywds", ".", "copy", "(", ")", "del", "matcher_args", "[", "'function'", "]", "del", "matcher_args", "[", "'recursive'", "]", "if", "'allow_empty'", "in", "matcher_args", ":", "del", "matcher_args", "[", "'allow_empty'", "]", "decl_matcher", "=", "match_class", "(", "*", "*", "matcher_args", ")", "if", "decl_matcher", ".", "decl_type", ":", "return", "decl_matcher", ".", "decl_type", "return", "None" ]
[ 391, 4 ]
[ 405, 19 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.__create_matcher
(self, match_class, **keywds)
implementation details
implementation details
def __create_matcher(self, match_class, **keywds): """implementation details""" matcher_args = keywds.copy() del matcher_args['function'] del matcher_args['recursive'] if 'allow_empty' in matcher_args: del matcher_args['allow_empty'] decl_matcher = decl_matcher = match_class(**matcher_args) if keywds['function']: self._logger.debug( 'running query: %s and <user defined function>', str(decl_matcher)) return lambda decl: decl_matcher(decl) and keywds['function'](decl) else: self._logger.debug('running query: %s', str(decl_matcher)) return decl_matcher
[ "def", "__create_matcher", "(", "self", ",", "match_class", ",", "*", "*", "keywds", ")", ":", "matcher_args", "=", "keywds", ".", "copy", "(", ")", "del", "matcher_args", "[", "'function'", "]", "del", "matcher_args", "[", "'recursive'", "]", "if", "'allow_empty'", "in", "matcher_args", ":", "del", "matcher_args", "[", "'allow_empty'", "]", "decl_matcher", "=", "decl_matcher", "=", "match_class", "(", "*", "*", "matcher_args", ")", "if", "keywds", "[", "'function'", "]", ":", "self", ".", "_logger", ".", "debug", "(", "'running query: %s and <user defined function>'", ",", "str", "(", "decl_matcher", ")", ")", "return", "lambda", "decl", ":", "decl_matcher", "(", "decl", ")", "and", "keywds", "[", "'function'", "]", "(", "decl", ")", "else", ":", "self", ".", "_logger", ".", "debug", "(", "'running query: %s'", ",", "str", "(", "decl_matcher", ")", ")", "return", "decl_matcher" ]
[ 407, 4 ]
[ 423, 31 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.__findout_range
(self, name, decl_type, recursive)
implementation details
implementation details
def __findout_range(self, name, decl_type, recursive): """implementation details""" if not self._optimized: self._logger.debug( 'running non optimized query - optimization has not been done') decls = self.declarations if recursive: decls = make_flatten(self.declarations) if decl_type: decls = [d for d in decls if isinstance(d, decl_type)] return decls if name and templates.is_instantiation(name): # templates has tricky mode to compare them, so lets check the # whole range name = None if name and decl_type: impl_match = scopedef_t._impl_matchers[scopedef_t.decl](name=name) if impl_match.is_full_name(): name = impl_match.decl_name_only if recursive: self._logger.debug( 'query has been optimized on type and name') return self._type2name2decls[decl_type].get(name, []) else: self._logger.debug( 'non recursive query has been optimized on type and name') return self._type2name2decls_nr[decl_type].get(name, []) elif decl_type: if recursive: self._logger.debug('query has been optimized on type') return self._type2decls[decl_type] else: self._logger.debug( 'non recursive query has been optimized on type') return self._type2decls_nr[decl_type] else: if recursive: self._logger.debug(( 'query has not been optimized ( hint: query does not ' + 'contain type and/or name )')) return self._all_decls else: self._logger.debug(( 'non recursive query has not been optimized ( hint: ' + 'query does not contain type and/or name )')) return self._all_decls_not_recursive
[ "def", "__findout_range", "(", "self", ",", "name", ",", "decl_type", ",", "recursive", ")", ":", "if", "not", "self", ".", "_optimized", ":", "self", ".", "_logger", ".", "debug", "(", "'running non optimized query - optimization has not been done'", ")", "decls", "=", "self", ".", "declarations", "if", "recursive", ":", "decls", "=", "make_flatten", "(", "self", ".", "declarations", ")", "if", "decl_type", ":", "decls", "=", "[", "d", "for", "d", "in", "decls", "if", "isinstance", "(", "d", ",", "decl_type", ")", "]", "return", "decls", "if", "name", "and", "templates", ".", "is_instantiation", "(", "name", ")", ":", "# templates has tricky mode to compare them, so lets check the", "# whole range", "name", "=", "None", "if", "name", "and", "decl_type", ":", "impl_match", "=", "scopedef_t", ".", "_impl_matchers", "[", "scopedef_t", ".", "decl", "]", "(", "name", "=", "name", ")", "if", "impl_match", ".", "is_full_name", "(", ")", ":", "name", "=", "impl_match", ".", "decl_name_only", "if", "recursive", ":", "self", ".", "_logger", ".", "debug", "(", "'query has been optimized on type and name'", ")", "return", "self", ".", "_type2name2decls", "[", "decl_type", "]", ".", "get", "(", "name", ",", "[", "]", ")", "else", ":", "self", ".", "_logger", ".", "debug", "(", "'non recursive query has been optimized on type and name'", ")", "return", "self", ".", "_type2name2decls_nr", "[", "decl_type", "]", ".", "get", "(", "name", ",", "[", "]", ")", "elif", "decl_type", ":", "if", "recursive", ":", "self", ".", "_logger", ".", "debug", "(", "'query has been optimized on type'", ")", "return", "self", ".", "_type2decls", "[", "decl_type", "]", "else", ":", "self", ".", "_logger", ".", "debug", "(", "'non recursive query has been optimized on type'", ")", "return", "self", ".", "_type2decls_nr", "[", "decl_type", "]", "else", ":", "if", "recursive", ":", "self", ".", "_logger", ".", "debug", "(", "(", "'query has not been optimized ( hint: query does not '", "+", "'contain type and/or name )'", ")", ")", "return", "self", ".", "_all_decls", "else", ":", "self", ".", "_logger", ".", "debug", "(", "(", "'non recursive query has not been optimized ( hint: '", "+", "'query does not contain type and/or name )'", ")", ")", "return", "self", ".", "_all_decls_not_recursive" ]
[ 425, 4 ]
[ 472, 52 ]
python
da
['eo', 'da', 'en']
False
scopedef_t._find_single
(self, match_class, **keywds)
implementation details
implementation details
def _find_single(self, match_class, **keywds): """implementation details""" self._logger.debug('find single query execution - started') start_time = time.clock() norm_keywds = self.__normalize_args(**keywds) decl_matcher = self.__create_matcher(match_class, **norm_keywds) dtype = self.__findout_decl_type(match_class, **norm_keywds) recursive_ = self.__findout_recursive(**norm_keywds) decls = self.__findout_range(norm_keywds['name'], dtype, recursive_) found = matcher.get_single(decl_matcher, decls, False) self._logger.debug( 'find single query execution - done( %f seconds )', (time.clock() - start_time)) return found
[ "def", "_find_single", "(", "self", ",", "match_class", ",", "*", "*", "keywds", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'find single query execution - started'", ")", "start_time", "=", "time", ".", "clock", "(", ")", "norm_keywds", "=", "self", ".", "__normalize_args", "(", "*", "*", "keywds", ")", "decl_matcher", "=", "self", ".", "__create_matcher", "(", "match_class", ",", "*", "*", "norm_keywds", ")", "dtype", "=", "self", ".", "__findout_decl_type", "(", "match_class", ",", "*", "*", "norm_keywds", ")", "recursive_", "=", "self", ".", "__findout_recursive", "(", "*", "*", "norm_keywds", ")", "decls", "=", "self", ".", "__findout_range", "(", "norm_keywds", "[", "'name'", "]", ",", "dtype", ",", "recursive_", ")", "found", "=", "matcher", ".", "get_single", "(", "decl_matcher", ",", "decls", ",", "False", ")", "self", ".", "_logger", ".", "debug", "(", "'find single query execution - done( %f seconds )'", ",", "(", "time", ".", "clock", "(", ")", "-", "start_time", ")", ")", "return", "found" ]
[ 474, 4 ]
[ 487, 20 ]
python
da
['eo', 'da', 'en']
False
scopedef_t._find_multiple
(self, match_class, **keywds)
implementation details
implementation details
def _find_multiple(self, match_class, **keywds): """implementation details""" self._logger.debug('find all query execution - started') start_time = time.clock() norm_keywds = self.__normalize_args(**keywds) decl_matcher = self.__create_matcher(match_class, **norm_keywds) dtype = self.__findout_decl_type(match_class, **norm_keywds) recursive_ = self.__findout_recursive(**norm_keywds) allow_empty = self.__findout_allow_empty(**norm_keywds) decls = self.__findout_range(norm_keywds['name'], dtype, recursive_) found = matcher.find(decl_matcher, decls, False) mfound = mdecl_wrapper.mdecl_wrapper_t(found) self._logger.debug('%d declaration(s) that match query', len(mfound)) self._logger.debug( 'find single query execution - done( %f seconds )', (time.clock() - start_time)) if not mfound and not allow_empty: raise RuntimeError( "Multi declaration query returned 0 declarations.") return mfound
[ "def", "_find_multiple", "(", "self", ",", "match_class", ",", "*", "*", "keywds", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'find all query execution - started'", ")", "start_time", "=", "time", ".", "clock", "(", ")", "norm_keywds", "=", "self", ".", "__normalize_args", "(", "*", "*", "keywds", ")", "decl_matcher", "=", "self", ".", "__create_matcher", "(", "match_class", ",", "*", "*", "norm_keywds", ")", "dtype", "=", "self", ".", "__findout_decl_type", "(", "match_class", ",", "*", "*", "norm_keywds", ")", "recursive_", "=", "self", ".", "__findout_recursive", "(", "*", "*", "norm_keywds", ")", "allow_empty", "=", "self", ".", "__findout_allow_empty", "(", "*", "*", "norm_keywds", ")", "decls", "=", "self", ".", "__findout_range", "(", "norm_keywds", "[", "'name'", "]", ",", "dtype", ",", "recursive_", ")", "found", "=", "matcher", ".", "find", "(", "decl_matcher", ",", "decls", ",", "False", ")", "mfound", "=", "mdecl_wrapper", ".", "mdecl_wrapper_t", "(", "found", ")", "self", ".", "_logger", ".", "debug", "(", "'%d declaration(s) that match query'", ",", "len", "(", "mfound", ")", ")", "self", ".", "_logger", ".", "debug", "(", "'find single query execution - done( %f seconds )'", ",", "(", "time", ".", "clock", "(", ")", "-", "start_time", ")", ")", "if", "not", "mfound", "and", "not", "allow_empty", ":", "raise", "RuntimeError", "(", "\"Multi declaration query returned 0 declarations.\"", ")", "return", "mfound" ]
[ 489, 4 ]
[ 508, 21 ]
python
da
['eo', 'da', 'en']
False
scopedef_t.decl
( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None)
returns reference to declaration, that is matched defined criteria
returns reference to declaration, that is matched defined criteria
def decl( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None): """returns reference to declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[ scopedef_t.decl], name=name, function=function, decl_type=decl_type, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "decl", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "decl_type", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "decl", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "decl_type", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 510, 4 ]
[ 530, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.decls
( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of declarations, that are matched defined criteria
returns a set of declarations, that are matched defined criteria
def decls( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[ scopedef_t.decl], name=name, function=function, decl_type=decl_type, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "decls", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "decl_type", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "decl", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "decl_type", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 532, 4 ]
[ 553, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.class_
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None)
returns reference to class declaration, that is matched defined criteria
returns reference to class declaration, that is matched defined criteria
def class_( self, name=None, function=None, header_dir=None, header_file=None, recursive=None): """returns reference to class declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.class_], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.class_], header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "class_", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "class_", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "class_", "]", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 555, 4 ]
[ 574, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.classes
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of class declarations, that are matched defined criteria
returns a set of class declarations, that are matched defined criteria
def classes( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of class declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.class_], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.class_], header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "classes", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "class_", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "class_", "]", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 576, 4 ]
[ 597, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.variable
( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None)
returns reference to variable declaration, that is matched defined criteria
returns reference to variable declaration, that is matched defined criteria
def variable( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None): """returns reference to variable declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[ scopedef_t.variable], name=name, function=function, decl_type=decl_type, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "variable", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "decl_type", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "variable", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "decl_type", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 599, 4 ]
[ 620, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.variables
( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of variable declarations, that are matched defined criteria
returns a set of variable declarations, that are matched defined criteria
def variables( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of variable declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[ scopedef_t.variable], name=name, function=function, decl_type=decl_type, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "variables", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "decl_type", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "variable", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "decl_type", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 622, 4 ]
[ 645, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.calldef
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
returns reference to "calldef" declaration, that is matched defined criteria
returns reference to "calldef" declaration, that is matched defined criteria
def calldef( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """returns reference to "calldef" declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.calldef], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.calldef], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "calldef", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "calldef", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "calldef", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 647, 4 ]
[ 670, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.calldefs
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of :class:`calldef_t` declarations, that are matched defined criteria
returns a set of :class:`calldef_t` declarations, that are matched defined criteria
def calldefs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of :class:`calldef_t` declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.calldef], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.calldef], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "calldefs", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "calldef", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "calldef", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 672, 4 ]
[ 697, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.operator
( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
returns reference to operator declaration, that is matched defined criteria
returns reference to operator declaration, that is matched defined criteria
def operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """returns reference to operator declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.operator], name=self._build_operator_name(name, function, symbol), symbol=symbol, function=self._build_operator_function(name, function), decl_type=self._impl_decl_types[scopedef_t.operator], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "operator", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "symbol", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "operator", "]", ",", "name", "=", "self", ".", "_build_operator_name", "(", "name", ",", "function", ",", "symbol", ")", ",", "symbol", "=", "symbol", ",", "function", "=", "self", ".", "_build_operator_function", "(", "name", ",", "function", ")", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "operator", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 699, 4 ]
[ 726, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.operators
( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of operator declarations, that are matched defined criteria
returns a set of operator declarations, that are matched defined criteria
def operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of operator declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.operator], name=self._build_operator_name(name, function, symbol), symbol=symbol, function=self._build_operator_function(name, function), decl_type=self._impl_decl_types[scopedef_t.operator], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "operators", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "symbol", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "operator", "]", ",", "name", "=", "self", ".", "_build_operator_name", "(", "name", ",", "function", ",", "symbol", ")", ",", "symbol", "=", "symbol", ",", "function", "=", "self", ".", "_build_operator_function", "(", "name", ",", "function", ")", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "operator", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 728, 4 ]
[ 757, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.member_function
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
returns reference to member declaration, that is matched defined criteria
returns reference to member declaration, that is matched defined criteria
def member_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """returns reference to member declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.member_function], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.member_function], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "member_function", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "member_function", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "member_function", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 759, 4 ]
[ 782, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.mem_fun
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
Deprecated method. Use the member_function() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0
Deprecated method. Use the member_function() method instead.
def mem_fun( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """ Deprecated method. Use the member_function() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0 """ warnings.warn( "The mem_fun() method is deprecated. \n" + "Please use the member_function() method instead.", DeprecationWarning) return self.member_function( name, function, return_type, arg_types, header_dir, header_file, recursive)
[ "def", "mem_fun", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The mem_fun() method is deprecated. \\n\"", "+", "\"Please use the member_function() method instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "member_function", "(", "name", ",", "function", ",", "return_type", ",", "arg_types", ",", "header_dir", ",", "header_file", ",", "recursive", ")" ]
[ 784, 4 ]
[ 807, 22 ]
python
en
['en', 'error', 'th']
False
scopedef_t.member_functions
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of member function declarations, that are matched defined criteria
returns a set of member function declarations, that are matched defined criteria
def member_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of member function declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.member_function], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.member_function], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "member_functions", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "member_function", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "member_function", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 809, 4 ]
[ 834, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.mem_funs
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
Deprecated method. Use the member_functions() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0
Deprecated method. Use the member_functions() method instead.
def mem_funs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """ Deprecated method. Use the member_functions() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0 """ warnings.warn( "The mem_funs() method is deprecated. \n" + "Please use the member_functions() method instead.", DeprecationWarning) return self.member_functions( name, function, return_type, arg_types, header_dir, header_file, recursive, allow_empty)
[ "def", "mem_funs", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The mem_funs() method is deprecated. \\n\"", "+", "\"Please use the member_functions() method instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "member_functions", "(", "name", ",", "function", ",", "return_type", ",", "arg_types", ",", "header_dir", ",", "header_file", ",", "recursive", ",", "allow_empty", ")" ]
[ 836, 4 ]
[ 860, 35 ]
python
en
['en', 'error', 'th']
False
scopedef_t.constructor
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
returns reference to constructor declaration, that is matched defined criteria
returns reference to constructor declaration, that is matched defined criteria
def constructor( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """returns reference to constructor declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.constructor], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.constructor], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "constructor", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "constructor", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "constructor", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 862, 4 ]
[ 885, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.constructors
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of constructor declarations, that are matched defined criteria
returns a set of constructor declarations, that are matched defined criteria
def constructors( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of constructor declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.constructor], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.constructor], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "constructors", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "constructor", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "constructor", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 887, 4 ]
[ 912, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.member_operator
( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
returns reference to member operator declaration, that is matched defined criteria
returns reference to member operator declaration, that is matched defined criteria
def member_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """returns reference to member operator declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.member_operator], name=self._build_operator_name(name, function, symbol), symbol=symbol, function=self._build_operator_function(name, function), decl_type=self._impl_decl_types[scopedef_t.member_operator], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "member_operator", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "symbol", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "member_operator", "]", ",", "name", "=", "self", ".", "_build_operator_name", "(", "name", ",", "function", ",", "symbol", ")", ",", "symbol", "=", "symbol", ",", "function", "=", "self", ".", "_build_operator_function", "(", "name", ",", "function", ")", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "member_operator", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 914, 4 ]
[ 941, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.mem_oper
( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
Deprecated method. Use the member_operator() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0
Deprecated method. Use the member_operator() method instead.
def mem_oper( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """ Deprecated method. Use the member_operator() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0 """ warnings.warn( "The mem_oper() method is deprecated. \n" + "Please use the member_operator() method instead.", DeprecationWarning) return self.member_operator( name, function, symbol, return_type, arg_types, header_dir, header_file, recursive)
[ "def", "mem_oper", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "symbol", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The mem_oper() method is deprecated. \\n\"", "+", "\"Please use the member_operator() method instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "member_operator", "(", "name", ",", "function", ",", "symbol", ",", "return_type", ",", "arg_types", ",", "header_dir", ",", "header_file", ",", "recursive", ")" ]
[ 943, 4 ]
[ 967, 35 ]
python
en
['en', 'error', 'th']
False
scopedef_t.member_operators
( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of member operator declarations, that are matched defined criteria
returns a set of member operator declarations, that are matched defined criteria
def member_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of member operator declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.member_operator], name=self._build_operator_name(name, function, symbol), symbol=symbol, function=self._build_operator_function(name, function), decl_type=self._impl_decl_types[scopedef_t.member_operator], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "member_operators", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "symbol", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "member_operator", "]", ",", "name", "=", "self", ".", "_build_operator_name", "(", "name", ",", "function", ",", "symbol", ")", ",", "symbol", "=", "symbol", ",", "function", "=", "self", ".", "_build_operator_function", "(", "name", ",", "function", ")", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "member_operator", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 969, 4 ]
[ 998, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.mem_opers
( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
Deprecated method. Use the member_operators() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0
Deprecated method. Use the member_operators() method instead.
def mem_opers( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """ Deprecated method. Use the member_operators() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0 """ warnings.warn( "The mem_opers() method is deprecated. \n" + "Please use the member_operators() method instead.", DeprecationWarning) return self.member_operators( name, function, symbol, return_type, arg_types, header_dir, header_file, recursive, allow_empty)
[ "def", "mem_opers", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "symbol", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The mem_opers() method is deprecated. \\n\"", "+", "\"Please use the member_operators() method instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "member_operators", "(", "name", ",", "function", ",", "symbol", ",", "return_type", ",", "arg_types", ",", "header_dir", ",", "header_file", ",", "recursive", ",", "allow_empty", ")" ]
[ 1000, 4 ]
[ 1026, 24 ]
python
en
['en', 'error', 'th']
False
scopedef_t.casting_operator
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)
returns reference to casting operator declaration, that is matched defined criteria
returns reference to casting operator declaration, that is matched defined criteria
def casting_operator( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None): """returns reference to casting operator declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.casting_operator], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.casting_operator], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "casting_operator", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "casting_operator", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "casting_operator", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 1028, 4 ]
[ 1051, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.casting_operators
( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of casting operator declarations, that are matched defined criteria
returns a set of casting operator declarations, that are matched defined criteria
def casting_operators( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of casting operator declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.casting_operator], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.casting_operator], return_type=return_type, arg_types=arg_types, header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "casting_operators", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "return_type", "=", "None", ",", "arg_types", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "casting_operator", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "casting_operator", "]", ",", "return_type", "=", "return_type", ",", "arg_types", "=", "arg_types", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 1053, 4 ]
[ 1078, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.enumeration
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None)
returns reference to enumeration declaration, that is matched defined criteria
returns reference to enumeration declaration, that is matched defined criteria
def enumeration( self, name=None, function=None, header_dir=None, header_file=None, recursive=None): """returns reference to enumeration declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.enumeration], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.enumeration], header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "enumeration", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "enumeration", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "enumeration", "]", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 1080, 4 ]
[ 1099, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.enum
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None)
Deprecated method. Use the enumeration() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0
Deprecated method. Use the enumeration() method instead.
def enum( self, name=None, function=None, header_dir=None, header_file=None, recursive=None): """ Deprecated method. Use the enumeration() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0 """ warnings.warn( "The enum() method is deprecated. \n" + "Please use the enumeration() method instead.", DeprecationWarning) return self.enumeration( name, function, header_dir, header_file, recursive)
[ "def", "enum", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The enum() method is deprecated. \\n\"", "+", "\"Please use the enumeration() method instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "enumeration", "(", "name", ",", "function", ",", "header_dir", ",", "header_file", ",", "recursive", ")" ]
[ 1101, 4 ]
[ 1119, 63 ]
python
en
['en', 'error', 'th']
False
scopedef_t.enumerations
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
returns a set of enumeration declarations, that are matched defined criteria
returns a set of enumeration declarations, that are matched defined criteria
def enumerations( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """returns a set of enumeration declarations, that are matched defined criteria""" return ( self._find_multiple( self._impl_matchers[scopedef_t.enumeration], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.enumeration], header_dir=header_dir, header_file=header_file, recursive=recursive, allow_empty=allow_empty) )
[ "def", "enumerations", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "return", "(", "self", ".", "_find_multiple", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "enumeration", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "enumeration", "]", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ",", "allow_empty", "=", "allow_empty", ")", ")" ]
[ 1121, 4 ]
[ 1142, 9 ]
python
en
['en', 'en', 'en']
True
scopedef_t.enums
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)
Deprecated method. Use the enumerations() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0
Deprecated method. Use the enumerations() method instead.
def enums( self, name=None, function=None, header_dir=None, header_file=None, recursive=None, allow_empty=None): """ Deprecated method. Use the enumerations() method instead. Deprecated since v1.9.0. Will be removed in v2.0.0 """ warnings.warn( "The enums() method is deprecated. \n" + "Please use the enumerations() method instead.", DeprecationWarning) return self.enumerations( name, function, header_dir, header_file, recursive, allow_empty)
[ "def", "enums", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ",", "allow_empty", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The enums() method is deprecated. \\n\"", "+", "\"Please use the enumerations() method instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "enumerations", "(", "name", ",", "function", ",", "header_dir", ",", "header_file", ",", "recursive", ",", "allow_empty", ")" ]
[ 1144, 4 ]
[ 1163, 76 ]
python
en
['en', 'error', 'th']
False
scopedef_t.typedef
( self, name=None, function=None, header_dir=None, header_file=None, recursive=None)
returns reference to typedef declaration, that is matched defined criteria
returns reference to typedef declaration, that is matched defined criteria
def typedef( self, name=None, function=None, header_dir=None, header_file=None, recursive=None): """returns reference to typedef declaration, that is matched defined criteria""" return ( self._find_single( self._impl_matchers[scopedef_t.typedef], name=name, function=function, decl_type=self._impl_decl_types[ scopedef_t.typedef], header_dir=header_dir, header_file=header_file, recursive=recursive) )
[ "def", "typedef", "(", "self", ",", "name", "=", "None", ",", "function", "=", "None", ",", "header_dir", "=", "None", ",", "header_file", "=", "None", ",", "recursive", "=", "None", ")", ":", "return", "(", "self", ".", "_find_single", "(", "self", ".", "_impl_matchers", "[", "scopedef_t", ".", "typedef", "]", ",", "name", "=", "name", ",", "function", "=", "function", ",", "decl_type", "=", "self", ".", "_impl_decl_types", "[", "scopedef_t", ".", "typedef", "]", ",", "header_dir", "=", "header_dir", ",", "header_file", "=", "header_file", ",", "recursive", "=", "recursive", ")", ")" ]
[ 1165, 4 ]
[ 1184, 9 ]
python
en
['en', 'en', 'en']
True