partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
QueryDbOrm.where
Select from a given Table or Column with the specified WHERE clause string. Additional keywords are passed to ExploreSqlDB.query(). For convenience, if there is no '=', '>', '<', 'like', or 'LIKE' clause in the WHERE statement .where() tries to match the input string against the primary ...
query/core.py
def where(self, where_string, **kwargs): """ Select from a given Table or Column with the specified WHERE clause string. Additional keywords are passed to ExploreSqlDB.query(). For convenience, if there is no '=', '>', '<', 'like', or 'LIKE' clause in the WHERE statement .where()...
def where(self, where_string, **kwargs): """ Select from a given Table or Column with the specified WHERE clause string. Additional keywords are passed to ExploreSqlDB.query(). For convenience, if there is no '=', '>', '<', 'like', or 'LIKE' clause in the WHERE statement .where()...
[ "Select", "from", "a", "given", "Table", "or", "Column", "with", "the", "specified", "WHERE", "clause", "string", ".", "Additional", "keywords", "are", "passed", "to", "ExploreSqlDB", ".", "query", "()", ".", "For", "convenience", "if", "there", "is", "no", ...
boydgreenfield/query
python
https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L140-L170
[ "def", "where", "(", "self", ",", "where_string", ",", "*", "*", "kwargs", ")", ":", "col", ",", "id_col", "=", "self", ".", "_query_helper", "(", "by", "=", "None", ")", "where_string", "=", "str", "(", "where_string", ")", "# Coerce here, for .__contains...
03aa43b746b43832af3f0403265e648a5617b62b
train
QueryDb.query
Execute a raw SQL query against the the SQL DB. Args: sql_query (str): A raw SQL query to execute. Kwargs: return_as (str): Specify what type of object should be returned. The following are acceptable types: - "dataframe": pandas.DataFrame or None if no ...
query/core.py
def query(self, sql_query, return_as="dataframe"): """ Execute a raw SQL query against the the SQL DB. Args: sql_query (str): A raw SQL query to execute. Kwargs: return_as (str): Specify what type of object should be returned. The following are accep...
def query(self, sql_query, return_as="dataframe"): """ Execute a raw SQL query against the the SQL DB. Args: sql_query (str): A raw SQL query to execute. Kwargs: return_as (str): Specify what type of object should be returned. The following are accep...
[ "Execute", "a", "raw", "SQL", "query", "against", "the", "the", "SQL", "DB", "." ]
boydgreenfield/query
python
https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L298-L335
[ "def", "query", "(", "self", ",", "sql_query", ",", "return_as", "=", "\"dataframe\"", ")", ":", "if", "isinstance", "(", "sql_query", ",", "str", ")", ":", "pass", "elif", "isinstance", "(", "sql_query", ",", "unicode", ")", ":", "sql_query", "=", "str"...
03aa43b746b43832af3f0403265e648a5617b62b
train
QueryDb._set_metadata
Internal helper to set metadata attributes.
query/core.py
def _set_metadata(self): """ Internal helper to set metadata attributes. """ meta = QueryDbMeta() with self._engine.connect() as conn: meta.bind = conn meta.reflect() self._meta = meta # Set an inspect attribute, whose subattributes ...
def _set_metadata(self): """ Internal helper to set metadata attributes. """ meta = QueryDbMeta() with self._engine.connect() as conn: meta.bind = conn meta.reflect() self._meta = meta # Set an inspect attribute, whose subattributes ...
[ "Internal", "helper", "to", "set", "metadata", "attributes", "." ]
boydgreenfield/query
python
https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L337-L373
[ "def", "_set_metadata", "(", "self", ")", ":", "meta", "=", "QueryDbMeta", "(", ")", "with", "self", ".", "_engine", ".", "connect", "(", ")", "as", "conn", ":", "meta", ".", "bind", "=", "conn", "meta", ".", "reflect", "(", ")", "self", ".", "_met...
03aa43b746b43832af3f0403265e648a5617b62b
train
QueryDb._to_df
Internal convert-to-DataFrame convenience wrapper.
query/core.py
def _to_df(self, query, conn, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None): """ Internal convert-to-DataFrame convenience wrapper. """ return pd.io.sql.read_sql(str(query), conn, index_col=index_col, coer...
def _to_df(self, query, conn, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None): """ Internal convert-to-DataFrame convenience wrapper. """ return pd.io.sql.read_sql(str(query), conn, index_col=index_col, coer...
[ "Internal", "convert", "-", "to", "-", "DataFrame", "convenience", "wrapper", "." ]
boydgreenfield/query
python
https://github.com/boydgreenfield/query/blob/03aa43b746b43832af3f0403265e648a5617b62b/query/core.py#L375-L382
[ "def", "_to_df", "(", "self", ",", "query", ",", "conn", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "params", "=", "None", ",", "parse_dates", "=", "None", ",", "columns", "=", "None", ")", ":", "return", "pd", ".", "io", ...
03aa43b746b43832af3f0403265e648a5617b62b
train
disaggregate_temperature
The disaggregation function for temperature Parameters ---- data_daily : daily data method : method to disaggregate min_max_time: "fix" - min/max temperature at fixed times 7h/14h, "sun_loc" - min/max calculated by sunrise/sunnoon + 2h, ...
melodist/temperature.py
def disaggregate_temperature(data_daily, method='sine_min_max', min_max_time='fix', mod_nighttime=False, max_delta=None, mean_course=None, sun_tim...
def disaggregate_temperature(data_daily, method='sine_min_max', min_max_time='fix', mod_nighttime=False, max_delta=None, mean_course=None, sun_tim...
[ "The", "disaggregation", "function", "for", "temperature" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/temperature.py#L33-L212
[ "def", "disaggregate_temperature", "(", "data_daily", ",", "method", "=", "'sine_min_max'", ",", "min_max_time", "=", "'fix'", ",", "mod_nighttime", "=", "False", ",", "max_delta", "=", "None", ",", "mean_course", "=", "None", ",", "sun_times", "=", "None", ")...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
get_shift_by_data
function to get max temp shift (monthly) by hourly data Parameters ---- hourly_data_obs : observed hourly data lat : latitude in DezDeg lon : longitude in DezDeg time_zone: timezone
melodist/temperature.py
def get_shift_by_data(temp_hourly, lon, lat, time_zone): '''function to get max temp shift (monthly) by hourly data Parameters ---- hourly_data_obs : observed hourly data lat : latitude in DezDeg lon : longitude in DezDeg time_zone: timezone ''' d...
def get_shift_by_data(temp_hourly, lon, lat, time_zone): '''function to get max temp shift (monthly) by hourly data Parameters ---- hourly_data_obs : observed hourly data lat : latitude in DezDeg lon : longitude in DezDeg time_zone: timezone ''' d...
[ "function", "to", "get", "max", "temp", "shift", "(", "monthly", ")", "by", "hourly", "data", "Parameters", "----", "hourly_data_obs", ":", "observed", "hourly", "data", "lat", ":", "latitude", "in", "DezDeg", "lon", ":", "longitude", "in", "DezDeg", "time_z...
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/temperature.py#L215-L235
[ "def", "get_shift_by_data", "(", "temp_hourly", ",", "lon", ",", "lat", ",", "time_zone", ")", ":", "daily_index", "=", "temp_hourly", ".", "resample", "(", "'D'", ")", ".", "mean", "(", ")", ".", "index", "sun_times", "=", "melodist", ".", "util", ".", ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
distribute_equally
Obtains hourly values by equally distributing the daily values. Args: daily_data: daily values divide: if True, divide resulting values by the number of hours in order to preserve the daily sum (required e.g. for precipitation). Returns: Equally distributed hourly values.
melodist/util/util.py
def distribute_equally(daily_data, divide=False): """Obtains hourly values by equally distributing the daily values. Args: daily_data: daily values divide: if True, divide resulting values by the number of hours in order to preserve the daily sum (required e.g. for precipitation). ...
def distribute_equally(daily_data, divide=False): """Obtains hourly values by equally distributing the daily values. Args: daily_data: daily values divide: if True, divide resulting values by the number of hours in order to preserve the daily sum (required e.g. for precipitation). ...
[ "Obtains", "hourly", "values", "by", "equally", "distributing", "the", "daily", "values", "." ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L50-L70
[ "def", "distribute_equally", "(", "daily_data", ",", "divide", "=", "False", ")", ":", "index", "=", "hourly_index", "(", "daily_data", ".", "index", ")", "hourly_data", "=", "daily_data", ".", "reindex", "(", "index", ")", "hourly_data", "=", "hourly_data", ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
vapor_pressure
Calculates vapor pressure from temperature and humidity after Sonntag (1990). Args: temp: temperature values hum: humidity value(s). Can be scalar (e.g. for calculating saturation vapor pressure). Returns: Vapor pressure in hPa.
melodist/util/util.py
def vapor_pressure(temp, hum): """ Calculates vapor pressure from temperature and humidity after Sonntag (1990). Args: temp: temperature values hum: humidity value(s). Can be scalar (e.g. for calculating saturation vapor pressure). Returns: Vapor pressure in hPa. """ i...
def vapor_pressure(temp, hum): """ Calculates vapor pressure from temperature and humidity after Sonntag (1990). Args: temp: temperature values hum: humidity value(s). Can be scalar (e.g. for calculating saturation vapor pressure). Returns: Vapor pressure in hPa. """ i...
[ "Calculates", "vapor", "pressure", "from", "temperature", "and", "humidity", "after", "Sonntag", "(", "1990", ")", "." ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L73-L95
[ "def", "vapor_pressure", "(", "temp", ",", "hum", ")", ":", "if", "np", ".", "isscalar", "(", "hum", ")", ":", "hum", "=", "np", ".", "zeros", "(", "temp", ".", "shape", ")", "+", "hum", "assert", "(", "temp", ".", "shape", "==", "hum", ".", "s...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
dewpoint_temperature
computes the dewpoint temperature Parameters ---- temp : temperature [K] hum : relative humidity Returns dewpoint temperature in K
melodist/util/util.py
def dewpoint_temperature(temp, hum): """computes the dewpoint temperature Parameters ---- temp : temperature [K] hum : relative humidity Returns dewpoint temperature in K """ assert(temp.shape == hum.shape) vap_press = vapor_pressure(temp, hum) positiv...
def dewpoint_temperature(temp, hum): """computes the dewpoint temperature Parameters ---- temp : temperature [K] hum : relative humidity Returns dewpoint temperature in K """ assert(temp.shape == hum.shape) vap_press = vapor_pressure(temp, hum) positiv...
[ "computes", "the", "dewpoint", "temperature" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L98-L119
[ "def", "dewpoint_temperature", "(", "temp", ",", "hum", ")", ":", "assert", "(", "temp", ".", "shape", "==", "hum", ".", "shape", ")", "vap_press", "=", "vapor_pressure", "(", "temp", ",", "hum", ")", "positives", "=", "np", ".", "array", "(", "temp", ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
linregress
linear regression calculation Parameters ---- x : independent variable (series) y : dependent variable (series) return_stats : returns statistical values as well if required (bool) Returns ---- list of parameters (and statistics)
melodist/util/util.py
def linregress(x, y, return_stats=False): """linear regression calculation Parameters ---- x : independent variable (series) y : dependent variable (series) return_stats : returns statistical values as well if required (bool) Returns ---- list of parameters (an...
def linregress(x, y, return_stats=False): """linear regression calculation Parameters ---- x : independent variable (series) y : dependent variable (series) return_stats : returns statistical values as well if required (bool) Returns ---- list of parameters (an...
[ "linear", "regression", "calculation" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L122-L142
[ "def", "linregress", "(", "x", ",", "y", ",", "return_stats", "=", "False", ")", ":", "a1", ",", "a0", ",", "r_value", ",", "p_value", ",", "stderr", "=", "scipy", ".", "stats", ".", "linregress", "(", "x", ",", "y", ")", "retval", "=", "a1", ","...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
get_sun_times
Computes the times of sunrise, solar noon, and sunset for each day. Parameters ---- dates: datetime lat : latitude in DecDeg lon : longitude in DecDeg time_zone : timezone Returns ---- DataFrame: [sunrise, sunnoon, sunset, day length] in dec hours
melodist/util/util.py
def get_sun_times(dates, lon, lat, time_zone): """Computes the times of sunrise, solar noon, and sunset for each day. Parameters ---- dates: datetime lat : latitude in DecDeg lon : longitude in DecDeg time_zone : timezone Returns ---- DataFrame: [sunrise,...
def get_sun_times(dates, lon, lat, time_zone): """Computes the times of sunrise, solar noon, and sunset for each day. Parameters ---- dates: datetime lat : latitude in DecDeg lon : longitude in DecDeg time_zone : timezone Returns ---- DataFrame: [sunrise,...
[ "Computes", "the", "times", "of", "sunrise", "solar", "noon", "and", "sunset", "for", "each", "day", "." ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L145-L221
[ "def", "get_sun_times", "(", "dates", ",", "lon", ",", "lat", ",", "time_zone", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "index", "=", "dates", ",", "columns", "=", "[", "'sunrise'", ",", "'sunnoon'", ",", "'sunset'", ",", "'daylength'", "]", ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
detect_gaps
checks if a given dataframe contains gaps and returns the number of gaps This funtion checks if a dataframe contains any gaps for a given temporal resolution that needs to be specified in seconds. The number of gaps detected in the dataframe is returned. Args: dataframe: A pandas dataframe obj...
melodist/util/util.py
def detect_gaps(dataframe, timestep, print_all=False, print_max=5, verbose=True): """checks if a given dataframe contains gaps and returns the number of gaps This funtion checks if a dataframe contains any gaps for a given temporal resolution that needs to be specified in seconds. The number of gaps de...
def detect_gaps(dataframe, timestep, print_all=False, print_max=5, verbose=True): """checks if a given dataframe contains gaps and returns the number of gaps This funtion checks if a dataframe contains any gaps for a given temporal resolution that needs to be specified in seconds. The number of gaps de...
[ "checks", "if", "a", "given", "dataframe", "contains", "gaps", "and", "returns", "the", "number", "of", "gaps" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L224-L265
[ "def", "detect_gaps", "(", "dataframe", ",", "timestep", ",", "print_all", "=", "False", ",", "print_max", "=", "5", ",", "verbose", "=", "True", ")", ":", "gcount", "=", "0", "msg_counter", "=", "0", "warning_printed", "=", "False", "try", ":", "n", "...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
drop_incomplete_days
truncates a given dataframe to full days only This funtion truncates a given pandas dataframe (time series) to full days only, thus dropping leading and tailing hours of incomplete days. Please note that this methodology only applies to hourly time series. Args: dataframe: A pandas dataframe o...
melodist/util/util.py
def drop_incomplete_days(dataframe, shift=0): """truncates a given dataframe to full days only This funtion truncates a given pandas dataframe (time series) to full days only, thus dropping leading and tailing hours of incomplete days. Please note that this methodology only applies to hourly time serie...
def drop_incomplete_days(dataframe, shift=0): """truncates a given dataframe to full days only This funtion truncates a given pandas dataframe (time series) to full days only, thus dropping leading and tailing hours of incomplete days. Please note that this methodology only applies to hourly time serie...
[ "truncates", "a", "given", "dataframe", "to", "full", "days", "only" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L268-L320
[ "def", "drop_incomplete_days", "(", "dataframe", ",", "shift", "=", "0", ")", ":", "dropped", "=", "0", "if", "shift", ">", "23", "or", "shift", "<", "0", ":", "print", "(", "\"Invalid shift parameter setting! Using defaults.\"", ")", "shift", "=", "0", "fir...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
daily_from_hourly
Aggregates data (hourly to daily values) according to the characteristics of each variable (e.g., average for temperature, sum for precipitation) Args: df: dataframe including time series with one hour time steps Returns: dataframe (daily)
melodist/util/util.py
def daily_from_hourly(df): """Aggregates data (hourly to daily values) according to the characteristics of each variable (e.g., average for temperature, sum for precipitation) Args: df: dataframe including time series with one hour time steps Returns: dataframe (daily) """ df_...
def daily_from_hourly(df): """Aggregates data (hourly to daily values) according to the characteristics of each variable (e.g., average for temperature, sum for precipitation) Args: df: dataframe including time series with one hour time steps Returns: dataframe (daily) """ df_...
[ "Aggregates", "data", "(", "hourly", "to", "daily", "values", ")", "according", "to", "the", "characteristics", "of", "each", "variable", "(", "e", ".", "g", ".", "average", "for", "temperature", "sum", "for", "precipitation", ")" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/util/util.py#L340-L380
[ "def", "daily_from_hourly", "(", "df", ")", ":", "df_daily", "=", "pd", ".", "DataFrame", "(", ")", "if", "'temp'", "in", "df", ":", "df_daily", "[", "'temp'", "]", "=", "df", ".", "temp", ".", "resample", "(", "'D'", ")", ".", "mean", "(", ")", ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
disagg_prec
The disaggregation function for precipitation. Parameters ---------- dailyData : pd.Series daily data method : str method to disaggregate cascade_options : cascade object including statistical parameters for the cascade model hourly_data_obs : pd.Series observed ...
melodist/precipitation.py
def disagg_prec(dailyData, method='equal', cascade_options=None, hourly_data_obs=None, zerodiv="uniform", shift=0): """The disaggregation function for precipitation. Parameters ---------- dailyData : pd.Series daily...
def disagg_prec(dailyData, method='equal', cascade_options=None, hourly_data_obs=None, zerodiv="uniform", shift=0): """The disaggregation function for precipitation. Parameters ---------- dailyData : pd.Series daily...
[ "The", "disaggregation", "function", "for", "precipitation", "." ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/precipitation.py#L45-L87
[ "def", "disagg_prec", "(", "dailyData", ",", "method", "=", "'equal'", ",", "cascade_options", "=", "None", ",", "hourly_data_obs", "=", "None", ",", "zerodiv", "=", "\"uniform\"", ",", "shift", "=", "0", ")", ":", "if", "method", "not", "in", "(", "'equ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
disagg_prec_cascade
Precipitation disaggregation with cascade model (Olsson, 1998) Parameters ---------- precip_daily : pd.Series daily data hourly: Boolean (for an hourly resolution disaggregation) if False, then returns 5-min disaggregated precipitation (disaggregation level depending on the "le...
melodist/precipitation.py
def disagg_prec_cascade(precip_daily, cascade_options, hourly=True,level=9, shift=0, test=False): """Precipitation disaggregation with cascade model (Olsson, 1998) Parameters ---------- precip_daily : pd.Series daily data ...
def disagg_prec_cascade(precip_daily, cascade_options, hourly=True,level=9, shift=0, test=False): """Precipitation disaggregation with cascade model (Olsson, 1998) Parameters ---------- precip_daily : pd.Series daily data ...
[ "Precipitation", "disaggregation", "with", "cascade", "model", "(", "Olsson", "1998", ")" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/precipitation.py#L90-L357
[ "def", "disagg_prec_cascade", "(", "precip_daily", ",", "cascade_options", ",", "hourly", "=", "True", ",", "level", "=", "9", ",", "shift", "=", "0", ",", "test", "=", "False", ")", ":", "if", "len", "(", "precip_daily", ")", "<", "2", ":", "raise", ...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
precip_master_station
Disaggregate precipitation based on the patterns of a master station Parameters ----------- precip_daily : pd.Series daily data master_precip_hourly : pd.Series observed hourly data of the master station zerodiv : str method to deal with zero division by key "uniform" --> u...
melodist/precipitation.py
def precip_master_station(precip_daily, master_precip_hourly, zerodiv): """Disaggregate precipitation based on the patterns of a master station Parameters ----------- precip_daily : pd.Series daily data master_precip_hourly : pd.Series ...
def precip_master_station(precip_daily, master_precip_hourly, zerodiv): """Disaggregate precipitation based on the patterns of a master station Parameters ----------- precip_daily : pd.Series daily data master_precip_hourly : pd.Series ...
[ "Disaggregate", "precipitation", "based", "on", "the", "patterns", "of", "a", "master", "station" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/precipitation.py#L359-L400
[ "def", "precip_master_station", "(", "precip_daily", ",", "master_precip_hourly", ",", "zerodiv", ")", ":", "precip_hourly", "=", "pd", ".", "Series", "(", "index", "=", "melodist", ".", "util", ".", "hourly_index", "(", "precip_daily", ".", "index", ")", ")",...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
aggregate_precipitation
Aggregates highly resolved precipitation data and creates statistics Parameters ---------- vec_data : pd.Series hourly (hourly=True) OR 5-min values Returns ------- output : cascade object representing statistics of the cascade model
melodist/precipitation.py
def aggregate_precipitation(vec_data,hourly=True, percentile=50): """Aggregates highly resolved precipitation data and creates statistics Parameters ---------- vec_data : pd.Series hourly (hourly=True) OR 5-min values Returns ------- output : cascade object representing st...
def aggregate_precipitation(vec_data,hourly=True, percentile=50): """Aggregates highly resolved precipitation data and creates statistics Parameters ---------- vec_data : pd.Series hourly (hourly=True) OR 5-min values Returns ------- output : cascade object representing st...
[ "Aggregates", "highly", "resolved", "precipitation", "data", "and", "creates", "statistics" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/precipitation.py#L403-L586
[ "def", "aggregate_precipitation", "(", "vec_data", ",", "hourly", "=", "True", ",", "percentile", "=", "50", ")", ":", "cascade_opt", "=", "cascade", ".", "CascadeStatistics", "(", ")", "cascade_opt", ".", "percentile", "=", "percentile", "# length of input time s...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
seasonal_subset
Get the seasonal data. Parameters ---------- dataframe : pd.DataFrame months: int, str Months to use for statistics, or 'all' for 1-12 (default='all')
melodist/precipitation.py
def seasonal_subset(dataframe, months='all'): '''Get the seasonal data. Parameters ---------- dataframe : pd.DataFrame months: int, str Months to use for statistics, or 'all' for 1-12 (default='all') ''' if isinstance(months, str) and months == 'all': mo...
def seasonal_subset(dataframe, months='all'): '''Get the seasonal data. Parameters ---------- dataframe : pd.DataFrame months: int, str Months to use for statistics, or 'all' for 1-12 (default='all') ''' if isinstance(months, str) and months == 'all': mo...
[ "Get", "the", "seasonal", "data", "." ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/precipitation.py#L589-L611
[ "def", "seasonal_subset", "(", "dataframe", ",", "months", "=", "'all'", ")", ":", "if", "isinstance", "(", "months", ",", "str", ")", "and", "months", "==", "'all'", ":", "months", "=", "np", ".", "arange", "(", "12", ")", "+", "1", "for", "month_nu...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
build_casc
Builds the cascade statistics of observed data for disaggregation Parameters ----------- ObsData : pd.Series hourly=True -> hourly obs data else -> 5min data (disaggregation level=9 (default), 10, 11) months : numpy array of ints Months for each seasons to be used for stati...
melodist/precipitation.py
def build_casc(ObsData, hourly=True,level=9, months=None, avg_stats=True, percentile=50): '''Builds the cascade statistics of observed data for disaggregation Parameters ----------- ObsData : pd.Series hourly=True -> hourly obs data else -> 5...
def build_casc(ObsData, hourly=True,level=9, months=None, avg_stats=True, percentile=50): '''Builds the cascade statistics of observed data for disaggregation Parameters ----------- ObsData : pd.Series hourly=True -> hourly obs data else -> 5...
[ "Builds", "the", "cascade", "statistics", "of", "observed", "data", "for", "disaggregation" ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/precipitation.py#L614-L690
[ "def", "build_casc", "(", "ObsData", ",", "hourly", "=", "True", ",", "level", "=", "9", ",", "months", "=", "None", ",", "avg_stats", "=", "True", ",", "percentile", "=", "50", ")", ":", "list_seasonal_casc", "=", "list", "(", ")", "if", "months", "...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
CascadeStatistics.fill_with_sample_data
This function fills the corresponding object with sample data.
melodist/cascade.py
def fill_with_sample_data(self): """This function fills the corresponding object with sample data.""" # replace these sample data with another dataset later # this function is deprecated as soon as a common file format for this # type of data will be available self.p01 = np.array...
def fill_with_sample_data(self): """This function fills the corresponding object with sample data.""" # replace these sample data with another dataset later # this function is deprecated as soon as a common file format for this # type of data will be available self.p01 = np.array...
[ "This", "function", "fills", "the", "corresponding", "object", "with", "sample", "data", "." ]
kristianfoerster/melodist
python
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/cascade.py#L54-L81
[ "def", "fill_with_sample_data", "(", "self", ")", ":", "# replace these sample data with another dataset later", "# this function is deprecated as soon as a common file format for this", "# type of data will be available", "self", ".", "p01", "=", "np", ".", "array", "(", "[", "[...
ddc155c77b65f791be0021dbbaf68c6bac42ecbd
train
Emoji.names
A list of all emoji names without file extension.
emoji/models.py
def names(cls): """A list of all emoji names without file extension.""" if not cls._files: for f in os.listdir(cls._image_path): if(not f.startswith('.') and os.path.isfile(os.path.join(cls._image_path, f))): cls._files.append(os.path.sp...
def names(cls): """A list of all emoji names without file extension.""" if not cls._files: for f in os.listdir(cls._image_path): if(not f.startswith('.') and os.path.isfile(os.path.join(cls._image_path, f))): cls._files.append(os.path.sp...
[ "A", "list", "of", "all", "emoji", "names", "without", "file", "extension", "." ]
gaqzi/django-emoji
python
https://github.com/gaqzi/django-emoji/blob/08625d14f5b4251f4784bb5abf2620cb46bbdcab/emoji/models.py#L114-L122
[ "def", "names", "(", "cls", ")", ":", "if", "not", "cls", ".", "_files", ":", "for", "f", "in", "os", ".", "listdir", "(", "cls", ".", "_image_path", ")", ":", "if", "(", "not", "f", ".", "startswith", "(", "'.'", ")", "and", "os", ".", "path",...
08625d14f5b4251f4784bb5abf2620cb46bbdcab
train
Emoji.replace
Add in valid emojis in a string where a valid emoji is between ::
emoji/models.py
def replace(cls, replacement_string): """Add in valid emojis in a string where a valid emoji is between ::""" e = cls() def _replace_emoji(match): val = match.group(1) if val in e: return e._image_string(match.group(1)) else: r...
def replace(cls, replacement_string): """Add in valid emojis in a string where a valid emoji is between ::""" e = cls() def _replace_emoji(match): val = match.group(1) if val in e: return e._image_string(match.group(1)) else: r...
[ "Add", "in", "valid", "emojis", "in", "a", "string", "where", "a", "valid", "emoji", "is", "between", "::" ]
gaqzi/django-emoji
python
https://github.com/gaqzi/django-emoji/blob/08625d14f5b4251f4784bb5abf2620cb46bbdcab/emoji/models.py#L125-L136
[ "def", "replace", "(", "cls", ",", "replacement_string", ")", ":", "e", "=", "cls", "(", ")", "def", "_replace_emoji", "(", "match", ")", ":", "val", "=", "match", ".", "group", "(", "1", ")", "if", "val", "in", "e", ":", "return", "e", ".", "_im...
08625d14f5b4251f4784bb5abf2620cb46bbdcab
train
Emoji.replace_unicode
This method will iterate over every character in ``replacement_string`` and see if it mathces any of the unicode codepoints that we recognize. If it does then it will replace that codepoint with an image just like ``replace``. NOTE: This will only work with Python versions built with wi...
emoji/models.py
def replace_unicode(cls, replacement_string): """This method will iterate over every character in ``replacement_string`` and see if it mathces any of the unicode codepoints that we recognize. If it does then it will replace that codepoint with an image just like ``replace``. NOT...
def replace_unicode(cls, replacement_string): """This method will iterate over every character in ``replacement_string`` and see if it mathces any of the unicode codepoints that we recognize. If it does then it will replace that codepoint with an image just like ``replace``. NOT...
[ "This", "method", "will", "iterate", "over", "every", "character", "in", "replacement_string", "and", "see", "if", "it", "mathces", "any", "of", "the", "unicode", "codepoints", "that", "we", "recognize", ".", "If", "it", "does", "then", "it", "will", "replac...
gaqzi/django-emoji
python
https://github.com/gaqzi/django-emoji/blob/08625d14f5b4251f4784bb5abf2620cb46bbdcab/emoji/models.py#L139-L188
[ "def", "replace_unicode", "(", "cls", ",", "replacement_string", ")", ":", "e", "=", "cls", "(", ")", "output", "=", "[", "]", "surrogate_character", "=", "None", "if", "settings", ".", "EMOJI_REPLACE_HTML_ENTITIES", ":", "replacement_string", "=", "cls", ".",...
08625d14f5b4251f4784bb5abf2620cb46bbdcab
train
Emoji.replace_html_entities
Replaces HTML escaped unicode entities with their unicode equivalent. If the setting `EMOJI_REPLACE_HTML_ENTITIES` is `True` then this conversation will always be done in `replace_unicode` (default: True).
emoji/models.py
def replace_html_entities(cls, replacement_string): """Replaces HTML escaped unicode entities with their unicode equivalent. If the setting `EMOJI_REPLACE_HTML_ENTITIES` is `True` then this conversation will always be done in `replace_unicode` (default: True). """ def _h...
def replace_html_entities(cls, replacement_string): """Replaces HTML escaped unicode entities with their unicode equivalent. If the setting `EMOJI_REPLACE_HTML_ENTITIES` is `True` then this conversation will always be done in `replace_unicode` (default: True). """ def _h...
[ "Replaces", "HTML", "escaped", "unicode", "entities", "with", "their", "unicode", "equivalent", ".", "If", "the", "setting", "EMOJI_REPLACE_HTML_ENTITIES", "is", "True", "then", "this", "conversation", "will", "always", "be", "done", "in", "replace_unicode", "(", ...
gaqzi/django-emoji
python
https://github.com/gaqzi/django-emoji/blob/08625d14f5b4251f4784bb5abf2620cb46bbdcab/emoji/models.py#L198-L234
[ "def", "replace_html_entities", "(", "cls", ",", "replacement_string", ")", ":", "def", "_hex_to_unicode", "(", "hex_code", ")", ":", "if", "PYTHON3", ":", "hex_code", "=", "'{0:0>8}'", ".", "format", "(", "hex_code", ")", "as_int", "=", "struct", ".", "unpa...
08625d14f5b4251f4784bb5abf2620cb46bbdcab
train
_convert_to_unicode
This method should work with both Python 2 and 3 with the caveat that they need to be compiled with wide unicode character support. If there isn't wide unicode character support it'll blow up with a warning.
bin/generate-unicode-aliases.py
def _convert_to_unicode(string): """This method should work with both Python 2 and 3 with the caveat that they need to be compiled with wide unicode character support. If there isn't wide unicode character support it'll blow up with a warning. """ codepoints = [] for character in string.sp...
def _convert_to_unicode(string): """This method should work with both Python 2 and 3 with the caveat that they need to be compiled with wide unicode character support. If there isn't wide unicode character support it'll blow up with a warning. """ codepoints = [] for character in string.sp...
[ "This", "method", "should", "work", "with", "both", "Python", "2", "and", "3", "with", "the", "caveat", "that", "they", "need", "to", "be", "compiled", "with", "wide", "unicode", "character", "support", "." ]
gaqzi/django-emoji
python
https://github.com/gaqzi/django-emoji/blob/08625d14f5b4251f4784bb5abf2620cb46bbdcab/bin/generate-unicode-aliases.py#L32-L49
[ "def", "_convert_to_unicode", "(", "string", ")", ":", "codepoints", "=", "[", "]", "for", "character", "in", "string", ".", "split", "(", "'-'", ")", ":", "if", "character", "in", "BLACKLIST_UNICODE", ":", "next", "codepoints", ".", "append", "(", "'\\U{0...
08625d14f5b4251f4784bb5abf2620cb46bbdcab
train
_delete_file
remove file and remove it's directories if empty
bobtemplates/odoo/hooks.py
def _delete_file(configurator, path): """ remove file and remove it's directories if empty """ path = os.path.join(configurator.target_directory, path) os.remove(path) try: os.removedirs(os.path.dirname(path)) except OSError: pass
def _delete_file(configurator, path): """ remove file and remove it's directories if empty """ path = os.path.join(configurator.target_directory, path) os.remove(path) try: os.removedirs(os.path.dirname(path)) except OSError: pass
[ "remove", "file", "and", "remove", "it", "s", "directories", "if", "empty" ]
acsone/bobtemplates.odoo
python
https://github.com/acsone/bobtemplates.odoo/blob/6e8c3cb12747d8b5af5a9821f995f285251e4d4d/bobtemplates/odoo/hooks.py#L34-L41
[ "def", "_delete_file", "(", "configurator", ",", "path", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "configurator", ".", "target_directory", ",", "path", ")", "os", ".", "remove", "(", "path", ")", "try", ":", "os", ".", "removedirs", ...
6e8c3cb12747d8b5af5a9821f995f285251e4d4d
train
_insert_manifest_item
Insert an item in the list of an existing manifest key
bobtemplates/odoo/hooks.py
def _insert_manifest_item(configurator, key, item): """ Insert an item in the list of an existing manifest key """ with _open_manifest(configurator) as f: manifest = f.read() if item in ast.literal_eval(manifest).get(key, []): return pattern = """(["']{}["']:\\s*\\[)""".format(key) r...
def _insert_manifest_item(configurator, key, item): """ Insert an item in the list of an existing manifest key """ with _open_manifest(configurator) as f: manifest = f.read() if item in ast.literal_eval(manifest).get(key, []): return pattern = """(["']{}["']:\\s*\\[)""".format(key) r...
[ "Insert", "an", "item", "in", "the", "list", "of", "an", "existing", "manifest", "key" ]
acsone/bobtemplates.odoo
python
https://github.com/acsone/bobtemplates.odoo/blob/6e8c3cb12747d8b5af5a9821f995f285251e4d4d/bobtemplates/odoo/hooks.py#L58-L68
[ "def", "_insert_manifest_item", "(", "configurator", ",", "key", ",", "item", ")", ":", "with", "_open_manifest", "(", "configurator", ")", "as", "f", ":", "manifest", "=", "f", ".", "read", "(", ")", "if", "item", "in", "ast", ".", "literal_eval", "(", ...
6e8c3cb12747d8b5af5a9821f995f285251e4d4d
train
_read_requirements
Parses a file for pip installation requirements.
setup.py
def _read_requirements(filename): """Parses a file for pip installation requirements.""" with open(filename) as requirements_file: contents = requirements_file.read() return [line.strip() for line in contents.splitlines() if _is_requirement(line)]
def _read_requirements(filename): """Parses a file for pip installation requirements.""" with open(filename) as requirements_file: contents = requirements_file.read() return [line.strip() for line in contents.splitlines() if _is_requirement(line)]
[ "Parses", "a", "file", "for", "pip", "installation", "requirements", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/setup.py#L17-L21
[ "def", "_read_requirements", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "requirements_file", ":", "contents", "=", "requirements_file", ".", "read", "(", ")", "return", "[", "line", ".", "strip", "(", ")", "for", "line", "in", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
assign_perm
Assigns a permission to a group
smartmin/perms.py
def assign_perm(perm, group): """ Assigns a permission to a group """ if not isinstance(perm, Permission): try: app_label, codename = perm.split('.', 1) except ValueError: raise ValueError("For global permissions, first argument must be in" ...
def assign_perm(perm, group): """ Assigns a permission to a group """ if not isinstance(perm, Permission): try: app_label, codename = perm.split('.', 1) except ValueError: raise ValueError("For global permissions, first argument must be in" ...
[ "Assigns", "a", "permission", "to", "a", "group" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/perms.py#L4-L17
[ "def", "assign_perm", "(", "perm", ",", "group", ")", ":", "if", "not", "isinstance", "(", "perm", ",", "Permission", ")", ":", "try", ":", "app_label", ",", "codename", "=", "perm", ".", "split", "(", "'.'", ",", "1", ")", "except", "ValueError", ":...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
remove_perm
Removes a permission from a group
smartmin/perms.py
def remove_perm(perm, group): """ Removes a permission from a group """ if not isinstance(perm, Permission): try: app_label, codename = perm.split('.', 1) except ValueError: raise ValueError("For global permissions, first argument must be in" ...
def remove_perm(perm, group): """ Removes a permission from a group """ if not isinstance(perm, Permission): try: app_label, codename = perm.split('.', 1) except ValueError: raise ValueError("For global permissions, first argument must be in" ...
[ "Removes", "a", "permission", "from", "a", "group" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/perms.py#L20-L33
[ "def", "remove_perm", "(", "perm", ",", "group", ")", ":", "if", "not", "isinstance", "(", "perm", ",", "Permission", ")", ":", "try", ":", "app_label", ",", "codename", "=", "perm", ".", "split", "(", "'.'", ",", "1", ")", "except", "ValueError", ":...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
get_list_class
Returns the class to use for the passed in list. We just build something up from the object type for the list.
smartmin/templatetags/smartmin.py
def get_list_class(context, list): """ Returns the class to use for the passed in list. We just build something up from the object type for the list. """ return "list_%s_%s" % (list.model._meta.app_label, list.model._meta.model_name)
def get_list_class(context, list): """ Returns the class to use for the passed in list. We just build something up from the object type for the list. """ return "list_%s_%s" % (list.model._meta.app_label, list.model._meta.model_name)
[ "Returns", "the", "class", "to", "use", "for", "the", "passed", "in", "list", ".", "We", "just", "build", "something", "up", "from", "the", "object", "type", "for", "the", "list", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/templatetags/smartmin.py#L24-L29
[ "def", "get_list_class", "(", "context", ",", "list", ")", ":", "return", "\"list_%s_%s\"", "%", "(", "list", ".", "model", ".", "_meta", ".", "app_label", ",", "list", ".", "model", ".", "_meta", ".", "model_name", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
format_datetime
Formats a date, converting the time to the user timezone if one is specified
smartmin/templatetags/smartmin.py
def format_datetime(time): """ Formats a date, converting the time to the user timezone if one is specified """ user_time_zone = timezone.get_current_timezone() if time.tzinfo is None: time = time.replace(tzinfo=pytz.utc) user_time_zone = pytz.timezone(getattr(settings, 'USER_TIME_ZO...
def format_datetime(time): """ Formats a date, converting the time to the user timezone if one is specified """ user_time_zone = timezone.get_current_timezone() if time.tzinfo is None: time = time.replace(tzinfo=pytz.utc) user_time_zone = pytz.timezone(getattr(settings, 'USER_TIME_ZO...
[ "Formats", "a", "date", "converting", "the", "time", "to", "the", "user", "timezone", "if", "one", "is", "specified" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/templatetags/smartmin.py#L32-L42
[ "def", "format_datetime", "(", "time", ")", ":", "user_time_zone", "=", "timezone", ".", "get_current_timezone", "(", ")", "if", "time", ".", "tzinfo", "is", "None", ":", "time", "=", "time", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
get_value_from_view
Responsible for deriving the displayed value for the passed in 'field'. This first checks for a particular method on the ListView, then looks for a method on the object, then finally treats it as an attribute.
smartmin/templatetags/smartmin.py
def get_value_from_view(context, field): """ Responsible for deriving the displayed value for the passed in 'field'. This first checks for a particular method on the ListView, then looks for a method on the object, then finally treats it as an attribute. """ view = context['view'] obj = Non...
def get_value_from_view(context, field): """ Responsible for deriving the displayed value for the passed in 'field'. This first checks for a particular method on the ListView, then looks for a method on the object, then finally treats it as an attribute. """ view = context['view'] obj = Non...
[ "Responsible", "for", "deriving", "the", "displayed", "value", "for", "the", "passed", "in", "field", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/templatetags/smartmin.py#L46-L64
[ "def", "get_value_from_view", "(", "context", ",", "field", ")", ":", "view", "=", "context", "[", "'view'", "]", "obj", "=", "None", "if", "'object'", "in", "context", ":", "obj", "=", "context", "[", "'object'", "]", "value", "=", "view", ".", "looku...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
get_class
Looks up the class for this field
smartmin/templatetags/smartmin.py
def get_class(context, field, obj=None): """ Looks up the class for this field """ view = context['view'] return view.lookup_field_class(field, obj, "field_" + field)
def get_class(context, field, obj=None): """ Looks up the class for this field """ view = context['view'] return view.lookup_field_class(field, obj, "field_" + field)
[ "Looks", "up", "the", "class", "for", "this", "field" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/templatetags/smartmin.py#L84-L89
[ "def", "get_class", "(", "context", ",", "field", ",", "obj", "=", "None", ")", ":", "view", "=", "context", "[", "'view'", "]", "return", "view", ".", "lookup_field_class", "(", "field", ",", "obj", ",", "\"field_\"", "+", "field", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
get_label
Responsible for figuring out the right label for the passed in field. The order of precedence is: 1) if the view has a field_config and a label specified there, use that label 2) check for a form in the view, if it contains that field, use it's value
smartmin/templatetags/smartmin.py
def get_label(context, field, obj=None): """ Responsible for figuring out the right label for the passed in field. The order of precedence is: 1) if the view has a field_config and a label specified there, use that label 2) check for a form in the view, if it contains that field, use it's val...
def get_label(context, field, obj=None): """ Responsible for figuring out the right label for the passed in field. The order of precedence is: 1) if the view has a field_config and a label specified there, use that label 2) check for a form in the view, if it contains that field, use it's val...
[ "Responsible", "for", "figuring", "out", "the", "right", "label", "for", "the", "passed", "in", "field", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/templatetags/smartmin.py#L93-L102
[ "def", "get_label", "(", "context", ",", "field", ",", "obj", "=", "None", ")", ":", "view", "=", "context", "[", "'view'", "]", "return", "view", ".", "lookup_field_label", "(", "context", ",", "field", ",", "obj", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
get_field_link
Determine what the field link should be for the given field, object pair
smartmin/templatetags/smartmin.py
def get_field_link(context, field, obj=None): """ Determine what the field link should be for the given field, object pair """ view = context['view'] return view.lookup_field_link(context, field, obj)
def get_field_link(context, field, obj=None): """ Determine what the field link should be for the given field, object pair """ view = context['view'] return view.lookup_field_link(context, field, obj)
[ "Determine", "what", "the", "field", "link", "should", "be", "for", "the", "given", "field", "object", "pair" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/templatetags/smartmin.py#L106-L111
[ "def", "get_field_link", "(", "context", ",", "field", ",", "obj", "=", "None", ")", ":", "view", "=", "context", "[", "'view'", "]", "return", "view", ".", "lookup_field_link", "(", "context", ",", "field", ",", "obj", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
get_permissions_app_name
Gets the app after which smartmin permissions should be installed. This can be specified by PERMISSIONS_APP in the Django settings or defaults to the last app with models
smartmin/management/__init__.py
def get_permissions_app_name(): """ Gets the app after which smartmin permissions should be installed. This can be specified by PERMISSIONS_APP in the Django settings or defaults to the last app with models """ global permissions_app_name if not permissions_app_name: permissions_app_nam...
def get_permissions_app_name(): """ Gets the app after which smartmin permissions should be installed. This can be specified by PERMISSIONS_APP in the Django settings or defaults to the last app with models """ global permissions_app_name if not permissions_app_name: permissions_app_nam...
[ "Gets", "the", "app", "after", "which", "smartmin", "permissions", "should", "be", "installed", ".", "This", "can", "be", "specified", "by", "PERMISSIONS_APP", "in", "the", "Django", "settings", "or", "defaults", "to", "the", "last", "app", "with", "models" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/__init__.py#L15-L30
[ "def", "get_permissions_app_name", "(", ")", ":", "global", "permissions_app_name", "if", "not", "permissions_app_name", ":", "permissions_app_name", "=", "getattr", "(", "settings", ",", "'PERMISSIONS_APP'", ",", "None", ")", "if", "not", "permissions_app_name", ":",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
check_role_permissions
Checks the the passed in role (can be user, group or AnonymousUser) has all the passed in permissions, granting them if necessary.
smartmin/management/__init__.py
def check_role_permissions(role, permissions, current_permissions): """ Checks the the passed in role (can be user, group or AnonymousUser) has all the passed in permissions, granting them if necessary. """ role_permissions = [] # get all the current permissions, we'll remove these as we verif...
def check_role_permissions(role, permissions, current_permissions): """ Checks the the passed in role (can be user, group or AnonymousUser) has all the passed in permissions, granting them if necessary. """ role_permissions = [] # get all the current permissions, we'll remove these as we verif...
[ "Checks", "the", "the", "passed", "in", "role", "(", "can", "be", "user", "group", "or", "AnonymousUser", ")", "has", "all", "the", "passed", "in", "permissions", "granting", "them", "if", "necessary", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/__init__.py#L40-L95
[ "def", "check_role_permissions", "(", "role", ",", "permissions", ",", "current_permissions", ")", ":", "role_permissions", "=", "[", "]", "# get all the current permissions, we'll remove these as we verify they should still be granted", "for", "permission", "in", "permissions", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
check_all_group_permissions
Checks that all the permissions specified in our settings.py are set for our groups.
smartmin/management/__init__.py
def check_all_group_permissions(sender, **kwargs): """ Checks that all the permissions specified in our settings.py are set for our groups. """ if not is_permissions_app(sender): return config = getattr(settings, 'GROUP_PERMISSIONS', dict()) # for each of our items for name, permis...
def check_all_group_permissions(sender, **kwargs): """ Checks that all the permissions specified in our settings.py are set for our groups. """ if not is_permissions_app(sender): return config = getattr(settings, 'GROUP_PERMISSIONS', dict()) # for each of our items for name, permis...
[ "Checks", "that", "all", "the", "permissions", "specified", "in", "our", "settings", ".", "py", "are", "set", "for", "our", "groups", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/__init__.py#L98-L114
[ "def", "check_all_group_permissions", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "if", "not", "is_permissions_app", "(", "sender", ")", ":", "return", "config", "=", "getattr", "(", "settings", ",", "'GROUP_PERMISSIONS'", ",", "dict", "(", ")", ")", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
add_permission
Adds the passed in permission to that content type. Note that the permission passed in should be a single word, or verb. The proper 'codename' will be generated from that.
smartmin/management/__init__.py
def add_permission(content_type, permission): """ Adds the passed in permission to that content type. Note that the permission passed in should be a single word, or verb. The proper 'codename' will be generated from that. """ # build our permission slug codename = "%s_%s" % (content_type.model...
def add_permission(content_type, permission): """ Adds the passed in permission to that content type. Note that the permission passed in should be a single word, or verb. The proper 'codename' will be generated from that. """ # build our permission slug codename = "%s_%s" % (content_type.model...
[ "Adds", "the", "passed", "in", "permission", "to", "that", "content", "type", ".", "Note", "that", "the", "permission", "passed", "in", "should", "be", "a", "single", "word", "or", "verb", ".", "The", "proper", "codename", "will", "be", "generated", "from"...
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/__init__.py#L117-L131
[ "def", "add_permission", "(", "content_type", ",", "permission", ")", ":", "# build our permission slug", "codename", "=", "\"%s_%s\"", "%", "(", "content_type", ".", "model", ",", "permission", ")", "# sys.stderr.write(\"Checking %s permission for %s\\n\" % (permission, cont...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
check_all_permissions
This syncdb checks our PERMISSIONS setting in settings.py and makes sure all those permissions actually exit.
smartmin/management/__init__.py
def check_all_permissions(sender, **kwargs): """ This syncdb checks our PERMISSIONS setting in settings.py and makes sure all those permissions actually exit. """ if not is_permissions_app(sender): return config = getattr(settings, 'PERMISSIONS', dict()) # for each of our items ...
def check_all_permissions(sender, **kwargs): """ This syncdb checks our PERMISSIONS setting in settings.py and makes sure all those permissions actually exit. """ if not is_permissions_app(sender): return config = getattr(settings, 'PERMISSIONS', dict()) # for each of our items ...
[ "This", "syncdb", "checks", "our", "PERMISSIONS", "setting", "in", "settings", ".", "py", "and", "makes", "sure", "all", "those", "permissions", "actually", "exit", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/__init__.py#L135-L164
[ "def", "check_all_permissions", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "if", "not", "is_permissions_app", "(", "sender", ")", ":", "return", "config", "=", "getattr", "(", "settings", ",", "'PERMISSIONS'", ",", "dict", "(", ")", ")", "# for each...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
UserForm.save
Overloaded so we can save any new password that is included.
smartmin/users/views.py
def save(self, commit=True): """ Overloaded so we can save any new password that is included. """ is_new_user = self.instance.pk is None user = super(UserForm, self).save(commit) # new users should be made active by default if is_new_user: user.is_ac...
def save(self, commit=True): """ Overloaded so we can save any new password that is included. """ is_new_user = self.instance.pk is None user = super(UserForm, self).save(commit) # new users should be made active by default if is_new_user: user.is_ac...
[ "Overloaded", "so", "we", "can", "save", "any", "new", "password", "that", "is", "included", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/users/views.py#L39-L58
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "is_new_user", "=", "self", ".", "instance", ".", "pk", "is", "None", "user", "=", "super", "(", "UserForm", ",", "self", ")", ".", "save", "(", "commit", ")", "# new users should be mad...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
smart_url
URLs that start with @ are reversed, using the passed in arguments. Otherwise a straight % substitution is applied.
smartmin/views.py
def smart_url(url, obj=None): """ URLs that start with @ are reversed, using the passed in arguments. Otherwise a straight % substitution is applied. """ if url.find("@") >= 0: (args, value) = url.split('@') if args: val = getattr(obj, args, None) return rev...
def smart_url(url, obj=None): """ URLs that start with @ are reversed, using the passed in arguments. Otherwise a straight % substitution is applied. """ if url.find("@") >= 0: (args, value) = url.split('@') if args: val = getattr(obj, args, None) return rev...
[ "URLs", "that", "start", "with", "@", "are", "reversed", "using", "the", "passed", "in", "arguments", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L31-L49
[ "def", "smart_url", "(", "url", ",", "obj", "=", "None", ")", ":", "if", "url", ".", "find", "(", "\"@\"", ")", ">=", "0", ":", "(", "args", ",", "value", ")", "=", "url", ".", "split", "(", "'@'", ")", "if", "args", ":", "val", "=", "getattr...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
derive_single_object_url_pattern
Utility function called by class methods for single object views
smartmin/views.py
def derive_single_object_url_pattern(slug_url_kwarg, path, action): """ Utility function called by class methods for single object views """ if slug_url_kwarg: return r'^%s/%s/(?P<%s>[^/]+)/$' % (path, action, slug_url_kwarg) else: return r'^%s/%s/(?P<pk>\d+)/$' % (path, action)
def derive_single_object_url_pattern(slug_url_kwarg, path, action): """ Utility function called by class methods for single object views """ if slug_url_kwarg: return r'^%s/%s/(?P<%s>[^/]+)/$' % (path, action, slug_url_kwarg) else: return r'^%s/%s/(?P<pk>\d+)/$' % (path, action)
[ "Utility", "function", "called", "by", "class", "methods", "for", "single", "object", "views" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L390-L397
[ "def", "derive_single_object_url_pattern", "(", "slug_url_kwarg", ",", "path", ",", "action", ")", ":", "if", "slug_url_kwarg", ":", "return", "r'^%s/%s/(?P<%s>[^/]+)/$'", "%", "(", "path", ",", "action", ",", "slug_url_kwarg", ")", "else", ":", "return", "r'^%s/%...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.has_permission
Figures out if the current user has permissions for this view.
smartmin/views.py
def has_permission(self, request, *args, **kwargs): """ Figures out if the current user has permissions for this view. """ self.kwargs = kwargs self.args = args self.request = request if not getattr(self, 'permission', None): return True else:...
def has_permission(self, request, *args, **kwargs): """ Figures out if the current user has permissions for this view. """ self.kwargs = kwargs self.args = args self.request = request if not getattr(self, 'permission', None): return True else:...
[ "Figures", "out", "if", "the", "current", "user", "has", "permissions", "for", "this", "view", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L88-L99
[ "def", "has_permission", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "kwargs", "=", "kwargs", "self", ".", "args", "=", "args", "self", ".", "request", "=", "request", "if", "not", "getattr", "(", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.dispatch
Overloaded to check permissions if appropriate
smartmin/views.py
def dispatch(self, request, *args, **kwargs): """ Overloaded to check permissions if appropriate """ def wrapper(request, *args, **kwargs): if not self.has_permission(request, *args, **kwargs): path = urlquote(request.get_full_path()) login_url...
def dispatch(self, request, *args, **kwargs): """ Overloaded to check permissions if appropriate """ def wrapper(request, *args, **kwargs): if not self.has_permission(request, *args, **kwargs): path = urlquote(request.get_full_path()) login_url...
[ "Overloaded", "to", "check", "permissions", "if", "appropriate" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L101-L118
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "has_permission", "(", "request", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.lookup_obj_attribute
Looks for a field's value from the passed in obj. Note that this will strip leading attributes to deal with subelements if possible
smartmin/views.py
def lookup_obj_attribute(self, obj, field): """ Looks for a field's value from the passed in obj. Note that this will strip leading attributes to deal with subelements if possible """ curr_field = field.encode('ascii', 'ignore').decode("utf-8") rest = None if fi...
def lookup_obj_attribute(self, obj, field): """ Looks for a field's value from the passed in obj. Note that this will strip leading attributes to deal with subelements if possible """ curr_field = field.encode('ascii', 'ignore').decode("utf-8") rest = None if fi...
[ "Looks", "for", "a", "field", "s", "value", "from", "the", "passed", "in", "obj", ".", "Note", "that", "this", "will", "strip", "leading", "attributes", "to", "deal", "with", "subelements", "if", "possible" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L130-L152
[ "def", "lookup_obj_attribute", "(", "self", ",", "obj", ",", "field", ")", ":", "curr_field", "=", "field", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ".", "decode", "(", "\"utf-8\"", ")", "rest", "=", "None", "if", "field", ".", "find", "(",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.lookup_field_value
Looks up the field value for the passed in object and field name. Note that this method is actually called from a template, but this provides a hook for subclasses to modify behavior if they wish to do so. This may be used for example to change the display value of a variable depending on ...
smartmin/views.py
def lookup_field_value(self, context, obj, field): """ Looks up the field value for the passed in object and field name. Note that this method is actually called from a template, but this provides a hook for subclasses to modify behavior if they wish to do so. This may be used ...
def lookup_field_value(self, context, obj, field): """ Looks up the field value for the passed in object and field name. Note that this method is actually called from a template, but this provides a hook for subclasses to modify behavior if they wish to do so. This may be used ...
[ "Looks", "up", "the", "field", "value", "for", "the", "passed", "in", "object", "and", "field", "name", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L154-L173
[ "def", "lookup_field_value", "(", "self", ",", "context", ",", "obj", ",", "field", ")", ":", "curr_field", "=", "field", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ".", "decode", "(", "\"utf-8\"", ")", "# if this isn't a subfield, check the view to se...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.lookup_field_label
Figures out what the field label should be for the passed in field name. Our heuristic is as follows: 1) we check to see if our field_config has a label specified 2) if not, then we derive a field value from the field name
smartmin/views.py
def lookup_field_label(self, context, field, default=None): """ Figures out what the field label should be for the passed in field name. Our heuristic is as follows: 1) we check to see if our field_config has a label specified 2) if not, then we derive a field value from...
def lookup_field_label(self, context, field, default=None): """ Figures out what the field label should be for the passed in field name. Our heuristic is as follows: 1) we check to see if our field_config has a label specified 2) if not, then we derive a field value from...
[ "Figures", "out", "what", "the", "field", "label", "should", "be", "for", "the", "passed", "in", "field", "name", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L175-L207
[ "def", "lookup_field_label", "(", "self", ",", "context", ",", "field", ",", "default", "=", "None", ")", ":", "# if this is a subfield, strip off everything but the last field name", "if", "field", ".", "find", "(", "'.'", ")", ">=", "0", ":", "return", "self", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.lookup_field_help
Looks up the help text for the passed in field.
smartmin/views.py
def lookup_field_help(self, field, default=None): """ Looks up the help text for the passed in field. """ help = None # is there a label specified for this field if field in self.field_config and 'help' in self.field_config[field]: help = self.field_config[fi...
def lookup_field_help(self, field, default=None): """ Looks up the help text for the passed in field. """ help = None # is there a label specified for this field if field in self.field_config and 'help' in self.field_config[field]: help = self.field_config[fi...
[ "Looks", "up", "the", "help", "text", "for", "the", "passed", "in", "field", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L209-L230
[ "def", "lookup_field_help", "(", "self", ",", "field", ",", "default", "=", "None", ")", ":", "help", "=", "None", "# is there a label specified for this field", "if", "field", "in", "self", ".", "field_config", "and", "'help'", "in", "self", ".", "field_config"...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.lookup_field_class
Looks up any additional class we should include when rendering this field
smartmin/views.py
def lookup_field_class(self, field, obj=None, default=None): """ Looks up any additional class we should include when rendering this field """ css = "" # is there a class specified for this field if field in self.field_config and 'class' in self.field_config[field]: ...
def lookup_field_class(self, field, obj=None, default=None): """ Looks up any additional class we should include when rendering this field """ css = "" # is there a class specified for this field if field in self.field_config and 'class' in self.field_config[field]: ...
[ "Looks", "up", "any", "additional", "class", "we", "should", "include", "when", "rendering", "this", "field" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L232-L246
[ "def", "lookup_field_class", "(", "self", ",", "field", ",", "obj", "=", "None", ",", "default", "=", "None", ")", ":", "css", "=", "\"\"", "# is there a class specified for this field", "if", "field", "in", "self", ".", "field_config", "and", "'class'", "in",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.get_template_names
Returns the name of the template to use to render this request. Smartmin provides default templates as fallbacks, so appends it's own templates names to the end of whatever list is built by the generic views. Subclasses can override this by setting a 'template_name' variable on the class.
smartmin/views.py
def get_template_names(self): """ Returns the name of the template to use to render this request. Smartmin provides default templates as fallbacks, so appends it's own templates names to the end of whatever list is built by the generic views. Subclasses can override this by set...
def get_template_names(self): """ Returns the name of the template to use to render this request. Smartmin provides default templates as fallbacks, so appends it's own templates names to the end of whatever list is built by the generic views. Subclasses can override this by set...
[ "Returns", "the", "name", "of", "the", "template", "to", "use", "to", "render", "this", "request", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L263-L281
[ "def", "get_template_names", "(", "self", ")", ":", "templates", "=", "[", "]", "if", "getattr", "(", "self", ",", "'template_name'", ",", "None", ")", ":", "templates", ".", "append", "(", "self", ".", "template_name", ")", "if", "getattr", "(", "self",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.derive_fields
Default implementation
smartmin/views.py
def derive_fields(self): """ Default implementation """ fields = [] if self.fields: fields.append(self.fields) return fields
def derive_fields(self): """ Default implementation """ fields = [] if self.fields: fields.append(self.fields) return fields
[ "Default", "implementation" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L283-L291
[ "def", "derive_fields", "(", "self", ")", ":", "fields", "=", "[", "]", "if", "self", ".", "fields", ":", "fields", ".", "append", "(", "self", ".", "fields", ")", "return", "fields" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.get_context_data
We supplement the normal context data by adding our fields and labels.
smartmin/views.py
def get_context_data(self, **kwargs): """ We supplement the normal context data by adding our fields and labels. """ context = super(SmartView, self).get_context_data(**kwargs) # derive our field config self.field_config = self.derive_field_config() # add our fi...
def get_context_data(self, **kwargs): """ We supplement the normal context data by adding our fields and labels. """ context = super(SmartView, self).get_context_data(**kwargs) # derive our field config self.field_config = self.derive_field_config() # add our fi...
[ "We", "supplement", "the", "normal", "context", "data", "by", "adding", "our", "fields", "and", "labels", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L309-L364
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "SmartView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "# derive our field config", "self", ".", "field_config", "=", "s...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartView.render_to_response
Overloaded to deal with _format arguments.
smartmin/views.py
def render_to_response(self, context, **response_kwargs): """ Overloaded to deal with _format arguments. """ # should we actually render in json? if '_format' in self.request.GET and self.request.GET['_format'] == 'json': return JsonResponse(self.as_json(context), saf...
def render_to_response(self, context, **response_kwargs): """ Overloaded to deal with _format arguments. """ # should we actually render in json? if '_format' in self.request.GET and self.request.GET['_format'] == 'json': return JsonResponse(self.as_json(context), saf...
[ "Overloaded", "to", "deal", "with", "_format", "arguments", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L373-L383
[ "def", "render_to_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "# should we actually render in json?", "if", "'_format'", "in", "self", ".", "request", ".", "GET", "and", "self", ".", "request", ".", "GET", "[", "'_format...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartReadView.derive_fields
Derives our fields. We first default to using our 'fields' variable if available, otherwise we figure it out from our object.
smartmin/views.py
def derive_fields(self): """ Derives our fields. We first default to using our 'fields' variable if available, otherwise we figure it out from our object. """ if self.fields: return list(self.fields) else: fields = [] for field in sel...
def derive_fields(self): """ Derives our fields. We first default to using our 'fields' variable if available, otherwise we figure it out from our object. """ if self.fields: return list(self.fields) else: fields = [] for field in sel...
[ "Derives", "our", "fields", ".", "We", "first", "default", "to", "using", "our", "fields", "variable", "if", "available", "otherwise", "we", "figure", "it", "out", "from", "our", "object", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L435-L454
[ "def", "derive_fields", "(", "self", ")", ":", "if", "self", ".", "fields", ":", "return", "list", "(", "self", ".", "fields", ")", "else", ":", "fields", "=", "[", "]", "for", "field", "in", "self", ".", "object", ".", "_meta", ".", "fields", ":",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartDeleteView.get_context_data
Add in the field to use for the name field
smartmin/views.py
def get_context_data(self, **kwargs): """ Add in the field to use for the name field """ context = super(SmartDeleteView, self).get_context_data(**kwargs) context['name_field'] = self.name_field context['cancel_url'] = self.get_cancel_url() return context
def get_context_data(self, **kwargs): """ Add in the field to use for the name field """ context = super(SmartDeleteView, self).get_context_data(**kwargs) context['name_field'] = self.name_field context['cancel_url'] = self.get_cancel_url() return context
[ "Add", "in", "the", "field", "to", "use", "for", "the", "name", "field" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L498-L503
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "SmartDeleteView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "context", "[", "'name_field'", "]", "=", "self", ".", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.derive_title
Derives our title from our list
smartmin/views.py
def derive_title(self): """ Derives our title from our list """ title = super(SmartListView, self).derive_title() if not title: return force_text(self.model._meta.verbose_name_plural).title() else: return title
def derive_title(self): """ Derives our title from our list """ title = super(SmartListView, self).derive_title() if not title: return force_text(self.model._meta.verbose_name_plural).title() else: return title
[ "Derives", "our", "title", "from", "our", "list" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L531-L540
[ "def", "derive_title", "(", "self", ")", ":", "title", "=", "super", "(", "SmartListView", ",", "self", ")", ".", "derive_title", "(", ")", "if", "not", "title", ":", "return", "force_text", "(", "self", ".", "model", ".", "_meta", ".", "verbose_name_plu...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.derive_link_fields
Used to derive which fields should be linked. This should return a set() containing the names of those fields which should be linkable.
smartmin/views.py
def derive_link_fields(self, context): """ Used to derive which fields should be linked. This should return a set() containing the names of those fields which should be linkable. """ if self.link_fields is not None: return self.link_fields else: ...
def derive_link_fields(self, context): """ Used to derive which fields should be linked. This should return a set() containing the names of those fields which should be linkable. """ if self.link_fields is not None: return self.link_fields else: ...
[ "Used", "to", "derive", "which", "fields", "should", "be", "linked", ".", "This", "should", "return", "a", "set", "()", "containing", "the", "names", "of", "those", "fields", "which", "should", "be", "linkable", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L542-L558
[ "def", "derive_link_fields", "(", "self", ",", "context", ")", ":", "if", "self", ".", "link_fields", "is", "not", "None", ":", "return", "self", ".", "link_fields", "else", ":", "link_fields", "=", "set", "(", ")", "if", "self", ".", "fields", ":", "f...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.lookup_field_orderable
Returns whether the passed in field is sortable or not, by default all 'raw' fields, that is fields that are part of the model are sortable.
smartmin/views.py
def lookup_field_orderable(self, field): """ Returns whether the passed in field is sortable or not, by default all 'raw' fields, that is fields that are part of the model are sortable. """ try: self.model._meta.get_field_by_name(field) return True ...
def lookup_field_orderable(self, field): """ Returns whether the passed in field is sortable or not, by default all 'raw' fields, that is fields that are part of the model are sortable. """ try: self.model._meta.get_field_by_name(field) return True ...
[ "Returns", "whether", "the", "passed", "in", "field", "is", "sortable", "or", "not", "by", "default", "all", "raw", "fields", "that", "is", "fields", "that", "are", "part", "of", "the", "model", "are", "sortable", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L566-L576
[ "def", "lookup_field_orderable", "(", "self", ",", "field", ")", ":", "try", ":", "self", ".", "model", ".", "_meta", ".", "get_field_by_name", "(", "field", ")", "return", "True", "except", "Exception", ":", "# that field doesn't exist, so not sortable", "return"...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.get_context_data
Add in what fields are linkable
smartmin/views.py
def get_context_data(self, **kwargs): """ Add in what fields are linkable """ context = super(SmartListView, self).get_context_data(**kwargs) # our linkable fields self.link_fields = self.derive_link_fields(context) # stuff it all in our context context[...
def get_context_data(self, **kwargs): """ Add in what fields are linkable """ context = super(SmartListView, self).get_context_data(**kwargs) # our linkable fields self.link_fields = self.derive_link_fields(context) # stuff it all in our context context[...
[ "Add", "in", "what", "fields", "are", "linkable" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L578-L604
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "SmartListView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "# our linkable fields", "self", ".", "link_fields", "=", "se...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.derive_queryset
Derives our queryset.
smartmin/views.py
def derive_queryset(self, **kwargs): """ Derives our queryset. """ # get our parent queryset queryset = super(SmartListView, self).get_queryset(**kwargs) # apply any filtering search_fields = self.derive_search_fields() search_query = self.request.GET.get...
def derive_queryset(self, **kwargs): """ Derives our queryset. """ # get our parent queryset queryset = super(SmartListView, self).get_queryset(**kwargs) # apply any filtering search_fields = self.derive_search_fields() search_query = self.request.GET.get...
[ "Derives", "our", "queryset", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L609-L635
[ "def", "derive_queryset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# get our parent queryset", "queryset", "=", "super", "(", "SmartListView", ",", "self", ")", ".", "get_queryset", "(", "*", "*", "kwargs", ")", "# apply any filtering", "search_fields", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.get_queryset
Gets our queryset. This takes care of filtering if there are any fields to filter by.
smartmin/views.py
def get_queryset(self, **kwargs): """ Gets our queryset. This takes care of filtering if there are any fields to filter by. """ queryset = self.derive_queryset(**kwargs) return self.order_queryset(queryset)
def get_queryset(self, **kwargs): """ Gets our queryset. This takes care of filtering if there are any fields to filter by. """ queryset = self.derive_queryset(**kwargs) return self.order_queryset(queryset)
[ "Gets", "our", "queryset", ".", "This", "takes", "care", "of", "filtering", "if", "there", "are", "any", "fields", "to", "filter", "by", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L637-L644
[ "def", "get_queryset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "self", ".", "derive_queryset", "(", "*", "*", "kwargs", ")", "return", "self", ".", "order_queryset", "(", "queryset", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.derive_ordering
Returns what field should be used for ordering (using a prepended '-' to indicate descending sort). If the default order of the queryset should be used, returns None
smartmin/views.py
def derive_ordering(self): """ Returns what field should be used for ordering (using a prepended '-' to indicate descending sort). If the default order of the queryset should be used, returns None """ if '_order' in self.request.GET: return self.request.GET['_order']...
def derive_ordering(self): """ Returns what field should be used for ordering (using a prepended '-' to indicate descending sort). If the default order of the queryset should be used, returns None """ if '_order' in self.request.GET: return self.request.GET['_order']...
[ "Returns", "what", "field", "should", "be", "used", "for", "ordering", "(", "using", "a", "prepended", "-", "to", "indicate", "descending", "sort", ")", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L646-L657
[ "def", "derive_ordering", "(", "self", ")", ":", "if", "'_order'", "in", "self", ".", "request", ".", "GET", ":", "return", "self", ".", "request", ".", "GET", "[", "'_order'", "]", "elif", "self", ".", "default_order", ":", "return", "self", ".", "def...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.order_queryset
Orders the passed in queryset, returning a new queryset in response. By default uses the _order query parameter.
smartmin/views.py
def order_queryset(self, queryset): """ Orders the passed in queryset, returning a new queryset in response. By default uses the _order query parameter. """ order = self.derive_ordering() # if we get our order from the request # make sure it is a valid field in ...
def order_queryset(self, queryset): """ Orders the passed in queryset, returning a new queryset in response. By default uses the _order query parameter. """ order = self.derive_ordering() # if we get our order from the request # make sure it is a valid field in ...
[ "Orders", "the", "passed", "in", "queryset", "returning", "a", "new", "queryset", "in", "response", ".", "By", "default", "uses", "the", "_order", "query", "parameter", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L659-L679
[ "def", "order_queryset", "(", "self", ",", "queryset", ")", ":", "order", "=", "self", ".", "derive_ordering", "(", ")", "# if we get our order from the request", "# make sure it is a valid field in the list", "if", "'_order'", "in", "self", ".", "request", ".", "GET"...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.derive_fields
Derives our fields.
smartmin/views.py
def derive_fields(self): """ Derives our fields. """ if self.fields: return self.fields else: fields = [] for field in self.object_list.model._meta.fields: if field.name != 'id': fields.append(field.name) ...
def derive_fields(self): """ Derives our fields. """ if self.fields: return self.fields else: fields = [] for field in self.object_list.model._meta.fields: if field.name != 'id': fields.append(field.name) ...
[ "Derives", "our", "fields", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L681-L693
[ "def", "derive_fields", "(", "self", ")", ":", "if", "self", ".", "fields", ":", "return", "self", ".", "fields", "else", ":", "fields", "=", "[", "]", "for", "field", "in", "self", ".", "object_list", ".", "model", ".", "_meta", ".", "fields", ":", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartListView.render_to_response
Overloaded to deal with _format arguments.
smartmin/views.py
def render_to_response(self, context, **response_kwargs): """ Overloaded to deal with _format arguments. """ # is this a select2 format response? if self.request.GET.get('_format', 'html') == 'select2': results = [] for obj in context['object_list']: ...
def render_to_response(self, context, **response_kwargs): """ Overloaded to deal with _format arguments. """ # is this a select2 format response? if self.request.GET.get('_format', 'html') == 'select2': results = [] for obj in context['object_list']: ...
[ "Overloaded", "to", "deal", "with", "_format", "arguments", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L707-L729
[ "def", "render_to_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "# is this a select2 format response?", "if", "self", ".", "request", ".", "GET", ".", "get", "(", "'_format'", ",", "'html'", ")", "==", "'select2'", ":", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.get_form
Returns an instance of the form to be used in this view.
smartmin/views.py
def get_form(self): """ Returns an instance of the form to be used in this view. """ self.form = super(SmartFormMixin, self).get_form() fields = list(self.derive_fields()) # apply our field filtering on our form class exclude = self.derive_exclude() excl...
def get_form(self): """ Returns an instance of the form to be used in this view. """ self.form = super(SmartFormMixin, self).get_form() fields = list(self.derive_fields()) # apply our field filtering on our form class exclude = self.derive_exclude() excl...
[ "Returns", "an", "instance", "of", "the", "form", "to", "be", "used", "in", "this", "view", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L825-L865
[ "def", "get_form", "(", "self", ")", ":", "self", ".", "form", "=", "super", "(", "SmartFormMixin", ",", "self", ")", ".", "get_form", "(", ")", "fields", "=", "list", "(", "self", ".", "derive_fields", "(", ")", ")", "# apply our field filtering on our fo...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.customize_form_field
Allows views to customize their form fields. By default, Smartmin replaces the plain textbox date input with it's own DatePicker implementation.
smartmin/views.py
def customize_form_field(self, name, field): """ Allows views to customize their form fields. By default, Smartmin replaces the plain textbox date input with it's own DatePicker implementation. """ if isinstance(field, forms.fields.DateField) and isinstance(field.widget, forms.w...
def customize_form_field(self, name, field): """ Allows views to customize their form fields. By default, Smartmin replaces the plain textbox date input with it's own DatePicker implementation. """ if isinstance(field, forms.fields.DateField) and isinstance(field.widget, forms.w...
[ "Allows", "views", "to", "customize", "their", "form", "fields", ".", "By", "default", "Smartmin", "replaces", "the", "plain", "textbox", "date", "input", "with", "it", "s", "own", "DatePicker", "implementation", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L867-L879
[ "def", "customize_form_field", "(", "self", ",", "name", ",", "field", ")", ":", "if", "isinstance", "(", "field", ",", "forms", ".", "fields", ".", "DateField", ")", "and", "isinstance", "(", "field", ".", "widget", ",", "forms", ".", "widgets", ".", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.lookup_field_label
Figures out what the field label should be for the passed in field name. We overload this so as to use our form to see if there is label set there. If so then we'll pass that as the default instead of having our parent derive the field from the name.
smartmin/views.py
def lookup_field_label(self, context, field, default=None): """ Figures out what the field label should be for the passed in field name. We overload this so as to use our form to see if there is label set there. If so then we'll pass that as the default instead of having our parent der...
def lookup_field_label(self, context, field, default=None): """ Figures out what the field label should be for the passed in field name. We overload this so as to use our form to see if there is label set there. If so then we'll pass that as the default instead of having our parent der...
[ "Figures", "out", "what", "the", "field", "label", "should", "be", "for", "the", "passed", "in", "field", "name", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L881-L896
[ "def", "lookup_field_label", "(", "self", ",", "context", ",", "field", ",", "default", "=", "None", ")", ":", "default", "=", "None", "for", "form_field", "in", "self", ".", "form", ":", "if", "form_field", ".", "name", "==", "field", ":", "default", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.lookup_field_help
Looks up the help text for the passed in field. This is overloaded so that we can check whether our form has help text set explicitely. If so, we will pass this as the default to our parent function.
smartmin/views.py
def lookup_field_help(self, field, default=None): """ Looks up the help text for the passed in field. This is overloaded so that we can check whether our form has help text set explicitely. If so, we will pass this as the default to our parent function. """ default = No...
def lookup_field_help(self, field, default=None): """ Looks up the help text for the passed in field. This is overloaded so that we can check whether our form has help text set explicitely. If so, we will pass this as the default to our parent function. """ default = No...
[ "Looks", "up", "the", "help", "text", "for", "the", "passed", "in", "field", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L898-L912
[ "def", "lookup_field_help", "(", "self", ",", "field", ",", "default", "=", "None", ")", ":", "default", "=", "None", "for", "form_field", "in", "self", ".", "form", ":", "if", "form_field", ".", "name", "==", "field", ":", "default", "=", "form_field", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.derive_readonly
Figures out what fields should be readonly. We iterate our field_config to find all that have a readonly of true
smartmin/views.py
def derive_readonly(self): """ Figures out what fields should be readonly. We iterate our field_config to find all that have a readonly of true """ readonly = list(self.readonly) for key, value in self.field_config.items(): if 'readonly' in value and value['r...
def derive_readonly(self): """ Figures out what fields should be readonly. We iterate our field_config to find all that have a readonly of true """ readonly = list(self.readonly) for key, value in self.field_config.items(): if 'readonly' in value and value['r...
[ "Figures", "out", "what", "fields", "should", "be", "readonly", ".", "We", "iterate", "our", "field_config", "to", "find", "all", "that", "have", "a", "readonly", "of", "true" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L914-L924
[ "def", "derive_readonly", "(", "self", ")", ":", "readonly", "=", "list", "(", "self", ".", "readonly", ")", "for", "key", ",", "value", "in", "self", ".", "field_config", ".", "items", "(", ")", ":", "if", "'readonly'", "in", "value", "and", "value", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.derive_fields
Derives our fields.
smartmin/views.py
def derive_fields(self): """ Derives our fields. """ if self.fields is not None: fields = list(self.fields) else: form = self.form fields = [] for field in form: fields.append(field.name) # this is sligh...
def derive_fields(self): """ Derives our fields. """ if self.fields is not None: fields = list(self.fields) else: form = self.form fields = [] for field in form: fields.append(field.name) # this is sligh...
[ "Derives", "our", "fields", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L926-L949
[ "def", "derive_fields", "(", "self", ")", ":", "if", "self", ".", "fields", "is", "not", "None", ":", "fields", "=", "list", "(", "self", ".", "fields", ")", "else", ":", "form", "=", "self", ".", "form", "fields", "=", "[", "]", "for", "field", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.get_form_class
Returns the form class to use in this view
smartmin/views.py
def get_form_class(self): """ Returns the form class to use in this view """ if self.form_class: form_class = self.form_class else: if self.model is not None: # If a model has been explicitly provided, use it model = self.m...
def get_form_class(self): """ Returns the form class to use in this view """ if self.form_class: form_class = self.form_class else: if self.model is not None: # If a model has been explicitly provided, use it model = self.m...
[ "Returns", "the", "form", "class", "to", "use", "in", "this", "view" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L951-L975
[ "def", "get_form_class", "(", "self", ")", ":", "if", "self", ".", "form_class", ":", "form_class", "=", "self", ".", "form_class", "else", ":", "if", "self", ".", "model", "is", "not", "None", ":", "# If a model has been explicitly provided, use it", "model", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.get_factory_kwargs
Let's us specify any extra parameters we might want to call for our form factory. These can include: 'form', 'fields', 'exclude' or 'formfield_callback'
smartmin/views.py
def get_factory_kwargs(self): """ Let's us specify any extra parameters we might want to call for our form factory. These can include: 'form', 'fields', 'exclude' or 'formfield_callback' """ params = dict() exclude = self.derive_exclude() exclude += self.derive_...
def get_factory_kwargs(self): """ Let's us specify any extra parameters we might want to call for our form factory. These can include: 'form', 'fields', 'exclude' or 'formfield_callback' """ params = dict() exclude = self.derive_exclude() exclude += self.derive_...
[ "Let", "s", "us", "specify", "any", "extra", "parameters", "we", "might", "want", "to", "call", "for", "our", "form", "factory", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L977-L999
[ "def", "get_factory_kwargs", "(", "self", ")", ":", "params", "=", "dict", "(", ")", "exclude", "=", "self", ".", "derive_exclude", "(", ")", "exclude", "+=", "self", ".", "derive_readonly", "(", ")", "if", "self", ".", "fields", ":", "fields", "=", "l...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.get_success_url
By default we use the referer that was stuffed in our form when it was created
smartmin/views.py
def get_success_url(self): """ By default we use the referer that was stuffed in our form when it was created """ if self.success_url: # if our smart url references an object, pass that in if self.success_url.find('@') > 0: return smart_url...
def get_success_url(self): """ By default we use the referer that was stuffed in our form when it was created """ if self.success_url: # if our smart url references an object, pass that in if self.success_url.find('@') > 0: return smart_url...
[ "By", "default", "we", "use", "the", "referer", "that", "was", "stuffed", "in", "our", "form", "when", "it", "was", "created" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1001-L1016
[ "def", "get_success_url", "(", "self", ")", ":", "if", "self", ".", "success_url", ":", "# if our smart url references an object, pass that in", "if", "self", ".", "success_url", ".", "find", "(", "'@'", ")", ">", "0", ":", "return", "smart_url", "(", "self", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartFormMixin.get_form_kwargs
We override this, using only those fields specified if they are specified. Otherwise we include all fields in a standard ModelForm.
smartmin/views.py
def get_form_kwargs(self): """ We override this, using only those fields specified if they are specified. Otherwise we include all fields in a standard ModelForm. """ kwargs = super(SmartFormMixin, self).get_form_kwargs() kwargs['initial'] = self.derive_initial() ...
def get_form_kwargs(self): """ We override this, using only those fields specified if they are specified. Otherwise we include all fields in a standard ModelForm. """ kwargs = super(SmartFormMixin, self).get_form_kwargs() kwargs['initial'] = self.derive_initial() ...
[ "We", "override", "this", "using", "only", "those", "fields", "specified", "if", "they", "are", "specified", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1024-L1032
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "SmartFormMixin", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "kwargs", "[", "'initial'", "]", "=", "self", ".", "derive_initial", "(", ")", "return", "kwargs" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCreateView.derive_title
Derives our title from our object
smartmin/views.py
def derive_title(self): """ Derives our title from our object """ if not self.title: return _("Create %s") % force_text(self.model._meta.verbose_name).title() else: return self.title
def derive_title(self): """ Derives our title from our object """ if not self.title: return _("Create %s") % force_text(self.model._meta.verbose_name).title() else: return self.title
[ "Derives", "our", "title", "from", "our", "object" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1276-L1283
[ "def", "derive_title", "(", "self", ")", ":", "if", "not", "self", ".", "title", ":", "return", "_", "(", "\"Create %s\"", ")", "%", "force_text", "(", "self", ".", "model", ".", "_meta", ".", "verbose_name", ")", ".", "title", "(", ")", "else", ":",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCRUDL.permission_for_action
Returns the permission to use for the passed in action
smartmin/views.py
def permission_for_action(self, action): """ Returns the permission to use for the passed in action """ return "%s.%s_%s" % (self.app_name.lower(), self.model_name.lower(), action)
def permission_for_action(self, action): """ Returns the permission to use for the passed in action """ return "%s.%s_%s" % (self.app_name.lower(), self.model_name.lower(), action)
[ "Returns", "the", "permission", "to", "use", "for", "the", "passed", "in", "action" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1349-L1353
[ "def", "permission_for_action", "(", "self", ",", "action", ")", ":", "return", "\"%s.%s_%s\"", "%", "(", "self", ".", "app_name", ".", "lower", "(", ")", ",", "self", ".", "model_name", ".", "lower", "(", ")", ",", "action", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCRUDL.template_for_action
Returns the template to use for the passed in action
smartmin/views.py
def template_for_action(self, action): """ Returns the template to use for the passed in action """ return "%s/%s_%s.html" % (self.module_name.lower(), self.model_name.lower(), action)
def template_for_action(self, action): """ Returns the template to use for the passed in action """ return "%s/%s_%s.html" % (self.module_name.lower(), self.model_name.lower(), action)
[ "Returns", "the", "template", "to", "use", "for", "the", "passed", "in", "action" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1355-L1359
[ "def", "template_for_action", "(", "self", ",", "action", ")", ":", "return", "\"%s/%s_%s.html\"", "%", "(", "self", ".", "module_name", ".", "lower", "(", ")", ",", "self", ".", "model_name", ".", "lower", "(", ")", ",", "action", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCRUDL.url_name_for_action
Returns the reverse name for this action
smartmin/views.py
def url_name_for_action(self, action): """ Returns the reverse name for this action """ return "%s.%s_%s" % (self.module_name.lower(), self.model_name.lower(), action)
def url_name_for_action(self, action): """ Returns the reverse name for this action """ return "%s.%s_%s" % (self.module_name.lower(), self.model_name.lower(), action)
[ "Returns", "the", "reverse", "name", "for", "this", "action" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1361-L1365
[ "def", "url_name_for_action", "(", "self", ",", "action", ")", ":", "return", "\"%s.%s_%s\"", "%", "(", "self", ".", "module_name", ".", "lower", "(", ")", ",", "self", ".", "model_name", ".", "lower", "(", ")", ",", "action", ")" ]
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCRUDL.view_for_action
Returns the appropriate view class for the passed in action
smartmin/views.py
def view_for_action(self, action): """ Returns the appropriate view class for the passed in action """ # this turns replace_foo into ReplaceFoo and read into Read class_name = "".join([word.capitalize() for word in action.split("_")]) view = None # see if we have...
def view_for_action(self, action): """ Returns the appropriate view class for the passed in action """ # this turns replace_foo into ReplaceFoo and read into Read class_name = "".join([word.capitalize() for word in action.split("_")]) view = None # see if we have...
[ "Returns", "the", "appropriate", "view", "class", "for", "the", "passed", "in", "action" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1367-L1478
[ "def", "view_for_action", "(", "self", ",", "action", ")", ":", "# this turns replace_foo into ReplaceFoo and read into Read", "class_name", "=", "\"\"", ".", "join", "(", "[", "word", ".", "capitalize", "(", ")", "for", "word", "in", "action", ".", "split", "("...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCRUDL.pattern_for_view
Returns the URL pattern for the passed in action.
smartmin/views.py
def pattern_for_view(self, view, action): """ Returns the URL pattern for the passed in action. """ # if this view knows how to define a URL pattern, call that if getattr(view, 'derive_url_pattern', None): return view.derive_url_pattern(self.path, action) # o...
def pattern_for_view(self, view, action): """ Returns the URL pattern for the passed in action. """ # if this view knows how to define a URL pattern, call that if getattr(view, 'derive_url_pattern', None): return view.derive_url_pattern(self.path, action) # o...
[ "Returns", "the", "URL", "pattern", "for", "the", "passed", "in", "action", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1480-L1490
[ "def", "pattern_for_view", "(", "self", ",", "view", ",", "action", ")", ":", "# if this view knows how to define a URL pattern, call that", "if", "getattr", "(", "view", ",", "'derive_url_pattern'", ",", "None", ")", ":", "return", "view", ".", "derive_url_pattern", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
SmartCRUDL.as_urlpatterns
Creates the appropriate URLs for this object.
smartmin/views.py
def as_urlpatterns(self): """ Creates the appropriate URLs for this object. """ urls = [] # for each of our actions for action in self.actions: view_class = self.view_for_action(action) view_pattern = self.pattern_for_view(view_class, action) ...
def as_urlpatterns(self): """ Creates the appropriate URLs for this object. """ urls = [] # for each of our actions for action in self.actions: view_class = self.view_for_action(action) view_pattern = self.pattern_for_view(view_class, action) ...
[ "Creates", "the", "appropriate", "URLs", "for", "this", "object", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L1492-L1505
[ "def", "as_urlpatterns", "(", "self", ")", ":", "urls", "=", "[", "]", "# for each of our actions", "for", "action", "in", "self", ".", "actions", ":", "view_class", "=", "self", ".", "view_for_action", "(", "action", ")", "view_pattern", "=", "self", ".", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
Command.load_migrations
Loads all migrations in the order they would be applied to a clean database
smartmin/management/commands/collect_sql.py
def load_migrations(self): # pragma: no cover """ Loads all migrations in the order they would be applied to a clean database """ executor = MigrationExecutor(connection=None) # create the forwards plan Django would follow on an empty database plan = executor.migration_...
def load_migrations(self): # pragma: no cover """ Loads all migrations in the order they would be applied to a clean database """ executor = MigrationExecutor(connection=None) # create the forwards plan Django would follow on an empty database plan = executor.migration_...
[ "Loads", "all", "migrations", "in", "the", "order", "they", "would", "be", "applied", "to", "a", "clean", "database" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L120-L133
[ "def", "load_migrations", "(", "self", ")", ":", "# pragma: no cover", "executor", "=", "MigrationExecutor", "(", "connection", "=", "None", ")", "# create the forwards plan Django would follow on an empty database", "plan", "=", "executor", ".", "migration_plan", "(", "e...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
Command.extract_operations
Extract SQL operations from the given migrations
smartmin/management/commands/collect_sql.py
def extract_operations(self, migrations): """ Extract SQL operations from the given migrations """ operations = [] for migration in migrations: for operation in migration.operations: if isinstance(operation, RunSQL): statements = s...
def extract_operations(self, migrations): """ Extract SQL operations from the given migrations """ operations = [] for migration in migrations: for operation in migration.operations: if isinstance(operation, RunSQL): statements = s...
[ "Extract", "SQL", "operations", "from", "the", "given", "migrations" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L135-L154
[ "def", "extract_operations", "(", "self", ",", "migrations", ")", ":", "operations", "=", "[", "]", "for", "migration", "in", "migrations", ":", "for", "operation", "in", "migration", ".", "operations", ":", "if", "isinstance", "(", "operation", ",", "RunSQL...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
Command.normalize_operations
Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X
smartmin/management/commands/collect_sql.py
def normalize_operations(self, operations): """ Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X """ normalized = OrderedDict() for operation in operations: op_key = (operation.sql_type, operation.obj_name) # do we already have an ...
def normalize_operations(self, operations): """ Removes redundant SQL operations - e.g. a CREATE X followed by a DROP X """ normalized = OrderedDict() for operation in operations: op_key = (operation.sql_type, operation.obj_name) # do we already have an ...
[ "Removes", "redundant", "SQL", "operations", "-", "e", ".", "g", ".", "a", "CREATE", "X", "followed", "by", "a", "DROP", "X" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L156-L178
[ "def", "normalize_operations", "(", "self", ",", "operations", ")", ":", "normalized", "=", "OrderedDict", "(", ")", "for", "operation", "in", "operations", ":", "op_key", "=", "(", "operation", ".", "sql_type", ",", "operation", ".", "obj_name", ")", "# do ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
Command.write_type_dumps
Splits the list of SQL operations by type and dumps these to separate files
smartmin/management/commands/collect_sql.py
def write_type_dumps(self, operations, preserve_order, output_dir): """ Splits the list of SQL operations by type and dumps these to separate files """ by_type = {SqlType.INDEX: [], SqlType.FUNCTION: [], SqlType.TRIGGER: []} for operation in operations: by_type[operat...
def write_type_dumps(self, operations, preserve_order, output_dir): """ Splits the list of SQL operations by type and dumps these to separate files """ by_type = {SqlType.INDEX: [], SqlType.FUNCTION: [], SqlType.TRIGGER: []} for operation in operations: by_type[operat...
[ "Splits", "the", "list", "of", "SQL", "operations", "by", "type", "and", "dumps", "these", "to", "separate", "files" ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/management/commands/collect_sql.py#L180-L198
[ "def", "write_type_dumps", "(", "self", ",", "operations", ",", "preserve_order", ",", "output_dir", ")", ":", "by_type", "=", "{", "SqlType", ".", "INDEX", ":", "[", "]", ",", "SqlType", ".", "FUNCTION", ":", "[", "]", ",", "SqlType", ".", "TRIGGER", ...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
VisibleHiddenWidget.render
Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively.
smartmin/widgets.py
def render(self, name, value, attrs=None, renderer=None): """ Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively. """ html = '' html += '%s' % va...
def render(self, name, value, attrs=None, renderer=None): """ Returns this Widget rendered as HTML, as a Unicode string. The 'value' given is not guaranteed to be valid input, so subclass implementations should program defensively. """ html = '' html += '%s' % va...
[ "Returns", "this", "Widget", "rendered", "as", "HTML", "as", "a", "Unicode", "string", "." ]
nyaruka/smartmin
python
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/widgets.py#L9-L19
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "renderer", "=", "None", ")", ":", "html", "=", "''", "html", "+=", "'%s'", "%", "value", "html", "+=", "'<input type=\"hidden\" name=\"%s\" value=\"%s\">'", "%", "(",...
488a676a4960555e4d216a7b95d6e01a4ad4efd8
train
add_atom_data
Add the atomic data to the DataTransferInterface. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param atom_nams the list of atom names for the group :param element_names the list of element names for this group :param atom_charges the list...
mmtf/utils/decoder_utils.py
def add_atom_data(data_api, data_setters, atom_names, element_names, atom_charges, group_atom_ind): """Add the atomic data to the DataTransferInterface. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param atom_nams the list of atom names for t...
def add_atom_data(data_api, data_setters, atom_names, element_names, atom_charges, group_atom_ind): """Add the atomic data to the DataTransferInterface. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param atom_nams the list of atom names for t...
[ "Add", "the", "atomic", "data", "to", "the", "DataTransferInterface", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", ...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L4-L23
[ "def", "add_atom_data", "(", "data_api", ",", "data_setters", ",", "atom_names", ",", "element_names", ",", "atom_charges", ",", "group_atom_ind", ")", ":", "atom_name", "=", "atom_names", "[", "group_atom_ind", "]", "element", "=", "element_names", "[", "group_at...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_group_bonds
Add the bonds for this group. :param data_setters the class to push the data to :param bond_indices the indices of the atoms in the group that are bonded (in pairs) :param bond_orders the orders of the bonds
mmtf/utils/decoder_utils.py
def add_group_bonds(data_setters, bond_indices, bond_orders): """Add the bonds for this group. :param data_setters the class to push the data to :param bond_indices the indices of the atoms in the group that are bonded (in pairs) :param bond_orders the orders of the bonds""" for bond_index in ra...
def add_group_bonds(data_setters, bond_indices, bond_orders): """Add the bonds for this group. :param data_setters the class to push the data to :param bond_indices the indices of the atoms in the group that are bonded (in pairs) :param bond_orders the orders of the bonds""" for bond_index in ra...
[ "Add", "the", "bonds", "for", "this", "group", ".", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", "param", "bond_indices", "the", "indices", "of", "the", "atoms", "in", "the", "group", "that", "are", "bonded", "(",...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L26-L33
[ "def", "add_group_bonds", "(", "data_setters", ",", "bond_indices", ",", "bond_orders", ")", ":", "for", "bond_index", "in", "range", "(", "len", "(", "bond_orders", ")", ")", ":", "data_setters", ".", "set_group_bond", "(", "bond_indices", "[", "bond_index", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_group
Add the data for a whole group. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param group_index the index for this group
mmtf/utils/decoder_utils.py
def add_group(data_api, data_setters, group_index): """Add the data for a whole group. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param group_index the index for this group""" group_type_ind = data_api.group_type_list[group_index] a...
def add_group(data_api, data_setters, group_index): """Add the data for a whole group. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param group_index the index for this group""" group_type_ind = data_api.group_type_list[group_index] a...
[ "Add", "the", "data", "for", "a", "whole", "group", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", "param", "group_...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L36-L61
[ "def", "add_group", "(", "data_api", ",", "data_setters", ",", "group_index", ")", ":", "group_type_ind", "=", "data_api", ".", "group_type_list", "[", "group_index", "]", "atom_count", "=", "len", "(", "data_api", ".", "group_list", "[", "group_type_ind", "]", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_chain_info
Add the data for a whole chain. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param chain_index the index for this chain
mmtf/utils/decoder_utils.py
def add_chain_info(data_api, data_setters, chain_index): """Add the data for a whole chain. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param chain_index the index for this chain""" chain_id = data_api.chain_id_list[chain_index] chai...
def add_chain_info(data_api, data_setters, chain_index): """Add the data for a whole chain. :param data_api the data api from where to get the data :param data_setters the class to push the data to :param chain_index the index for this chain""" chain_id = data_api.chain_id_list[chain_index] chai...
[ "Add", "the", "data", "for", "a", "whole", "chain", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to", ":", "param", "chain_...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L64-L78
[ "def", "add_chain_info", "(", "data_api", ",", "data_setters", ",", "chain_index", ")", ":", "chain_id", "=", "data_api", ".", "chain_id_list", "[", "chain_index", "]", "chain_name", "=", "data_api", ".", "chain_name_list", "[", "chain_index", "]", "num_groups", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_atomic_information
Add all the structural information. :param data_api the data api from where to get the data :param data_setters the class to push the data to
mmtf/utils/decoder_utils.py
def add_atomic_information(data_api, data_setters): """Add all the structural information. :param data_api the data api from where to get the data :param data_setters the class to push the data to""" for model_chains in data_api.chains_per_model: data_setters.set_model_info(data_api.model_counte...
def add_atomic_information(data_api, data_setters): """Add all the structural information. :param data_api the data api from where to get the data :param data_setters the class to push the data to""" for model_chains in data_api.chains_per_model: data_setters.set_model_info(data_api.model_counte...
[ "Add", "all", "the", "structural", "information", ".", ":", "param", "data_api", "the", "data", "api", "from", "where", "to", "get", "the", "data", ":", "param", "data_setters", "the", "class", "to", "push", "the", "data", "to" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L81-L91
[ "def", "add_atomic_information", "(", "data_api", ",", "data_setters", ")", ":", "for", "model_chains", "in", "data_api", ".", "chains_per_model", ":", "data_setters", ".", "set_model_info", "(", "data_api", ".", "model_counter", ",", "model_chains", ")", "tot_chain...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
generate_bio_assembly
Generate the bioassembly data. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
mmtf/utils/decoder_utils.py
def generate_bio_assembly(data_api, struct_inflator): """Generate the bioassembly data. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" bioassembly_count = 0 for bioassembly in data_api.bio_assembly: bioassembly...
def generate_bio_assembly(data_api, struct_inflator): """Generate the bioassembly data. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" bioassembly_count = 0 for bioassembly in data_api.bio_assembly: bioassembly...
[ "Generate", "the", "bioassembly", "data", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client", "object" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L94-L104
[ "def", "generate_bio_assembly", "(", "data_api", ",", "struct_inflator", ")", ":", "bioassembly_count", "=", "0", "for", "bioassembly", "in", "data_api", ".", "bio_assembly", ":", "bioassembly_count", "+=", "1", "for", "transform", "in", "bioassembly", "[", "\"tra...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_inter_group_bonds
Generate inter group bonds. Bond indices are specified within the whole structure and start at 0. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
mmtf/utils/decoder_utils.py
def add_inter_group_bonds(data_api, struct_inflator): """ Generate inter group bonds. Bond indices are specified within the whole structure and start at 0. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" for i in range(len(d...
def add_inter_group_bonds(data_api, struct_inflator): """ Generate inter group bonds. Bond indices are specified within the whole structure and start at 0. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" for i in range(len(d...
[ "Generate", "inter", "group", "bonds", ".", "Bond", "indices", "are", "specified", "within", "the", "whole", "structure", "and", "start", "at", "0", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_infl...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L106-L114
[ "def", "add_inter_group_bonds", "(", "data_api", ",", "struct_inflator", ")", ":", "for", "i", "in", "range", "(", "len", "(", "data_api", ".", "bond_order_list", ")", ")", ":", "struct_inflator", ".", "set_inter_group_bond", "(", "data_api", ".", "bond_atom_lis...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_header_info
Add ancilliary header information to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
mmtf/utils/decoder_utils.py
def add_header_info(data_api, struct_inflator): """ Add ancilliary header information to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ struct_inflator.set_header_info(data_api.r_free, ...
def add_header_info(data_api, struct_inflator): """ Add ancilliary header information to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ struct_inflator.set_header_info(data_api.r_free, ...
[ "Add", "ancilliary", "header", "information", "to", "the", "structure", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client",...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L118-L129
[ "def", "add_header_info", "(", "data_api", ",", "struct_inflator", ")", ":", "struct_inflator", ".", "set_header_info", "(", "data_api", ".", "r_free", ",", "data_api", ".", "r_work", ",", "data_api", ".", "resolution", ",", "data_api", ".", "title", ",", "dat...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_xtalographic_info
Add the crystallographic data to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
mmtf/utils/decoder_utils.py
def add_xtalographic_info(data_api, struct_inflator): """ Add the crystallographic data to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" if data_api.unit_cell == None and data_api.space_group is not None: ...
def add_xtalographic_info(data_api, struct_inflator): """ Add the crystallographic data to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object""" if data_api.unit_cell == None and data_api.space_group is not None: ...
[ "Add", "the", "crystallographic", "data", "to", "the", "structure", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client", "...
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L133-L148
[ "def", "add_xtalographic_info", "(", "data_api", ",", "struct_inflator", ")", ":", "if", "data_api", ".", "unit_cell", "==", "None", "and", "data_api", ".", "space_group", "is", "not", "None", ":", "struct_inflator", ".", "set_xtal_info", "(", "data_api", ".", ...
899bb877ca1b32a9396803d38c5bf38a2520754e
train
add_entity_info
Add the entity info to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object
mmtf/utils/decoder_utils.py
def add_entity_info( data_api, struct_inflator): """Add the entity info to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ for entity in data_api.entity_list: struct_inflator.set_entity_info(enti...
def add_entity_info( data_api, struct_inflator): """Add the entity info to the structure. :param data_api the interface to the decoded data :param struct_inflator the interface to put the data into the client object """ for entity in data_api.entity_list: struct_inflator.set_entity_info(enti...
[ "Add", "the", "entity", "info", "to", "the", "structure", ".", ":", "param", "data_api", "the", "interface", "to", "the", "decoded", "data", ":", "param", "struct_inflator", "the", "interface", "to", "put", "the", "data", "into", "the", "client", "object" ]
rcsb/mmtf-python
python
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/utils/decoder_utils.py#L150-L159
[ "def", "add_entity_info", "(", "data_api", ",", "struct_inflator", ")", ":", "for", "entity", "in", "data_api", ".", "entity_list", ":", "struct_inflator", ".", "set_entity_info", "(", "entity", "[", "\"chainIndexList\"", "]", ",", "entity", "[", "\"sequence\"", ...
899bb877ca1b32a9396803d38c5bf38a2520754e