hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
f4d05bcb89be46e0d605386e7263a4985c9d3773
ithaaswin/TeachersPetBot
src/bot.py
[ "MIT" ]
Python
on_ready
null
async def on_ready(): ''' run on bot start-up ''' global TESTING_MODE TESTING_MODE = False DiscordComponents(bot) db.connect() db.mutation_query(''' CREATE TABLE IF NOT EXISTS ta_office_hours ( guild_id INT, ta VARCHAR(50), day ...
run on bot start-up
run on bot start-up
[ "run", "on", "bot", "start", "-", "up" ]
async def on_ready(): global TESTING_MODE TESTING_MODE = False DiscordComponents(bot) db.connect() db.mutation_query(''' CREATE TABLE IF NOT EXISTS ta_office_hours ( guild_id INT, ta VARCHAR(50), day VARCHAR(4), begin_time ...
[ "async", "def", "on_ready", "(", ")", ":", "global", "TESTING_MODE", "TESTING_MODE", "=", "False", "DiscordComponents", "(", "bot", ")", "db", ".", "connect", "(", ")", "db", ".", "mutation_query", "(", "'''\r\n CREATE TABLE IF NOT EXISTS ta_office_hours (\r\n ...
run on bot start-up
[ "run", "on", "bot", "start", "-", "up" ]
[ "''' run on bot start-up '''" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f4d05bcb89be46e0d605386e7263a4985c9d3773
ithaaswin/TeachersPetBot
src/bot.py
[ "MIT" ]
Python
on_message
<not_specific>
async def on_message(message): ''' run on message sent to a channel ''' # allow messages from test bot if message.author.bot and message.author.id == Test_bot_application_ID: ctx = await bot.get_context(message) await bot.invoke(ctx) if message.author == bot.user: return...
run on message sent to a channel
run on message sent to a channel
[ "run", "on", "message", "sent", "to", "a", "channel" ]
async def on_message(message): if message.author.bot and message.author.id == Test_bot_application_ID: ctx = await bot.get_context(message) await bot.invoke(ctx) if message.author == bot.user: return if profanity.check_profanity(message.content): await message.channel.send(me...
[ "async", "def", "on_message", "(", "message", ")", ":", "if", "message", ".", "author", ".", "bot", "and", "message", ".", "author", ".", "id", "==", "Test_bot_application_ID", ":", "ctx", "=", "await", "bot", ".", "get_context", "(", "message", ")", "aw...
run on message sent to a channel
[ "run", "on", "message", "sent", "to", "a", "channel" ]
[ "''' run on message sent to a channel '''", "# allow messages from test bot\r" ]
[ { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "message", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
remove_event_rows
pd.DataFrame
def remove_event_rows(t: pd.DataFrame) -> pd.DataFrame: """Remove the event marker rows.""" t = t.loc[t[t.columns[0]] != t[t.columns[1]]] t = t.loc[t[t.columns[1]] != t[t.columns[2]]] t = t[t[t.columns[1]].notna()] return t
Remove the event marker rows.
Remove the event marker rows.
[ "Remove", "the", "event", "marker", "rows", "." ]
def remove_event_rows(t: pd.DataFrame) -> pd.DataFrame: t = t.loc[t[t.columns[0]] != t[t.columns[1]]] t = t.loc[t[t.columns[1]] != t[t.columns[2]]] t = t[t[t.columns[1]].notna()] return t
[ "def", "remove_event_rows", "(", "t", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "t", "=", "t", ".", "loc", "[", "t", "[", "t", ".", "columns", "[", "0", "]", "]", "!=", "t", "[", "t", ".", "columns", "[", "1", "]", ...
Remove the event marker rows.
[ "Remove", "the", "event", "marker", "rows", "." ]
[ "\"\"\"Remove the event marker rows.\"\"\"" ]
[ { "param": "t", "type": "pd.DataFrame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "pd.DataFrame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
drop_empty
pd.DataFrame
def drop_empty(t: pd.DataFrame) -> pd.DataFrame: """Remove all empty rows and columns.""" t = t.dropna(axis=0, how='all') t = t.dropna(axis=1, how='all') return t
Remove all empty rows and columns.
Remove all empty rows and columns.
[ "Remove", "all", "empty", "rows", "and", "columns", "." ]
def drop_empty(t: pd.DataFrame) -> pd.DataFrame: t = t.dropna(axis=0, how='all') t = t.dropna(axis=1, how='all') return t
[ "def", "drop_empty", "(", "t", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "t", "=", "t", ".", "dropna", "(", "axis", "=", "0", ",", "how", "=", "'all'", ")", "t", "=", "t", ".", "dropna", "(", "axis", "=", "1", ",", ...
Remove all empty rows and columns.
[ "Remove", "all", "empty", "rows", "and", "columns", "." ]
[ "\"\"\"Remove all empty rows and columns.\"\"\"" ]
[ { "param": "t", "type": "pd.DataFrame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "pd.DataFrame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
fix_numerical_cols
pd.DataFrame
def fix_numerical_cols(t: pd.DataFrame) -> pd.DataFrame: """Convert selected columns from strings to numeric data type.""" # some constants fixable_cols = ( # For the 2022 cycle 'Primary vote', '2pp vote', 'Preferred Prime Minister', 'Morrison', 'Albanese', 'Samp...
Convert selected columns from strings to numeric data type.
Convert selected columns from strings to numeric data type.
[ "Convert", "selected", "columns", "from", "strings", "to", "numeric", "data", "type", "." ]
def fix_numerical_cols(t: pd.DataFrame) -> pd.DataFrame: fixable_cols = ( 'Primary vote', '2pp vote', 'Preferred Prime Minister', 'Morrison', 'Albanese', 'Sample size', 'TPP vote', '2PP vote', 'Political parties', 'Two-party-preferred', ) for c in t....
[ "def", "fix_numerical_cols", "(", "t", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "fixable_cols", "=", "(", "'Primary vote'", ",", "'2pp vote'", ",", "'Preferred Prime Minister'", ",", "'Morrison'", ",", "'Albanese'", ",", "'Sample size...
Convert selected columns from strings to numeric data type.
[ "Convert", "selected", "columns", "from", "strings", "to", "numeric", "data", "type", "." ]
[ "\"\"\"Convert selected columns from strings to numeric data type.\"\"\"", "# some constants", "# For the 2022 cycle", "# For historical cycles", "# navigate fixable columns and convert to numerical dtype", "# remove footnotes", "# remove percent symbol", "# replace tilde with nothing", "# replace h...
[ { "param": "t", "type": "pd.DataFrame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "pd.DataFrame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
remove_footnotes
pd.DataFrame
def remove_footnotes(t: pd.DataFrame) -> pd.DataFrame: """Remove Wikipedia footnote references from the Brand column""" BRAND = ['Brand', 'Firm'] for brand in BRAND: if brand not in t.columns.get_level_values(0): continue col = t.columns[t.columns.get_level_values(0) ==...
Remove Wikipedia footnote references from the Brand column
Remove Wikipedia footnote references from the Brand column
[ "Remove", "Wikipedia", "footnote", "references", "from", "the", "Brand", "column" ]
def remove_footnotes(t: pd.DataFrame) -> pd.DataFrame: BRAND = ['Brand', 'Firm'] for brand in BRAND: if brand not in t.columns.get_level_values(0): continue col = t.columns[t.columns.get_level_values(0) == brand] assert(len(col) == 1) t.loc[:, col] = ( t.l...
[ "def", "remove_footnotes", "(", "t", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "BRAND", "=", "[", "'Brand'", ",", "'Firm'", "]", "for", "brand", "in", "BRAND", ":", "if", "brand", "not", "in", "t", ".", "columns", ".", "g...
Remove Wikipedia footnote references from the Brand column
[ "Remove", "Wikipedia", "footnote", "references", "from", "the", "Brand", "column" ]
[ "\"\"\"Remove Wikipedia footnote references from the Brand column\"\"\"", "# returns a single column DataFrame", "# make as Series", "# remove footnotes", "# remove any leading/trailing whitespaces" ]
[ { "param": "t", "type": "pd.DataFrame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "pd.DataFrame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
tokenise_dates
pd.Series
def tokenise_dates(dates: pd.Series) -> pd.Series: """Return the date as a list of tokens.""" if type(dates) is pd.DataFrame: dates = dates[dates.columns[0]] # WTF? return ( dates .str.replace('\[\d+\]$', '', regex=True) # footnotes .str.replace(endash, hyphen) ....
Return the date as a list of tokens.
Return the date as a list of tokens.
[ "Return", "the", "date", "as", "a", "list", "of", "tokens", "." ]
def tokenise_dates(dates: pd.Series) -> pd.Series: if type(dates) is pd.DataFrame: dates = dates[dates.columns[0]] return ( dates .str.replace('\[\d+\]$', '', regex=True) .str.replace(endash, hyphen) .str.replace(emdash, hyphen) .str.replace(minus, hyphen) ...
[ "def", "tokenise_dates", "(", "dates", ":", "pd", ".", "Series", ")", "->", "pd", ".", "Series", ":", "if", "type", "(", "dates", ")", "is", "pd", ".", "DataFrame", ":", "dates", "=", "dates", "[", "dates", ".", "columns", "[", "0", "]", "]", "re...
Return the date as a list of tokens.
[ "Return", "the", "date", "as", "a", "list", "of", "tokens", "." ]
[ "\"\"\"Return the date as a list of tokens.\"\"\"", "# WTF?", "# footnotes" ]
[ { "param": "dates", "type": "pd.Series" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dates", "type": "pd.Series", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
middle_date
pd.DataFrame
def middle_date(t: pd.DataFrame) -> pd.DataFrame: """Get the middle date in the date range, into column 'Mean Date'.""" # assumes dates in strings are ordered from first to last tokens = tokenise_dates(t['Date']) t['Mean Date'] = tokens.apply(get_mean_date).astype('datetime64[ns]') return t
Get the middle date in the date range, into column 'Mean Date'.
Get the middle date in the date range, into column 'Mean Date'.
[ "Get", "the", "middle", "date", "in", "the", "date", "range", "into", "column", "'", "Mean", "Date", "'", "." ]
def middle_date(t: pd.DataFrame) -> pd.DataFrame: tokens = tokenise_dates(t['Date']) t['Mean Date'] = tokens.apply(get_mean_date).astype('datetime64[ns]') return t
[ "def", "middle_date", "(", "t", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "tokens", "=", "tokenise_dates", "(", "t", "[", "'Date'", "]", ")", "t", "[", "'Mean Date'", "]", "=", "tokens", ".", "apply", "(", "get_mean_date", ...
Get the middle date in the date range, into column 'Mean Date'.
[ "Get", "the", "middle", "date", "in", "the", "date", "range", "into", "column", "'", "Mean", "Date", "'", "." ]
[ "\"\"\"Get the middle date in the date range, into column 'Mean Date'.\"\"\"", "# assumes dates in strings are ordered from first to last" ]
[ { "param": "t", "type": "pd.DataFrame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "pd.DataFrame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
clean
pd.DataFrame
def clean(table: pd.DataFrame) -> pd.DataFrame: """Clean the extracted data tables.""" t = table.copy() t = remove_event_rows(t) t = drop_empty(t) t = fix_numerical_cols(t) t = fix_column_names(t) t = remove_footnotes(t) t = middle_date(t) t = t.set_index(('Mean Date', '')) ...
Clean the extracted data tables.
Clean the extracted data tables.
[ "Clean", "the", "extracted", "data", "tables", "." ]
def clean(table: pd.DataFrame) -> pd.DataFrame: t = table.copy() t = remove_event_rows(t) t = drop_empty(t) t = fix_numerical_cols(t) t = fix_column_names(t) t = remove_footnotes(t) t = middle_date(t) t = t.set_index(('Mean Date', '')) t = t.sort_index(ascending=True) return t
[ "def", "clean", "(", "table", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "t", "=", "table", ".", "copy", "(", ")", "t", "=", "remove_event_rows", "(", "t", ")", "t", "=", "drop_empty", "(", "t", ")", "t", "=", "fix_numer...
Clean the extracted data tables.
[ "Clean", "the", "extracted", "data", "tables", "." ]
[ "\"\"\"Clean the extracted data tables.\"\"\"", "# Note we keep the hierarchical index at this point", "# because it makes the checking row additions simpler" ]
[ { "param": "table", "type": "pd.DataFrame" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "table", "type": "pd.DataFrame", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
calculate_ewm
<not_specific>
def calculate_ewm(series, times, halflife): """Calculate an exponentially weighted mean for a series.""" # sanity checks assert len(series) == len(times) assert series.notna().all() assert times.notna().all() return ( series .ewm(halflife=halflife, times=times) ...
Calculate an exponentially weighted mean for a series.
Calculate an exponentially weighted mean for a series.
[ "Calculate", "an", "exponentially", "weighted", "mean", "for", "a", "series", "." ]
def calculate_ewm(series, times, halflife): assert len(series) == len(times) assert series.notna().all() assert times.notna().all() return ( series .ewm(halflife=halflife, times=times) .mean() )
[ "def", "calculate_ewm", "(", "series", ",", "times", ",", "halflife", ")", ":", "assert", "len", "(", "series", ")", "==", "len", "(", "times", ")", "assert", "series", ".", "notna", "(", ")", ".", "all", "(", ")", "assert", "times", ".", "notna", ...
Calculate an exponentially weighted mean for a series.
[ "Calculate", "an", "exponentially", "weighted", "mean", "for", "a", "series", "." ]
[ "\"\"\"Calculate an exponentially weighted mean for a series.\"\"\"", "# sanity checks" ]
[ { "param": "series", "type": null }, { "param": "times", "type": null }, { "param": "halflife", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "series", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "times", "type": null, "docstring": null, "docstring_tokens"...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
initiate_plot
<not_specific>
def initiate_plot(): """Get a matplotlib figure and axes instance.""" fig, ax = plt.subplots(figsize=(9, 4.5), constrained_layout=False) ax.margins(0.02) return fig, ax
Get a matplotlib figure and axes instance.
Get a matplotlib figure and axes instance.
[ "Get", "a", "matplotlib", "figure", "and", "axes", "instance", "." ]
def initiate_plot(): fig, ax = plt.subplots(figsize=(9, 4.5), constrained_layout=False) ax.margins(0.02) return fig, ax
[ "def", "initiate_plot", "(", ")", ":", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", "figsize", "=", "(", "9", ",", "4.5", ")", ",", "constrained_layout", "=", "False", ")", "ax", ".", "margins", "(", "0.02", ")", "return", "fig", ",", "ax" ]
Get a matplotlib figure and axes instance.
[ "Get", "a", "matplotlib", "figure", "and", "axes", "instance", "." ]
[ "\"\"\"Get a matplotlib figure and axes instance.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
annotate_endpoint
null
def annotate_endpoint(ax, series: pd.Series, end=None, rot=90): """Annotate the endpoint of a series on a plot.""" xlim = ax.get_xlim() span = xlim[1] - xlim[0] x = xlim[1] - 0.0075 * span # Based on 2% margins in initiate_plot() x = x if end is None else end font_size = 13 if rot == 90 else 10...
Annotate the endpoint of a series on a plot.
Annotate the endpoint of a series on a plot.
[ "Annotate", "the", "endpoint", "of", "a", "series", "on", "a", "plot", "." ]
def annotate_endpoint(ax, series: pd.Series, end=None, rot=90): xlim = ax.get_xlim() span = xlim[1] - xlim[0] x = xlim[1] - 0.0075 * span x = x if end is None else end font_size = 13 if rot == 90 else 10 ax.text(x, series.iloc[-1], f'{round(series.iloc[-1], 1)}', ha='l...
[ "def", "annotate_endpoint", "(", "ax", ",", "series", ":", "pd", ".", "Series", ",", "end", "=", "None", ",", "rot", "=", "90", ")", ":", "xlim", "=", "ax", ".", "get_xlim", "(", ")", "span", "=", "xlim", "[", "1", "]", "-", "xlim", "[", "0", ...
Annotate the endpoint of a series on a plot.
[ "Annotate", "the", "endpoint", "of", "a", "series", "on", "a", "plot", "." ]
[ "\"\"\"Annotate the endpoint of a series on a plot.\"\"\"", "# Based on 2% margins in initiate_plot()" ]
[ { "param": "ax", "type": null }, { "param": "series", "type": "pd.Series" }, { "param": "end", "type": null }, { "param": "rot", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ax", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "series", "type": "pd.Series", "docstring": null, "docstring_tok...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
add_data_points_by_pollster
null
def add_data_points_by_pollster(ax, df, column, p_color, brand_col='Brand', date_col='Mean Date', no_label=False, marker=None): """Add individual poll results to the plot.""" for i, brand in enumerate(sorted(df[brand_col].unique())): poll...
Add individual poll results to the plot.
Add individual poll results to the plot.
[ "Add", "individual", "poll", "results", "to", "the", "plot", "." ]
def add_data_points_by_pollster(ax, df, column, p_color, brand_col='Brand', date_col='Mean Date', no_label=False, marker=None): for i, brand in enumerate(sorted(df[brand_col].unique())): poll = df[df[brand_col] == brand] series = ( ...
[ "def", "add_data_points_by_pollster", "(", "ax", ",", "df", ",", "column", ",", "p_color", ",", "brand_col", "=", "'Brand'", ",", "date_col", "=", "'Mean Date'", ",", "no_label", "=", "False", ",", "marker", "=", "None", ")", ":", "for", "i", ",", "brand...
Add individual poll results to the plot.
[ "Add", "individual", "poll", "results", "to", "the", "plot", "." ]
[ "\"\"\"Add individual poll results to the plot.\"\"\"" ]
[ { "param": "ax", "type": null }, { "param": "df", "type": null }, { "param": "column", "type": null }, { "param": "p_color", "type": null }, { "param": "brand_col", "type": null }, { "param": "date_col", "type": null }, { "param": "no_label...
{ "returns": [], "raises": [], "params": [ { "identifier": "ax", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [], ...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
add_h_refence
null
def add_h_refence(ax, reference): """Add a horizontal reference line.""" span = ax.get_ylim() if span[0] <= reference <= span[1]: ax.axhline(y=reference, c='#999999', lw=0.5)
Add a horizontal reference line.
Add a horizontal reference line.
[ "Add", "a", "horizontal", "reference", "line", "." ]
def add_h_refence(ax, reference): span = ax.get_ylim() if span[0] <= reference <= span[1]: ax.axhline(y=reference, c='#999999', lw=0.5)
[ "def", "add_h_refence", "(", "ax", ",", "reference", ")", ":", "span", "=", "ax", ".", "get_ylim", "(", ")", "if", "span", "[", "0", "]", "<=", "reference", "<=", "span", "[", "1", "]", ":", "ax", ".", "axhline", "(", "y", "=", "reference", ",", ...
Add a horizontal reference line.
[ "Add", "a", "horizontal", "reference", "line", "." ]
[ "\"\"\"Add a horizontal reference line.\"\"\"" ]
[ { "param": "ax", "type": null }, { "param": "reference", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ax", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reference", "type": null, "docstring": null, "docstring_tokens"...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
add_summary_line
null
def add_summary_line(ax, df, column, l_color, function, argument, label=None, rot=0): """Add a line summary to the plot as calculated by function()""" series = df[column].sum(axis=1, skipna=True) if type(column) is list else df[column] times = df['Mean Date'] summary = function(series, times, argument) ...
Add a line summary to the plot as calculated by function()
Add a line summary to the plot as calculated by function()
[ "Add", "a", "line", "summary", "to", "the", "plot", "as", "calculated", "by", "function", "()" ]
def add_summary_line(ax, df, column, l_color, function, argument, label=None, rot=0): series = df[column].sum(axis=1, skipna=True) if type(column) is list else df[column] times = df['Mean Date'] summary = function(series, times, argument) if summary is not None: ax.plot(times, summary, lw=2.5, c...
[ "def", "add_summary_line", "(", "ax", ",", "df", ",", "column", ",", "l_color", ",", "function", ",", "argument", ",", "label", "=", "None", ",", "rot", "=", "0", ")", ":", "series", "=", "df", "[", "column", "]", ".", "sum", "(", "axis", "=", "1...
Add a line summary to the plot as calculated by function()
[ "Add", "a", "line", "summary", "to", "the", "plot", "as", "calculated", "by", "function", "()" ]
[ "\"\"\"Add a line summary to the plot as calculated by function()\"\"\"" ]
[ { "param": "ax", "type": null }, { "param": "df", "type": null }, { "param": "column", "type": null }, { "param": "l_color", "type": null }, { "param": "function", "type": null }, { "param": "argument", "type": null }, { "param": "label", ...
{ "returns": [], "raises": [], "params": [ { "identifier": "ax", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [], ...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
plot_finalise
null
def plot_finalise(ax, title=None, xlabel=None, ylabel=None, lfooter=None, rfooter='marktheballot.blogspot.com', location='../charts/', close=True, concise_dates=False, straighten_tl=False, **kwargs): """Complete and save a plot image""" # annotate the ...
Complete and save a plot image
Complete and save a plot image
[ "Complete", "and", "save", "a", "plot", "image" ]
def plot_finalise(ax, title=None, xlabel=None, ylabel=None, lfooter=None, rfooter='marktheballot.blogspot.com', location='../charts/', close=True, concise_dates=False, straighten_tl=False, **kwargs): if title is not None: ax.set_title(title) ax.set_...
[ "def", "plot_finalise", "(", "ax", ",", "title", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", "=", "None", ",", "lfooter", "=", "None", ",", "rfooter", "=", "'marktheballot.blogspot.com'", ",", "location", "=", "'../charts/'", ",", "close", "=",...
Complete and save a plot image
[ "Complete", "and", "save", "a", "plot", "image" ]
[ "\"\"\"Complete and save a plot image\"\"\"", "# annotate the plot", "# format dates", "# straigten tick labels", "# close" ]
[ { "param": "ax", "type": null }, { "param": "title", "type": null }, { "param": "xlabel", "type": null }, { "param": "ylabel", "type": null }, { "param": "lfooter", "type": null }, { "param": "rfooter", "type": null }, { "param": "location"...
{ "returns": [], "raises": [], "params": [ { "identifier": "ax", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "title", "type": null, "docstring": null, "docstring_tokens": []...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
plot_summary_line
null
def plot_summary_line(df, column, p_color, l_color, title, function, argument, label, lfooter, rot=90): """Generate a summary line plot, where the line is generated by function()""" fig, ax = initiate_plot() add_data_points_by_pollster(ax, df, column, p_color) add_summary_line(ax, ...
Generate a summary line plot, where the line is generated by function()
Generate a summary line plot, where the line is generated by function()
[ "Generate", "a", "summary", "line", "plot", "where", "the", "line", "is", "generated", "by", "function", "()" ]
def plot_summary_line(df, column, p_color, l_color, title, function, argument, label, lfooter, rot=90): fig, ax = initiate_plot() add_data_points_by_pollster(ax, df, column, p_color) add_summary_line(ax, df, column, l_color, function, argument, label, rot=rot) ax.legend(loc='best')...
[ "def", "plot_summary_line", "(", "df", ",", "column", ",", "p_color", ",", "l_color", ",", "title", ",", "function", ",", "argument", ",", "label", ",", "lfooter", ",", "rot", "=", "90", ")", ":", "fig", ",", "ax", "=", "initiate_plot", "(", ")", "ad...
Generate a summary line plot, where the line is generated by function()
[ "Generate", "a", "summary", "line", "plot", "where", "the", "line", "is", "generated", "by", "function", "()" ]
[ "\"\"\"Generate a summary line plot, where the line is generated by function()\"\"\"" ]
[ { "param": "df", "type": null }, { "param": "column", "type": null }, { "param": "p_color", "type": null }, { "param": "l_color", "type": null }, { "param": "title", "type": null }, { "param": "function", "type": null }, { "param": "argumen...
{ "returns": [], "raises": [], "params": [ { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "column", "type": null, "docstring": null, "docstring_tokens": [...
42b87959edb84ef8eaebef5ef42823fd8ab5f6ec
bpalmer4/Australian-Federal-Election-2022
notebooks/common.py
[ "MIT" ]
Python
plot_summary_line_by_pollster
null
def plot_summary_line_by_pollster(df, column, title, function, argument, lfooter, rot=0): """For each pollster, plot a summary line calculated with function()""" MINIMUM_POLLS_REQUIRED = 2 # two polls needed for a line fig, ax = initiate_plot() for i, pollster in enumer...
For each pollster, plot a summary line calculated with function()
For each pollster, plot a summary line calculated with function()
[ "For", "each", "pollster", "plot", "a", "summary", "line", "calculated", "with", "function", "()" ]
def plot_summary_line_by_pollster(df, column, title, function, argument, lfooter, rot=0): MINIMUM_POLLS_REQUIRED = 2 fig, ax = initiate_plot() for i, pollster in enumerate(sorted(df['Brand'].unique())): polls = df[df['Brand'] == pollster].copy() if len(poll...
[ "def", "plot_summary_line_by_pollster", "(", "df", ",", "column", ",", "title", ",", "function", ",", "argument", ",", "lfooter", ",", "rot", "=", "0", ")", ":", "MINIMUM_POLLS_REQUIRED", "=", "2", "fig", ",", "ax", "=", "initiate_plot", "(", ")", "for", ...
For each pollster, plot a summary line calculated with function()
[ "For", "each", "pollster", "plot", "a", "summary", "line", "calculated", "with", "function", "()" ]
[ "\"\"\"For each pollster, plot a summary line calculated with function()\"\"\"", "# two polls needed for a line" ]
[ { "param": "df", "type": null }, { "param": "column", "type": null }, { "param": "title", "type": null }, { "param": "function", "type": null }, { "param": "argument", "type": null }, { "param": "lfooter", "type": null }, { "param": "rot", ...
{ "returns": [], "raises": [], "params": [ { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "column", "type": null, "docstring": null, "docstring_tokens": [...
2d29063b61cc362f06493dcd470ee63c158273c2
spineki/pi_temp
main.py
[ "MIT" ]
Python
sendMessageCreator
<not_specific>
def sendMessageCreator(bot, bot_chatID): """ callback creator for botfrom the chat """ def _worker(message): bot.send_message(bot_chatID, message) return _worker
callback creator for botfrom the chat
callback creator for botfrom the chat
[ "callback", "creator", "for", "botfrom", "the", "chat" ]
def sendMessageCreator(bot, bot_chatID): def _worker(message): bot.send_message(bot_chatID, message) return _worker
[ "def", "sendMessageCreator", "(", "bot", ",", "bot_chatID", ")", ":", "def", "_worker", "(", "message", ")", ":", "bot", ".", "send_message", "(", "bot_chatID", ",", "message", ")", "return", "_worker" ]
callback creator for botfrom the chat
[ "callback", "creator", "for", "botfrom", "the", "chat" ]
[ "\"\"\"\n callback creator for botfrom the chat\n \"\"\"" ]
[ { "param": "bot", "type": null }, { "param": "bot_chatID", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bot", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bot_chatID", "type": null, "docstring": null, "docstring_token...
3ecdcce53b8a285735b1ad7fc6367f0c94ceb9b9
AidanDelaney/textext
scribus_textext.py
[ "BSD-3-Clause" ]
Python
exec_command
null
def exec_command(self, cmd): """Run given command, check return value""" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) out, err = p.communicate() if p...
Run given command, check return value
Run given command, check return value
[ "Run", "given", "command", "check", "return", "value" ]
def exec_command(self, cmd): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) out, err = p.communicate() if p.returncode != 0: raise RuntimeError("Co...
[ "def", "exec_command", "(", "self", ",", "cmd", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ",", "stdin", "=", "subprocess", ".", "PIPE", ")...
Run given command, check return value
[ "Run", "given", "command", "check", "return", "value" ]
[ "\"\"\"Run given command, check return value\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "cmd", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmd", "type": null, "docstring": null, "docstring_tokens": []...
3ecdcce53b8a285735b1ad7fc6367f0c94ceb9b9
AidanDelaney/textext
scribus_textext.py
[ "BSD-3-Clause" ]
Python
remove_temp_files
null
def remove_temp_files(self, path): """Remove files made in /tmp""" for filename in ['x.tex', 'x.log', 'x.aux', 'x.pdf', 'x.svg', 'x.pdf.sk', 'x.eps', 'x.dvi', 'x.ps', 'x.png']: self.try_remove(os.path.join(path, filename)) self.try_remove(path)
Remove files made in /tmp
Remove files made in /tmp
[ "Remove", "files", "made", "in", "/", "tmp" ]
def remove_temp_files(self, path): for filename in ['x.tex', 'x.log', 'x.aux', 'x.pdf', 'x.svg', 'x.pdf.sk', 'x.eps', 'x.dvi', 'x.ps', 'x.png']: self.try_remove(os.path.join(path, filename)) self.try_remove(path)
[ "def", "remove_temp_files", "(", "self", ",", "path", ")", ":", "for", "filename", "in", "[", "'x.tex'", ",", "'x.log'", ",", "'x.aux'", ",", "'x.pdf'", ",", "'x.svg'", ",", "'x.pdf.sk'", ",", "'x.eps'", ",", "'x.dvi'", ",", "'x.ps'", ",", "'x.png'", "]"...
Remove files made in /tmp
[ "Remove", "files", "made", "in", "/", "tmp" ]
[ "\"\"\"Remove files made in /tmp\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [...
3ecdcce53b8a285735b1ad7fc6367f0c94ceb9b9
AidanDelaney/textext
scribus_textext.py
[ "BSD-3-Clause" ]
Python
try_remove
null
def try_remove(self, filename): """Try to remove given file, skipping if not exists.""" if os.path.isfile(filename): os.remove(filename) elif os.path.isdir(filename): os.rmdir(filename)
Try to remove given file, skipping if not exists.
Try to remove given file, skipping if not exists.
[ "Try", "to", "remove", "given", "file", "skipping", "if", "not", "exists", "." ]
def try_remove(self, filename): if os.path.isfile(filename): os.remove(filename) elif os.path.isdir(filename): os.rmdir(filename)
[ "def", "try_remove", "(", "self", ",", "filename", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "os", ".", "remove", "(", "filename", ")", "elif", "os", ".", "path", ".", "isdir", "(", "filename", ")", ":", "os", "...
Try to remove given file, skipping if not exists.
[ "Try", "to", "remove", "given", "file", "skipping", "if", "not", "exists", "." ]
[ "\"\"\"Try to remove given file, skipping if not exists.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
a52f6a9e8399f29c00d276b15dd425b491e90e0e
xArty4/TinyAPI
tinyapi/routing.py
[ "MIT" ]
Python
after
None
def after(self, callback: typing.Callable) -> None: """ This method is used to register a after middleware. The callback is a function that will be called after the callback of the route. """ self.after_middlewares.append(callback)
This method is used to register a after middleware. The callback is a function that will be called after the callback of the route.
This method is used to register a after middleware. The callback is a function that will be called after the callback of the route.
[ "This", "method", "is", "used", "to", "register", "a", "after", "middleware", ".", "The", "callback", "is", "a", "function", "that", "will", "be", "called", "after", "the", "callback", "of", "the", "route", "." ]
def after(self, callback: typing.Callable) -> None: self.after_middlewares.append(callback)
[ "def", "after", "(", "self", ",", "callback", ":", "typing", ".", "Callable", ")", "->", "None", ":", "self", ".", "after_middlewares", ".", "append", "(", "callback", ")" ]
This method is used to register a after middleware.
[ "This", "method", "is", "used", "to", "register", "a", "after", "middleware", "." ]
[ "\"\"\"\n This method is used to register a after middleware.\n The callback is a function that will be called after the callback of the route.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "callback", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "typing.Callable", "docstring": null, "doc...
a285c6c30186387a972d3dc5cec79a5fbeb86b15
xArty4/TinyAPI
tinyapi/application.py
[ "MIT" ]
Python
rule
typing.Callable
def rule(self, rule:str, methods: typing.List[str]) -> typing.Callable: """ This method is used to register a rule. The rule is a regular expression that will be used to match the request. Parameters ---------- rule: `str` The rule tha...
This method is used to register a rule. The rule is a regular expression that will be used to match the request. Parameters ---------- rule: `str` The rule that will be used to match the request. methods: `typing.List[str]` ...
This method is used to register a rule. The rule is a regular expression that will be used to match the request. Parameters `str` The rule that will be used to match the request. methods: `typing.List[str]` The methods that will be used to match the request.
[ "This", "method", "is", "used", "to", "register", "a", "rule", ".", "The", "rule", "is", "a", "regular", "expression", "that", "will", "be", "used", "to", "match", "the", "request", ".", "Parameters", "`", "str", "`", "The", "rule", "that", "will", "be...
def rule(self, rule:str, methods: typing.List[str]) -> typing.Callable: def decorator(func: typing.Callable) -> typing.Callable: return self.add_rule(rule, methods, func) return decorator
[ "def", "rule", "(", "self", ",", "rule", ":", "str", ",", "methods", ":", "typing", ".", "List", "[", "str", "]", ")", "->", "typing", ".", "Callable", ":", "def", "decorator", "(", "func", ":", "typing", ".", "Callable", ")", "->", "typing", ".", ...
This method is used to register a rule.
[ "This", "method", "is", "used", "to", "register", "a", "rule", "." ]
[ "\"\"\"\n This method is used to register a rule.\n The rule is a regular expression that will be used to match the request.\n\n Parameters\n ----------\n rule: `str`\n The rule that will be used to match the request.\n methods: `typin...
[ { "param": "self", "type": null }, { "param": "rule", "type": "str" }, { "param": "methods", "type": "typing.List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rule", "type": "str", "docstring": null, "docstring_tokens": ...
a285c6c30186387a972d3dc5cec79a5fbeb86b15
xArty4/TinyAPI
tinyapi/application.py
[ "MIT" ]
Python
run
None
def run(self, host: typing.Optional[str] = 'localhost', port: typing.Optional[int] = 5000) -> None: """ This method is used to run the application. Parameters ---------- host: `str` The host that will be used to run the application. po...
This method is used to run the application. Parameters ---------- host: `str` The host that will be used to run the application. port: `int` The port that will be used to run the application.
This method is used to run the application. Parameters `str` The host that will be used to run the application. port: `int` The port that will be used to run the application.
[ "This", "method", "is", "used", "to", "run", "the", "application", ".", "Parameters", "`", "str", "`", "The", "host", "that", "will", "be", "used", "to", "run", "the", "application", ".", "port", ":", "`", "int", "`", "The", "port", "that", "will", "...
def run(self, host: typing.Optional[str] = 'localhost', port: typing.Optional[int] = 5000) -> None: from wsgiref.simple_server import make_server logger.info(f"* Running on http://{host}:{port}") logger.info(f"* Use Ctrl+C to stop the server.") make_server(host, port, self.server).serve_...
[ "def", "run", "(", "self", ",", "host", ":", "typing", ".", "Optional", "[", "str", "]", "=", "'localhost'", ",", "port", ":", "typing", ".", "Optional", "[", "int", "]", "=", "5000", ")", "->", "None", ":", "from", "wsgiref", ".", "simple_server", ...
This method is used to run the application.
[ "This", "method", "is", "used", "to", "run", "the", "application", "." ]
[ "\"\"\"\n This method is used to run the application.\n\n Parameters\n ----------\n host: `str`\n The host that will be used to run the application.\n port: `int`\n The port that will be used to run the application.\n \"\"\"...
[ { "param": "self", "type": null }, { "param": "host", "type": "typing.Optional[str]" }, { "param": "port", "type": "typing.Optional[int]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "host", "type": "typing.Optional[str]", "docstring": null, "do...
a285c6c30186387a972d3dc5cec79a5fbeb86b15
xArty4/TinyAPI
tinyapi/application.py
[ "MIT" ]
Python
add_extension
None
def add_extension(self, extension: "Extension") -> None: """ This method is used to add an extension to the application. """ extension.app = self self.extensions.append(extension) logger.debug(f"* Extension {extension.name} added.")
This method is used to add an extension to the application.
This method is used to add an extension to the application.
[ "This", "method", "is", "used", "to", "add", "an", "extension", "to", "the", "application", "." ]
def add_extension(self, extension: "Extension") -> None: extension.app = self self.extensions.append(extension) logger.debug(f"* Extension {extension.name} added.")
[ "def", "add_extension", "(", "self", ",", "extension", ":", "\"Extension\"", ")", "->", "None", ":", "extension", ".", "app", "=", "self", "self", ".", "extensions", ".", "append", "(", "extension", ")", "logger", ".", "debug", "(", "f\"* Extension {extensio...
This method is used to add an extension to the application.
[ "This", "method", "is", "used", "to", "add", "an", "extension", "to", "the", "application", "." ]
[ "\"\"\"\n This method is used to add an extension to the application.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "extension", "type": "\"Extension\"" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "extension", "type": "\"Extension\"", "docstring": null, "docs...
a285c6c30186387a972d3dc5cec79a5fbeb86b15
xArty4/TinyAPI
tinyapi/application.py
[ "MIT" ]
Python
remove_extension
None
def remove_extension(self, extension_name: str) -> None: """ This method is used to remove an extension from the application. """ try: extension = [extension for extension in self.extensions if extension.name == extension_name][0] except IndexError: ra...
This method is used to remove an extension from the application.
This method is used to remove an extension from the application.
[ "This", "method", "is", "used", "to", "remove", "an", "extension", "from", "the", "application", "." ]
def remove_extension(self, extension_name: str) -> None: try: extension = [extension for extension in self.extensions if extension.name == extension_name][0] except IndexError: raise ExtensionNotFound(f"Extension {extension_name} not found.") for rule in extension.rules: ...
[ "def", "remove_extension", "(", "self", ",", "extension_name", ":", "str", ")", "->", "None", ":", "try", ":", "extension", "=", "[", "extension", "for", "extension", "in", "self", ".", "extensions", "if", "extension", ".", "name", "==", "extension_name", ...
This method is used to remove an extension from the application.
[ "This", "method", "is", "used", "to", "remove", "an", "extension", "from", "the", "application", "." ]
[ "\"\"\"\n This method is used to remove an extension from the application.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "extension_name", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "extension_name", "type": "str", "docstring": null, "docstring...
77b8fc3fbe05f1af598ed17ec88c1ad5567a68d5
xArty4/TinyAPI
tinyapi/tools/redirect.py
[ "MIT" ]
Python
redirect
"Respone"
def redirect(url: str) -> "Respone": """ This function return the repsone object with the given url. Parameters ---------- url : `str` The url to redirect to. """ html = f""" <!DOCTYPE html> <html> <p>Redirecting...</p> <a ...
This function return the repsone object with the given url. Parameters ---------- url : `str` The url to redirect to.
This function return the repsone object with the given url. Parameters url : `str` The url to redirect to.
[ "This", "function", "return", "the", "repsone", "object", "with", "the", "given", "url", ".", "Parameters", "url", ":", "`", "str", "`", "The", "url", "to", "redirect", "to", "." ]
def redirect(url: str) -> "Respone": html = f""" <!DOCTYPE html> <html> <p>Redirecting...</p> <a href="{url}"><p>Click here if you are not redirected</p></a> </html> """ resp = Respone(html, f'301 {STATUS_MESSAGE[301]}','text/html') resp.add_header('Locat...
[ "def", "redirect", "(", "url", ":", "str", ")", "->", "\"Respone\"", ":", "html", "=", "f\"\"\"\n <!DOCTYPE html>\n <html>\n <p>Redirecting...</p>\n <a href=\"{url}\"><p>Click here if you are not redirected</p></a>\n </html>\n \"\"\"", "resp", ...
This function return the repsone object with the given url.
[ "This", "function", "return", "the", "repsone", "object", "with", "the", "given", "url", "." ]
[ "\"\"\"\n This function return the repsone object with the given url.\n\n Parameters\n ----------\n url : `str`\n The url to redirect to.\n \"\"\"" ]
[ { "param": "url", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "url", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
method_not_allowed
None
def method_not_allowed(self, start_response: typing.Callable) -> None: """ This method will return a 405 error. """ start_response("405 Method Not Allowed", [("Content-Type", "text/html")]) return [b'405 Method Not Allowed']
This method will return a 405 error.
This method will return a 405 error.
[ "This", "method", "will", "return", "a", "405", "error", "." ]
def method_not_allowed(self, start_response: typing.Callable) -> None: start_response("405 Method Not Allowed", [("Content-Type", "text/html")]) return [b'405 Method Not Allowed']
[ "def", "method_not_allowed", "(", "self", ",", "start_response", ":", "typing", ".", "Callable", ")", "->", "None", ":", "start_response", "(", "\"405 Method Not Allowed\"", ",", "[", "(", "\"Content-Type\"", ",", "\"text/html\"", ")", "]", ")", "return", "[", ...
This method will return a 405 error.
[ "This", "method", "will", "return", "a", "405", "error", "." ]
[ "\"\"\"\n This method will return a 405 error.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_response", "type": "typing.Callable", "docstring": null, ...
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
not_found
None
def not_found(self, start_response: typing.Callable) -> None: """ This method will return a 404 error. """ start_response("404 Not Found", [("Content-Type", "text/html")]) return [b'404 Not Found']
This method will return a 404 error.
This method will return a 404 error.
[ "This", "method", "will", "return", "a", "404", "error", "." ]
def not_found(self, start_response: typing.Callable) -> None: start_response("404 Not Found", [("Content-Type", "text/html")]) return [b'404 Not Found']
[ "def", "not_found", "(", "self", ",", "start_response", ":", "typing", ".", "Callable", ")", "->", "None", ":", "start_response", "(", "\"404 Not Found\"", ",", "[", "(", "\"Content-Type\"", ",", "\"text/html\"", ")", "]", ")", "return", "[", "b'404 Not Found'...
This method will return a 404 error.
[ "This", "method", "will", "return", "a", "404", "error", "." ]
[ "\"\"\"\n This method will return a 404 error.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_response", "type": "typing.Callable", "docstring": null, ...
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
no_body_found
None
def no_body_found(self, start_response: typing.Callable) -> None: """ This method will return a 404 error. """ start_response("404 Not Found", [("Content-Type", "text/html")]) return [b'No body returned']
This method will return a 404 error.
This method will return a 404 error.
[ "This", "method", "will", "return", "a", "404", "error", "." ]
def no_body_found(self, start_response: typing.Callable) -> None: start_response("404 Not Found", [("Content-Type", "text/html")]) return [b'No body returned']
[ "def", "no_body_found", "(", "self", ",", "start_response", ":", "typing", ".", "Callable", ")", "->", "None", ":", "start_response", "(", "\"404 Not Found\"", ",", "[", "(", "\"Content-Type\"", ",", "\"text/html\"", ")", "]", ")", "return", "[", "b'No body re...
This method will return a 404 error.
[ "This", "method", "will", "return", "a", "404", "error", "." ]
[ "\"\"\"\n This method will return a 404 error.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_response", "type": "typing.Callable", "docstring": null, ...
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
error_handler
None
def error_handler(self, code: int, start_response: typing.Callable) -> None: """ This method is the entry point of the error handler. It will dispatch the error to the callback of the error rule. """ error_rule = self.get_error_rule(code) if error_rule is None: ...
This method is the entry point of the error handler. It will dispatch the error to the callback of the error rule.
This method is the entry point of the error handler. It will dispatch the error to the callback of the error rule.
[ "This", "method", "is", "the", "entry", "point", "of", "the", "error", "handler", ".", "It", "will", "dispatch", "the", "error", "to", "the", "callback", "of", "the", "error", "rule", "." ]
def error_handler(self, code: int, start_response: typing.Callable) -> None: error_rule = self.get_error_rule(code) if error_rule is None: self.not_found(start_response) return [self.get_isinstance(self.get_error_rule(404).callback())] start_response(f"{self.get_status_me...
[ "def", "error_handler", "(", "self", ",", "code", ":", "int", ",", "start_response", ":", "typing", ".", "Callable", ")", "->", "None", ":", "error_rule", "=", "self", ".", "get_error_rule", "(", "code", ")", "if", "error_rule", "is", "None", ":", "self"...
This method is the entry point of the error handler.
[ "This", "method", "is", "the", "entry", "point", "of", "the", "error", "handler", "." ]
[ "\"\"\"\n This method is the entry point of the error handler.\n It will dispatch the error to the callback of the error rule.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "code", "type": "int" }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "int", "docstring": null, "docstring_tokens": ...
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
request_handler
None
def request_handler(self, callback: typing.Any, status_code: int, headers: typing.List[typing.Tuple[str]], start_response: typing.Callable) -> None: """ This method is the entry point of the request handler. It will dispatch the request to the callback of the rule. If the req...
This method is the entry point of the request handler. It will dispatch the request to the callback of the rule. If the request doesn't match any rule, it will return a 404 error.
This method is the entry point of the request handler. It will dispatch the request to the callback of the rule. If the request doesn't match any rule, it will return a 404 error.
[ "This", "method", "is", "the", "entry", "point", "of", "the", "request", "handler", ".", "It", "will", "dispatch", "the", "request", "to", "the", "callback", "of", "the", "rule", ".", "If", "the", "request", "doesn", "'", "t", "match", "any", "rule", "...
def request_handler(self, callback: typing.Any, status_code: int, headers: typing.List[typing.Tuple[str]], start_response: typing.Callable) -> None: if isinstance(callback, Respone): self.error_handler(callback.status_code, start_response) start_response(callback.status_code, callback._f...
[ "def", "request_handler", "(", "self", ",", "callback", ":", "typing", ".", "Any", ",", "status_code", ":", "int", ",", "headers", ":", "typing", ".", "List", "[", "typing", ".", "Tuple", "[", "str", "]", "]", ",", "start_response", ":", "typing", ".",...
This method is the entry point of the request handler.
[ "This", "method", "is", "the", "entry", "point", "of", "the", "request", "handler", "." ]
[ "\"\"\"\n This method is the entry point of the request handler.\n It will dispatch the request to the callback of the rule.\n If the request doesn't match any rule, it will return a 404 error.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "callback", "type": "typing.Any" }, { "param": "status_code", "type": "int" }, { "param": "headers", "type": "typing.List[typing.Tuple[str]]" }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "typing.Any", "docstring": null, "docstrin...
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
middleware_handler
None
def middleware_handler(self, middleware: typing.Callable, start_response: typing.Callable) -> None: """ This method is responsible for handling the middlewares. """ resp = middleware() if isinstance(resp, Respone): start_response(self.get_status_message(resp.statu...
This method is responsible for handling the middlewares.
This method is responsible for handling the middlewares.
[ "This", "method", "is", "responsible", "for", "handling", "the", "middlewares", "." ]
def middleware_handler(self, middleware: typing.Callable, start_response: typing.Callable) -> None: resp = middleware() if isinstance(resp, Respone): start_response(self.get_status_message(resp.status_code), resp._form_header()) if resp is not None: return self.ge...
[ "def", "middleware_handler", "(", "self", ",", "middleware", ":", "typing", ".", "Callable", ",", "start_response", ":", "typing", ".", "Callable", ")", "->", "None", ":", "resp", "=", "middleware", "(", ")", "if", "isinstance", "(", "resp", ",", "Respone"...
This method is responsible for handling the middlewares.
[ "This", "method", "is", "responsible", "for", "handling", "the", "middlewares", "." ]
[ "\"\"\"\n This method is responsible for handling the middlewares.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "middleware", "type": "typing.Callable" }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "middleware", "type": "typing.Callable", "docstring": null, "d...
466ba3135f15eb9a969f9b9b67c0971e81e65a5c
xArty4/TinyAPI
tinyapi/serving.py
[ "MIT" ]
Python
traceback_handler
None
def traceback_handler(self,traceback: typing.Any ,start_response: typing.Callable) -> None: """ This method is responsible for handling the tracebacks. When a traceback is raised, it will return a 500 error. """ start_response(self.get_status_message(500), [("Content-Type...
This method is responsible for handling the tracebacks. When a traceback is raised, it will return a 500 error.
This method is responsible for handling the tracebacks. When a traceback is raised, it will return a 500 error.
[ "This", "method", "is", "responsible", "for", "handling", "the", "tracebacks", ".", "When", "a", "traceback", "is", "raised", "it", "will", "return", "a", "500", "error", "." ]
def traceback_handler(self,traceback: typing.Any ,start_response: typing.Callable) -> None: start_response(self.get_status_message(500), [("Content-Type", "text/html")]) return self.get_isinstance(traceback)
[ "def", "traceback_handler", "(", "self", ",", "traceback", ":", "typing", ".", "Any", ",", "start_response", ":", "typing", ".", "Callable", ")", "->", "None", ":", "start_response", "(", "self", ".", "get_status_message", "(", "500", ")", ",", "[", "(", ...
This method is responsible for handling the tracebacks.
[ "This", "method", "is", "responsible", "for", "handling", "the", "tracebacks", "." ]
[ "\"\"\"\n This method is responsible for handling the tracebacks.\n When a traceback is raised, it will return a 500 error.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "traceback", "type": "typing.Any" }, { "param": "start_response", "type": "typing.Callable" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "traceback", "type": "typing.Any", "docstring": null, "docstri...
83d9a4966d01fa0ee2efe5ac058cee453ed13369
xArty4/TinyAPI
tinyapi/wrappers/respone.py
[ "MIT" ]
Python
add_header
None
def add_header(self, key: str, value: str) -> None: """ This method adds a header to the respone. """ self.headers[key] = value
This method adds a header to the respone.
This method adds a header to the respone.
[ "This", "method", "adds", "a", "header", "to", "the", "respone", "." ]
def add_header(self, key: str, value: str) -> None: self.headers[key] = value
[ "def", "add_header", "(", "self", ",", "key", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "self", ".", "headers", "[", "key", "]", "=", "value" ]
This method adds a header to the respone.
[ "This", "method", "adds", "a", "header", "to", "the", "respone", "." ]
[ "\"\"\"\n This method adds a header to the respone.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "key", "type": "str" }, { "param": "value", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "str", "docstring": null, "docstring_tokens": [...
83d9a4966d01fa0ee2efe5ac058cee453ed13369
xArty4/TinyAPI
tinyapi/wrappers/respone.py
[ "MIT" ]
Python
remove_header
None
def remove_header(self, key: str) -> None: """ This method removes a header from the respone. """ del self.headers[key]
This method removes a header from the respone.
This method removes a header from the respone.
[ "This", "method", "removes", "a", "header", "from", "the", "respone", "." ]
def remove_header(self, key: str) -> None: del self.headers[key]
[ "def", "remove_header", "(", "self", ",", "key", ":", "str", ")", "->", "None", ":", "del", "self", ".", "headers", "[", "key", "]" ]
This method removes a header from the respone.
[ "This", "method", "removes", "a", "header", "from", "the", "respone", "." ]
[ "\"\"\"\n This method removes a header from the respone.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "key", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "str", "docstring": null, "docstring_tokens": [...
83d9a4966d01fa0ee2efe5ac058cee453ed13369
xArty4/TinyAPI
tinyapi/wrappers/respone.py
[ "MIT" ]
Python
add_cookie
None
def add_cookie(self, key: str, value: str) -> None: """ This method adds a cookie to the respone. """ self.cookies[key] = value
This method adds a cookie to the respone.
This method adds a cookie to the respone.
[ "This", "method", "adds", "a", "cookie", "to", "the", "respone", "." ]
def add_cookie(self, key: str, value: str) -> None: self.cookies[key] = value
[ "def", "add_cookie", "(", "self", ",", "key", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "self", ".", "cookies", "[", "key", "]", "=", "value" ]
This method adds a cookie to the respone.
[ "This", "method", "adds", "a", "cookie", "to", "the", "respone", "." ]
[ "\"\"\"\n This method adds a cookie to the respone.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "key", "type": "str" }, { "param": "value", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "str", "docstring": null, "docstring_tokens": [...
83d9a4966d01fa0ee2efe5ac058cee453ed13369
xArty4/TinyAPI
tinyapi/wrappers/respone.py
[ "MIT" ]
Python
remove_cookie
None
def remove_cookie(self, key: str) -> None: """ This method removes a cookie from the respone. """ del self.cookies[key]
This method removes a cookie from the respone.
This method removes a cookie from the respone.
[ "This", "method", "removes", "a", "cookie", "from", "the", "respone", "." ]
def remove_cookie(self, key: str) -> None: del self.cookies[key]
[ "def", "remove_cookie", "(", "self", ",", "key", ":", "str", ")", "->", "None", ":", "del", "self", ".", "cookies", "[", "key", "]" ]
This method removes a cookie from the respone.
[ "This", "method", "removes", "a", "cookie", "from", "the", "respone", "." ]
[ "\"\"\"\n This method removes a cookie from the respone.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "key", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "str", "docstring": null, "docstring_tokens": [...
83d9a4966d01fa0ee2efe5ac058cee453ed13369
xArty4/TinyAPI
tinyapi/wrappers/respone.py
[ "MIT" ]
Python
_form_header
<not_specific>
def _form_header(self): """ This method returns the headers of the respone. """ if self.cookies != {}: self.headers["Set-Cookie"] = [ f"{key}={value};" for key,value in self.cookies.items() ] if self.mimi_type: self.headers[...
This method returns the headers of the respone.
This method returns the headers of the respone.
[ "This", "method", "returns", "the", "headers", "of", "the", "respone", "." ]
def _form_header(self): if self.cookies != {}: self.headers["Set-Cookie"] = [ f"{key}={value};" for key,value in self.cookies.items() ] if self.mimi_type: self.headers['Content-Type'] = self.mimi_type if self.body: self.headers['Con...
[ "def", "_form_header", "(", "self", ")", ":", "if", "self", ".", "cookies", "!=", "{", "}", ":", "self", ".", "headers", "[", "\"Set-Cookie\"", "]", "=", "[", "f\"{key}={value};\"", "for", "key", ",", "value", "in", "self", ".", "cookies", ".", "items"...
This method returns the headers of the respone.
[ "This", "method", "returns", "the", "headers", "of", "the", "respone", "." ]
[ "\"\"\"\n This method returns the headers of the respone.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): """Grants an user to site admin. :form username: The username of granted user. :<header Authorization: Huskar Token (See :ref:`token`) :status 404: The user is not found. :status 200: The user is a site admin already. :status 201: The user has been grante...
Grants an user to site admin. :form username: The username of granted user. :<header Authorization: Huskar Token (See :ref:`token`) :status 404: The user is not found. :status 200: The user is a site admin already. :status 201: The user has been granted successfully.
Grants an user to site admin.
[ "Grants", "an", "user", "to", "site", "admin", "." ]
def post(self): g.auth.require_admin('only admin can add huskar admin') user = self._get_user_or_404(request.form['username']) if user and user.is_admin: return api_response(), 200 with audit_log(audit_log.types.GRANT_HUSKAR_ADMIN, user=user): user.grant_admin() ...
[ "def", "post", "(", "self", ")", ":", "g", ".", "auth", ".", "require_admin", "(", "'only admin can add huskar admin'", ")", "user", "=", "self", ".", "_get_user_or_404", "(", "request", ".", "form", "[", "'username'", "]", ")", "if", "user", "and", "user"...
Grants an user to site admin.
[ "Grants", "an", "user", "to", "site", "admin", "." ]
[ "\"\"\"Grants an user to site admin.\n\n :form username: The username of granted user.\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 404: The user is not found.\n :status 200: The user is a site admin already.\n :status 201: The user has been granted successf...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "form", "docstring": "The userna...
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, username): """Dismisses an user from site admin. :form username: The username of dismissed user. :<header Authorization: Huskar Token (See :ref:`token`) :status 403: The dismissing is not permitted. :status 404: The user is not found. :status 200: The us...
Dismisses an user from site admin. :form username: The username of dismissed user. :<header Authorization: Huskar Token (See :ref:`token`) :status 403: The dismissing is not permitted. :status 404: The user is not found. :status 200: The user has been dismissed successfully. ...
Dismisses an user from site admin.
[ "Dismisses", "an", "user", "from", "site", "admin", "." ]
def delete(self, username): g.auth.require_admin('only admin can delete admin') user = self._get_user_or_404(username) if user.username == g.auth.username: abort(403, 'It is not allowed to dismiss yourself') with audit_log(audit_log.types.DISMISS_HUSKAR_ADMIN, user=user): ...
[ "def", "delete", "(", "self", ",", "username", ")", ":", "g", ".", "auth", ".", "require_admin", "(", "'only admin can delete admin'", ")", "user", "=", "self", ".", "_get_user_or_404", "(", "username", ")", "if", "user", ".", "username", "==", "g", ".", ...
Dismisses an user from site admin.
[ "Dismisses", "an", "user", "from", "site", "admin", "." ]
[ "\"\"\"Dismisses an user from site admin.\n\n :form username: The username of dismissed user.\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 403: The dismissing is not permitted.\n :status 404: The user is not found.\n :status 200: The user has been dismissed ...
[ { "param": "self", "type": null }, { "param": "username", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "username", "type": null, "docstring": null, "docstring_tokens...
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, application_name): """Grants an user to have specified authority of current application. :param application_name: The name of application. :form authority: The authority name, ``read`` or ``write``. :form username: The username of granting one. :<header Authorizat...
Grants an user to have specified authority of current application. :param application_name: The name of application. :form authority: The authority name, ``read`` or ``write``. :form username: The username of granting one. :<header Authorization: Huskar Token (See :ref:`token`) ...
Grants an user to have specified authority of current application.
[ "Grants", "an", "user", "to", "have", "specified", "authority", "of", "current", "application", "." ]
def post(self, application_name): authority = request.form['authority'].strip() user = self._get_user_or_400(request.form['username'].strip()) application = self._get_application_or_404(application_name) with audit_log(audit_log.types.GRANT_APPLICATION_AUTH, user=u...
[ "def", "post", "(", "self", ",", "application_name", ")", ":", "authority", "=", "request", ".", "form", "[", "'authority'", "]", ".", "strip", "(", ")", "user", "=", "self", ".", "_get_user_or_400", "(", "request", ".", "form", "[", "'username'", "]", ...
Grants an user to have specified authority of current application.
[ "Grants", "an", "user", "to", "have", "specified", "authority", "of", "current", "application", "." ]
[ "\"\"\"Grants an user to have specified authority of current application.\n\n :param application_name: The name of application.\n :form authority: The authority name, ``read`` or ``write``.\n :form username: The username of granting one.\n :<header Authorization: Huskar Token (See :ref:`...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of applicat...
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, application_name): """Dismisses an user from specified authority of current application. :param application_name: The name of application. :form authority: The authority name, ``read`` or ``write``. :form username: The username of dismissing one. :<header Author...
Dismisses an user from specified authority of current application. :param application_name: The name of application. :form authority: The authority name, ``read`` or ``write``. :form username: The username of dismissing one. :<header Authorization: Huskar Token (See :ref:`token`) ...
Dismisses an user from specified authority of current application.
[ "Dismisses", "an", "user", "from", "specified", "authority", "of", "current", "application", "." ]
def delete(self, application_name): authority = request.form['authority'].strip() user = self._get_user_or_400(request.form['username'].strip()) application = self._get_application_or_404(application_name) with audit_log(audit_log.types.DISMISS_APPLICATION_AUTH, us...
[ "def", "delete", "(", "self", ",", "application_name", ")", ":", "authority", "=", "request", ".", "form", "[", "'authority'", "]", ".", "strip", "(", ")", "user", "=", "self", ".", "_get_user_or_400", "(", "request", ".", "form", "[", "'username'", "]",...
Dismisses an user from specified authority of current application.
[ "Dismisses", "an", "user", "from", "specified", "authority", "of", "current", "application", "." ]
[ "\"\"\"Dismisses an user from specified authority of current application.\n\n :param application_name: The name of application.\n :form authority: The authority name, ``read`` or ``write``.\n :form username: The username of dismissing one.\n :<header Authorization: Huskar Token (See :ref...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of applicat...
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): """Obtains an user token by checking username and password. :form username: Required. The username of user. :form password: Required. The password of user. :form expiration: Optional. The life time in seconds of the token. ``0`` or omitted will ...
Obtains an user token by checking username and password. :form username: Required. The username of user. :form password: Required. The password of user. :form expiration: Optional. The life time in seconds of the token. ``0`` or omitted will make token be expired in 30...
Obtains an user token by checking username and password.
[ "Obtains", "an", "user", "token", "by", "checking", "username", "and", "password", "." ]
def post(self): username = request.form['username'].strip() password = request.form['password'].strip() expires_in = request.form.get('expiration', type=int, default=0) if expires_in > 0: expires_in = min(expires_in, settings.ADMIN_MAX_EXPIRATION) else: ex...
[ "def", "post", "(", "self", ")", ":", "username", "=", "request", ".", "form", "[", "'username'", "]", ".", "strip", "(", ")", "password", "=", "request", ".", "form", "[", "'password'", "]", ".", "strip", "(", ")", "expires_in", "=", "request", ".",...
Obtains an user token by checking username and password.
[ "Obtains", "an", "user", "token", "by", "checking", "username", "and", "password", "." ]
[ "\"\"\"Obtains an user token by checking username and password.\n\n :form username: Required. The username of user.\n :form password: Required. The password of user.\n :form expiration: Optional. The life time in seconds of the token.\n ``0`` or omitted will make token ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "form", "docstring": "Required. ...
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, team_name): """Grants an user to the admin of specified team. :param team_name: The name of specified team. :form username: The username of granting user. :<header Authorization: Huskar Token (See :ref:`token`) :status 400: The granting user is not found. ...
Grants an user to the admin of specified team. :param team_name: The name of specified team. :form username: The username of granting user. :<header Authorization: Huskar Token (See :ref:`token`) :status 400: The granting user is not found. :status 404: The team with specified n...
Grants an user to the admin of specified team.
[ "Grants", "an", "user", "to", "the", "admin", "of", "specified", "team", "." ]
def post(self, team_name): g.auth.require_admin('only huskar admin can add team admin') user_name = request.form['username'].strip() team = self._get_team_or_404(team_name) user = self._get_user_or_400(user_name) if team.check_auth(Authority.WRITE, user.id): return ap...
[ "def", "post", "(", "self", ",", "team_name", ")", ":", "g", ".", "auth", ".", "require_admin", "(", "'only huskar admin can add team admin'", ")", "user_name", "=", "request", ".", "form", "[", "'username'", "]", ".", "strip", "(", ")", "team", "=", "self...
Grants an user to the admin of specified team.
[ "Grants", "an", "user", "to", "the", "admin", "of", "specified", "team", "." ]
[ "\"\"\"Grants an user to the admin of specified team.\n\n :param team_name: The name of specified team.\n :form username: The username of granting user.\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 400: The granting user is not found.\n :status 404: The team...
[ { "param": "self", "type": null }, { "param": "team_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "team_name", "type": null, "docstring": "The name of specified team....
30711f94e68e9e3e78d6a1cb25d729cae90a187e
mowangdk/huskar
huskar_api/api/auth.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, team_name): """Dismisses an user from the admin of specified team. :param team_name: The name of specified team. :form username: The username of dismissing user. :<header Authorization: Huskar Token (See :ref:`token`) :status 400: The user is not admin of specif...
Dismisses an user from the admin of specified team. :param team_name: The name of specified team. :form username: The username of dismissing user. :<header Authorization: Huskar Token (See :ref:`token`) :status 400: The user is not admin of specified team. :status 404: The team ...
Dismisses an user from the admin of specified team.
[ "Dismisses", "an", "user", "from", "the", "admin", "of", "specified", "team", "." ]
def delete(self, team_name): g.auth.require_admin('only huskar admin can delete team admin') user_name = request.form['username'].strip() team = self._get_team_or_404(team_name) user = self._get_user_or_400(user_name) if not team.check_auth(Authority.WRITE, user.id): ...
[ "def", "delete", "(", "self", ",", "team_name", ")", ":", "g", ".", "auth", ".", "require_admin", "(", "'only huskar admin can delete team admin'", ")", "user_name", "=", "request", ".", "form", "[", "'username'", "]", ".", "strip", "(", ")", "team", "=", ...
Dismisses an user from the admin of specified team.
[ "Dismisses", "an", "user", "from", "the", "admin", "of", "specified", "team", "." ]
[ "\"\"\"Dismisses an user from the admin of specified team.\n\n :param team_name: The name of specified team.\n :form username: The username of dismissing user.\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 400: The user is not admin of specified team.\n :stat...
[ { "param": "self", "type": null }, { "param": "team_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "team_name", "type": null, "docstring": "The name of specified team....
5a9f2f04dc16d614156f1968435a8b6e34302a42
mowangdk/huskar
huskar_api/models/tree/common.py
[ "MIT" ]
Python
parse
<not_specific>
def parse(cls, path, base_path=''): """Parses a string path and creates a structured path. :param path: The path of a ZooKeeper node. :param base_path: The base path such as ``/huskar``. :returns Path: A path tuple. For unknown path, none path will be returned. ...
Parses a string path and creates a structured path. :param path: The path of a ZooKeeper node. :param base_path: The base path such as ``/huskar``. :returns Path: A path tuple. For unknown path, none path will be returned.
Parses a string path and creates a structured path.
[ "Parses", "a", "string", "path", "and", "creates", "a", "structured", "path", "." ]
def parse(cls, path, base_path=''): base_path = '{0}/'.format(base_path.rstrip('/')) if not path.startswith(base_path): return cls.make() components = path[len(base_path):].rstrip('/').split('/') if components == [''] or len(components) > 4: return cls.make() ...
[ "def", "parse", "(", "cls", ",", "path", ",", "base_path", "=", "''", ")", ":", "base_path", "=", "'{0}/'", ".", "format", "(", "base_path", ".", "rstrip", "(", "'/'", ")", ")", "if", "not", "path", ".", "startswith", "(", "base_path", ")", ":", "r...
Parses a string path and creates a structured path.
[ "Parses", "a", "string", "path", "and", "creates", "a", "structured", "path", "." ]
[ "\"\"\"Parses a string path and creates a structured path.\n\n :param path: The path of a ZooKeeper node.\n :param base_path: The base path such as ``/huskar``.\n :returns Path: A path tuple. For unknown path, none path will be\n returned.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "path", "type": null }, { "param": "base_path", "type": null } ]
{ "returns": [ { "docstring": "A path tuple. For unknown path, none path will be\nreturned.", "docstring_tokens": [ "A", "path", "tuple", ".", "For", "unknown", "path", "none", "path", "will", "be", "return...
7dc5460672252a768da1bfc12edc56ba10818e2c
mowangdk/huskar
huskar_api/api/service_instance.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, application_name, cluster_name, key): """Updates the weight of specified service instance. :param application_name: The name of application. :param cluster_name: The name of cluster. :param key: The key of service instance. :form weight: The target weight of insta...
Updates the weight of specified service instance. :param application_name: The name of application. :param cluster_name: The name of cluster. :param key: The key of service instance. :form weight: The target weight of instance. It should be a positive integer. ...
Updates the weight of specified service instance.
[ "Updates", "the", "weight", "of", "specified", "service", "instance", "." ]
def post(self, application_name, cluster_name, key): check_application_auth(application_name, Authority.WRITE) check_cluster_name(cluster_name, application_name) validate_fields(instance_schema, { 'application': application_name, 'cluster': cluster_name, 'key'...
[ "def", "post", "(", "self", ",", "application_name", ",", "cluster_name", ",", "key", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "check_cluster_name", "(", "cluster_name", ",", "application_name", ")", "valida...
Updates the weight of specified service instance.
[ "Updates", "the", "weight", "of", "specified", "service", "instance", "." ]
[ "\"\"\"Updates the weight of specified service instance.\n\n :param application_name: The name of application.\n :param cluster_name: The name of cluster.\n :param key: The key of service instance.\n :form weight: The target weight of instance. It should be a positive\n ...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null }, { "param": "key", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of applicat...
078f12048a1526270748793c94d998f54e8af714
mowangdk/huskar
huskar_api/models/route/resolver.py
[ "MIT" ]
Python
resolve
<not_specific>
def resolve(self, cluster_name, from_application_name=None, intent=None, force_route_cluster_name=None): """Resolves the cluster name and returns the name of physical cluster. There are two steps to resolve a cluster. First, the route table will be checked if ``from_application_...
Resolves the cluster name and returns the name of physical cluster. There are two steps to resolve a cluster. First, the route table will be checked if ``from_application_name`` is provided. Then, the resolved cluster will be resolved again, but uses the symlink configuration. There is...
Resolves the cluster name and returns the name of physical cluster. There are two steps to resolve a cluster. First, the route table will be checked if ``from_application_name`` is provided. Then, the resolved cluster will be resolved again, but uses the symlink configuration.
[ "Resolves", "the", "cluster", "name", "and", "returns", "the", "name", "of", "physical", "cluster", ".", "There", "are", "two", "steps", "to", "resolve", "a", "cluster", ".", "First", "the", "route", "table", "will", "be", "checked", "if", "`", "`", "fro...
def resolve(self, cluster_name, from_application_name=None, intent=None, force_route_cluster_name=None): cluster_info = None resolved_name = cluster_name if from_application_name: resolve_via_default = False try: cluster_info = self.get_clu...
[ "def", "resolve", "(", "self", ",", "cluster_name", ",", "from_application_name", "=", "None", ",", "intent", "=", "None", ",", "force_route_cluster_name", "=", "None", ")", ":", "cluster_info", "=", "None", "resolved_name", "=", "cluster_name", "if", "from_appl...
Resolves the cluster name and returns the name of physical cluster.
[ "Resolves", "the", "cluster", "name", "and", "returns", "the", "name", "of", "physical", "cluster", "." ]
[ "\"\"\"Resolves the cluster name and returns the name of physical cluster.\n\n There are two steps to resolve a cluster. First, the route table will\n be checked if ``from_application_name`` is provided. Then, the resolved\n cluster will be resolved again, but uses the symlink configuration.\n\...
[ { "param": "self", "type": null }, { "param": "cluster_name", "type": null }, { "param": "from_application_name", "type": null }, { "param": "intent", "type": null }, { "param": "force_route_cluster_name", "type": null } ]
{ "returns": [ { "docstring": "The physical cluster name or ``None``.", "docstring_tokens": [ "The", "physical", "cluster", "name", "or", "`", "`", "None", "`", "`", "." ], "type": null } ], "ra...
3c105c0447c1b51c1a21625bc7c8a22c35c47fdf
mowangdk/huskar
huskar_api/models/tree/watcher.py
[ "MIT" ]
Python
limit_cluster_name
null
def limit_cluster_name(self, application_name, type_name, cluster_name): """Adds a whitelist item to limit events by cluster name. :param application_name: The appid of subtree. (e.g. ``base.foo``) :param type_name: The type of subtree. (e.g. ``service``) :param cluster_name: Only added...
Adds a whitelist item to limit events by cluster name. :param application_name: The appid of subtree. (e.g. ``base.foo``) :param type_name: The type of subtree. (e.g. ``service``) :param cluster_name: Only added cluster names will be shown.
Adds a whitelist item to limit events by cluster name.
[ "Adds", "a", "whitelist", "item", "to", "limit", "events", "by", "cluster", "name", "." ]
def limit_cluster_name(self, application_name, type_name, cluster_name): self.cluster_whitelist[application_name, type_name].add(cluster_name)
[ "def", "limit_cluster_name", "(", "self", ",", "application_name", ",", "type_name", ",", "cluster_name", ")", ":", "self", ".", "cluster_whitelist", "[", "application_name", ",", "type_name", "]", ".", "add", "(", "cluster_name", ")" ]
Adds a whitelist item to limit events by cluster name.
[ "Adds", "a", "whitelist", "item", "to", "limit", "events", "by", "cluster", "name", "." ]
[ "\"\"\"Adds a whitelist item to limit events by cluster name.\n\n :param application_name: The appid of subtree. (e.g. ``base.foo``)\n :param type_name: The type of subtree. (e.g. ``service``)\n :param cluster_name: Only added cluster names will be shown.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "type_name", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The appid of subtree...
974d1f5e1e000b529676b3993d31187a8dff1f1d
mowangdk/huskar
huskar_api/models/auth/user.py
[ "MIT" ]
Python
parse_username_in_token
<not_specific>
def parse_username_in_token(cls, secret_key, token, raises=False): """Parses the token and returns the username inside it. :param str secret_key: The secret key for HMAC signature of JWT. :param str token: The token value. :param bool raises: ``True`` if you want to raise exceptions whi...
Parses the token and returns the username inside it. :param str secret_key: The secret key for HMAC signature of JWT. :param str token: The token value. :param bool raises: ``True`` if you want to raise exceptions while token is invalid or expired. :returns: ...
Parses the token and returns the username inside it.
[ "Parses", "the", "token", "and", "returns", "the", "username", "inside", "it", "." ]
def parse_username_in_token(cls, secret_key, token, raises=False): try: res = _load_token(secret_key, token, raises) if res is None: res = _load_fallback_token(token) return res except Exception: res = _load_fallback_token(token) ...
[ "def", "parse_username_in_token", "(", "cls", ",", "secret_key", ",", "token", ",", "raises", "=", "False", ")", ":", "try", ":", "res", "=", "_load_token", "(", "secret_key", ",", "token", ",", "raises", ")", "if", "res", "is", "None", ":", "res", "="...
Parses the token and returns the username inside it.
[ "Parses", "the", "token", "and", "returns", "the", "username", "inside", "it", "." ]
[ "\"\"\"Parses the token and returns the username inside it.\n\n :param str secret_key: The secret key for HMAC signature of JWT.\n :param str token: The token value.\n :param bool raises: ``True`` if you want to raise exceptions while\n token is invalid or expired.\n ...
[ { "param": "cls", "type": null }, { "param": "secret_key", "type": null }, { "param": "token", "type": null }, { "param": "raises", "type": null } ]
{ "returns": [ { "docstring": "The username string or ``None``.", "docstring_tokens": [ "The", "username", "string", "or", "`", "`", "None", "`", "`", "." ], "type": null } ], "raises": [], "params": ...
974d1f5e1e000b529676b3993d31187a8dff1f1d
mowangdk/huskar
huskar_api/models/auth/user.py
[ "MIT" ]
Python
_set_active_status
null
def _set_active_status(self, is_active): """Set value of `is_active` column to disable or active this user. """ with DBSession().close_on_exit(False): self.is_active = is_active self.__class__.get_id_by_name.flush(self.username) self.__class__.get_ids_of_norm...
Set value of `is_active` column to disable or active this user.
Set value of `is_active` column to disable or active this user.
[ "Set", "value", "of", "`", "is_active", "`", "column", "to", "disable", "or", "active", "this", "user", "." ]
def _set_active_status(self, is_active): with DBSession().close_on_exit(False): self.is_active = is_active self.__class__.get_id_by_name.flush(self.username) self.__class__.get_ids_of_normal.flush() self.__class__.flush([self.id])
[ "def", "_set_active_status", "(", "self", ",", "is_active", ")", ":", "with", "DBSession", "(", ")", ".", "close_on_exit", "(", "False", ")", ":", "self", ".", "is_active", "=", "is_active", "self", ".", "__class__", ".", "get_id_by_name", ".", "flush", "(...
Set value of `is_active` column to disable or active this user.
[ "Set", "value", "of", "`", "is_active", "`", "column", "to", "disable", "or", "active", "this", "user", "." ]
[ "\"\"\"Set value of `is_active` column to\n disable or active this user.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "is_active", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_active", "type": null, "docstring": null, "docstring_token...
f234e73f7ab40e7a73006222d1ff3c3fba90156b
mowangdk/huskar
huskar_api/api/long_polling.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): """Subscribes changes of service, switch or config via HTTP long polling connection. This API accepts requests in following schema:: { "service": { # "service" / "switch" / "config" "base.foo": [ # the application name ...
Subscribes changes of service, switch or config via HTTP long polling connection. This API accepts requests in following schema:: { "service": { # "service" / "switch" / "config" "base.foo": [ # the application name "cluster-bar", ...
Subscribes changes of service, switch or config via HTTP long polling connection. This API accepts requests in following schema:. The events in all clusters will be subscribed, if the cluster list is empty. The placeholder of cluster name accepts "intent" also, if you enables the route mode via the HTTP header `...
[ "Subscribes", "changes", "of", "service", "switch", "or", "config", "via", "HTTP", "long", "polling", "connection", ".", "This", "API", "accepts", "requests", "in", "following", "schema", ":", ".", "The", "events", "in", "all", "clusters", "will", "be", "sub...
def post(self): trigger = request.args.get('trigger', type=int, default=1) life_span = request.args.get('life_span', type=int, default=0) request_data = self.get_request_data() tree_watcher = tree_hub.make_watcher( with_initial=bool(trigger), life_span=get_life_sp...
[ "def", "post", "(", "self", ")", ":", "trigger", "=", "request", ".", "args", ".", "get", "(", "'trigger'", ",", "type", "=", "int", ",", "default", "=", "1", ")", "life_span", "=", "request", ".", "args", ".", "get", "(", "'life_span'", ",", "type...
Subscribes changes of service, switch or config via HTTP long polling connection.
[ "Subscribes", "changes", "of", "service", "switch", "or", "config", "via", "HTTP", "long", "polling", "connection", "." ]
[ "\"\"\"Subscribes changes of service, switch or config via HTTP long\n polling connection.\n\n This API accepts requests in following schema::\n\n {\n \"service\": { # \"service\" / \"switch\" / \"config\"\n \"base.foo\": [ # the application name\n ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "ref", "docstring": "`Traffic Co...
f234e73f7ab40e7a73006222d1ff3c3fba90156b
mowangdk/huskar
huskar_api/api/long_polling.py
[ "MIT" ]
Python
perform
null
def perform(self, request_data, tree_watcher, tree_watcher_decorator): """Performs long polling session as an iterator. The iterator returned by this method will always generate a ``None`` in the first time. It indicates that the watcher is started and we could put the iterator into a r...
Performs long polling session as an iterator. The iterator returned by this method will always generate a ``None`` in the first time. It indicates that the watcher is started and we could put the iterator into a response stream now. .. note:: You should never touch the database (SQLAlc...
Performs long polling session as an iterator. The iterator returned by this method will always generate a ``None`` in the first time. It indicates that the watcher is started and we could put the iterator into a response stream now. : You should never touch the database (SQLAlchemy session) here or the connection may ...
[ "Performs", "long", "polling", "session", "as", "an", "iterator", ".", "The", "iterator", "returned", "by", "this", "method", "will", "always", "generate", "a", "`", "`", "None", "`", "`", "in", "the", "first", "time", ".", "It", "indicates", "that", "th...
def perform(self, request_data, tree_watcher, tree_watcher_decorator): self.declare_upstream_from_request(request_data) for type_name, application_names in request_data.items(): for application_name, cluster_names in application_names.items(): tree_watcher.watch(application_n...
[ "def", "perform", "(", "self", ",", "request_data", ",", "tree_watcher", ",", "tree_watcher_decorator", ")", ":", "self", ".", "declare_upstream_from_request", "(", "request_data", ")", "for", "type_name", ",", "application_names", "in", "request_data", ".", "items"...
Performs long polling session as an iterator.
[ "Performs", "long", "polling", "session", "as", "an", "iterator", "." ]
[ "\"\"\"Performs long polling session as an iterator.\n\n The iterator returned by this method will always generate a ``None``\n in the first time. It indicates that the watcher is started and we\n could put the iterator into a response stream now.\n\n .. note:: You should never touch the...
[ { "param": "self", "type": null }, { "param": "request_data", "type": null }, { "param": "tree_watcher", "type": null }, { "param": "tree_watcher_decorator", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request_data", "type": null, "docstring": null, "docstring_to...
f2622136e6829e17834956b82caa521de6171600
mowangdk/huskar
huskar_api/models/infra/utils.py
[ "MIT" ]
Python
parse_rfc1738_args
<not_specific>
def parse_rfc1738_args(url): """Parse URL with the RFC 1738.""" m = rfc1738_pattern.match(url) if m is None: raise ValueError('Cannot parse RFC 1738 URL: {!r}'.format(url)) return m.groupdict()
Parse URL with the RFC 1738.
Parse URL with the RFC 1738.
[ "Parse", "URL", "with", "the", "RFC", "1738", "." ]
def parse_rfc1738_args(url): m = rfc1738_pattern.match(url) if m is None: raise ValueError('Cannot parse RFC 1738 URL: {!r}'.format(url)) return m.groupdict()
[ "def", "parse_rfc1738_args", "(", "url", ")", ":", "m", "=", "rfc1738_pattern", ".", "match", "(", "url", ")", "if", "m", "is", "None", ":", "raise", "ValueError", "(", "'Cannot parse RFC 1738 URL: {!r}'", ".", "format", "(", "url", ")", ")", "return", "m"...
Parse URL with the RFC 1738.
[ "Parse", "URL", "with", "the", "RFC", "1738", "." ]
[ "\"\"\"Parse URL with the RFC 1738.\"\"\"" ]
[ { "param": "url", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "url", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f2622136e6829e17834956b82caa521de6171600
mowangdk/huskar
huskar_api/models/infra/utils.py
[ "MIT" ]
Python
extract_application_name
<not_specific>
def extract_application_name(url): """Parses the Sam URL and returns its application name. :param url: The URL string. :returns: The application name, or ``None`` if this is not a Sam URL. """ try: args = parse_rfc1738_args(url) except ValueError: return scheme = args['name'...
Parses the Sam URL and returns its application name. :param url: The URL string. :returns: The application name, or ``None`` if this is not a Sam URL.
Parses the Sam URL and returns its application name.
[ "Parses", "the", "Sam", "URL", "and", "returns", "its", "application", "name", "." ]
def extract_application_name(url): try: args = parse_rfc1738_args(url) except ValueError: return scheme = args['name'] or '' if scheme.startswith('sam+'): return args['ipv4host'] or args['ipv6host']
[ "def", "extract_application_name", "(", "url", ")", ":", "try", ":", "args", "=", "parse_rfc1738_args", "(", "url", ")", "except", "ValueError", ":", "return", "scheme", "=", "args", "[", "'name'", "]", "or", "''", "if", "scheme", ".", "startswith", "(", ...
Parses the Sam URL and returns its application name.
[ "Parses", "the", "Sam", "URL", "and", "returns", "its", "application", "name", "." ]
[ "\"\"\"Parses the Sam URL and returns its application name.\n\n :param url: The URL string.\n :returns: The application name, or ``None`` if this is not a Sam URL.\n \"\"\"" ]
[ { "param": "url", "type": null } ]
{ "returns": [ { "docstring": "The application name, or ``None`` if this is not a Sam URL.", "docstring_tokens": [ "The", "application", "name", "or", "`", "`", "None", "`", "`", "if", "this", "is", ...
f2622136e6829e17834956b82caa521de6171600
mowangdk/huskar
huskar_api/models/infra/utils.py
[ "MIT" ]
Python
extract_application_names
<not_specific>
def extract_application_names(urls): """Parses the Sam URLs and returns names of valid applications. :param urls: The list or dictionary of Sam URLs. :returns: The list or dictionary of application names. """ if isinstance(urls, dict): iterator = ( (key, extract_application_name...
Parses the Sam URLs and returns names of valid applications. :param urls: The list or dictionary of Sam URLs. :returns: The list or dictionary of application names.
Parses the Sam URLs and returns names of valid applications.
[ "Parses", "the", "Sam", "URLs", "and", "returns", "names", "of", "valid", "applications", "." ]
def extract_application_names(urls): if isinstance(urls, dict): iterator = ( (key, extract_application_name(url)) for key, url in urls.iteritems()) return {key: name for key, name in iterator if name} iterator = (extract_application_name(url) for url in urls) return [...
[ "def", "extract_application_names", "(", "urls", ")", ":", "if", "isinstance", "(", "urls", ",", "dict", ")", ":", "iterator", "=", "(", "(", "key", ",", "extract_application_name", "(", "url", ")", ")", "for", "key", ",", "url", "in", "urls", ".", "it...
Parses the Sam URLs and returns names of valid applications.
[ "Parses", "the", "Sam", "URLs", "and", "returns", "names", "of", "valid", "applications", "." ]
[ "\"\"\"Parses the Sam URLs and returns names of valid applications.\n\n :param urls: The list or dictionary of Sam URLs.\n :returns: The list or dictionary of application names.\n \"\"\"" ]
[ { "param": "urls", "type": null } ]
{ "returns": [ { "docstring": "The list or dictionary of application names.", "docstring_tokens": [ "The", "list", "or", "dictionary", "of", "application", "names", "." ], "type": null } ], "raises": [], "params": [ ...
2d4c47c828b0a02cdddcb6e5df537cd4178711df
mowangdk/huskar
huskar_api/api/infra_config.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, application_name, infra_type, infra_name): """Configures the infrastructure in specified application. The input schema looks like:: { "url": "sam+redis://redis.foobar/overall" } :param application_name: The application which uses infrastruct...
Configures the infrastructure in specified application. The input schema looks like:: { "url": "sam+redis://redis.foobar/overall" } :param application_name: The application which uses infrastructure. :param infra_type: ``database``, ``redis`` or ``amqp``....
Configures the infrastructure in specified application. The input schema looks like:.
[ "Configures", "the", "infrastructure", "in", "specified", "application", ".", "The", "input", "schema", "looks", "like", ":", "." ]
def put(self, application_name, infra_type, infra_name): with self._update( application_name, request, infra_type, infra_name) as args: application_name, infra_info, scope_type, scope_name, value = args owner_mail = request.args.get('owner_mail', '').strip() i...
[ "def", "put", "(", "self", ",", "application_name", ",", "infra_type", ",", "infra_name", ")", ":", "with", "self", ".", "_update", "(", "application_name", ",", "request", ",", "infra_type", ",", "infra_name", ")", "as", "args", ":", "application_name", ","...
Configures the infrastructure in specified application.
[ "Configures", "the", "infrastructure", "in", "specified", "application", "." ]
[ "\"\"\"Configures the infrastructure in specified application.\n\n The input schema looks like::\n\n {\n \"url\": \"sam+redis://redis.foobar/overall\"\n }\n\n :param application_name: The application which uses infrastructure.\n :param infra_type: ``database``...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "infra_type", "type": null }, { "param": "infra_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The application whic...
2d4c47c828b0a02cdddcb6e5df537cd4178711df
mowangdk/huskar
huskar_api/api/infra_config.py
[ "MIT" ]
Python
patch
<not_specific>
def patch(self, application_name, infra_type, infra_name): """Partially update existing infrastructures in specified application. The input schema looks like(for example for redis):: { "url": "sam+redis://redis.foobar/overall", "max_pool_size": 100, ...
Partially update existing infrastructures in specified application. The input schema looks like(for example for redis):: { "url": "sam+redis://redis.foobar/overall", "max_pool_size": 100, "connect_timeout_ms": 5, ... } ...
Partially update existing infrastructures in specified application. The input schema looks like(for example for redis):.
[ "Partially", "update", "existing", "infrastructures", "in", "specified", "application", ".", "The", "input", "schema", "looks", "like", "(", "for", "example", "for", "redis", ")", ":", "." ]
def patch(self, application_name, infra_type, infra_name): with self._update( application_name, request, infra_type, infra_name) as args: application_name, infra_info, scope_type, scope_name, value = args scope_infra_content = infra_info.list_by_infra_name(infra_name) ...
[ "def", "patch", "(", "self", ",", "application_name", ",", "infra_type", ",", "infra_name", ")", ":", "with", "self", ".", "_update", "(", "application_name", ",", "request", ",", "infra_type", ",", "infra_name", ")", "as", "args", ":", "application_name", "...
Partially update existing infrastructures in specified application.
[ "Partially", "update", "existing", "infrastructures", "in", "specified", "application", "." ]
[ "\"\"\"Partially update existing infrastructures in specified application.\n\n The input schema looks like(for example for redis)::\n\n {\n \"url\": \"sam+redis://redis.foobar/overall\",\n \"max_pool_size\": 100,\n \"connect_timeout_ms\": 5,\n ...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "infra_type", "type": null }, { "param": "infra_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The application whic...
2d4c47c828b0a02cdddcb6e5df537cd4178711df
mowangdk/huskar
huskar_api/api/infra_config.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, application_name, infra_type, infra_name): """Deletes the infrastructure configuration in specified application. :param application_name: The application which uses infrastructure. :param infra_type: ``database``, ``redis`` or ``amqp``. :param infra_name: The unique cod...
Deletes the infrastructure configuration in specified application. :param application_name: The application which uses infrastructure. :param infra_type: ``database``, ``redis`` or ``amqp``. :param infra_name: The unique code-reference name of infrastructure. :query scope_type: ``idcs``...
Deletes the infrastructure configuration in specified application.
[ "Deletes", "the", "infrastructure", "configuration", "in", "specified", "application", "." ]
def delete(self, application_name, infra_type, infra_name): check_application_auth(application_name, Authority.WRITE) check_infra_type(infra_type) scope_type = request.args['scope_type'] scope_name = request.args['scope_name'] check_scope(scope_type, scope_name) infra_inf...
[ "def", "delete", "(", "self", ",", "application_name", ",", "infra_type", ",", "infra_name", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "check_infra_type", "(", "infra_type", ")", "scope_type", "=", "request",...
Deletes the infrastructure configuration in specified application.
[ "Deletes", "the", "infrastructure", "configuration", "in", "specified", "application", "." ]
[ "\"\"\"Deletes the infrastructure configuration in specified application.\n\n :param application_name: The application which uses infrastructure.\n :param infra_type: ``database``, ``redis`` or ``amqp``.\n :param infra_name: The unique code-reference name of infrastructure.\n :query scop...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "infra_type", "type": null }, { "param": "infra_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The application whic...
2d4c47c828b0a02cdddcb6e5df537cd4178711df
mowangdk/huskar
huskar_api/api/infra_config.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, infra_application_name): """Invalidates cache and shows downstream information of infra. The response is the same to the ``GET`` method. :param infra_application_name: The application name of infrastructure. :<header Authorization: Huskar Token (See :ref:`token`) ...
Invalidates cache and shows downstream information of infra. The response is the same to the ``GET`` method. :param infra_application_name: The application name of infrastructure. :<header Authorization: Huskar Token (See :ref:`token`) :status 200: The result is in the response. ...
Invalidates cache and shows downstream information of infra. The response is the same to the ``GET`` method.
[ "Invalidates", "cache", "and", "shows", "downstream", "information", "of", "infra", ".", "The", "response", "is", "the", "same", "to", "the", "`", "`", "GET", "`", "`", "method", "." ]
def post(self, infra_application_name): InfraDownstream.flush_cache_by_application(infra_application_name) return self.get(infra_application_name)
[ "def", "post", "(", "self", ",", "infra_application_name", ")", ":", "InfraDownstream", ".", "flush_cache_by_application", "(", "infra_application_name", ")", "return", "self", ".", "get", "(", "infra_application_name", ")" ]
Invalidates cache and shows downstream information of infra.
[ "Invalidates", "cache", "and", "shows", "downstream", "information", "of", "infra", "." ]
[ "\"\"\"Invalidates cache and shows downstream information of infra.\n\n The response is the same to the ``GET`` method.\n\n :param infra_application_name: The application name of infrastructure.\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 200: The result is in the...
[ { "param": "self", "type": null }, { "param": "infra_application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "infra_application_name", "type": null, "docstring": "The applicatio...
194a324aa704d4585fbbb8184d4ccf0c9dd2258a
mowangdk/huskar
huskar_api/models/route/hijack.py
[ "MIT" ]
Python
hijack_request
<not_specific>
def hijack_request(self, request_data): """Checks or hijacks the request arguments.""" if self.route_mode == ROUTE_MODE_ROUTE: return request_data if (self.hijack_mode is self.Mode.disabled and not self._force_enable_dest_apps): return request_data ...
Checks or hijacks the request arguments.
Checks or hijacks the request arguments.
[ "Checks", "or", "hijacks", "the", "request", "arguments", "." ]
def hijack_request(self, request_data): if self.route_mode == ROUTE_MODE_ROUTE: return request_data if (self.hijack_mode is self.Mode.disabled and not self._force_enable_dest_apps): return request_data request_data = copy.deepcopy(request_data) for...
[ "def", "hijack_request", "(", "self", ",", "request_data", ")", ":", "if", "self", ".", "route_mode", "==", "ROUTE_MODE_ROUTE", ":", "return", "request_data", "if", "(", "self", ".", "hijack_mode", "is", "self", ".", "Mode", ".", "disabled", "and", "not", ...
Checks or hijacks the request arguments.
[ "Checks", "or", "hijacks", "the", "request", "arguments", "." ]
[ "\"\"\"Checks or hijacks the request arguments.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "request_data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "request_data", "type": null, "docstring": null, "docstring_to...
194a324aa704d4585fbbb8184d4ccf0c9dd2258a
mowangdk/huskar
huskar_api/models/route/hijack.py
[ "MIT" ]
Python
hijack_response
null
def hijack_response(self, tree_watcher): """Checks or hijacks the response iterator.""" is_enabled = ( self.hijack_mode in (self.Mode.enabled, self.Mode.standalone) and self.route_mode != ROUTE_MODE_ROUTE) is_enabled = is_enabled or len(self._force_enable_dest_apps) > 0 ...
Checks or hijacks the response iterator.
Checks or hijacks the response iterator.
[ "Checks", "or", "hijacks", "the", "response", "iterator", "." ]
def hijack_response(self, tree_watcher): is_enabled = ( self.hijack_mode in (self.Mode.enabled, self.Mode.standalone) and self.route_mode != ROUTE_MODE_ROUTE) is_enabled = is_enabled or len(self._force_enable_dest_apps) > 0 for message, body in tree_watcher: i...
[ "def", "hijack_response", "(", "self", ",", "tree_watcher", ")", ":", "is_enabled", "=", "(", "self", ".", "hijack_mode", "in", "(", "self", ".", "Mode", ".", "enabled", ",", "self", ".", "Mode", ".", "standalone", ")", "and", "self", ".", "route_mode", ...
Checks or hijacks the response iterator.
[ "Checks", "or", "hijacks", "the", "response", "iterator", "." ]
[ "\"\"\"Checks or hijacks the response iterator.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "tree_watcher", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tree_watcher", "type": null, "docstring": null, "docstring_to...
fa2479dbeef00e6d2e2556439d97b7e1163f25ec
mowangdk/huskar
database/migration/env.py
[ "MIT" ]
Python
run_migrations_offline
null
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output....
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
[ "Run", "migrations", "in", "'", "offline", "'", "mode", ".", "This", "configures", "the", "context", "with", "just", "a", "URL", "and", "not", "an", "Engine", "though", "an", "Engine", "is", "acceptable", "here", "as", "well", ".", "By", "skipping", "the...
def run_migrations_offline(): engine = db_manager.get_session('default').get_bind() context.configure(url=engine.url, target_metadata=target_metadata) with context.begin_transaction(): context.run_migrations()
[ "def", "run_migrations_offline", "(", ")", ":", "engine", "=", "db_manager", ".", "get_session", "(", "'default'", ")", ".", "get_bind", "(", ")", "context", ".", "configure", "(", "url", "=", "engine", ".", "url", ",", "target_metadata", "=", "target_metada...
Run migrations in 'offline' mode.
[ "Run", "migrations", "in", "'", "offline", "'", "mode", "." ]
[ "\"\"\"Run migrations in 'offline' mode.\n\n This configures the context with just a URL\n and not an Engine, though an Engine is acceptable\n here as well. By skipping the Engine creation\n we don't even need a DBAPI to be available.\n\n Calls to context.execute() here emit the given string to the\...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fa2479dbeef00e6d2e2556439d97b7e1163f25ec
mowangdk/huskar
database/migration/env.py
[ "MIT" ]
Python
run_migrations_online
null
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ connectable = db_manager.get_session('default').get_bind() with connectable.connect() as connection: context.configure( ...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "'", "online", "'", "mode", ".", "In", "this", "scenario", "we", "need", "to", "create", "an", "Engine", "and", "associate", "a", "connection", "with", "the", "context", "." ]
def run_migrations_online(): connectable = db_manager.get_session('default').get_bind() with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata, compare_type=True, ) with context.begin_transac...
[ "def", "run_migrations_online", "(", ")", ":", "connectable", "=", "db_manager", ".", "get_session", "(", "'default'", ")", ".", "get_bind", "(", ")", "with", "connectable", ".", "connect", "(", ")", "as", "connection", ":", "context", ".", "configure", "(",...
Run migrations in 'online' mode.
[ "Run", "migrations", "in", "'", "online", "'", "mode", "." ]
[ "\"\"\"Run migrations in 'online' mode.\n\n In this scenario we need to create an Engine\n and associate a connection with the context.\n\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b18dbbba48b7388e1235bbaf5f63b0d017912cd8
mowangdk/huskar
huskar_api/models/utils.py
[ "MIT" ]
Python
retry
<not_specific>
def retry(exceptions, interval, max_retry): """A decorator with arguments to make view functions could be retried. :param exceptions: The tuple of exception set. :param interval: The sleep interval in seconds. :param max_retry: The max retry times. """ def decorator(wrapped): @functools...
A decorator with arguments to make view functions could be retried. :param exceptions: The tuple of exception set. :param interval: The sleep interval in seconds. :param max_retry: The max retry times.
A decorator with arguments to make view functions could be retried.
[ "A", "decorator", "with", "arguments", "to", "make", "view", "functions", "could", "be", "retried", "." ]
def retry(exceptions, interval, max_retry): def decorator(wrapped): @functools.wraps(wrapped) def wrapper(*args, **kwargs): for i in xrange(max_retry): try: return wrapped(*args, **kwargs) except exceptions: if i == ...
[ "def", "retry", "(", "exceptions", ",", "interval", ",", "max_retry", ")", ":", "def", "decorator", "(", "wrapped", ")", ":", "@", "functools", ".", "wraps", "(", "wrapped", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "for...
A decorator with arguments to make view functions could be retried.
[ "A", "decorator", "with", "arguments", "to", "make", "view", "functions", "could", "be", "retried", "." ]
[ "\"\"\"A decorator with arguments to make view functions could be retried.\n\n :param exceptions: The tuple of exception set.\n :param interval: The sleep interval in seconds.\n :param max_retry: The max retry times.\n \"\"\"" ]
[ { "param": "exceptions", "type": null }, { "param": "interval", "type": null }, { "param": "max_retry", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "exceptions", "type": null, "docstring": "The tuple of exception set.", "docstring_tokens": [ "The", "tuple", "of", "exception", "set", "." ], "default": null, "...
b18dbbba48b7388e1235bbaf5f63b0d017912cd8
mowangdk/huskar
huskar_api/models/utils.py
[ "MIT" ]
Python
make_cache_decorator
<not_specific>
def make_cache_decorator(redis_client): """Creates a decorator to apply cache on arguments.""" def cache_on_arguments(expiration_time): def decorator(fn): fn_generate_key = function_key_generator( 'cache_on_arguments:v1', fn, to_str=unicode) fn_args = inspect.get...
Creates a decorator to apply cache on arguments.
Creates a decorator to apply cache on arguments.
[ "Creates", "a", "decorator", "to", "apply", "cache", "on", "arguments", "." ]
def make_cache_decorator(redis_client): def cache_on_arguments(expiration_time): def decorator(fn): fn_generate_key = function_key_generator( 'cache_on_arguments:v1', fn, to_str=unicode) fn_args = inspect.getargspec(fn) fn_has_self = fn_args[0] and fn_args...
[ "def", "make_cache_decorator", "(", "redis_client", ")", ":", "def", "cache_on_arguments", "(", "expiration_time", ")", ":", "def", "decorator", "(", "fn", ")", ":", "fn_generate_key", "=", "function_key_generator", "(", "'cache_on_arguments:v1'", ",", "fn", ",", ...
Creates a decorator to apply cache on arguments.
[ "Creates", "a", "decorator", "to", "apply", "cache", "on", "arguments", "." ]
[ "\"\"\"Creates a decorator to apply cache on arguments.\"\"\"" ]
[ { "param": "redis_client", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "redis_client", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b18dbbba48b7388e1235bbaf5f63b0d017912cd8
mowangdk/huskar
huskar_api/models/utils.py
[ "MIT" ]
Python
normalize_cluster_name
<not_specific>
def normalize_cluster_name(cluster_name): """Normalizes the cluster name to avoid from duplicated E-Zone prefix.""" fragments = cluster_name.split(u'-') prefix = first(fragments) if prefix and prefix in settings.ROUTE_EZONE_LIST: return u'-'.join(dedupleft(fragments, prefix)) return unicode(...
Normalizes the cluster name to avoid from duplicated E-Zone prefix.
Normalizes the cluster name to avoid from duplicated E-Zone prefix.
[ "Normalizes", "the", "cluster", "name", "to", "avoid", "from", "duplicated", "E", "-", "Zone", "prefix", "." ]
def normalize_cluster_name(cluster_name): fragments = cluster_name.split(u'-') prefix = first(fragments) if prefix and prefix in settings.ROUTE_EZONE_LIST: return u'-'.join(dedupleft(fragments, prefix)) return unicode(cluster_name)
[ "def", "normalize_cluster_name", "(", "cluster_name", ")", ":", "fragments", "=", "cluster_name", ".", "split", "(", "u'-'", ")", "prefix", "=", "first", "(", "fragments", ")", "if", "prefix", "and", "prefix", "in", "settings", ".", "ROUTE_EZONE_LIST", ":", ...
Normalizes the cluster name to avoid from duplicated E-Zone prefix.
[ "Normalizes", "the", "cluster", "name", "to", "avoid", "from", "duplicated", "E", "-", "Zone", "prefix", "." ]
[ "\"\"\"Normalizes the cluster name to avoid from duplicated E-Zone prefix.\"\"\"" ]
[ { "param": "cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cluster_name", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b18dbbba48b7388e1235bbaf5f63b0d017912cd8
mowangdk/huskar
huskar_api/models/utils.py
[ "MIT" ]
Python
dedupleft
<not_specific>
def dedupleft(iterable, marker): """Deduplicates the marker on the left of an iterable object.""" iterator = peekable(iterable) for x in iterator: if iterator.peek(None) != marker: break return itertools.chain([marker], iterator)
Deduplicates the marker on the left of an iterable object.
Deduplicates the marker on the left of an iterable object.
[ "Deduplicates", "the", "marker", "on", "the", "left", "of", "an", "iterable", "object", "." ]
def dedupleft(iterable, marker): iterator = peekable(iterable) for x in iterator: if iterator.peek(None) != marker: break return itertools.chain([marker], iterator)
[ "def", "dedupleft", "(", "iterable", ",", "marker", ")", ":", "iterator", "=", "peekable", "(", "iterable", ")", "for", "x", "in", "iterator", ":", "if", "iterator", ".", "peek", "(", "None", ")", "!=", "marker", ":", "break", "return", "itertools", "....
Deduplicates the marker on the left of an iterable object.
[ "Deduplicates", "the", "marker", "on", "the", "left", "of", "an", "iterable", "object", "." ]
[ "\"\"\"Deduplicates the marker on the left of an iterable object.\"\"\"" ]
[ { "param": "iterable", "type": null }, { "param": "marker", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "iterable", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "marker", "type": null, "docstring": null, "docstring_toke...
d2aad0d85c88ef72fb2a64d55c086767a70d94b6
mowangdk/huskar
huskar_api/api/schema/__init__.py
[ "MIT" ]
Python
validate_fields
<not_specific>
def validate_fields(schema, data, optional_fields=(), partial=True): """validate fields value but which field name in `optional_fields` and the value is None. """ if not switch.is_switched_on(SWITCH_VALIDATE_SCHEMA, True): return fields = set(data) if not fields.issubset(schema.fields):...
validate fields value but which field name in `optional_fields` and the value is None.
validate fields value but which field name in `optional_fields` and the value is None.
[ "validate", "fields", "value", "but", "which", "field", "name", "in", "`", "optional_fields", "`", "and", "the", "value", "is", "None", "." ]
def validate_fields(schema, data, optional_fields=(), partial=True): if not switch.is_switched_on(SWITCH_VALIDATE_SCHEMA, True): return fields = set(data) if not fields.issubset(schema.fields): raise ValidationError( 'The set of fields "%s" is not a subset of %s' % (f...
[ "def", "validate_fields", "(", "schema", ",", "data", ",", "optional_fields", "=", "(", ")", ",", "partial", "=", "True", ")", ":", "if", "not", "switch", ".", "is_switched_on", "(", "SWITCH_VALIDATE_SCHEMA", ",", "True", ")", ":", "return", "fields", "=",...
validate fields value but which field name in `optional_fields` and the value is None.
[ "validate", "fields", "value", "but", "which", "field", "name", "in", "`", "optional_fields", "`", "and", "the", "value", "is", "None", "." ]
[ "\"\"\"validate fields value but which field name in `optional_fields`\n and the value is None.\n \"\"\"" ]
[ { "param": "schema", "type": null }, { "param": "data", "type": null }, { "param": "optional_fields", "type": null }, { "param": "partial", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "schema", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens":...
5a7ff7d80143c166ac31245a4e45ffd3b7ab913b
mowangdk/huskar
huskar_api/models/db.py
[ "MIT" ]
Python
model_base
<not_specific>
def model_base(cls=object, **kwds): """Construct a base class for declarative class definitions, kwds params must be a subset of ``declarative_base`` params in sqlalchemy. :param cls: Atype to use as the base for the generated declarative base class. Defaults to :class:`object`. May be a class ...
Construct a base class for declarative class definitions, kwds params must be a subset of ``declarative_base`` params in sqlalchemy. :param cls: Atype to use as the base for the generated declarative base class. Defaults to :class:`object`. May be a class or tuple of classes.
Construct a base class for declarative class definitions, kwds params must be a subset of ``declarative_base`` params in sqlalchemy.
[ "Construct", "a", "base", "class", "for", "declarative", "class", "definitions", "kwds", "params", "must", "be", "a", "subset", "of", "`", "`", "declarative_base", "`", "`", "params", "in", "sqlalchemy", "." ]
def model_base(cls=object, **kwds): return declarative_base(cls=cls, metaclass=ModelMeta, **kwds)
[ "def", "model_base", "(", "cls", "=", "object", ",", "**", "kwds", ")", ":", "return", "declarative_base", "(", "cls", "=", "cls", ",", "metaclass", "=", "ModelMeta", ",", "**", "kwds", ")" ]
Construct a base class for declarative class definitions, kwds params must be a subset of ``declarative_base`` params in sqlalchemy.
[ "Construct", "a", "base", "class", "for", "declarative", "class", "definitions", "kwds", "params", "must", "be", "a", "subset", "of", "`", "`", "declarative_base", "`", "`", "params", "in", "sqlalchemy", "." ]
[ "\"\"\"Construct a base class for declarative class definitions, kwds params\n must be a subset of ``declarative_base`` params in sqlalchemy.\n\n :param cls:\n Atype to use as the base for the generated declarative base class.\n Defaults to :class:`object`. May be a class or tuple of classes.\n \...
[ { "param": "cls", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": "Atype to use as the base for the generated declarative base class.\nDefaults to :class:`object`. May be a class or tuple of classes.", "docstring_tokens": [ "Atype", "to", ...
1dbba398fcd2452bad50bc92bf660df803da78df
mowangdk/huskar
huskar_api/models/route/management.py
[ "MIT" ]
Python
list_route
null
def list_route(self): """Lists all route rules for this source application and cluster. :raises MalformedDataError: if any dirty data is present :returns: Yields ``(application_name, intent, cluster_name)`` tuples. """ dependency = self.make_service_info().get_dependency() ...
Lists all route rules for this source application and cluster. :raises MalformedDataError: if any dirty data is present :returns: Yields ``(application_name, intent, cluster_name)`` tuples.
Lists all route rules for this source application and cluster.
[ "Lists", "all", "route", "rules", "for", "this", "source", "application", "and", "cluster", "." ]
def list_route(self): dependency = self.make_service_info().get_dependency() for application_name in dependency: if self.cluster_name not in dependency[application_name]: continue is_found = False for route_key, cluster_name in self.yield_route_pairs( ...
[ "def", "list_route", "(", "self", ")", ":", "dependency", "=", "self", ".", "make_service_info", "(", ")", ".", "get_dependency", "(", ")", "for", "application_name", "in", "dependency", ":", "if", "self", ".", "cluster_name", "not", "in", "dependency", "[",...
Lists all route rules for this source application and cluster.
[ "Lists", "all", "route", "rules", "for", "this", "source", "application", "and", "cluster", "." ]
[ "\"\"\"Lists all route rules for this source application and cluster.\n\n :raises MalformedDataError: if any dirty data is present\n :returns: Yields ``(application_name, intent, cluster_name)`` tuples.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "Yields ``(application_name, intent, cluster_name)`` tuples.", "docstring_tokens": [ "Yields", "`", "`", "(", "application_name", "intent", "cluster_name", ")", "`", "`", "tuples", ...
1dbba398fcd2452bad50bc92bf660df803da78df
mowangdk/huskar
huskar_api/models/route/management.py
[ "MIT" ]
Python
discard_default_route
<not_specific>
def discard_default_route(self, ezone, intent): """Deletes a default route policy of this application. :param ezone: The ezone ID (e.g. alta1). :param intent: The optional intent flag (could be ``None``). :returns: The default route dictionary since this change. """ inte...
Deletes a default route policy of this application. :param ezone: The ezone ID (e.g. alta1). :param intent: The optional intent flag (could be ``None``). :returns: The default route dictionary since this change.
Deletes a default route policy of this application.
[ "Deletes", "a", "default", "route", "policy", "of", "this", "application", "." ]
def discard_default_route(self, ezone, intent): intent = intent or ROUTE_DEFAULT_INTENT service_info = safe_call(self.make_service_info) service_info.discard_default_route(ezone, intent) service_info.save() return service_info.get_default_route()
[ "def", "discard_default_route", "(", "self", ",", "ezone", ",", "intent", ")", ":", "intent", "=", "intent", "or", "ROUTE_DEFAULT_INTENT", "service_info", "=", "safe_call", "(", "self", ".", "make_service_info", ")", "service_info", ".", "discard_default_route", "...
Deletes a default route policy of this application.
[ "Deletes", "a", "default", "route", "policy", "of", "this", "application", "." ]
[ "\"\"\"Deletes a default route policy of this application.\n\n :param ezone: The ezone ID (e.g. alta1).\n :param intent: The optional intent flag (could be ``None``).\n :returns: The default route dictionary since this change.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ezone", "type": null }, { "param": "intent", "type": null } ]
{ "returns": [ { "docstring": "The default route dictionary since this change.", "docstring_tokens": [ "The", "default", "route", "dictionary", "since", "this", "change", "." ], "type": null } ], "raises": [], "param...
1dbba398fcd2452bad50bc92bf660df803da78df
mowangdk/huskar
huskar_api/models/route/management.py
[ "MIT" ]
Python
declare_upstream
<not_specific>
def declare_upstream(self, application_names): """Declares specified application and cluster as upstream. A common situation to call this method is in a service discovery session:: route_management.declare_upstream(["foo.test"]) :param application_names: A name list of app...
Declares specified application and cluster as upstream. A common situation to call this method is in a service discovery session:: route_management.declare_upstream(["foo.test"]) :param application_names: A name list of applications.
Declares specified application and cluster as upstream. A common situation to call this method is in a service discovery session:.
[ "Declares", "specified", "application", "and", "cluster", "as", "upstream", ".", "A", "common", "situation", "to", "call", "this", "method", "is", "in", "a", "service", "discovery", "session", ":", "." ]
def declare_upstream(self, application_names): service_info = safe_call(self.make_service_info) snapshot = service_info.freeze_dependency() for application_name in application_names: service_info.add_dependency(application_name, self.cluster_name) if service_info.freeze_depen...
[ "def", "declare_upstream", "(", "self", ",", "application_names", ")", ":", "service_info", "=", "safe_call", "(", "self", ".", "make_service_info", ")", "snapshot", "=", "service_info", ".", "freeze_dependency", "(", ")", "for", "application_name", "in", "applica...
Declares specified application and cluster as upstream.
[ "Declares", "specified", "application", "and", "cluster", "as", "upstream", "." ]
[ "\"\"\"Declares specified application and cluster as upstream.\n\n A common situation to call this method is in a service discovery\n session::\n\n route_management.declare_upstream([\"foo.test\"])\n\n :param application_names: A name list of applications.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "application_names", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_names", "type": null, "docstring": "A name list of appl...
b949b8f39b026b0063a44cc40229697b7ad1c193
mowangdk/huskar
huskar_api/models/catalog/schema.py
[ "MIT" ]
Python
make_dummy
<not_specific>
def make_dummy(cls, data, **kwargs): """Make a dummy instance to support read-only operations.""" # TODO Could we find a better way? instance = cls(client=None, **kwargs) instance.load = None instance.save = None if data: try: instance.data, _ ...
Make a dummy instance to support read-only operations.
Make a dummy instance to support read-only operations.
[ "Make", "a", "dummy", "instance", "to", "support", "read", "-", "only", "operations", "." ]
def make_dummy(cls, data, **kwargs): instance = cls(client=None, **kwargs) instance.load = None instance.save = None if data: try: instance.data, _ = cls.MARSHMALLOW_SCHEMA.loads(data) except cls._MALFORMED_DATA_EXCEPTIONS as e: rai...
[ "def", "make_dummy", "(", "cls", ",", "data", ",", "**", "kwargs", ")", ":", "instance", "=", "cls", "(", "client", "=", "None", ",", "**", "kwargs", ")", "instance", ".", "load", "=", "None", "instance", ".", "save", "=", "None", "if", "data", ":"...
Make a dummy instance to support read-only operations.
[ "Make", "a", "dummy", "instance", "to", "support", "read", "-", "only", "operations", "." ]
[ "\"\"\"Make a dummy instance to support read-only operations.\"\"\"", "# TODO Could we find a better way?" ]
[ { "param": "cls", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": []...
c6ebed5118d5509f8d129a26a4138ed258abfdbf
mowangdk/huskar
huskar_api/api/organization.py
[ "MIT" ]
Python
put
<not_specific>
def put(self): """creates a new application. This method is same as **POST** but calling it once or several times successively has the same effect. :form team: The name of team to place the new application. :form application: The name of new application. :<header Author...
creates a new application. This method is same as **POST** but calling it once or several times successively has the same effect. :form team: The name of team to place the new application. :form application: The name of new application. :<header Authorization: Huskar Token (See...
creates a new application. This method is same as **POST** but calling it once or several times successively has the same effect.
[ "creates", "a", "new", "application", ".", "This", "method", "is", "same", "as", "**", "POST", "**", "but", "calling", "it", "once", "or", "several", "times", "successively", "has", "the", "same", "effect", "." ]
def put(self): return self._create(ignore_existed=True)
[ "def", "put", "(", "self", ")", ":", "return", "self", ".", "_create", "(", "ignore_existed", "=", "True", ")" ]
creates a new application.
[ "creates", "a", "new", "application", "." ]
[ "\"\"\"creates a new application.\n\n This method is same as **POST** but calling it once or several times\n successively has the same effect.\n\n :form team: The name of team to place the new application.\n :form application: The name of new application.\n :<header Authorization:...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "form", "docstring": "The name o...
c6ebed5118d5509f8d129a26a4138ed258abfdbf
mowangdk/huskar
huskar_api/api/organization.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, team_name, application_name): """Ensures the related resources exist and gets an application token. .. note:: This is an internal API. We guarantee nothing if you are not developers of Huskar and you are using this API. :param team_name: The name of team. ...
Ensures the related resources exist and gets an application token. .. note:: This is an internal API. We guarantee nothing if you are not developers of Huskar and you are using this API. :param team_name: The name of team. :param application_name: The name of application. ...
Ensures the related resources exist and gets an application token. note:: This is an internal API. We guarantee nothing if you are not developers of Huskar and you are using this API.
[ "Ensures", "the", "related", "resources", "exist", "and", "gets", "an", "application", "token", ".", "note", "::", "This", "is", "an", "internal", "API", ".", "We", "guarantee", "nothing", "if", "you", "are", "not", "developers", "of", "Huskar", "and", "yo...
def post(self, team_name, application_name): if not g.auth.is_admin: abort(403, 'user "%s" has no admin permission' % g.auth.username) owner_email = request.form['owner_email'].strip() validate_email(owner_email) owner_name = owner_email.split('@')[0] try: ...
[ "def", "post", "(", "self", ",", "team_name", ",", "application_name", ")", ":", "if", "not", "g", ".", "auth", ".", "is_admin", ":", "abort", "(", "403", ",", "'user \"%s\" has no admin permission'", "%", "g", ".", "auth", ".", "username", ")", "owner_ema...
Ensures the related resources exist and gets an application token.
[ "Ensures", "the", "related", "resources", "exist", "and", "gets", "an", "application", "token", "." ]
[ "\"\"\"Ensures the related resources exist and gets an application token.\n\n .. note:: This is an internal API. We guarantee nothing if you are not\n developers of Huskar and you are using this API.\n\n :param team_name: The name of team.\n :param application_name: The name of...
[ { "param": "self", "type": null }, { "param": "team_name", "type": null }, { "param": "application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "team_name", "type": null, "docstring": "The name of team.", "...
846c034a9599701e7041345c31dedf8a08c9636b
mowangdk/huskar
huskar_api/models/audit/audit.py
[ "MIT" ]
Python
create
<not_specific>
def create(cls, user_id, remote_addr, action, rollback_to=None): """Creates a new audit log. :param int user_id: The id of operator. :param str remote_addr: The IP address of operator. :param tuple action: Use :meth:`action_creator.make_action` to create thi...
Creates a new audit log. :param int user_id: The id of operator. :param str remote_addr: The IP address of operator. :param tuple action: Use :meth:`action_creator.make_action` to create this tuple. :param int rollback_to: Optional. Default is :obj:`None`. I...
Creates a new audit log.
[ "Creates", "a", "new", "audit", "log", "." ]
def create(cls, user_id, remote_addr, action, rollback_to=None): if rollback_to is not None and cls.get(rollback_to) is None: raise ValueError('rollback_to is not a valid id') action_type, action_data, action_indices = action trace_all_application_events(action_type, action_data) ...
[ "def", "create", "(", "cls", ",", "user_id", ",", "remote_addr", ",", "action", ",", "rollback_to", "=", "None", ")", ":", "if", "rollback_to", "is", "not", "None", "and", "cls", ".", "get", "(", "rollback_to", ")", "is", "None", ":", "raise", "ValueEr...
Creates a new audit log.
[ "Creates", "a", "new", "audit", "log", "." ]
[ "\"\"\"Creates a new audit log.\n\n :param int user_id: The id of operator.\n :param str remote_addr: The IP address of operator.\n :param tuple action: Use :meth:`action_creator.make_action` to create\n this tuple.\n :param int rollback_to: Optional. Default ...
[ { "param": "cls", "type": null }, { "param": "user_id", "type": null }, { "param": "remote_addr", "type": null }, { "param": "action", "type": null }, { "param": "rollback_to", "type": null } ]
{ "returns": [ { "docstring": "The created instance.", "docstring_tokens": [ "The", "created", "instance", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docst...
846c034a9599701e7041345c31dedf8a08c9636b
mowangdk/huskar
huskar_api/models/audit/audit.py
[ "MIT" ]
Python
rollback_to
<not_specific>
def rollback_to(self): """The action log which rollbacked by this action.""" if self.rollback_id is None: return return self.get(self.rollback_id)
The action log which rollbacked by this action.
The action log which rollbacked by this action.
[ "The", "action", "log", "which", "rollbacked", "by", "this", "action", "." ]
def rollback_to(self): if self.rollback_id is None: return return self.get(self.rollback_id)
[ "def", "rollback_to", "(", "self", ")", ":", "if", "self", ".", "rollback_id", "is", "None", ":", "return", "return", "self", ".", "get", "(", "self", ".", "rollback_id", ")" ]
The action log which rollbacked by this action.
[ "The", "action", "log", "which", "rollbacked", "by", "this", "action", "." ]
[ "\"\"\"The action log which rollbacked by this action.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c687d34dcd5bbe84c6450083def4b891882b1428
mowangdk/huskar
huskar_api/models/tree/hub.py
[ "MIT" ]
Python
release_tree_holder
<not_specific>
def release_tree_holder(self, application_name, type_name): """Releases the tree holder. This method should be called after the :exc:`huskar_api.models.exceptions.TreeTimeoutError` raised. """ holder = self.tree_map.pop((application_name, type_name), None) if holder is n...
Releases the tree holder. This method should be called after the :exc:`huskar_api.models.exceptions.TreeTimeoutError` raised.
Releases the tree holder. This method should be called after the
[ "Releases", "the", "tree", "holder", ".", "This", "method", "should", "be", "called", "after", "the" ]
def release_tree_holder(self, application_name, type_name): holder = self.tree_map.pop((application_name, type_name), None) if holder is not None: holder.close() return holder
[ "def", "release_tree_holder", "(", "self", ",", "application_name", ",", "type_name", ")", ":", "holder", "=", "self", ".", "tree_map", ".", "pop", "(", "(", "application_name", ",", "type_name", ")", ",", "None", ")", "if", "holder", "is", "not", "None", ...
Releases the tree holder.
[ "Releases", "the", "tree", "holder", "." ]
[ "\"\"\"Releases the tree holder.\n\n This method should be called after the\n :exc:`huskar_api.models.exceptions.TreeTimeoutError` raised.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "type_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": null, "docstrin...
c687d34dcd5bbe84c6450083def4b891882b1428
mowangdk/huskar
huskar_api/models/tree/hub.py
[ "MIT" ]
Python
make_watcher
<not_specific>
def make_watcher(self, *args, **kwargs): """Creates a watcher and binds it to tree holders of this instance. :returns: A :class:`TreeWatcher` instance. """ return self.tree_watcher_class(self, *args, **kwargs)
Creates a watcher and binds it to tree holders of this instance. :returns: A :class:`TreeWatcher` instance.
Creates a watcher and binds it to tree holders of this instance.
[ "Creates", "a", "watcher", "and", "binds", "it", "to", "tree", "holders", "of", "this", "instance", "." ]
def make_watcher(self, *args, **kwargs): return self.tree_watcher_class(self, *args, **kwargs)
[ "def", "make_watcher", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "tree_watcher_class", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")" ]
Creates a watcher and binds it to tree holders of this instance.
[ "Creates", "a", "watcher", "and", "binds", "it", "to", "tree", "holders", "of", "this", "instance", "." ]
[ "\"\"\"Creates a watcher and binds it to tree holders of this instance.\n\n :returns: A :class:`TreeWatcher` instance.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "A :class:`TreeWatcher` instance.", "docstring_tokens": [ "A", ":", "class", ":", "`", "TreeWatcher", "`", "instance", "." ], "type": null } ], "raises": [], "params": [ { ...
2153e60a417385e8bfd3ca52f932e72c4fdd7914
mowangdk/huskar
huskar_api/models/container/management.py
[ "MIT" ]
Python
register_to
null
def register_to(self, application_name, cluster_name): """Registers this container to a specific application and cluster. :param application_name: The name of registering application. :param cluster_name: The name of registering cluster. """ location = _pack(application_name, cl...
Registers this container to a specific application and cluster. :param application_name: The name of registering application. :param cluster_name: The name of registering cluster.
Registers this container to a specific application and cluster.
[ "Registers", "this", "container", "to", "a", "specific", "application", "and", "cluster", "." ]
def register_to(self, application_name, cluster_name): location = _pack(application_name, cluster_name) path = self._make_location_path(location) self.huskar_client.client.ensure_path(path) monitor_client.increment('container.register')
[ "def", "register_to", "(", "self", ",", "application_name", ",", "cluster_name", ")", ":", "location", "=", "_pack", "(", "application_name", ",", "cluster_name", ")", "path", "=", "self", ".", "_make_location_path", "(", "location", ")", "self", ".", "huskar_...
Registers this container to a specific application and cluster.
[ "Registers", "this", "container", "to", "a", "specific", "application", "and", "cluster", "." ]
[ "\"\"\"Registers this container to a specific application and cluster.\n\n :param application_name: The name of registering application.\n :param cluster_name: The name of registering cluster.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of register...
2153e60a417385e8bfd3ca52f932e72c4fdd7914
mowangdk/huskar
huskar_api/models/container/management.py
[ "MIT" ]
Python
deregister_from
null
def deregister_from(self, application_name, cluster_name): """Deregisters a specific application and cluster on this container. :param application_name: The name of registering application. :param cluster_name: The name of registering cluster. """ location = _pack(application_na...
Deregisters a specific application and cluster on this container. :param application_name: The name of registering application. :param cluster_name: The name of registering cluster.
Deregisters a specific application and cluster on this container.
[ "Deregisters", "a", "specific", "application", "and", "cluster", "on", "this", "container", "." ]
def deregister_from(self, application_name, cluster_name): location = _pack(application_name, cluster_name) path = self._make_location_path(location) self.huskar_client.client.delete(path, recursive=True) monitor_client.increment('container.deregister')
[ "def", "deregister_from", "(", "self", ",", "application_name", ",", "cluster_name", ")", ":", "location", "=", "_pack", "(", "application_name", ",", "cluster_name", ")", "path", "=", "self", ".", "_make_location_path", "(", "location", ")", "self", ".", "hus...
Deregisters a specific application and cluster on this container.
[ "Deregisters", "a", "specific", "application", "and", "cluster", "on", "this", "container", "." ]
[ "\"\"\"Deregisters a specific application and cluster on this container.\n\n :param application_name: The name of registering application.\n :param cluster_name: The name of registering cluster.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of register...
2153e60a417385e8bfd3ca52f932e72c4fdd7914
mowangdk/huskar
huskar_api/models/container/management.py
[ "MIT" ]
Python
lookup
<not_specific>
def lookup(self): """Lists all applications and clusters on this container. :returns: A list of ``(application_name, cluster_name)`` tuples. """ path = self._make_container_path() try: location_list = self.huskar_client.client.get_children(path) return so...
Lists all applications and clusters on this container. :returns: A list of ``(application_name, cluster_name)`` tuples.
Lists all applications and clusters on this container.
[ "Lists", "all", "applications", "and", "clusters", "on", "this", "container", "." ]
def lookup(self): path = self._make_container_path() try: location_list = self.huskar_client.client.get_children(path) return sorted(_unpack_list(location_list, self.container_id)) except NoNodeError: return []
[ "def", "lookup", "(", "self", ")", ":", "path", "=", "self", ".", "_make_container_path", "(", ")", "try", ":", "location_list", "=", "self", ".", "huskar_client", ".", "client", ".", "get_children", "(", "path", ")", "return", "sorted", "(", "_unpack_list...
Lists all applications and clusters on this container.
[ "Lists", "all", "applications", "and", "clusters", "on", "this", "container", "." ]
[ "\"\"\"Lists all applications and clusters on this container.\n\n :returns: A list of ``(application_name, cluster_name)`` tuples.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "A list of ``(application_name, cluster_name)`` tuples.", "docstring_tokens": [ "A", "list", "of", "`", "`", "(", "application_name", "cluster_name", ")", "`", "`", "tuples", ...
2153e60a417385e8bfd3ca52f932e72c4fdd7914
mowangdk/huskar
huskar_api/models/container/management.py
[ "MIT" ]
Python
destroy
<not_specific>
def destroy(self): """Destroys this container at all. :raises NotEmptyError: The container is still used by some clusters. You should lookup and deregister again. """ path = self._make_container_path() try: self.huskar_client.client.del...
Destroys this container at all. :raises NotEmptyError: The container is still used by some clusters. You should lookup and deregister again.
Destroys this container at all.
[ "Destroys", "this", "container", "at", "all", "." ]
def destroy(self): path = self._make_container_path() try: self.huskar_client.client.delete(path) except NoNodeError: return except KazooNotEmptyError: raise NotEmptyError() else: monitor_client.increment('container.destroy')
[ "def", "destroy", "(", "self", ")", ":", "path", "=", "self", ".", "_make_container_path", "(", ")", "try", ":", "self", ".", "huskar_client", ".", "client", ".", "delete", "(", "path", ")", "except", "NoNodeError", ":", "return", "except", "KazooNotEmptyE...
Destroys this container at all.
[ "Destroys", "this", "container", "at", "all", "." ]
[ "\"\"\"Destroys this container at all.\n\n :raises NotEmptyError: The container is still used by some clusters.\n You should lookup and deregister again.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "The container is still used by some clusters.\nYou should lookup and deregister again.", "docstring_tokens": [ "The", "container", "is", "still", "used", "by", "some", "clusters", "."...
2153e60a417385e8bfd3ca52f932e72c4fdd7914
mowangdk/huskar
huskar_api/models/container/management.py
[ "MIT" ]
Python
has_barrier
<not_specific>
def has_barrier(self): """Checks whether a registering barrier is here. There is a configuration item, ``CONTAINER_BARRIER_LIFESPAN``, which decides the max lifespan of a barrier in seconds. """ path = self._make_barrier_path() stat = self.huskar_client.client.exists(pat...
Checks whether a registering barrier is here. There is a configuration item, ``CONTAINER_BARRIER_LIFESPAN``, which decides the max lifespan of a barrier in seconds.
Checks whether a registering barrier is here. There is a configuration item, ``CONTAINER_BARRIER_LIFESPAN``, which decides the max lifespan of a barrier in seconds.
[ "Checks", "whether", "a", "registering", "barrier", "is", "here", ".", "There", "is", "a", "configuration", "item", "`", "`", "CONTAINER_BARRIER_LIFESPAN", "`", "`", "which", "decides", "the", "max", "lifespan", "of", "a", "barrier", "in", "seconds", "." ]
def has_barrier(self): path = self._make_barrier_path() stat = self.huskar_client.client.exists(path) return stat is not None and _barrier_is_still_alive(stat)
[ "def", "has_barrier", "(", "self", ")", ":", "path", "=", "self", ".", "_make_barrier_path", "(", ")", "stat", "=", "self", ".", "huskar_client", ".", "client", ".", "exists", "(", "path", ")", "return", "stat", "is", "not", "None", "and", "_barrier_is_s...
Checks whether a registering barrier is here.
[ "Checks", "whether", "a", "registering", "barrier", "is", "here", "." ]
[ "\"\"\"Checks whether a registering barrier is here.\n\n There is a configuration item, ``CONTAINER_BARRIER_LIFESPAN``, which\n decides the max lifespan of a barrier in seconds.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2153e60a417385e8bfd3ca52f932e72c4fdd7914
mowangdk/huskar
huskar_api/models/container/management.py
[ "MIT" ]
Python
vacuum_stale_barriers
null
def vacuum_stale_barriers(cls, huskar_client): """Scans stale barriers and deletes them. This is an iterator factory. You need to use ``next`` to drive it running continually. If you just invoke this method and leave it alone, nothing will happen. The returned iterator deletes ...
Scans stale barriers and deletes them. This is an iterator factory. You need to use ``next`` to drive it running continually. If you just invoke this method and leave it alone, nothing will happen. The returned iterator deletes one stale barrier on its each step. :param huskar...
Scans stale barriers and deletes them. This is an iterator factory. You need to use ``next`` to drive it running continually. If you just invoke this method and leave it alone, nothing will happen. The returned iterator deletes one stale barrier on its each step.
[ "Scans", "stale", "barriers", "and", "deletes", "them", ".", "This", "is", "an", "iterator", "factory", ".", "You", "need", "to", "use", "`", "`", "next", "`", "`", "to", "drive", "it", "running", "continually", ".", "If", "you", "just", "invoke", "thi...
def vacuum_stale_barriers(cls, huskar_client): directory_path = cls._ZPATH_BARRIER_DIRECTORY container_ids = huskar_client.client.get_children(directory_path) for container_id in sorted(container_ids): management = cls(huskar_client, container_id) if management.has_barrie...
[ "def", "vacuum_stale_barriers", "(", "cls", ",", "huskar_client", ")", ":", "directory_path", "=", "cls", ".", "_ZPATH_BARRIER_DIRECTORY", "container_ids", "=", "huskar_client", ".", "client", ".", "get_children", "(", "directory_path", ")", "for", "container_id", "...
Scans stale barriers and deletes them.
[ "Scans", "stale", "barriers", "and", "deletes", "them", "." ]
[ "\"\"\"Scans stale barriers and deletes them.\n\n This is an iterator factory. You need to use ``next`` to drive it\n running continually. If you just invoke this method and leave it alone,\n nothing will happen.\n\n The returned iterator deletes one stale barrier on its each step.\n\n ...
[ { "param": "cls", "type": null }, { "param": "huskar_client", "type": null } ]
{ "returns": [ { "docstring": "An iterator which generates ``(container_id, is_stale)``", "docstring_tokens": [ "An", "iterator", "which", "generates", "`", "`", "(", "container_id", "is_stale", ")", "`", "...
11c1a44330f6df14281e2e328ebeffe11d51d6f9
mowangdk/huskar
huskar_api/api/user.py
[ "MIT" ]
Python
post
<not_specific>
def post(self): """Creates a new user with your site admin authority. We will send you an email of random password if don't specify password explicitly. :form username: The username of new user. :form password: The optional password of new user. :form email: The email o...
Creates a new user with your site admin authority. We will send you an email of random password if don't specify password explicitly. :form username: The username of new user. :form password: The optional password of new user. :form email: The email of new user. :<heade...
Creates a new user with your site admin authority. We will send you an email of random password if don't specify password explicitly.
[ "Creates", "a", "new", "user", "with", "your", "site", "admin", "authority", ".", "We", "will", "send", "you", "an", "email", "of", "random", "password", "if", "don", "'", "t", "specify", "password", "explicitly", "." ]
def post(self): g.auth.require_admin('only admin can add users') username = request.form['username'].strip() password = request.form.get('password', gen_salt(30)) is_generated_password = 'password' not in request.form email = request.form['email'].strip() validate_fields(...
[ "def", "post", "(", "self", ")", ":", "g", ".", "auth", ".", "require_admin", "(", "'only admin can add users'", ")", "username", "=", "request", ".", "form", "[", "'username'", "]", ".", "strip", "(", ")", "password", "=", "request", ".", "form", ".", ...
Creates a new user with your site admin authority.
[ "Creates", "a", "new", "user", "with", "your", "site", "admin", "authority", "." ]
[ "\"\"\"Creates a new user with your site admin authority.\n\n We will send you an email of random password if don't specify password\n explicitly.\n\n :form username: The username of new user.\n :form password: The optional password of new user.\n :form email: The email of new use...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "form", "docstring": "The userna...
11c1a44330f6df14281e2e328ebeffe11d51d6f9
mowangdk/huskar
huskar_api/api/user.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, username): """Deletes an user permanently with your site admin authority. :param username: The username of deleting user. :<header Authorization: Huskar Token (See :ref:`token`) :status 404: The user is not found. :status 200: The user is deleted successfully. ...
Deletes an user permanently with your site admin authority. :param username: The username of deleting user. :<header Authorization: Huskar Token (See :ref:`token`) :status 404: The user is not found. :status 200: The user is deleted successfully.
Deletes an user permanently with your site admin authority.
[ "Deletes", "an", "user", "permanently", "with", "your", "site", "admin", "authority", "." ]
def delete(self, username): g.auth.require_admin('only admin can delete users') user = self._get_user_or_404(username) with audit_log(audit_log.types.ARCHIVE_USER, user=user): user.archive() return api_response()
[ "def", "delete", "(", "self", ",", "username", ")", ":", "g", ".", "auth", ".", "require_admin", "(", "'only admin can delete users'", ")", "user", "=", "self", ".", "_get_user_or_404", "(", "username", ")", "with", "audit_log", "(", "audit_log", ".", "types...
Deletes an user permanently with your site admin authority.
[ "Deletes", "an", "user", "permanently", "with", "your", "site", "admin", "authority", "." ]
[ "\"\"\"Deletes an user permanently with your site admin authority.\n\n :param username: The username of deleting user.\n :<header Authorization: Huskar Token (See :ref:`token`)\n :status 404: The user is not found.\n :status 200: The user is deleted successfully.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "username", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "username", "type": null, "docstring": "The username of deleting use...
11c1a44330f6df14281e2e328ebeffe11d51d6f9
mowangdk/huskar
huskar_api/api/user.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, username): """Changes the password or email of specified user. :param username: The username of specified user. :form old_password: The old passwor of specified user. :form new_password: Optional. If you want to modify your password, specify it....
Changes the password or email of specified user. :param username: The username of specified user. :form old_password: The old passwor of specified user. :form new_password: Optional. If you want to modify your password, specify it. :form email: Optional. If y...
Changes the password or email of specified user.
[ "Changes", "the", "password", "or", "email", "of", "specified", "user", "." ]
def put(self, username): old_password = request.form['old_password'] new_password = request.form.get('new_password') new_email = request.form.get('email') if g.auth.username != username: abort(403, '%s is not permitted to modify %s.' % ( g.auth.username, usern...
[ "def", "put", "(", "self", ",", "username", ")", ":", "old_password", "=", "request", ".", "form", "[", "'old_password'", "]", "new_password", "=", "request", ".", "form", ".", "get", "(", "'new_password'", ")", "new_email", "=", "request", ".", "form", ...
Changes the password or email of specified user.
[ "Changes", "the", "password", "or", "email", "of", "specified", "user", "." ]
[ "\"\"\"Changes the password or email of specified user.\n\n :param username: The username of specified user.\n :form old_password: The old passwor of specified user.\n :form new_password: Optional. If you want to modify your password,\n specify it.\n :form emai...
[ { "param": "self", "type": null }, { "param": "username", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "username", "type": null, "docstring": "The username of specified us...
11c1a44330f6df14281e2e328ebeffe11d51d6f9
mowangdk/huskar
huskar_api/api/user.py
[ "MIT" ]
Python
post
<not_specific>
def post(self, username): """Resets password of specified user. If you request this API without the optional ``token`` argument, the specified user will receive a validation email which contains a token. The token will expire in ten minutes. Once you request this API again with...
Resets password of specified user. If you request this API without the optional ``token`` argument, the specified user will receive a validation email which contains a token. The token will expire in ten minutes. Once you request this API again with the valid token, the password of ...
Resets password of specified user. If you request this API without the optional ``token`` argument, the specified user will receive a validation email which contains a token. The token will expire in ten minutes. Once you request this API again with the valid token, the password of specified user will be reset into th...
[ "Resets", "password", "of", "specified", "user", ".", "If", "you", "request", "this", "API", "without", "the", "optional", "`", "`", "token", "`", "`", "argument", "the", "specified", "user", "will", "receive", "a", "validation", "email", "which", "contains"...
def post(self, username): token = request.form.get('token', type=uuid.UUID) if token: new_password = request.form['password'] user = reset_password(username, token, new_password) audit_log.emit(audit_log.types.CHANGE_USER_PASSWORD, user=user) return api_re...
[ "def", "post", "(", "self", ",", "username", ")", ":", "token", "=", "request", ".", "form", ".", "get", "(", "'token'", ",", "type", "=", "uuid", ".", "UUID", ")", "if", "token", ":", "new_password", "=", "request", ".", "form", "[", "'password'", ...
Resets password of specified user.
[ "Resets", "password", "of", "specified", "user", "." ]
[ "\"\"\"Resets password of specified user.\n\n If you request this API without the optional ``token`` argument, the\n specified user will receive a validation email which contains a token.\n The token will expire in ten minutes.\n\n Once you request this API again with the valid token, th...
[ { "param": "self", "type": null }, { "param": "username", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "username", "type": null, "docstring": "The username of specified us...
f63a2fd330c87091c3c1eec06116812f40807598
mowangdk/huskar
run.py
[ "MIT" ]
Python
run
null
def run(ctx, script_or_uri, force_import): """ Run a script or uri. """ group_name = ctx.parent.command.name + ' ' if ctx.parent else '' prog_name = "{}{}".format(group_name, ctx.command.name) sys.argv = [prog_name] + ctx.args try: ret = None entry = import_obj(script_or_ur...
Run a script or uri.
Run a script or uri.
[ "Run", "a", "script", "or", "uri", "." ]
def run(ctx, script_or_uri, force_import): group_name = ctx.parent.command.name + ' ' if ctx.parent else '' prog_name = "{}{}".format(group_name, ctx.command.name) sys.argv = [prog_name] + ctx.args try: ret = None entry = import_obj(script_or_uri, hard=force_import) if entry: ...
[ "def", "run", "(", "ctx", ",", "script_or_uri", ",", "force_import", ")", ":", "group_name", "=", "ctx", ".", "parent", ".", "command", ".", "name", "+", "' '", "if", "ctx", ".", "parent", "else", "''", "prog_name", "=", "\"{}{}\"", ".", "format", "(",...
Run a script or uri.
[ "Run", "a", "script", "or", "uri", "." ]
[ "\"\"\"\n Run a script or uri.\n \"\"\"", "# Backward compatibility: if ret is int,", "# means it's cli return code." ]
[ { "param": "ctx", "type": null }, { "param": "script_or_uri", "type": null }, { "param": "force_import", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "script_or_uri", "type": null, "docstring": null, "docstring_to...
b26f724e2cba16b4c6dcb1a5cfa4969de35ab2f7
mowangdk/huskar
huskar_api/api/service_route.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, application_name, cluster_name, destination): """Changes the outgoing route of specific cluster. :param application_name: The name of source application. :param cluster_name: The name of source cluster. :param destination: The name of destination application. :form...
Changes the outgoing route of specific cluster. :param application_name: The name of source application. :param cluster_name: The name of source cluster. :param destination: The name of destination application. :form intent: The intent of route. (``direct``) :form cluster_name: ...
Changes the outgoing route of specific cluster.
[ "Changes", "the", "outgoing", "route", "of", "specific", "cluster", "." ]
def put(self, application_name, cluster_name, destination): if cluster_name in settings.FORCE_ROUTING_CLUSTERS: abort(403, 'Can not modify {}\'s value'.format(cluster_name)) self._check_auth(application_name, destination) check_cluster_name(cluster_name, application_name) sel...
[ "def", "put", "(", "self", ",", "application_name", ",", "cluster_name", ",", "destination", ")", ":", "if", "cluster_name", "in", "settings", ".", "FORCE_ROUTING_CLUSTERS", ":", "abort", "(", "403", ",", "'Can not modify {}\\'s value'", ".", "format", "(", "clu...
Changes the outgoing route of specific cluster.
[ "Changes", "the", "outgoing", "route", "of", "specific", "cluster", "." ]
[ "\"\"\"Changes the outgoing route of specific cluster.\n\n :param application_name: The name of source application.\n :param cluster_name: The name of source cluster.\n :param destination: The name of destination application.\n :form intent: The intent of route. (``direct``)\n :fo...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null }, { "param": "destination", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of source a...
b26f724e2cba16b4c6dcb1a5cfa4969de35ab2f7
mowangdk/huskar
huskar_api/api/service_route.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, application_name, cluster_name, destination): """Discards the outgoing route of specific cluster. :param application_name: The name of source application. :param cluster_name: The name of source cluster. :param destination: The name of destination application. :...
Discards the outgoing route of specific cluster. :param application_name: The name of source application. :param cluster_name: The name of source cluster. :param destination: The name of destination application. :form intent: The intent of route. (``direct``) :<header Authorizat...
Discards the outgoing route of specific cluster.
[ "Discards", "the", "outgoing", "route", "of", "specific", "cluster", "." ]
def delete(self, application_name, cluster_name, destination): self._check_auth(application_name, destination) check_cluster_name(cluster_name, application_name) self._delete(application_name, cluster_name, destination) return api_response()
[ "def", "delete", "(", "self", ",", "application_name", ",", "cluster_name", ",", "destination", ")", ":", "self", ".", "_check_auth", "(", "application_name", ",", "destination", ")", "check_cluster_name", "(", "cluster_name", ",", "application_name", ")", "self",...
Discards the outgoing route of specific cluster.
[ "Discards", "the", "outgoing", "route", "of", "specific", "cluster", "." ]
[ "\"\"\"Discards the outgoing route of specific cluster.\n\n :param application_name: The name of source application.\n :param cluster_name: The name of source cluster.\n :param destination: The name of destination application.\n :form intent: The intent of route. (``direct``)\n :<...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null }, { "param": "cluster_name", "type": null }, { "param": "destination", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of source a...
b26f724e2cba16b4c6dcb1a5cfa4969de35ab2f7
mowangdk/huskar
huskar_api/api/service_route.py
[ "MIT" ]
Python
put
<not_specific>
def put(self, application_name): """Creates or updates a default route policy of specific application. :param application_name: The name of specific application. :form ezone: Optional. The ezone of default route. Default: ``overall`` :form intent: Optional. The intent of default route. ...
Creates or updates a default route policy of specific application. :param application_name: The name of specific application. :form ezone: Optional. The ezone of default route. Default: ``overall`` :form intent: Optional. The intent of default route. Default: ``direct`` ...
Creates or updates a default route policy of specific application.
[ "Creates", "or", "updates", "a", "default", "route", "policy", "of", "specific", "application", "." ]
def put(self, application_name): check_application_auth(application_name, Authority.WRITE) ezone = request.form.get('ezone') or OVERALL intent = request.form.get('intent') or ROUTE_DEFAULT_INTENT cluster_name = request.form['cluster_name'] check_cluster_name(cluster_name, applica...
[ "def", "put", "(", "self", ",", "application_name", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "ezone", "=", "request", ".", "form", ".", "get", "(", "'ezone'", ")", "or", "OVERALL", "intent", "=", "re...
Creates or updates a default route policy of specific application.
[ "Creates", "or", "updates", "a", "default", "route", "policy", "of", "specific", "application", "." ]
[ "\"\"\"Creates or updates a default route policy of specific application.\n\n :param application_name: The name of specific application.\n :form ezone: Optional. The ezone of default route. Default: ``overall``\n :form intent: Optional. The intent of default route. Default:\n ...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of specific...
b26f724e2cba16b4c6dcb1a5cfa4969de35ab2f7
mowangdk/huskar
huskar_api/api/service_route.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self, application_name): """Discards a default route policy of specific application. :param application_name: The name of specific application. :form ezone: Optional. The ezone of default route. Default: ``overall`` :form intent: Optional. The intent of default route. Default...
Discards a default route policy of specific application. :param application_name: The name of specific application. :form ezone: Optional. The ezone of default route. Default: ``overall`` :form intent: Optional. The intent of default route. Default: ``direct`` :<he...
Discards a default route policy of specific application.
[ "Discards", "a", "default", "route", "policy", "of", "specific", "application", "." ]
def delete(self, application_name): check_application_auth(application_name, Authority.WRITE) ezone = request.form.get('ezone') or OVERALL intent = request.form.get('intent') or ROUTE_DEFAULT_INTENT facade = RouteManagement(huskar_client, application_name, None) try: ...
[ "def", "delete", "(", "self", ",", "application_name", ")", ":", "check_application_auth", "(", "application_name", ",", "Authority", ".", "WRITE", ")", "ezone", "=", "request", ".", "form", ".", "get", "(", "'ezone'", ")", "or", "OVERALL", "intent", "=", ...
Discards a default route policy of specific application.
[ "Discards", "a", "default", "route", "policy", "of", "specific", "application", "." ]
[ "\"\"\"Discards a default route policy of specific application.\n\n :param application_name: The name of specific application.\n :form ezone: Optional. The ezone of default route. Default: ``overall``\n :form intent: Optional. The intent of default route. Default:\n ``direc...
[ { "param": "self", "type": null }, { "param": "application_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "application_name", "type": null, "docstring": "The name of specific...
a817a390a9fac0df933b25e904403263adbf283f
mowangdk/huskar
huskar_api/extras/auth.py
[ "MIT" ]
Python
authorize_owners
null
def authorize_owners(app_info): """Grants the authority of application owners. The application owners should be authorized to write his (her) applications. """ application = app_info.ensure_application() now_auth = set([(i.user_id, Authority(i.authority)) for i in applicatio...
Grants the authority of application owners. The application owners should be authorized to write his (her) applications.
Grants the authority of application owners. The application owners should be authorized to write his (her) applications.
[ "Grants", "the", "authority", "of", "application", "owners", ".", "The", "application", "owners", "should", "be", "authorized", "to", "write", "his", "(", "her", ")", "applications", "." ]
def authorize_owners(app_info): application = app_info.ensure_application() now_auth = set([(i.user_id, Authority(i.authority)) for i in application.list_auth()]) need_ensure_owners = set([(user.id, authority) for (user, authority) in ensure_owners( ...
[ "def", "authorize_owners", "(", "app_info", ")", ":", "application", "=", "app_info", ".", "ensure_application", "(", ")", "now_auth", "=", "set", "(", "[", "(", "i", ".", "user_id", ",", "Authority", "(", "i", ".", "authority", ")", ")", "for", "i", "...
Grants the authority of application owners.
[ "Grants", "the", "authority", "of", "application", "owners", "." ]
[ "\"\"\"Grants the authority of application owners.\n\n The application owners should be authorized to write his (her)\n applications.\n \"\"\"" ]
[ { "param": "app_info", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "app_info", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f28754953d1233f3b393c2025a7692c549b0bb19
mowangdk/huskar
huskar_api/models/instance/management.py
[ "MIT" ]
Python
list_cluster_names
<not_specific>
def list_cluster_names(self): """Gets all cluster names of current application. :returns: The list of names. """ info = self._make_service_info() try: return sorted(self.huskar_client.client.get_children(info.path)) except NoNodeError: return []
Gets all cluster names of current application. :returns: The list of names.
Gets all cluster names of current application.
[ "Gets", "all", "cluster", "names", "of", "current", "application", "." ]
def list_cluster_names(self): info = self._make_service_info() try: return sorted(self.huskar_client.client.get_children(info.path)) except NoNodeError: return []
[ "def", "list_cluster_names", "(", "self", ")", ":", "info", "=", "self", ".", "_make_service_info", "(", ")", "try", ":", "return", "sorted", "(", "self", ".", "huskar_client", ".", "client", ".", "get_children", "(", "info", ".", "path", ")", ")", "exce...
Gets all cluster names of current application.
[ "Gets", "all", "cluster", "names", "of", "current", "application", "." ]
[ "\"\"\"Gets all cluster names of current application.\n\n :returns: The list of names.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "The list of names.", "docstring_tokens": [ "The", "list", "of", "names", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, ...
f28754953d1233f3b393c2025a7692c549b0bb19
mowangdk/huskar
huskar_api/models/instance/management.py
[ "MIT" ]
Python
list_instance_keys
<not_specific>
def list_instance_keys(self, cluster_name, resolve=True): """Gets all keys of specified cluster. The cluster will be resolved here, including the symlink and route. :param cluster_name: The name of callee cluster. :param resolve: ``False`` if you don't wanna resolving the cluster. ...
Gets all keys of specified cluster. The cluster will be resolved here, including the symlink and route. :param cluster_name: The name of callee cluster. :param resolve: ``False`` if you don't wanna resolving the cluster. :returns: The list of keys.
Gets all keys of specified cluster. The cluster will be resolved here, including the symlink and route.
[ "Gets", "all", "keys", "of", "specified", "cluster", ".", "The", "cluster", "will", "be", "resolved", "here", "including", "the", "symlink", "and", "route", "." ]
def list_instance_keys(self, cluster_name, resolve=True): if resolve: physical_name = self.resolve_cluster_name(cluster_name) cluster_name = physical_name or cluster_name info = self._make_cluster_info(cluster_name) try: keys = sorted(self.huskar_client.client...
[ "def", "list_instance_keys", "(", "self", ",", "cluster_name", ",", "resolve", "=", "True", ")", ":", "if", "resolve", ":", "physical_name", "=", "self", ".", "resolve_cluster_name", "(", "cluster_name", ")", "cluster_name", "=", "physical_name", "or", "cluster_...
Gets all keys of specified cluster.
[ "Gets", "all", "keys", "of", "specified", "cluster", "." ]
[ "\"\"\"Gets all keys of specified cluster.\n\n The cluster will be resolved here, including the symlink and route.\n\n :param cluster_name: The name of callee cluster.\n :param resolve: ``False`` if you don't wanna resolving the cluster.\n :returns: The list of keys.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "cluster_name", "type": null }, { "param": "resolve", "type": null } ]
{ "returns": [ { "docstring": "The list of keys.", "docstring_tokens": [ "The", "list", "of", "keys", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "d...