repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
edx/i18n-tools | i18n/transifex.py | pull_all_rtl | def pull_all_rtl(configuration):
"""
Pulls all translations - reviewed or not - for RTL languages
"""
print("Pulling all translated RTL languages from transifex...")
for lang in configuration.rtl_langs:
print('rm -rf conf/locale/' + lang)
execute('rm -rf conf/locale/' + lang)
... | python | def pull_all_rtl(configuration):
"""
Pulls all translations - reviewed or not - for RTL languages
"""
print("Pulling all translated RTL languages from transifex...")
for lang in configuration.rtl_langs:
print('rm -rf conf/locale/' + lang)
execute('rm -rf conf/locale/' + lang)
... | [
"def",
"pull_all_rtl",
"(",
"configuration",
")",
":",
"print",
"(",
"\"Pulling all translated RTL languages from transifex...\"",
")",
"for",
"lang",
"in",
"configuration",
".",
"rtl_langs",
":",
"print",
"(",
"'rm -rf conf/locale/'",
"+",
"lang",
")",
"execute",
"("... | Pulls all translations - reviewed or not - for RTL languages | [
"Pulls",
"all",
"translations",
"-",
"reviewed",
"or",
"not",
"-",
"for",
"RTL",
"languages"
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L91-L100 |
edx/i18n-tools | i18n/transifex.py | clean_translated_locales | def clean_translated_locales(configuration, langs=None):
"""
Strips out the warning from all translated po files
about being an English source file.
"""
if not langs:
langs = configuration.translated_locales
for locale in langs:
clean_locale(configuration, locale) | python | def clean_translated_locales(configuration, langs=None):
"""
Strips out the warning from all translated po files
about being an English source file.
"""
if not langs:
langs = configuration.translated_locales
for locale in langs:
clean_locale(configuration, locale) | [
"def",
"clean_translated_locales",
"(",
"configuration",
",",
"langs",
"=",
"None",
")",
":",
"if",
"not",
"langs",
":",
"langs",
"=",
"configuration",
".",
"translated_locales",
"for",
"locale",
"in",
"langs",
":",
"clean_locale",
"(",
"configuration",
",",
"... | Strips out the warning from all translated po files
about being an English source file. | [
"Strips",
"out",
"the",
"warning",
"from",
"all",
"translated",
"po",
"files",
"about",
"being",
"an",
"English",
"source",
"file",
"."
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L103-L111 |
edx/i18n-tools | i18n/transifex.py | clean_locale | def clean_locale(configuration, locale):
"""
Strips out the warning from all of a locale's translated po files
about being an English source file.
Iterates over machine-generated files.
"""
dirname = configuration.get_messages_dir(locale)
if not dirname.exists():
# Happens when we ha... | python | def clean_locale(configuration, locale):
"""
Strips out the warning from all of a locale's translated po files
about being an English source file.
Iterates over machine-generated files.
"""
dirname = configuration.get_messages_dir(locale)
if not dirname.exists():
# Happens when we ha... | [
"def",
"clean_locale",
"(",
"configuration",
",",
"locale",
")",
":",
"dirname",
"=",
"configuration",
".",
"get_messages_dir",
"(",
"locale",
")",
"if",
"not",
"dirname",
".",
"exists",
"(",
")",
":",
"# Happens when we have a supported locale that doesn't exist in T... | Strips out the warning from all of a locale's translated po files
about being an English source file.
Iterates over machine-generated files. | [
"Strips",
"out",
"the",
"warning",
"from",
"all",
"of",
"a",
"locale",
"s",
"translated",
"po",
"files",
"about",
"being",
"an",
"English",
"source",
"file",
".",
"Iterates",
"over",
"machine",
"-",
"generated",
"files",
"."
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L114-L125 |
edx/i18n-tools | i18n/transifex.py | clean_file | def clean_file(configuration, filename):
"""
Strips out the warning from a translated po file about being an English source file.
Replaces warning with a note about coming from Transifex.
"""
pofile = polib.pofile(filename)
if pofile.header.find(EDX_MARKER) != -1:
new_header = get_new_h... | python | def clean_file(configuration, filename):
"""
Strips out the warning from a translated po file about being an English source file.
Replaces warning with a note about coming from Transifex.
"""
pofile = polib.pofile(filename)
if pofile.header.find(EDX_MARKER) != -1:
new_header = get_new_h... | [
"def",
"clean_file",
"(",
"configuration",
",",
"filename",
")",
":",
"pofile",
"=",
"polib",
".",
"pofile",
"(",
"filename",
")",
"if",
"pofile",
".",
"header",
".",
"find",
"(",
"EDX_MARKER",
")",
"!=",
"-",
"1",
":",
"new_header",
"=",
"get_new_header... | Strips out the warning from a translated po file about being an English source file.
Replaces warning with a note about coming from Transifex. | [
"Strips",
"out",
"the",
"warning",
"from",
"a",
"translated",
"po",
"file",
"about",
"being",
"an",
"English",
"source",
"file",
".",
"Replaces",
"warning",
"with",
"a",
"note",
"about",
"coming",
"from",
"Transifex",
"."
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L128-L139 |
edx/i18n-tools | i18n/transifex.py | get_new_header | def get_new_header(configuration, pofile):
"""
Insert info about edX into the po file headers
"""
team = pofile.metadata.get('Language-Team', None)
if not team:
return TRANSIFEX_HEADER.format(configuration.TRANSIFEX_URL)
return TRANSIFEX_HEADER.format(team) | python | def get_new_header(configuration, pofile):
"""
Insert info about edX into the po file headers
"""
team = pofile.metadata.get('Language-Team', None)
if not team:
return TRANSIFEX_HEADER.format(configuration.TRANSIFEX_URL)
return TRANSIFEX_HEADER.format(team) | [
"def",
"get_new_header",
"(",
"configuration",
",",
"pofile",
")",
":",
"team",
"=",
"pofile",
".",
"metadata",
".",
"get",
"(",
"'Language-Team'",
",",
"None",
")",
"if",
"not",
"team",
":",
"return",
"TRANSIFEX_HEADER",
".",
"format",
"(",
"configuration",... | Insert info about edX into the po file headers | [
"Insert",
"info",
"about",
"edX",
"into",
"the",
"po",
"file",
"headers"
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L142-L149 |
edx/i18n-tools | i18n/converter.py | Converter.convert | def convert(self, string):
"""Returns: a converted tagged string
param: string (contains html tags)
Don't replace characters inside tags
"""
(string, tags) = self.detag_string(string)
string = self.inner_convert_string(string)
string = self.retag_string(str... | python | def convert(self, string):
"""Returns: a converted tagged string
param: string (contains html tags)
Don't replace characters inside tags
"""
(string, tags) = self.detag_string(string)
string = self.inner_convert_string(string)
string = self.retag_string(str... | [
"def",
"convert",
"(",
"self",
",",
"string",
")",
":",
"(",
"string",
",",
"tags",
")",
"=",
"self",
".",
"detag_string",
"(",
"string",
")",
"string",
"=",
"self",
".",
"inner_convert_string",
"(",
"string",
")",
"string",
"=",
"self",
".",
"retag_st... | Returns: a converted tagged string
param: string (contains html tags)
Don't replace characters inside tags | [
"Returns",
":",
"a",
"converted",
"tagged",
"string",
"param",
":",
"string",
"(",
"contains",
"html",
"tags",
")"
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/converter.py#L40-L49 |
edx/i18n-tools | i18n/converter.py | Converter.detag_string | def detag_string(self, string):
"""Extracts tags from string.
returns (string, list) where
string: string has tags replaced by indices (<BR>... => <0>, <1>, <2>, etc.)
list: list of the removed tags ('<BR>', '<I>', '</I>')
"""
counter = itertools.count(0)
... | python | def detag_string(self, string):
"""Extracts tags from string.
returns (string, list) where
string: string has tags replaced by indices (<BR>... => <0>, <1>, <2>, etc.)
list: list of the removed tags ('<BR>', '<I>', '</I>')
"""
counter = itertools.count(0)
... | [
"def",
"detag_string",
"(",
"self",
",",
"string",
")",
":",
"counter",
"=",
"itertools",
".",
"count",
"(",
"0",
")",
"count",
"=",
"lambda",
"m",
":",
"'<%s>'",
"%",
"next",
"(",
"counter",
")",
"tags",
"=",
"self",
".",
"tag_pattern",
".",
"findal... | Extracts tags from string.
returns (string, list) where
string: string has tags replaced by indices (<BR>... => <0>, <1>, <2>, etc.)
list: list of the removed tags ('<BR>', '<I>', '</I>') | [
"Extracts",
"tags",
"from",
"string",
"."
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/converter.py#L51-L65 |
edx/i18n-tools | i18n/converter.py | Converter.retag_string | def retag_string(self, string, tags):
"""substitutes each tag back into string, into occurrences of <0>, <1> etc"""
for i, tag in enumerate(tags):
bracketed = '<%s>' % i
string = re.sub(bracketed, tag, string, 1)
return string | python | def retag_string(self, string, tags):
"""substitutes each tag back into string, into occurrences of <0>, <1> etc"""
for i, tag in enumerate(tags):
bracketed = '<%s>' % i
string = re.sub(bracketed, tag, string, 1)
return string | [
"def",
"retag_string",
"(",
"self",
",",
"string",
",",
"tags",
")",
":",
"for",
"i",
",",
"tag",
"in",
"enumerate",
"(",
"tags",
")",
":",
"bracketed",
"=",
"'<%s>'",
"%",
"i",
"string",
"=",
"re",
".",
"sub",
"(",
"bracketed",
",",
"tag",
",",
... | substitutes each tag back into string, into occurrences of <0>, <1> etc | [
"substitutes",
"each",
"tag",
"back",
"into",
"string",
"into",
"occurrences",
"of",
"<0",
">",
"<1",
">",
"etc"
] | train | https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/converter.py#L67-L72 |
protream/iquery | iquery/utils.py | Args.options | def options(self):
"""Train tickets query options."""
arg = self.get(0)
if arg.startswith('-') and not self.is_asking_for_help:
return arg[1:]
return ''.join(x for x in arg if x in 'dgktz') | python | def options(self):
"""Train tickets query options."""
arg = self.get(0)
if arg.startswith('-') and not self.is_asking_for_help:
return arg[1:]
return ''.join(x for x in arg if x in 'dgktz') | [
"def",
"options",
"(",
"self",
")",
":",
"arg",
"=",
"self",
".",
"get",
"(",
"0",
")",
"if",
"arg",
".",
"startswith",
"(",
"'-'",
")",
"and",
"not",
"self",
".",
"is_asking_for_help",
":",
"return",
"arg",
"[",
"1",
":",
"]",
"return",
"''",
".... | Train tickets query options. | [
"Train",
"tickets",
"query",
"options",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/utils.py#L79-L84 |
protream/iquery | iquery/trains.py | TrainsCollection.trains | def trains(self):
"""Filter rows according to `headers`"""
for row in self._rows:
train_no = row.get('station_train_code')
initial = train_no[0].lower()
if not self._opts or initial in self._opts:
train = [
# Column: '车次'
... | python | def trains(self):
"""Filter rows according to `headers`"""
for row in self._rows:
train_no = row.get('station_train_code')
initial = train_no[0].lower()
if not self._opts or initial in self._opts:
train = [
# Column: '车次'
... | [
"def",
"trains",
"(",
"self",
")",
":",
"for",
"row",
"in",
"self",
".",
"_rows",
":",
"train_no",
"=",
"row",
".",
"get",
"(",
"'station_train_code'",
")",
"initial",
"=",
"train_no",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"if",
"not",
"self",
"."... | Filter rows according to `headers` | [
"Filter",
"rows",
"according",
"to",
"headers"
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/trains.py#L63-L101 |
protream/iquery | iquery/trains.py | TrainsCollection.pretty_print | def pretty_print(self):
"""Use `PrettyTable` to perform formatted outprint."""
pt = PrettyTable()
if len(self) == 0:
pt._set_field_names(['Sorry,'])
pt.add_row([TRAIN_NOT_FOUND])
else:
pt._set_field_names(self.headers)
for train in self.tra... | python | def pretty_print(self):
"""Use `PrettyTable` to perform formatted outprint."""
pt = PrettyTable()
if len(self) == 0:
pt._set_field_names(['Sorry,'])
pt.add_row([TRAIN_NOT_FOUND])
else:
pt._set_field_names(self.headers)
for train in self.tra... | [
"def",
"pretty_print",
"(",
"self",
")",
":",
"pt",
"=",
"PrettyTable",
"(",
")",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"pt",
".",
"_set_field_names",
"(",
"[",
"'Sorry,'",
"]",
")",
"pt",
".",
"add_row",
"(",
"[",
"TRAIN_NOT_FOUND",
"]",
... | Use `PrettyTable` to perform formatted outprint. | [
"Use",
"PrettyTable",
"to",
"perform",
"formatted",
"outprint",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/trains.py#L103-L113 |
protream/iquery | iquery/trains.py | TrainTicketsQuery._valid_date | def _valid_date(self):
"""Check and return a valid query date."""
date = self._parse_date(self.date)
if not date:
exit_after_echo(INVALID_DATE)
try:
date = datetime.strptime(date, '%Y%m%d')
except ValueError:
exit_after_echo(INVALID_DATE)
... | python | def _valid_date(self):
"""Check and return a valid query date."""
date = self._parse_date(self.date)
if not date:
exit_after_echo(INVALID_DATE)
try:
date = datetime.strptime(date, '%Y%m%d')
except ValueError:
exit_after_echo(INVALID_DATE)
... | [
"def",
"_valid_date",
"(",
"self",
")",
":",
"date",
"=",
"self",
".",
"_parse_date",
"(",
"self",
".",
"date",
")",
"if",
"not",
"date",
":",
"exit_after_echo",
"(",
"INVALID_DATE",
")",
"try",
":",
"date",
"=",
"datetime",
".",
"strptime",
"(",
"date... | Check and return a valid query date. | [
"Check",
"and",
"return",
"a",
"valid",
"query",
"date",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/trains.py#L177-L194 |
protream/iquery | iquery/trains.py | TrainTicketsQuery._parse_date | def _parse_date(date):
"""Parse from the user input `date`.
e.g. current year 2016:
input 6-26, 626, ... return 2016626
input 2016-6-26, 2016/6/26, ... retrun 2016626
This fn wouldn't check the date, it only gather the number as a string.
"""
result = ''.j... | python | def _parse_date(date):
"""Parse from the user input `date`.
e.g. current year 2016:
input 6-26, 626, ... return 2016626
input 2016-6-26, 2016/6/26, ... retrun 2016626
This fn wouldn't check the date, it only gather the number as a string.
"""
result = ''.j... | [
"def",
"_parse_date",
"(",
"date",
")",
":",
"result",
"=",
"''",
".",
"join",
"(",
"re",
".",
"findall",
"(",
"'\\d'",
",",
"date",
")",
")",
"l",
"=",
"len",
"(",
"result",
")",
"# User only input month and day, eg 6-1, 6.26, 0626...",
"if",
"l",
"in",
... | Parse from the user input `date`.
e.g. current year 2016:
input 6-26, 626, ... return 2016626
input 2016-6-26, 2016/6/26, ... retrun 2016626
This fn wouldn't check the date, it only gather the number as a string. | [
"Parse",
"from",
"the",
"user",
"input",
"date",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/trains.py#L197-L218 |
protream/iquery | iquery/trains.py | TrainTicketsQuery._build_params | def _build_params(self):
"""Have no idea why wrong params order can't get data.
So, use `OrderedDict` here.
"""
d = OrderedDict()
d['purpose_codes'] = 'ADULT'
d['queryDate'] = self._valid_date
d['from_station'] = self._from_station_telecode
d['to_station']... | python | def _build_params(self):
"""Have no idea why wrong params order can't get data.
So, use `OrderedDict` here.
"""
d = OrderedDict()
d['purpose_codes'] = 'ADULT'
d['queryDate'] = self._valid_date
d['from_station'] = self._from_station_telecode
d['to_station']... | [
"def",
"_build_params",
"(",
"self",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"d",
"[",
"'purpose_codes'",
"]",
"=",
"'ADULT'",
"d",
"[",
"'queryDate'",
"]",
"=",
"self",
".",
"_valid_date",
"d",
"[",
"'from_station'",
"]",
"=",
"self",
".",
"_from... | Have no idea why wrong params order can't get data.
So, use `OrderedDict` here. | [
"Have",
"no",
"idea",
"why",
"wrong",
"params",
"order",
"can",
"t",
"get",
"data",
".",
"So",
"use",
"OrderedDict",
"here",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/trains.py#L220-L229 |
protream/iquery | iquery/showes.py | ShowTicketsQuery.date_range | def date_range(self):
"""Generate date range according to the `days` user input."""
try:
days = int(self.days)
except ValueError:
exit_after_echo(QUERY_DAYS_INVALID)
if days < 1:
exit_after_echo(QUERY_DAYS_INVALID)
start = datetime.today()
... | python | def date_range(self):
"""Generate date range according to the `days` user input."""
try:
days = int(self.days)
except ValueError:
exit_after_echo(QUERY_DAYS_INVALID)
if days < 1:
exit_after_echo(QUERY_DAYS_INVALID)
start = datetime.today()
... | [
"def",
"date_range",
"(",
"self",
")",
":",
"try",
":",
"days",
"=",
"int",
"(",
"self",
".",
"days",
")",
"except",
"ValueError",
":",
"exit_after_echo",
"(",
"QUERY_DAYS_INVALID",
")",
"if",
"days",
"<",
"1",
":",
"exit_after_echo",
"(",
"QUERY_DAYS_INVA... | Generate date range according to the `days` user input. | [
"Generate",
"date",
"range",
"according",
"to",
"the",
"days",
"user",
"input",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/showes.py#L121-L135 |
protream/iquery | iquery/showes.py | ShowTicketsQuery.parse | def parse(self, items):
"""Parse `主题`, `时间`, `场馆`, 票价` in every item."""
rows = []
for i, item in enumerate(items):
theme = colored.green(item.find(class_='ico').a.text.strip())
text = item.find(class_='mt10').text.strip()
mix = re.sub('\s+', ' ', text).split(... | python | def parse(self, items):
"""Parse `主题`, `时间`, `场馆`, 票价` in every item."""
rows = []
for i, item in enumerate(items):
theme = colored.green(item.find(class_='ico').a.text.strip())
text = item.find(class_='mt10').text.strip()
mix = re.sub('\s+', ' ', text).split(... | [
"def",
"parse",
"(",
"self",
",",
"items",
")",
":",
"rows",
"=",
"[",
"]",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"items",
")",
":",
"theme",
"=",
"colored",
".",
"green",
"(",
"item",
".",
"find",
"(",
"class_",
"=",
"'ico'",
")",
"... | Parse `主题`, `时间`, `场馆`, 票价` in every item. | [
"Parse",
"主题",
"时间",
"场馆",
"票价",
"in",
"every",
"item",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/showes.py#L146-L159 |
protream/iquery | iquery/hospitals.py | query | def query(params):
"""`params` is a city name or a city name + hospital name.
CLI:
1. query all putian hospitals in a city:
$ iquery -p 南京
+------+
| 南京 |
+------+
|... |
+------+
|... |
+------+
...
2. query if the... | python | def query(params):
"""`params` is a city name or a city name + hospital name.
CLI:
1. query all putian hospitals in a city:
$ iquery -p 南京
+------+
| 南京 |
+------+
|... |
+------+
|... |
+------+
...
2. query if the... | [
"def",
"query",
"(",
"params",
")",
":",
"r",
"=",
"requests_get",
"(",
"QUERY_URL",
",",
"verify",
"=",
"True",
")",
"return",
"HospitalCollection",
"(",
"r",
".",
"json",
"(",
")",
",",
"params",
")"
] | `params` is a city name or a city name + hospital name.
CLI:
1. query all putian hospitals in a city:
$ iquery -p 南京
+------+
| 南京 |
+------+
|... |
+------+
|... |
+------+
...
2. query if the hospital in the city is p... | [
"params",
"is",
"a",
"city",
"name",
"or",
"a",
"city",
"name",
"+",
"hospital",
"name",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/hospitals.py#L67-L99 |
protream/iquery | iquery/core.py | cli | def cli():
"""Various information query via command line.
Usage:
iquery -l <song> [singer]
iquery (-m|电影)
iquery (-c|彩票)
iquery -p <city>
iquery -p <city> <hospital>
iquery <city> <show> [days]
iquery [-dgktz] <from> <to> <date>
Arguments:
from 出发站
to ... | python | def cli():
"""Various information query via command line.
Usage:
iquery -l <song> [singer]
iquery (-m|电影)
iquery (-c|彩票)
iquery -p <city>
iquery -p <city> <hospital>
iquery <city> <show> [days]
iquery [-dgktz] <from> <to> <date>
Arguments:
from 出发站
to ... | [
"def",
"cli",
"(",
")",
":",
"if",
"args",
".",
"is_asking_for_help",
":",
"exit_after_echo",
"(",
"cli",
".",
"__doc__",
",",
"color",
"=",
"None",
")",
"elif",
"args",
".",
"is_querying_lottery",
":",
"from",
".",
"lottery",
"import",
"query",
"result",
... | Various information query via command line.
Usage:
iquery -l <song> [singer]
iquery (-m|电影)
iquery (-c|彩票)
iquery -p <city>
iquery -p <city> <hospital>
iquery <city> <show> [days]
iquery [-dgktz] <from> <to> <date>
Arguments:
from 出发站
to 到达站
date ... | [
"Various",
"information",
"query",
"via",
"command",
"line",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/core.py#L44-L117 |
protream/iquery | iquery/lyrics.py | query | def query(song_name):
"""CLI:
$ iquery -l song_name
"""
r = requests_get(SONG_SEARCH_URL.format(song_name))
try:
# Get the first result.
song_url = re.search(r'(http://www.xiami.com/song/\d+)', r.text).group(0)
except AttributeError:
exit_after_echo(SONG_NOT_FOUND)
... | python | def query(song_name):
"""CLI:
$ iquery -l song_name
"""
r = requests_get(SONG_SEARCH_URL.format(song_name))
try:
# Get the first result.
song_url = re.search(r'(http://www.xiami.com/song/\d+)', r.text).group(0)
except AttributeError:
exit_after_echo(SONG_NOT_FOUND)
... | [
"def",
"query",
"(",
"song_name",
")",
":",
"r",
"=",
"requests_get",
"(",
"SONG_SEARCH_URL",
".",
"format",
"(",
"song_name",
")",
")",
"try",
":",
"# Get the first result.",
"song_url",
"=",
"re",
".",
"search",
"(",
"r'(http://www.xiami.com/song/\\d+)'",
",",... | CLI:
$ iquery -l song_name | [
"CLI",
":"
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/lyrics.py#L58-L71 |
protream/iquery | iquery/lottery.py | LotteryPage.lotteries | def lotteries(self):
"""用于生成所有彩种最近开奖信息"""
for idx, row in enumerate(self._rows):
i = pq(row)
cz = i('td:eq(0)').text().strip()
if cz in self.need_to_show:
qh = i('td:eq(1)').text().strip()
kjsj = i('td:eq(2)').text().strip()
... | python | def lotteries(self):
"""用于生成所有彩种最近开奖信息"""
for idx, row in enumerate(self._rows):
i = pq(row)
cz = i('td:eq(0)').text().strip()
if cz in self.need_to_show:
qh = i('td:eq(1)').text().strip()
kjsj = i('td:eq(2)').text().strip()
... | [
"def",
"lotteries",
"(",
"self",
")",
":",
"for",
"idx",
",",
"row",
"in",
"enumerate",
"(",
"self",
".",
"_rows",
")",
":",
"i",
"=",
"pq",
"(",
"row",
")",
"cz",
"=",
"i",
"(",
"'td:eq(0)'",
")",
".",
"text",
"(",
")",
".",
"strip",
"(",
")... | 用于生成所有彩种最近开奖信息 | [
"用于生成所有彩种最近开奖信息"
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/lottery.py#L43-L57 |
protream/iquery | iquery/lottery.py | LotteryPage._get_lottery_detail_by_id | def _get_lottery_detail_by_id(self, id):
"""
相应彩种历史信息生成
百度详细信息页有两种结构,需要分开处理
"""
header = '编号 期号 开奖日期 开奖号码'.split()
pt = PrettyTable()
pt._set_field_names(header)
url = QUERY_DETAIL_URL.format(id=id)
import requests
content = requests.get(u... | python | def _get_lottery_detail_by_id(self, id):
"""
相应彩种历史信息生成
百度详细信息页有两种结构,需要分开处理
"""
header = '编号 期号 开奖日期 开奖号码'.split()
pt = PrettyTable()
pt._set_field_names(header)
url = QUERY_DETAIL_URL.format(id=id)
import requests
content = requests.get(u... | [
"def",
"_get_lottery_detail_by_id",
"(",
"self",
",",
"id",
")",
":",
"header",
"=",
"'编号 期号 开奖日期 开奖号码'.split()",
"",
"",
"",
"",
"pt",
"=",
"PrettyTable",
"(",
")",
"pt",
".",
"_set_field_names",
"(",
"header",
")",
"url",
"=",
"QUERY_DETAIL_URL",
".",
"f... | 相应彩种历史信息生成
百度详细信息页有两种结构,需要分开处理 | [
"相应彩种历史信息生成",
"百度详细信息页有两种结构,需要分开处理"
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/lottery.py#L59-L105 |
protream/iquery | iquery/movies.py | query | def query():
"""Query hot movies infomation from douban."""
r = requests_get(QUERY_URL)
try:
rows = r.json()['subject_collection_items']
except (IndexError, TypeError):
rows = []
return MoviesCollection(rows) | python | def query():
"""Query hot movies infomation from douban."""
r = requests_get(QUERY_URL)
try:
rows = r.json()['subject_collection_items']
except (IndexError, TypeError):
rows = []
return MoviesCollection(rows) | [
"def",
"query",
"(",
")",
":",
"r",
"=",
"requests_get",
"(",
"QUERY_URL",
")",
"try",
":",
"rows",
"=",
"r",
".",
"json",
"(",
")",
"[",
"'subject_collection_items'",
"]",
"except",
"(",
"IndexError",
",",
"TypeError",
")",
":",
"rows",
"=",
"[",
"]... | Query hot movies infomation from douban. | [
"Query",
"hot",
"movies",
"infomation",
"from",
"douban",
"."
] | train | https://github.com/protream/iquery/blob/7272e68af610f1dd63cf695209cfa44b75adc0e6/iquery/movies.py#L93-L103 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory.action_draft | def action_draft(self):
"""Set a change request as draft"""
for rec in self:
if not rec.state == 'cancelled':
raise UserError(
_('You need to cancel it before reopening.'))
if not (rec.am_i_owner or rec.am_i_approver):
raise Use... | python | def action_draft(self):
"""Set a change request as draft"""
for rec in self:
if not rec.state == 'cancelled':
raise UserError(
_('You need to cancel it before reopening.'))
if not (rec.am_i_owner or rec.am_i_approver):
raise Use... | [
"def",
"action_draft",
"(",
"self",
")",
":",
"for",
"rec",
"in",
"self",
":",
"if",
"not",
"rec",
".",
"state",
"==",
"'cancelled'",
":",
"raise",
"UserError",
"(",
"_",
"(",
"'You need to cancel it before reopening.'",
")",
")",
"if",
"not",
"(",
"rec",
... | Set a change request as draft | [
"Set",
"a",
"change",
"request",
"as",
"draft"
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L54-L64 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory.action_to_approve | def action_to_approve(self):
"""Set a change request as to approve"""
template = self.env.ref(
'document_page_approval.email_template_new_draft_need_approval')
approver_gid = self.env.ref(
'document_page_approval.group_document_approver_user')
for rec in self:
... | python | def action_to_approve(self):
"""Set a change request as to approve"""
template = self.env.ref(
'document_page_approval.email_template_new_draft_need_approval')
approver_gid = self.env.ref(
'document_page_approval.group_document_approver_user')
for rec in self:
... | [
"def",
"action_to_approve",
"(",
"self",
")",
":",
"template",
"=",
"self",
".",
"env",
".",
"ref",
"(",
"'document_page_approval.email_template_new_draft_need_approval'",
")",
"approver_gid",
"=",
"self",
".",
"env",
".",
"ref",
"(",
"'document_page_approval.group_do... | Set a change request as to approve | [
"Set",
"a",
"change",
"request",
"as",
"to",
"approve"
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L67-L92 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory.action_approve | def action_approve(self):
"""Set a change request as approved."""
for rec in self:
if rec.state not in ['draft', 'to approve']:
raise UserError(
_("Can't approve page in '%s' state.") % rec.state)
if not rec.am_i_approver:
raise... | python | def action_approve(self):
"""Set a change request as approved."""
for rec in self:
if rec.state not in ['draft', 'to approve']:
raise UserError(
_("Can't approve page in '%s' state.") % rec.state)
if not rec.am_i_approver:
raise... | [
"def",
"action_approve",
"(",
"self",
")",
":",
"for",
"rec",
"in",
"self",
":",
"if",
"rec",
".",
"state",
"not",
"in",
"[",
"'draft'",
",",
"'to approve'",
"]",
":",
"raise",
"UserError",
"(",
"_",
"(",
"\"Can't approve page in '%s' state.\"",
")",
"%",
... | Set a change request as approved. | [
"Set",
"a",
"change",
"request",
"as",
"approved",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L95-L129 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory.action_cancel | def action_cancel(self):
"""Set a change request as cancelled."""
self.write({'state': 'cancelled'})
for rec in self:
rec.message_post(
subtype='mt_comment',
body=_(
'Change request <b>%s</b> has been cancelled by %s.'
... | python | def action_cancel(self):
"""Set a change request as cancelled."""
self.write({'state': 'cancelled'})
for rec in self:
rec.message_post(
subtype='mt_comment',
body=_(
'Change request <b>%s</b> has been cancelled by %s.'
... | [
"def",
"action_cancel",
"(",
"self",
")",
":",
"self",
".",
"write",
"(",
"{",
"'state'",
":",
"'cancelled'",
"}",
")",
"for",
"rec",
"in",
"self",
":",
"rec",
".",
"message_post",
"(",
"subtype",
"=",
"'mt_comment'",
",",
"body",
"=",
"_",
"(",
"'Ch... | Set a change request as cancelled. | [
"Set",
"a",
"change",
"request",
"as",
"cancelled",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L132-L141 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory._compute_am_i_owner | def _compute_am_i_owner(self):
"""Check if current user is the owner"""
for rec in self:
rec.am_i_owner = (rec.create_uid == self.env.user) | python | def _compute_am_i_owner(self):
"""Check if current user is the owner"""
for rec in self:
rec.am_i_owner = (rec.create_uid == self.env.user) | [
"def",
"_compute_am_i_owner",
"(",
"self",
")",
":",
"for",
"rec",
"in",
"self",
":",
"rec",
".",
"am_i_owner",
"=",
"(",
"rec",
".",
"create_uid",
"==",
"self",
".",
"env",
".",
"user",
")"
] | Check if current user is the owner | [
"Check",
"if",
"current",
"user",
"is",
"the",
"owner"
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L150-L153 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory._compute_page_url | def _compute_page_url(self):
"""Compute the page url."""
for page in self:
base_url = self.env['ir.config_parameter'].sudo().get_param(
'web.base.url',
default='http://localhost:8069'
)
page.page_url = (
'{}/web#db={}&i... | python | def _compute_page_url(self):
"""Compute the page url."""
for page in self:
base_url = self.env['ir.config_parameter'].sudo().get_param(
'web.base.url',
default='http://localhost:8069'
)
page.page_url = (
'{}/web#db={}&i... | [
"def",
"_compute_page_url",
"(",
"self",
")",
":",
"for",
"page",
"in",
"self",
":",
"base_url",
"=",
"self",
".",
"env",
"[",
"'ir.config_parameter'",
"]",
".",
"sudo",
"(",
")",
".",
"get_param",
"(",
"'web.base.url'",
",",
"default",
"=",
"'http://local... | Compute the page url. | [
"Compute",
"the",
"page",
"url",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L156-L170 |
OCA/knowledge | document_page_approval/models/document_page_history.py | DocumentPageHistory._compute_diff | def _compute_diff(self):
"""Shows a diff between this version and the previous version"""
history = self.env['document.page.history']
for rec in self:
domain = [
('page_id', '=', rec.page_id.id),
('state', '=', 'approved')]
if rec.approved_... | python | def _compute_diff(self):
"""Shows a diff between this version and the previous version"""
history = self.env['document.page.history']
for rec in self:
domain = [
('page_id', '=', rec.page_id.id),
('state', '=', 'approved')]
if rec.approved_... | [
"def",
"_compute_diff",
"(",
"self",
")",
":",
"history",
"=",
"self",
".",
"env",
"[",
"'document.page.history'",
"]",
"for",
"rec",
"in",
"self",
":",
"domain",
"=",
"[",
"(",
"'page_id'",
",",
"'='",
",",
"rec",
".",
"page_id",
".",
"id",
")",
","... | Shows a diff between this version and the previous version | [
"Shows",
"a",
"diff",
"between",
"this",
"version",
"and",
"the",
"previous",
"version"
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page_history.py#L173-L186 |
OCA/knowledge | document_url/wizard/document_url.py | AddUrlWizard.action_add_url | def action_add_url(self):
"""Adds the URL with the given name as an ir.attachment record."""
if not self.env.context.get('active_model'):
return
attachment_obj = self.env['ir.attachment']
for form in self:
url = parse.urlparse(form.url)
if not url.sche... | python | def action_add_url(self):
"""Adds the URL with the given name as an ir.attachment record."""
if not self.env.context.get('active_model'):
return
attachment_obj = self.env['ir.attachment']
for form in self:
url = parse.urlparse(form.url)
if not url.sche... | [
"def",
"action_add_url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"env",
".",
"context",
".",
"get",
"(",
"'active_model'",
")",
":",
"return",
"attachment_obj",
"=",
"self",
".",
"env",
"[",
"'ir.attachment'",
"]",
"for",
"form",
"in",
"self",
... | Adds the URL with the given name as an ir.attachment record. | [
"Adds",
"the",
"URL",
"with",
"the",
"given",
"name",
"as",
"an",
"ir",
".",
"attachment",
"record",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_url/wizard/document_url.py#L14-L32 |
OCA/knowledge | document_page_approval/models/document_page.py | DocumentPage._compute_is_approval_required | def _compute_is_approval_required(self):
"""Check if the document required approval based on his parents."""
for page in self:
res = page.approval_required
if page.parent_id:
res = res or page.parent_id.is_approval_required
page.is_approval_required = ... | python | def _compute_is_approval_required(self):
"""Check if the document required approval based on his parents."""
for page in self:
res = page.approval_required
if page.parent_id:
res = res or page.parent_id.is_approval_required
page.is_approval_required = ... | [
"def",
"_compute_is_approval_required",
"(",
"self",
")",
":",
"for",
"page",
"in",
"self",
":",
"res",
"=",
"page",
".",
"approval_required",
"if",
"page",
".",
"parent_id",
":",
"res",
"=",
"res",
"or",
"page",
".",
"parent_id",
".",
"is_approval_required"... | Check if the document required approval based on his parents. | [
"Check",
"if",
"the",
"document",
"required",
"approval",
"based",
"on",
"his",
"parents",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page.py#L76-L82 |
OCA/knowledge | document_page_approval/models/document_page.py | DocumentPage._compute_approver_group_ids | def _compute_approver_group_ids(self):
"""Compute the approver groups based on his parents."""
for page in self:
res = page.approver_gid
if page.parent_id:
res = res | page.parent_id.approver_group_ids
page.approver_group_ids = res | python | def _compute_approver_group_ids(self):
"""Compute the approver groups based on his parents."""
for page in self:
res = page.approver_gid
if page.parent_id:
res = res | page.parent_id.approver_group_ids
page.approver_group_ids = res | [
"def",
"_compute_approver_group_ids",
"(",
"self",
")",
":",
"for",
"page",
"in",
"self",
":",
"res",
"=",
"page",
".",
"approver_gid",
"if",
"page",
".",
"parent_id",
":",
"res",
"=",
"res",
"|",
"page",
".",
"parent_id",
".",
"approver_group_ids",
"page"... | Compute the approver groups based on his parents. | [
"Compute",
"the",
"approver",
"groups",
"based",
"on",
"his",
"parents",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page.py#L86-L92 |
OCA/knowledge | document_page_approval/models/document_page.py | DocumentPage._compute_am_i_approver | def _compute_am_i_approver(self):
"""Check if the current user can approve changes to this page."""
for rec in self:
rec.am_i_approver = rec.can_user_approve_this_page(self.env.user) | python | def _compute_am_i_approver(self):
"""Check if the current user can approve changes to this page."""
for rec in self:
rec.am_i_approver = rec.can_user_approve_this_page(self.env.user) | [
"def",
"_compute_am_i_approver",
"(",
"self",
")",
":",
"for",
"rec",
"in",
"self",
":",
"rec",
".",
"am_i_approver",
"=",
"rec",
".",
"can_user_approve_this_page",
"(",
"self",
".",
"env",
".",
"user",
")"
] | Check if the current user can approve changes to this page. | [
"Check",
"if",
"the",
"current",
"user",
"can",
"approve",
"changes",
"to",
"this",
"page",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page.py#L96-L99 |
OCA/knowledge | document_page_approval/models/document_page.py | DocumentPage.can_user_approve_this_page | def can_user_approve_this_page(self, user):
"""Check if a user can approve this page."""
self.ensure_one()
# if it's not required, anyone can approve
if not self.is_approval_required:
return True
# if user belongs to 'Knowledge / Manager', he can approve anything
... | python | def can_user_approve_this_page(self, user):
"""Check if a user can approve this page."""
self.ensure_one()
# if it's not required, anyone can approve
if not self.is_approval_required:
return True
# if user belongs to 'Knowledge / Manager', he can approve anything
... | [
"def",
"can_user_approve_this_page",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"ensure_one",
"(",
")",
"# if it's not required, anyone can approve",
"if",
"not",
"self",
".",
"is_approval_required",
":",
"return",
"True",
"# if user belongs to 'Knowledge / Manager'... | Check if a user can approve this page. | [
"Check",
"if",
"a",
"user",
"can",
"approve",
"this",
"page",
"."
] | train | https://github.com/OCA/knowledge/blob/77fa06019c989b56ce34839e9f6343577184223a/document_page_approval/models/document_page.py#L102-L119 |
watchforstock/evohome-client | evohomeclient2/location.py | Location.status | def status(self):
"""Retrieves the location status."""
response = requests.get(
"https://tccna.honeywell.com/WebAPI/emea/api/v1/"
"location/%s/status?includeTemperatureControlSystems=True" %
self.locationId,
headers=self.client._headers() ... | python | def status(self):
"""Retrieves the location status."""
response = requests.get(
"https://tccna.honeywell.com/WebAPI/emea/api/v1/"
"location/%s/status?includeTemperatureControlSystems=True" %
self.locationId,
headers=self.client._headers() ... | [
"def",
"status",
"(",
"self",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"\"https://tccna.honeywell.com/WebAPI/emea/api/v1/\"",
"\"location/%s/status?includeTemperatureControlSystems=True\"",
"%",
"self",
".",
"locationId",
",",
"headers",
"=",
"self",
".",
... | Retrieves the location status. | [
"Retrieves",
"the",
"location",
"status",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/location.py#L26-L55 |
watchforstock/evohome-client | evohomeclient2/hotwater.py | HotWater.set_dhw_on | def set_dhw_on(self, until=None):
"""Sets the DHW on until a given time, or permanently."""
if until is None:
data = {"Mode": "PermanentOverride",
"State": "On",
"UntilTime": None}
else:
data = {"Mode": "TemporaryOverride",
... | python | def set_dhw_on(self, until=None):
"""Sets the DHW on until a given time, or permanently."""
if until is None:
data = {"Mode": "PermanentOverride",
"State": "On",
"UntilTime": None}
else:
data = {"Mode": "TemporaryOverride",
... | [
"def",
"set_dhw_on",
"(",
"self",
",",
"until",
"=",
"None",
")",
":",
"if",
"until",
"is",
"None",
":",
"data",
"=",
"{",
"\"Mode\"",
":",
"\"PermanentOverride\"",
",",
"\"State\"",
":",
"\"On\"",
",",
"\"UntilTime\"",
":",
"None",
"}",
"else",
":",
"... | Sets the DHW on until a given time, or permanently. | [
"Sets",
"the",
"DHW",
"on",
"until",
"a",
"given",
"time",
"or",
"permanently",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/hotwater.py#L34-L45 |
watchforstock/evohome-client | evohomeclient2/hotwater.py | HotWater.set_dhw_off | def set_dhw_off(self, until=None):
"""Sets the DHW off until a given time, or permanently."""
if until is None:
data = {"Mode": "PermanentOverride",
"State": "Off",
"UntilTime": None}
else:
data = {"Mode": "TemporaryOverride",
... | python | def set_dhw_off(self, until=None):
"""Sets the DHW off until a given time, or permanently."""
if until is None:
data = {"Mode": "PermanentOverride",
"State": "Off",
"UntilTime": None}
else:
data = {"Mode": "TemporaryOverride",
... | [
"def",
"set_dhw_off",
"(",
"self",
",",
"until",
"=",
"None",
")",
":",
"if",
"until",
"is",
"None",
":",
"data",
"=",
"{",
"\"Mode\"",
":",
"\"PermanentOverride\"",
",",
"\"State\"",
":",
"\"Off\"",
",",
"\"UntilTime\"",
":",
"None",
"}",
"else",
":",
... | Sets the DHW off until a given time, or permanently. | [
"Sets",
"the",
"DHW",
"off",
"until",
"a",
"given",
"time",
"or",
"permanently",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/hotwater.py#L47-L58 |
watchforstock/evohome-client | evohomeclient2/zone.py | ZoneBase.schedule | def schedule(self):
"""Gets the schedule for the given zone"""
response = requests.get(
"https://tccna.honeywell.com/WebAPI/emea/api/v1"
"/%s/%s/schedule" % (self.zone_type, self.zoneId),
headers=self.client._headers() # pylint: d... | python | def schedule(self):
"""Gets the schedule for the given zone"""
response = requests.get(
"https://tccna.honeywell.com/WebAPI/emea/api/v1"
"/%s/%s/schedule" % (self.zone_type, self.zoneId),
headers=self.client._headers() # pylint: d... | [
"def",
"schedule",
"(",
"self",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"\"https://tccna.honeywell.com/WebAPI/emea/api/v1\"",
"\"/%s/%s/schedule\"",
"%",
"(",
"self",
".",
"zone_type",
",",
"self",
".",
"zoneId",
")",
",",
"headers",
"=",
"self",... | Gets the schedule for the given zone | [
"Gets",
"the",
"schedule",
"for",
"the",
"given",
"zone"
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/zone.py#L16-L42 |
watchforstock/evohome-client | evohomeclient2/zone.py | ZoneBase.set_schedule | def set_schedule(self, zone_info):
"""Sets the schedule for this zone"""
# must only POST json, otherwise server API handler raises exceptions
try:
json.loads(zone_info)
except ValueError as error:
raise ValueError("zone_info must be valid JSON: ", error)
... | python | def set_schedule(self, zone_info):
"""Sets the schedule for this zone"""
# must only POST json, otherwise server API handler raises exceptions
try:
json.loads(zone_info)
except ValueError as error:
raise ValueError("zone_info must be valid JSON: ", error)
... | [
"def",
"set_schedule",
"(",
"self",
",",
"zone_info",
")",
":",
"# must only POST json, otherwise server API handler raises exceptions",
"try",
":",
"json",
".",
"loads",
"(",
"zone_info",
")",
"except",
"ValueError",
"as",
"error",
":",
"raise",
"ValueError",
"(",
... | Sets the schedule for this zone | [
"Sets",
"the",
"schedule",
"for",
"this",
"zone"
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/zone.py#L44-L63 |
watchforstock/evohome-client | evohomeclient/__init__.py | EvohomeClient.temperatures | def temperatures(self, force_refresh=False):
"""Retrieve the current details for each zone. Returns a generator."""
self._populate_full_data(force_refresh)
for device in self.full_data['devices']:
set_point = 0
status = ""
if 'heatSetpoint' in device['thermost... | python | def temperatures(self, force_refresh=False):
"""Retrieve the current details for each zone. Returns a generator."""
self._populate_full_data(force_refresh)
for device in self.full_data['devices']:
set_point = 0
status = ""
if 'heatSetpoint' in device['thermost... | [
"def",
"temperatures",
"(",
"self",
",",
"force_refresh",
"=",
"False",
")",
":",
"self",
".",
"_populate_full_data",
"(",
"force_refresh",
")",
"for",
"device",
"in",
"self",
".",
"full_data",
"[",
"'devices'",
"]",
":",
"set_point",
"=",
"0",
"status",
"... | Retrieve the current details for each zone. Returns a generator. | [
"Retrieve",
"the",
"current",
"details",
"for",
"each",
"zone",
".",
"Returns",
"a",
"generator",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient/__init__.py#L115-L133 |
watchforstock/evohome-client | evohomeclient/__init__.py | EvohomeClient.get_modes | def get_modes(self, zone):
"""Returns the set of modes the device can be assigned."""
self._populate_full_data()
device = self._get_device(zone)
return device['thermostat']['allowedModes'] | python | def get_modes(self, zone):
"""Returns the set of modes the device can be assigned."""
self._populate_full_data()
device = self._get_device(zone)
return device['thermostat']['allowedModes'] | [
"def",
"get_modes",
"(",
"self",
",",
"zone",
")",
":",
"self",
".",
"_populate_full_data",
"(",
")",
"device",
"=",
"self",
".",
"_get_device",
"(",
"zone",
")",
"return",
"device",
"[",
"'thermostat'",
"]",
"[",
"'allowedModes'",
"]"
] | Returns the set of modes the device can be assigned. | [
"Returns",
"the",
"set",
"of",
"modes",
"the",
"device",
"can",
"be",
"assigned",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient/__init__.py#L135-L139 |
watchforstock/evohome-client | evohomeclient/__init__.py | EvohomeClient.set_temperature | def set_temperature(self, zone, temperature, until=None):
"""Sets the temperature of the given zone."""
if until is None:
data = {"Value": temperature, "Status": "Hold", "NextTime": None}
else:
data = {"Value": temperature,
"Status": "Temporary",
... | python | def set_temperature(self, zone, temperature, until=None):
"""Sets the temperature of the given zone."""
if until is None:
data = {"Value": temperature, "Status": "Hold", "NextTime": None}
else:
data = {"Value": temperature,
"Status": "Temporary",
... | [
"def",
"set_temperature",
"(",
"self",
",",
"zone",
",",
"temperature",
",",
"until",
"=",
"None",
")",
":",
"if",
"until",
"is",
"None",
":",
"data",
"=",
"{",
"\"Value\"",
":",
"temperature",
",",
"\"Status\"",
":",
"\"Hold\"",
",",
"\"NextTime\"",
":"... | Sets the temperature of the given zone. | [
"Sets",
"the",
"temperature",
"of",
"the",
"given",
"zone",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient/__init__.py#L266-L275 |
watchforstock/evohome-client | evohomeclient/__init__.py | EvohomeClient._set_dhw | def _set_dhw(self, status="Scheduled", mode=None, next_time=None):
"""Set DHW to On, Off or Auto, either indefinitely, or until a
specified time.
"""
data = {"Status": status,
"Mode": mode,
"NextTime": next_time,
"SpecialModes": None,
... | python | def _set_dhw(self, status="Scheduled", mode=None, next_time=None):
"""Set DHW to On, Off or Auto, either indefinitely, or until a
specified time.
"""
data = {"Status": status,
"Mode": mode,
"NextTime": next_time,
"SpecialModes": None,
... | [
"def",
"_set_dhw",
"(",
"self",
",",
"status",
"=",
"\"Scheduled\"",
",",
"mode",
"=",
"None",
",",
"next_time",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"Status\"",
":",
"status",
",",
"\"Mode\"",
":",
"mode",
",",
"\"NextTime\"",
":",
"next_time",
... | Set DHW to On, Off or Auto, either indefinitely, or until a
specified time. | [
"Set",
"DHW",
"to",
"On",
"Off",
"or",
"Auto",
"either",
"indefinitely",
"or",
"until",
"a",
"specified",
"time",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient/__init__.py#L288-L311 |
watchforstock/evohome-client | evohomeclient/__init__.py | EvohomeClient.set_dhw_on | def set_dhw_on(self, until=None):
"""Set DHW to on, either indefinitely, or until a specified time.
When On, the DHW controller will work to keep its target temperature
at/above its target temperature. After the specified time, it will
revert to its scheduled behaviour.
"""
... | python | def set_dhw_on(self, until=None):
"""Set DHW to on, either indefinitely, or until a specified time.
When On, the DHW controller will work to keep its target temperature
at/above its target temperature. After the specified time, it will
revert to its scheduled behaviour.
"""
... | [
"def",
"set_dhw_on",
"(",
"self",
",",
"until",
"=",
"None",
")",
":",
"time_until",
"=",
"None",
"if",
"until",
"is",
"None",
"else",
"until",
".",
"strftime",
"(",
"'%Y-%m-%dT%H:%M:%SZ'",
")",
"self",
".",
"_set_dhw",
"(",
"status",
"=",
"\"Hold\"",
",... | Set DHW to on, either indefinitely, or until a specified time.
When On, the DHW controller will work to keep its target temperature
at/above its target temperature. After the specified time, it will
revert to its scheduled behaviour. | [
"Set",
"DHW",
"to",
"on",
"either",
"indefinitely",
"or",
"until",
"a",
"specified",
"time",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient/__init__.py#L313-L324 |
watchforstock/evohome-client | evohomeclient2/__init__.py | EvohomeClient._headers | def _headers(self):
"""Ensure the Authorization Header has a valid Access Token."""
if not self.access_token or not self.access_token_expires:
self._basic_login()
elif datetime.now() > self.access_token_expires - timedelta(seconds=30):
self._basic_login()
return... | python | def _headers(self):
"""Ensure the Authorization Header has a valid Access Token."""
if not self.access_token or not self.access_token_expires:
self._basic_login()
elif datetime.now() > self.access_token_expires - timedelta(seconds=30):
self._basic_login()
return... | [
"def",
"_headers",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"access_token",
"or",
"not",
"self",
".",
"access_token_expires",
":",
"self",
".",
"_basic_login",
"(",
")",
"elif",
"datetime",
".",
"now",
"(",
")",
">",
"self",
".",
"access_token_ex... | Ensure the Authorization Header has a valid Access Token. | [
"Ensure",
"the",
"Authorization",
"Header",
"has",
"a",
"valid",
"Access",
"Token",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/__init__.py#L84-L93 |
watchforstock/evohome-client | evohomeclient2/__init__.py | EvohomeClient._basic_login | def _basic_login(self):
"""Obtain a new access token from the vendor.
First, try using the refresh_token, if one is available, otherwise
authenticate using the user credentials.
"""
_LOGGER.debug("No/Expired/Invalid access_token, re-authenticating...")
self.access_token ... | python | def _basic_login(self):
"""Obtain a new access token from the vendor.
First, try using the refresh_token, if one is available, otherwise
authenticate using the user credentials.
"""
_LOGGER.debug("No/Expired/Invalid access_token, re-authenticating...")
self.access_token ... | [
"def",
"_basic_login",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"No/Expired/Invalid access_token, re-authenticating...\"",
")",
"self",
".",
"access_token",
"=",
"self",
".",
"access_token_expires",
"=",
"None",
"if",
"self",
".",
"refresh_token",
":",... | Obtain a new access token from the vendor.
First, try using the refresh_token, if one is available, otherwise
authenticate using the user credentials. | [
"Obtain",
"a",
"new",
"access",
"token",
"from",
"the",
"vendor",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/__init__.py#L95-L130 |
watchforstock/evohome-client | evohomeclient2/__init__.py | EvohomeClient.user_account | def user_account(self):
"""Return the user account information."""
self.account_info = None
url = 'https://tccna.honeywell.com/WebAPI/emea/api/v1/userAccount'
response = requests.get(url, headers=self._headers())
response.raise_for_status()
self.account_info = response... | python | def user_account(self):
"""Return the user account information."""
self.account_info = None
url = 'https://tccna.honeywell.com/WebAPI/emea/api/v1/userAccount'
response = requests.get(url, headers=self._headers())
response.raise_for_status()
self.account_info = response... | [
"def",
"user_account",
"(",
"self",
")",
":",
"self",
".",
"account_info",
"=",
"None",
"url",
"=",
"'https://tccna.honeywell.com/WebAPI/emea/api/v1/userAccount'",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"self",
".",
"_headers",
... | Return the user account information. | [
"Return",
"the",
"user",
"account",
"information",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/__init__.py#L192-L202 |
watchforstock/evohome-client | evohomeclient2/__init__.py | EvohomeClient.installation | def installation(self):
"""Return the details of the installation."""
self.locations = []
url = ("https://tccna.honeywell.com/WebAPI/emea/api/v1/location"
"/installationInfo?userId=%s"
"&includeTemperatureControlSystems=True"
% self.account_info['use... | python | def installation(self):
"""Return the details of the installation."""
self.locations = []
url = ("https://tccna.honeywell.com/WebAPI/emea/api/v1/location"
"/installationInfo?userId=%s"
"&includeTemperatureControlSystems=True"
% self.account_info['use... | [
"def",
"installation",
"(",
"self",
")",
":",
"self",
".",
"locations",
"=",
"[",
"]",
"url",
"=",
"(",
"\"https://tccna.honeywell.com/WebAPI/emea/api/v1/location\"",
"\"/installationInfo?userId=%s\"",
"\"&includeTemperatureControlSystems=True\"",
"%",
"self",
".",
"account... | Return the details of the installation. | [
"Return",
"the",
"details",
"of",
"the",
"installation",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/__init__.py#L204-L223 |
watchforstock/evohome-client | evohomeclient2/__init__.py | EvohomeClient.full_installation | def full_installation(self, location=None):
"""Return the full details of the installation."""
url = ("https://tccna.honeywell.com/WebAPI/emea/api/v1/location"
"/%s/installationInfo?includeTemperatureControlSystems=True"
% self._get_location(location))
response = r... | python | def full_installation(self, location=None):
"""Return the full details of the installation."""
url = ("https://tccna.honeywell.com/WebAPI/emea/api/v1/location"
"/%s/installationInfo?includeTemperatureControlSystems=True"
% self._get_location(location))
response = r... | [
"def",
"full_installation",
"(",
"self",
",",
"location",
"=",
"None",
")",
":",
"url",
"=",
"(",
"\"https://tccna.honeywell.com/WebAPI/emea/api/v1/location\"",
"\"/%s/installationInfo?includeTemperatureControlSystems=True\"",
"%",
"self",
".",
"_get_location",
"(",
"location... | Return the full details of the installation. | [
"Return",
"the",
"full",
"details",
"of",
"the",
"installation",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/__init__.py#L225-L234 |
watchforstock/evohome-client | evohomeclient2/__init__.py | EvohomeClient.gateway | def gateway(self):
"""Return the detail of the gateway."""
url = 'https://tccna.honeywell.com/WebAPI/emea/api/v1/gateway'
response = requests.get(url, headers=self._headers())
response.raise_for_status()
return response.json() | python | def gateway(self):
"""Return the detail of the gateway."""
url = 'https://tccna.honeywell.com/WebAPI/emea/api/v1/gateway'
response = requests.get(url, headers=self._headers())
response.raise_for_status()
return response.json() | [
"def",
"gateway",
"(",
"self",
")",
":",
"url",
"=",
"'https://tccna.honeywell.com/WebAPI/emea/api/v1/gateway'",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"self",
".",
"_headers",
"(",
")",
")",
"response",
".",
"raise_for_status"... | Return the detail of the gateway. | [
"Return",
"the",
"detail",
"of",
"the",
"gateway",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/__init__.py#L236-L243 |
watchforstock/evohome-client | evohomeclient2/controlsystem.py | ControlSystem.temperatures | def temperatures(self):
"""Return a generator with the details of each zone."""
self.location.status()
if self.hotwater:
yield {
'thermostat': 'DOMESTIC_HOT_WATER',
'id': self.hotwater.dhwId,
'name': '',
'temp': self.ho... | python | def temperatures(self):
"""Return a generator with the details of each zone."""
self.location.status()
if self.hotwater:
yield {
'thermostat': 'DOMESTIC_HOT_WATER',
'id': self.hotwater.dhwId,
'name': '',
'temp': self.ho... | [
"def",
"temperatures",
"(",
"self",
")",
":",
"self",
".",
"location",
".",
"status",
"(",
")",
"if",
"self",
".",
"hotwater",
":",
"yield",
"{",
"'thermostat'",
":",
"'DOMESTIC_HOT_WATER'",
",",
"'id'",
":",
"self",
".",
"hotwater",
".",
"dhwId",
",",
... | Return a generator with the details of each zone. | [
"Return",
"a",
"generator",
"with",
"the",
"details",
"of",
"each",
"zone",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/controlsystem.py#L92-L116 |
watchforstock/evohome-client | evohomeclient2/controlsystem.py | ControlSystem.zone_schedules_backup | def zone_schedules_backup(self, filename):
"""Backup all zones on control system to the given file."""
_LOGGER.info("Backing up schedules from ControlSystem: %s (%s)...",
self.systemId, self.location.name)
schedules = {}
if self.hotwater:
_LOGGER.info("... | python | def zone_schedules_backup(self, filename):
"""Backup all zones on control system to the given file."""
_LOGGER.info("Backing up schedules from ControlSystem: %s (%s)...",
self.systemId, self.location.name)
schedules = {}
if self.hotwater:
_LOGGER.info("... | [
"def",
"zone_schedules_backup",
"(",
"self",
",",
"filename",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Backing up schedules from ControlSystem: %s (%s)...\"",
",",
"self",
".",
"systemId",
",",
"self",
".",
"location",
".",
"name",
")",
"schedules",
"=",
"{",
"... | Backup all zones on control system to the given file. | [
"Backup",
"all",
"zones",
"on",
"control",
"system",
"to",
"the",
"given",
"file",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/controlsystem.py#L118-L149 |
watchforstock/evohome-client | evohomeclient2/controlsystem.py | ControlSystem.zone_schedules_restore | def zone_schedules_restore(self, filename):
"""Restore all zones on control system from the given file."""
_LOGGER.info("Restoring schedules to ControlSystem %s (%s)...",
self.systemId, self.location)
_LOGGER.info("Reading from backup file: %s...", filename)
with op... | python | def zone_schedules_restore(self, filename):
"""Restore all zones on control system from the given file."""
_LOGGER.info("Restoring schedules to ControlSystem %s (%s)...",
self.systemId, self.location)
_LOGGER.info("Reading from backup file: %s...", filename)
with op... | [
"def",
"zone_schedules_restore",
"(",
"self",
",",
"filename",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Restoring schedules to ControlSystem %s (%s)...\"",
",",
"self",
".",
"systemId",
",",
"self",
".",
"location",
")",
"_LOGGER",
".",
"info",
"(",
"\"Reading fr... | Restore all zones on control system from the given file. | [
"Restore",
"all",
"zones",
"on",
"control",
"system",
"from",
"the",
"given",
"file",
"."
] | train | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient2/controlsystem.py#L151-L174 |
softlayer/softlayer-python | SoftLayer/CLI/order/item_list.py | cli | def cli(env, package_keyname, keyword, category):
"""List package items used for ordering.
The item keyNames listed can be used with `slcli order place` to specify
the items that are being ordered in the package.
.. Note::
Items with a numbered category, like disk0 or gpu0, can be included
... | python | def cli(env, package_keyname, keyword, category):
"""List package items used for ordering.
The item keyNames listed can be used with `slcli order place` to specify
the items that are being ordered in the package.
.. Note::
Items with a numbered category, like disk0 or gpu0, can be included
... | [
"def",
"cli",
"(",
"env",
",",
"package_keyname",
",",
"keyword",
",",
"category",
")",
":",
"table",
"=",
"formatting",
".",
"Table",
"(",
"COLUMNS",
")",
"manager",
"=",
"ordering",
".",
"OrderingManager",
"(",
"env",
".",
"client",
")",
"_filter",
"="... | List package items used for ordering.
The item keyNames listed can be used with `slcli order place` to specify
the items that are being ordered in the package.
.. Note::
Items with a numbered category, like disk0 or gpu0, can be included
multiple times in an order to match how many of the ... | [
"List",
"package",
"items",
"used",
"for",
"ordering",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/item_list.py#L18-L53 |
softlayer/softlayer-python | SoftLayer/CLI/order/item_list.py | sort_items | def sort_items(items):
"""sorts the items into a dictionary of categories, with a list of items"""
sorted_items = {}
for item in items:
category = lookup(item, 'itemCategory', 'categoryCode')
if sorted_items.get(category) is None:
sorted_items[category] = []
sorted_items... | python | def sort_items(items):
"""sorts the items into a dictionary of categories, with a list of items"""
sorted_items = {}
for item in items:
category = lookup(item, 'itemCategory', 'categoryCode')
if sorted_items.get(category) is None:
sorted_items[category] = []
sorted_items... | [
"def",
"sort_items",
"(",
"items",
")",
":",
"sorted_items",
"=",
"{",
"}",
"for",
"item",
"in",
"items",
":",
"category",
"=",
"lookup",
"(",
"item",
",",
"'itemCategory'",
",",
"'categoryCode'",
")",
"if",
"sorted_items",
".",
"get",
"(",
"category",
"... | sorts the items into a dictionary of categories, with a list of items | [
"sorts",
"the",
"items",
"into",
"a",
"dictionary",
"of",
"categories",
"with",
"a",
"list",
"of",
"items"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/item_list.py#L56-L66 |
softlayer/softlayer-python | SoftLayer/CLI/vlan/list.py | cli | def cli(env, sortby, datacenter, number, name, limit):
"""List VLANs."""
mgr = SoftLayer.NetworkManager(env.client)
table = formatting.Table(COLUMNS)
table.sortby = sortby
vlans = mgr.list_vlans(datacenter=datacenter,
vlan_number=number,
name=... | python | def cli(env, sortby, datacenter, number, name, limit):
"""List VLANs."""
mgr = SoftLayer.NetworkManager(env.client)
table = formatting.Table(COLUMNS)
table.sortby = sortby
vlans = mgr.list_vlans(datacenter=datacenter,
vlan_number=number,
name=... | [
"def",
"cli",
"(",
"env",
",",
"sortby",
",",
"datacenter",
",",
"number",
",",
"name",
",",
"limit",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"NetworkManager",
"(",
"env",
".",
"client",
")",
"table",
"=",
"formatting",
".",
"Table",
"(",
"COLUMNS",
... | List VLANs. | [
"List",
"VLANs",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vlan/list.py#L34-L58 |
softlayer/softlayer-python | SoftLayer/CLI/nas/list.py | cli | def cli(env):
"""List NAS accounts."""
account = env.client['Account']
nas_accounts = account.getNasNetworkStorage(
mask='eventCount,serviceResource[datacenter.name]')
table = formatting.Table(['id', 'datacenter', 'size', 'server'])
for nas_account in nas_accounts:
table.add_row(... | python | def cli(env):
"""List NAS accounts."""
account = env.client['Account']
nas_accounts = account.getNasNetworkStorage(
mask='eventCount,serviceResource[datacenter.name]')
table = formatting.Table(['id', 'datacenter', 'size', 'server'])
for nas_account in nas_accounts:
table.add_row(... | [
"def",
"cli",
"(",
"env",
")",
":",
"account",
"=",
"env",
".",
"client",
"[",
"'Account'",
"]",
"nas_accounts",
"=",
"account",
".",
"getNasNetworkStorage",
"(",
"mask",
"=",
"'eventCount,serviceResource[datacenter.name]'",
")",
"table",
"=",
"formatting",
".",... | List NAS accounts. | [
"List",
"NAS",
"accounts",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/nas/list.py#L13-L36 |
softlayer/softlayer-python | SoftLayer/CLI/config/setup.py | get_api_key | def get_api_key(client, username, secret):
"""Attempts API-Key and password auth to get an API key.
This will also generate an API key if one doesn't exist
"""
# Try to use a client with username/api key
if len(secret) == 64:
try:
client['Account'].getCurrentUser()
... | python | def get_api_key(client, username, secret):
"""Attempts API-Key and password auth to get an API key.
This will also generate an API key if one doesn't exist
"""
# Try to use a client with username/api key
if len(secret) == 64:
try:
client['Account'].getCurrentUser()
... | [
"def",
"get_api_key",
"(",
"client",
",",
"username",
",",
"secret",
")",
":",
"# Try to use a client with username/api key",
"if",
"len",
"(",
"secret",
")",
"==",
"64",
":",
"try",
":",
"client",
"[",
"'Account'",
"]",
".",
"getCurrentUser",
"(",
")",
"ret... | Attempts API-Key and password auth to get an API key.
This will also generate an API key if one doesn't exist | [
"Attempts",
"API",
"-",
"Key",
"and",
"password",
"auth",
"to",
"get",
"an",
"API",
"key",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/config/setup.py#L15-L37 |
softlayer/softlayer-python | SoftLayer/CLI/config/setup.py | cli | def cli(env):
"""Edit configuration."""
username, secret, endpoint_url, timeout = get_user_input(env)
new_client = SoftLayer.Client(username=username, api_key=secret, endpoint_url=endpoint_url, timeout=timeout)
api_key = get_api_key(new_client, username, secret)
path = '~/.softlayer'
if env.co... | python | def cli(env):
"""Edit configuration."""
username, secret, endpoint_url, timeout = get_user_input(env)
new_client = SoftLayer.Client(username=username, api_key=secret, endpoint_url=endpoint_url, timeout=timeout)
api_key = get_api_key(new_client, username, secret)
path = '~/.softlayer'
if env.co... | [
"def",
"cli",
"(",
"env",
")",
":",
"username",
",",
"secret",
",",
"endpoint_url",
",",
"timeout",
"=",
"get_user_input",
"(",
"env",
")",
"new_client",
"=",
"SoftLayer",
".",
"Client",
"(",
"username",
"=",
"username",
",",
"api_key",
"=",
"secret",
",... | Edit configuration. | [
"Edit",
"configuration",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/config/setup.py#L42-L86 |
softlayer/softlayer-python | SoftLayer/CLI/config/setup.py | get_user_input | def get_user_input(env):
"""Ask for username, secret (api_key or password) and endpoint_url."""
defaults = config.get_settings_from_client(env.client)
# Ask for username
username = env.input('Username', default=defaults['username'])
# Ask for 'secret' which can be api_key or their password
se... | python | def get_user_input(env):
"""Ask for username, secret (api_key or password) and endpoint_url."""
defaults = config.get_settings_from_client(env.client)
# Ask for username
username = env.input('Username', default=defaults['username'])
# Ask for 'secret' which can be api_key or their password
se... | [
"def",
"get_user_input",
"(",
"env",
")",
":",
"defaults",
"=",
"config",
".",
"get_settings_from_client",
"(",
"env",
".",
"client",
")",
"# Ask for username",
"username",
"=",
"env",
".",
"input",
"(",
"'Username'",
",",
"default",
"=",
"defaults",
"[",
"'... | Ask for username, secret (api_key or password) and endpoint_url. | [
"Ask",
"for",
"username",
"secret",
"(",
"api_key",
"or",
"password",
")",
"and",
"endpoint_url",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/config/setup.py#L89-L119 |
softlayer/softlayer-python | SoftLayer/CLI/loadbal/__init__.py | parse_id | def parse_id(input_id):
"""Parse the load balancer kind and actual id from the "kind:id" form."""
parts = input_id.split(':')
if len(parts) != 2:
raise exceptions.CLIAbort(
'Invalid ID %s: ID should be of the form "kind:id"' % input_id)
return parts[0], int(parts[1]) | python | def parse_id(input_id):
"""Parse the load balancer kind and actual id from the "kind:id" form."""
parts = input_id.split(':')
if len(parts) != 2:
raise exceptions.CLIAbort(
'Invalid ID %s: ID should be of the form "kind:id"' % input_id)
return parts[0], int(parts[1]) | [
"def",
"parse_id",
"(",
"input_id",
")",
":",
"parts",
"=",
"input_id",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
":",
"raise",
"exceptions",
".",
"CLIAbort",
"(",
"'Invalid ID %s: ID should be of the form \"kind:id\"'",
"%",
... | Parse the load balancer kind and actual id from the "kind:id" form. | [
"Parse",
"the",
"load",
"balancer",
"kind",
"and",
"actual",
"id",
"from",
"the",
"kind",
":",
"id",
"form",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/__init__.py#L6-L12 |
softlayer/softlayer-python | SoftLayer/CLI/dedicatedhost/create_options.py | cli | def cli(env, **kwargs):
"""host order options for a given dedicated host.
To get a list of available backend routers see example:
slcli dh create-options --datacenter dal05 --flavor 56_CORES_X_242_RAM_X_1_4_TB
"""
mgr = SoftLayer.DedicatedHostManager(env.client)
tables = []
if not kwargs[... | python | def cli(env, **kwargs):
"""host order options for a given dedicated host.
To get a list of available backend routers see example:
slcli dh create-options --datacenter dal05 --flavor 56_CORES_X_242_RAM_X_1_4_TB
"""
mgr = SoftLayer.DedicatedHostManager(env.client)
tables = []
if not kwargs[... | [
"def",
"cli",
"(",
"env",
",",
"*",
"*",
"kwargs",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"DedicatedHostManager",
"(",
"env",
".",
"client",
")",
"tables",
"=",
"[",
"]",
"if",
"not",
"kwargs",
"[",
"'flavor'",
"]",
"and",
"not",
"kwargs",
"[",
"'... | host order options for a given dedicated host.
To get a list of available backend routers see example:
slcli dh create-options --datacenter dal05 --flavor 56_CORES_X_242_RAM_X_1_4_TB | [
"host",
"order",
"options",
"for",
"a",
"given",
"dedicated",
"host",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dedicatedhost/create_options.py#L22-L61 |
softlayer/softlayer-python | SoftLayer/CLI/hardware/cancel_reasons.py | cli | def cli(env):
"""Display a list of cancellation reasons."""
table = formatting.Table(['Code', 'Reason'])
table.align['Code'] = 'r'
table.align['Reason'] = 'l'
mgr = SoftLayer.HardwareManager(env.client)
for code, reason in mgr.get_cancellation_reasons().items():
table.add_row([code, r... | python | def cli(env):
"""Display a list of cancellation reasons."""
table = formatting.Table(['Code', 'Reason'])
table.align['Code'] = 'r'
table.align['Reason'] = 'l'
mgr = SoftLayer.HardwareManager(env.client)
for code, reason in mgr.get_cancellation_reasons().items():
table.add_row([code, r... | [
"def",
"cli",
"(",
"env",
")",
":",
"table",
"=",
"formatting",
".",
"Table",
"(",
"[",
"'Code'",
",",
"'Reason'",
"]",
")",
"table",
".",
"align",
"[",
"'Code'",
"]",
"=",
"'r'",
"table",
".",
"align",
"[",
"'Reason'",
"]",
"=",
"'l'",
"mgr",
"=... | Display a list of cancellation reasons. | [
"Display",
"a",
"list",
"of",
"cancellation",
"reasons",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/hardware/cancel_reasons.py#L13-L25 |
softlayer/softlayer-python | SoftLayer/CLI/vpn/ipsec/list.py | cli | def cli(env):
"""List IPSec VPN tunnel contexts"""
manager = SoftLayer.IPSECManager(env.client)
contexts = manager.get_tunnel_contexts()
table = formatting.Table(['id',
'name',
'friendly name',
'internal peer IP a... | python | def cli(env):
"""List IPSec VPN tunnel contexts"""
manager = SoftLayer.IPSECManager(env.client)
contexts = manager.get_tunnel_contexts()
table = formatting.Table(['id',
'name',
'friendly name',
'internal peer IP a... | [
"def",
"cli",
"(",
"env",
")",
":",
"manager",
"=",
"SoftLayer",
".",
"IPSECManager",
"(",
"env",
".",
"client",
")",
"contexts",
"=",
"manager",
".",
"get_tunnel_contexts",
"(",
")",
"table",
"=",
"formatting",
".",
"Table",
"(",
"[",
"'id'",
",",
"'n... | List IPSec VPN tunnel contexts | [
"List",
"IPSec",
"VPN",
"tunnel",
"contexts"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vpn/ipsec/list.py#L13-L31 |
softlayer/softlayer-python | SoftLayer/CLI/file/replication/locations.py | cli | def cli(env, columns, sortby, volume_id):
"""List suitable replication datacenters for the given volume."""
file_storage_manager = SoftLayer.FileStorageManager(env.client)
legal_centers = file_storage_manager.get_replication_locations(
volume_id
)
if not legal_centers:
click.echo("... | python | def cli(env, columns, sortby, volume_id):
"""List suitable replication datacenters for the given volume."""
file_storage_manager = SoftLayer.FileStorageManager(env.client)
legal_centers = file_storage_manager.get_replication_locations(
volume_id
)
if not legal_centers:
click.echo("... | [
"def",
"cli",
"(",
"env",
",",
"columns",
",",
"sortby",
",",
"volume_id",
")",
":",
"file_storage_manager",
"=",
"SoftLayer",
".",
"FileStorageManager",
"(",
"env",
".",
"client",
")",
"legal_centers",
"=",
"file_storage_manager",
".",
"get_replication_locations"... | List suitable replication datacenters for the given volume. | [
"List",
"suitable",
"replication",
"datacenters",
"for",
"the",
"given",
"volume",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/replication/locations.py#L32-L49 |
softlayer/softlayer-python | SoftLayer/CLI/dedicatedhost/list_guests.py | cli | def cli(env, identifier, sortby, cpu, domain, hostname, memory, tag, columns):
"""List guests which are in a dedicated host server."""
mgr = SoftLayer.DedicatedHostManager(env.client)
guests = mgr.list_guests(host_id=identifier,
cpus=cpu,
hostname=h... | python | def cli(env, identifier, sortby, cpu, domain, hostname, memory, tag, columns):
"""List guests which are in a dedicated host server."""
mgr = SoftLayer.DedicatedHostManager(env.client)
guests = mgr.list_guests(host_id=identifier,
cpus=cpu,
hostname=h... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
",",
"sortby",
",",
"cpu",
",",
"domain",
",",
"hostname",
",",
"memory",
",",
"tag",
",",
"columns",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"DedicatedHostManager",
"(",
"env",
".",
"client",
")",
"guests",... | List guests which are in a dedicated host server. | [
"List",
"guests",
"which",
"are",
"in",
"a",
"dedicated",
"host",
"server",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dedicatedhost/list_guests.py#L57-L76 |
softlayer/softlayer-python | SoftLayer/CLI/ticket/detail.py | cli | def cli(env, identifier, count):
"""Get details for a ticket."""
mgr = SoftLayer.TicketManager(env.client)
ticket_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'ticket')
env.fout(ticket.get_ticket_results(mgr, ticket_id, update_count=count)) | python | def cli(env, identifier, count):
"""Get details for a ticket."""
mgr = SoftLayer.TicketManager(env.client)
ticket_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'ticket')
env.fout(ticket.get_ticket_results(mgr, ticket_id, update_count=count)) | [
"def",
"cli",
"(",
"env",
",",
"identifier",
",",
"count",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"TicketManager",
"(",
"env",
".",
"client",
")",
"ticket_id",
"=",
"helpers",
".",
"resolve_id",
"(",
"mgr",
".",
"resolve_ids",
",",
"identifier",
",",
... | Get details for a ticket. | [
"Get",
"details",
"for",
"a",
"ticket",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ticket/detail.py#L20-L26 |
softlayer/softlayer-python | SoftLayer/transports.py | get_session | def get_session(user_agent):
"""Sets up urllib sessions"""
client = requests.Session()
client.headers.update({
'Content-Type': 'application/json',
'User-Agent': user_agent,
})
retry = Retry(connect=3, backoff_factor=3)
adapter = HTTPAdapter(max_retries=retry)
client.mount('h... | python | def get_session(user_agent):
"""Sets up urllib sessions"""
client = requests.Session()
client.headers.update({
'Content-Type': 'application/json',
'User-Agent': user_agent,
})
retry = Retry(connect=3, backoff_factor=3)
adapter = HTTPAdapter(max_retries=retry)
client.mount('h... | [
"def",
"get_session",
"(",
"user_agent",
")",
":",
"client",
"=",
"requests",
".",
"Session",
"(",
")",
"client",
".",
"headers",
".",
"update",
"(",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'User-Agent'",
":",
"user_agent",
",",
"}",
")",
"... | Sets up urllib sessions | [
"Sets",
"up",
"urllib",
"sessions"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L45-L56 |
softlayer/softlayer-python | SoftLayer/transports.py | _format_object_mask | def _format_object_mask(objectmask):
"""Format the new style object mask.
This wraps the user mask with mask[USER_MASK] if it does not already
have one. This makes it slightly easier for users.
:param objectmask: a string-based object mask
"""
objectmask = objectmask.strip()
if (not obje... | python | def _format_object_mask(objectmask):
"""Format the new style object mask.
This wraps the user mask with mask[USER_MASK] if it does not already
have one. This makes it slightly easier for users.
:param objectmask: a string-based object mask
"""
objectmask = objectmask.strip()
if (not obje... | [
"def",
"_format_object_mask",
"(",
"objectmask",
")",
":",
"objectmask",
"=",
"objectmask",
".",
"strip",
"(",
")",
"if",
"(",
"not",
"objectmask",
".",
"startswith",
"(",
"'mask'",
")",
"and",
"not",
"objectmask",
".",
"startswith",
"(",
"'['",
")",
")",
... | Format the new style object mask.
This wraps the user mask with mask[USER_MASK] if it does not already
have one. This makes it slightly easier for users.
:param objectmask: a string-based object mask | [
"Format",
"the",
"new",
"style",
"object",
"mask",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L544-L558 |
softlayer/softlayer-python | SoftLayer/transports.py | XmlRpcTransport.client | def client(self):
"""Returns client session object"""
if self._client is None:
self._client = get_session(self.user_agent)
return self._client | python | def client(self):
"""Returns client session object"""
if self._client is None:
self._client = get_session(self.user_agent)
return self._client | [
"def",
"client",
"(",
"self",
")",
":",
"if",
"self",
".",
"_client",
"is",
"None",
":",
"self",
".",
"_client",
"=",
"get_session",
"(",
"self",
".",
"user_agent",
")",
"return",
"self",
".",
"_client"
] | Returns client session object | [
"Returns",
"client",
"session",
"object"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L158-L163 |
softlayer/softlayer-python | SoftLayer/transports.py | XmlRpcTransport.print_reproduceable | def print_reproduceable(self, request):
"""Prints out the minimal python code to reproduce a specific request
The will also automatically replace the API key so its not accidently exposed.
:param request request: Request object
"""
from string import Template
output = T... | python | def print_reproduceable(self, request):
"""Prints out the minimal python code to reproduce a specific request
The will also automatically replace the API key so its not accidently exposed.
:param request request: Request object
"""
from string import Template
output = T... | [
"def",
"print_reproduceable",
"(",
"self",
",",
"request",
")",
":",
"from",
"string",
"import",
"Template",
"output",
"=",
"Template",
"(",
"'''============= testing.py =============\nimport requests\nfrom requests.adapters import HTTPAdapter\nfrom urllib3.util.retry import Retry\nf... | Prints out the minimal python code to reproduce a specific request
The will also automatically replace the API key so its not accidently exposed.
:param request request: Request object | [
"Prints",
"out",
"the",
"minimal",
"python",
"code",
"to",
"reproduce",
"a",
"specific",
"request"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L246-L282 |
softlayer/softlayer-python | SoftLayer/transports.py | RestTransport.print_reproduceable | def print_reproduceable(self, request):
"""Prints out the minimal python code to reproduce a specific request
The will also automatically replace the API key so its not accidently exposed.
:param request request: Request object
"""
command = "curl -u $SL_USER:$SL_APIKEY -X {met... | python | def print_reproduceable(self, request):
"""Prints out the minimal python code to reproduce a specific request
The will also automatically replace the API key so its not accidently exposed.
:param request request: Request object
"""
command = "curl -u $SL_USER:$SL_APIKEY -X {met... | [
"def",
"print_reproduceable",
"(",
"self",
",",
"request",
")",
":",
"command",
"=",
"\"curl -u $SL_USER:$SL_APIKEY -X {method} -H {headers} {data} '{uri}'\"",
"method",
"=",
"REST_SPECIAL_METHODS",
".",
"get",
"(",
"request",
".",
"method",
")",
"if",
"method",
"is",
... | Prints out the minimal python code to reproduce a specific request
The will also automatically replace the API key so its not accidently exposed.
:param request request: Request object | [
"Prints",
"out",
"the",
"minimal",
"python",
"code",
"to",
"reproduce",
"a",
"specific",
"request"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L412-L434 |
softlayer/softlayer-python | SoftLayer/transports.py | DebugTransport.post_transport_log | def post_transport_log(self, call):
"""Prints the result "Returned Data: \n%s" % (call.result)of an API call"""
output = "Returned Data: \n{}".format(call.result)
LOGGER.debug(output) | python | def post_transport_log(self, call):
"""Prints the result "Returned Data: \n%s" % (call.result)of an API call"""
output = "Returned Data: \n{}".format(call.result)
LOGGER.debug(output) | [
"def",
"post_transport_log",
"(",
"self",
",",
"call",
")",
":",
"output",
"=",
"\"Returned Data: \\n{}\"",
".",
"format",
"(",
"call",
".",
"result",
")",
"LOGGER",
".",
"debug",
"(",
"output",
")"
] | Prints the result "Returned Data: \n%s" % (call.result)of an API call | [
"Prints",
"the",
"result",
"Returned",
"Data",
":",
"\\",
"n%s",
"%",
"(",
"call",
".",
"result",
")",
"of",
"an",
"API",
"call"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/transports.py#L471-L474 |
softlayer/softlayer-python | SoftLayer/CLI/hardware/toggle_ipmi.py | cli | def cli(env, identifier, enable):
"""Toggle the IPMI interface on and off"""
mgr = SoftLayer.HardwareManager(env.client)
hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
result = env.client['Hardware_Server'].toggleManagementInterface(enable, id=hw_id)
env.fout(result) | python | def cli(env, identifier, enable):
"""Toggle the IPMI interface on and off"""
mgr = SoftLayer.HardwareManager(env.client)
hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
result = env.client['Hardware_Server'].toggleManagementInterface(enable, id=hw_id)
env.fout(result) | [
"def",
"cli",
"(",
"env",
",",
"identifier",
",",
"enable",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"HardwareManager",
"(",
"env",
".",
"client",
")",
"hw_id",
"=",
"helpers",
".",
"resolve_id",
"(",
"mgr",
".",
"resolve_ids",
",",
"identifier",
",",
"... | Toggle the IPMI interface on and off | [
"Toggle",
"the",
"IPMI",
"interface",
"on",
"and",
"off"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/hardware/toggle_ipmi.py#L16-L22 |
softlayer/softlayer-python | SoftLayer/CLI/dns/record_remove.py | cli | def cli(env, record_id):
"""Remove resource record."""
manager = SoftLayer.DNSManager(env.client)
if not (env.skip_confirmations or formatting.no_going_back('yes')):
raise exceptions.CLIAbort("Aborted.")
manager.delete_record(record_id) | python | def cli(env, record_id):
"""Remove resource record."""
manager = SoftLayer.DNSManager(env.client)
if not (env.skip_confirmations or formatting.no_going_back('yes')):
raise exceptions.CLIAbort("Aborted.")
manager.delete_record(record_id) | [
"def",
"cli",
"(",
"env",
",",
"record_id",
")",
":",
"manager",
"=",
"SoftLayer",
".",
"DNSManager",
"(",
"env",
".",
"client",
")",
"if",
"not",
"(",
"env",
".",
"skip_confirmations",
"or",
"formatting",
".",
"no_going_back",
"(",
"'yes'",
")",
")",
... | Remove resource record. | [
"Remove",
"resource",
"record",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dns/record_remove.py#L15-L23 |
softlayer/softlayer-python | SoftLayer/CLI/block/count.py | cli | def cli(env, sortby, datacenter):
"""List number of block storage volumes per datacenter."""
block_manager = SoftLayer.BlockStorageManager(env.client)
mask = "mask[serviceResource[datacenter[name]],"\
"replicationPartners[serviceResource[datacenter[name]]]]"
block_volumes = block_manager.list... | python | def cli(env, sortby, datacenter):
"""List number of block storage volumes per datacenter."""
block_manager = SoftLayer.BlockStorageManager(env.client)
mask = "mask[serviceResource[datacenter[name]],"\
"replicationPartners[serviceResource[datacenter[name]]]]"
block_volumes = block_manager.list... | [
"def",
"cli",
"(",
"env",
",",
"sortby",
",",
"datacenter",
")",
":",
"block_manager",
"=",
"SoftLayer",
".",
"BlockStorageManager",
"(",
"env",
".",
"client",
")",
"mask",
"=",
"\"mask[serviceResource[datacenter[name]],\"",
"\"replicationPartners[serviceResource[datace... | List number of block storage volumes per datacenter. | [
"List",
"number",
"of",
"block",
"storage",
"volumes",
"per",
"datacenter",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/count.py#L19-L42 |
softlayer/softlayer-python | SoftLayer/CLI/cdn/load.py | cli | def cli(env, account_id, content_url):
"""Cache one or more files on all edge nodes."""
manager = SoftLayer.CDNManager(env.client)
manager.load_content(account_id, content_url) | python | def cli(env, account_id, content_url):
"""Cache one or more files on all edge nodes."""
manager = SoftLayer.CDNManager(env.client)
manager.load_content(account_id, content_url) | [
"def",
"cli",
"(",
"env",
",",
"account_id",
",",
"content_url",
")",
":",
"manager",
"=",
"SoftLayer",
".",
"CDNManager",
"(",
"env",
".",
"client",
")",
"manager",
".",
"load_content",
"(",
"account_id",
",",
"content_url",
")"
] | Cache one or more files on all edge nodes. | [
"Cache",
"one",
"or",
"more",
"files",
"on",
"all",
"edge",
"nodes",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/cdn/load.py#L14-L18 |
softlayer/softlayer-python | SoftLayer/CLI/vlan/detail.py | cli | def cli(env, identifier, no_vs, no_hardware):
"""Get details about a VLAN."""
mgr = SoftLayer.NetworkManager(env.client)
vlan_id = helpers.resolve_id(mgr.resolve_vlan_ids, identifier, 'VLAN')
vlan = mgr.get_vlan(vlan_id)
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] ... | python | def cli(env, identifier, no_vs, no_hardware):
"""Get details about a VLAN."""
mgr = SoftLayer.NetworkManager(env.client)
vlan_id = helpers.resolve_id(mgr.resolve_vlan_ids, identifier, 'VLAN')
vlan = mgr.get_vlan(vlan_id)
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] ... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
",",
"no_vs",
",",
"no_hardware",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"NetworkManager",
"(",
"env",
".",
"client",
")",
"vlan_id",
"=",
"helpers",
".",
"resolve_id",
"(",
"mgr",
".",
"resolve_vlan_ids",
",... | Get details about a VLAN. | [
"Get",
"details",
"about",
"a",
"VLAN",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vlan/detail.py#L21-L83 |
softlayer/softlayer-python | SoftLayer/CLI/block/lun.py | cli | def cli(env, volume_id, lun_id):
"""Set the LUN ID on an existing block storage volume.
The LUN ID only takes effect during the Host Authorization process. It is
recommended (but not necessary) to de-authorize all hosts before using this
method. See `block access-revoke`.
VOLUME_ID - the volume ID... | python | def cli(env, volume_id, lun_id):
"""Set the LUN ID on an existing block storage volume.
The LUN ID only takes effect during the Host Authorization process. It is
recommended (but not necessary) to de-authorize all hosts before using this
method. See `block access-revoke`.
VOLUME_ID - the volume ID... | [
"def",
"cli",
"(",
"env",
",",
"volume_id",
",",
"lun_id",
")",
":",
"block_storage_manager",
"=",
"SoftLayer",
".",
"BlockStorageManager",
"(",
"env",
".",
"client",
")",
"res",
"=",
"block_storage_manager",
".",
"create_or_update_lun_id",
"(",
"volume_id",
","... | Set the LUN ID on an existing block storage volume.
The LUN ID only takes effect during the Host Authorization process. It is
recommended (but not necessary) to de-authorize all hosts before using this
method. See `block access-revoke`.
VOLUME_ID - the volume ID on which to set the LUN ID.
LUN_ID... | [
"Set",
"the",
"LUN",
"ID",
"on",
"an",
"existing",
"block",
"storage",
"volume",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/lun.py#L14-L36 |
softlayer/softlayer-python | SoftLayer/CLI/loadbal/detail.py | cli | def cli(env, identifier):
"""Get Load balancer details."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, loadbal_id = loadbal.parse_id(identifier)
load_balancer = mgr.get_local_lb(loadbal_id)
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] = 'l'
table.align['v... | python | def cli(env, identifier):
"""Get Load balancer details."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, loadbal_id = loadbal.parse_id(identifier)
load_balancer = mgr.get_local_lb(loadbal_id)
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] = 'l'
table.align['v... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"LoadBalancerManager",
"(",
"env",
".",
"client",
")",
"_",
",",
"loadbal_id",
"=",
"loadbal",
".",
"parse_id",
"(",
"identifier",
")",
"load_balancer",
"=",
"mgr",
".",... | Get Load balancer details. | [
"Get",
"Load",
"balancer",
"details",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/detail.py#L15-L81 |
softlayer/softlayer-python | SoftLayer/CLI/core.py | cli | def cli(env,
format='table',
config=None,
verbose=0,
proxy=None,
really=False,
demo=False,
**kwargs):
"""Main click CLI entry-point."""
# Populate environement with client and set it as the context object
env.skip_confirmations = really
env.config... | python | def cli(env,
format='table',
config=None,
verbose=0,
proxy=None,
really=False,
demo=False,
**kwargs):
"""Main click CLI entry-point."""
# Populate environement with client and set it as the context object
env.skip_confirmations = really
env.config... | [
"def",
"cli",
"(",
"env",
",",
"format",
"=",
"'table'",
",",
"config",
"=",
"None",
",",
"verbose",
"=",
"0",
",",
"proxy",
"=",
"None",
",",
"really",
"=",
"False",
",",
"demo",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Populate environ... | Main click CLI entry-point. | [
"Main",
"click",
"CLI",
"entry",
"-",
"point",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/core.py#L108-L135 |
softlayer/softlayer-python | SoftLayer/CLI/core.py | output_diagnostics | def output_diagnostics(env, result, verbose=0, **kwargs):
"""Output diagnostic information."""
if verbose > 0:
diagnostic_table = formatting.Table(['name', 'value'])
diagnostic_table.add_row(['execution_time', '%fs' % (time.time() - START_TIME)])
api_call_value = []
for call in... | python | def output_diagnostics(env, result, verbose=0, **kwargs):
"""Output diagnostic information."""
if verbose > 0:
diagnostic_table = formatting.Table(['name', 'value'])
diagnostic_table.add_row(['execution_time', '%fs' % (time.time() - START_TIME)])
api_call_value = []
for call in... | [
"def",
"output_diagnostics",
"(",
"env",
",",
"result",
",",
"verbose",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"verbose",
">",
"0",
":",
"diagnostic_table",
"=",
"formatting",
".",
"Table",
"(",
"[",
"'name'",
",",
"'value'",
"]",
")",
"d... | Output diagnostic information. | [
"Output",
"diagnostic",
"information",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/core.py#L140-L174 |
softlayer/softlayer-python | SoftLayer/CLI/core.py | main | def main(reraise_exceptions=False, **kwargs):
"""Main program. Catches several common errors and displays them nicely."""
exit_status = 0
try:
cli.main(**kwargs)
except SoftLayer.SoftLayerAPIError as ex:
if 'invalid api token' in ex.faultString.lower():
print("Authentication... | python | def main(reraise_exceptions=False, **kwargs):
"""Main program. Catches several common errors and displays them nicely."""
exit_status = 0
try:
cli.main(**kwargs)
except SoftLayer.SoftLayerAPIError as ex:
if 'invalid api token' in ex.faultString.lower():
print("Authentication... | [
"def",
"main",
"(",
"reraise_exceptions",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"exit_status",
"=",
"0",
"try",
":",
"cli",
".",
"main",
"(",
"*",
"*",
"kwargs",
")",
"except",
"SoftLayer",
".",
"SoftLayerAPIError",
"as",
"ex",
":",
"if",
... | Main program. Catches several common errors and displays them nicely. | [
"Main",
"program",
".",
"Catches",
"several",
"common",
"errors",
"and",
"displays",
"them",
"nicely",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/core.py#L177-L208 |
softlayer/softlayer-python | SoftLayer/CLI/core.py | CommandLoader.list_commands | def list_commands(self, ctx):
"""List all sub-commands."""
env = ctx.ensure_object(environment.Environment)
env.load()
return sorted(env.list_commands(*self.path)) | python | def list_commands(self, ctx):
"""List all sub-commands."""
env = ctx.ensure_object(environment.Environment)
env.load()
return sorted(env.list_commands(*self.path)) | [
"def",
"list_commands",
"(",
"self",
",",
"ctx",
")",
":",
"env",
"=",
"ctx",
".",
"ensure_object",
"(",
"environment",
".",
"Environment",
")",
"env",
".",
"load",
"(",
")",
"return",
"sorted",
"(",
"env",
".",
"list_commands",
"(",
"*",
"self",
".",
... | List all sub-commands. | [
"List",
"all",
"sub",
"-",
"commands",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/core.py#L47-L52 |
softlayer/softlayer-python | SoftLayer/CLI/core.py | CommandLoader.get_command | def get_command(self, ctx, name):
"""Get command for click."""
env = ctx.ensure_object(environment.Environment)
env.load()
# Do alias lookup (only available for root commands)
if len(self.path) == 0:
name = env.resolve_alias(name)
new_path = list(self.path)
... | python | def get_command(self, ctx, name):
"""Get command for click."""
env = ctx.ensure_object(environment.Environment)
env.load()
# Do alias lookup (only available for root commands)
if len(self.path) == 0:
name = env.resolve_alias(name)
new_path = list(self.path)
... | [
"def",
"get_command",
"(",
"self",
",",
"ctx",
",",
"name",
")",
":",
"env",
"=",
"ctx",
".",
"ensure_object",
"(",
"environment",
".",
"Environment",
")",
"env",
".",
"load",
"(",
")",
"# Do alias lookup (only available for root commands)",
"if",
"len",
"(",
... | Get command for click. | [
"Get",
"command",
"for",
"click",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/core.py#L54-L69 |
softlayer/softlayer-python | SoftLayer/CLI/block/access/revoke.py | cli | def cli(env, volume_id, hardware_id, virtual_id, ip_address_id, ip_address):
"""Revokes authorization for hosts accessing a given volume"""
block_manager = SoftLayer.BlockStorageManager(env.client)
ip_address_id_list = list(ip_address_id)
# Convert actual IP Addresses to their SoftLayer ids
if ip_a... | python | def cli(env, volume_id, hardware_id, virtual_id, ip_address_id, ip_address):
"""Revokes authorization for hosts accessing a given volume"""
block_manager = SoftLayer.BlockStorageManager(env.client)
ip_address_id_list = list(ip_address_id)
# Convert actual IP Addresses to their SoftLayer ids
if ip_a... | [
"def",
"cli",
"(",
"env",
",",
"volume_id",
",",
"hardware_id",
",",
"virtual_id",
",",
"ip_address_id",
",",
"ip_address",
")",
":",
"block_manager",
"=",
"SoftLayer",
".",
"BlockStorageManager",
"(",
"env",
".",
"client",
")",
"ip_address_id_list",
"=",
"lis... | Revokes authorization for hosts accessing a given volume | [
"Revokes",
"authorization",
"for",
"hosts",
"accessing",
"a",
"given",
"volume"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/access/revoke.py#L23-L41 |
softlayer/softlayer-python | SoftLayer/CLI/dedicatedhost/create.py | cli | def cli(env, **kwargs):
"""Order/create a dedicated host."""
mgr = SoftLayer.DedicatedHostManager(env.client)
order = {
'hostname': kwargs['hostname'],
'domain': kwargs['domain'],
'flavor': kwargs['flavor'],
'location': kwargs['datacenter'],
'hourly': kwargs.get('bil... | python | def cli(env, **kwargs):
"""Order/create a dedicated host."""
mgr = SoftLayer.DedicatedHostManager(env.client)
order = {
'hostname': kwargs['hostname'],
'domain': kwargs['domain'],
'flavor': kwargs['flavor'],
'location': kwargs['datacenter'],
'hourly': kwargs.get('bil... | [
"def",
"cli",
"(",
"env",
",",
"*",
"*",
"kwargs",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"DedicatedHostManager",
"(",
"env",
".",
"client",
")",
"order",
"=",
"{",
"'hostname'",
":",
"kwargs",
"[",
"'hostname'",
"]",
",",
"'domain'",
":",
"kwargs",
... | Order/create a dedicated host. | [
"Order",
"/",
"create",
"a",
"dedicated",
"host",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dedicatedhost/create.py#L49-L114 |
softlayer/softlayer-python | SoftLayer/CLI/loadbal/group_add.py | cli | def cli(env, identifier, allocation, port, routing_type, routing_method):
"""Adds a new load_balancer service."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, loadbal_id = loadbal.parse_id(identifier)
mgr.add_service_group(loadbal_id,
allocation=allocation,
... | python | def cli(env, identifier, allocation, port, routing_type, routing_method):
"""Adds a new load_balancer service."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, loadbal_id = loadbal.parse_id(identifier)
mgr.add_service_group(loadbal_id,
allocation=allocation,
... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
",",
"allocation",
",",
"port",
",",
"routing_type",
",",
"routing_method",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"LoadBalancerManager",
"(",
"env",
".",
"client",
")",
"_",
",",
"loadbal_id",
"=",
"loadbal",
... | Adds a new load_balancer service. | [
"Adds",
"a",
"new",
"load_balancer",
"service",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/group_add.py#L28-L41 |
softlayer/softlayer-python | SoftLayer/CLI/loadbal/routing_methods.py | cli | def cli(env):
"""List routing types."""
mgr = SoftLayer.LoadBalancerManager(env.client)
routing_methods = mgr.get_routing_methods()
table = formatting.KeyValueTable(['ID', 'Name'])
table.align['ID'] = 'l'
table.align['Name'] = 'l'
table.sortby = 'ID'
for routing_method in routing_method... | python | def cli(env):
"""List routing types."""
mgr = SoftLayer.LoadBalancerManager(env.client)
routing_methods = mgr.get_routing_methods()
table = formatting.KeyValueTable(['ID', 'Name'])
table.align['ID'] = 'l'
table.align['Name'] = 'l'
table.sortby = 'ID'
for routing_method in routing_method... | [
"def",
"cli",
"(",
"env",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"LoadBalancerManager",
"(",
"env",
".",
"client",
")",
"routing_methods",
"=",
"mgr",
".",
"get_routing_methods",
"(",
")",
"table",
"=",
"formatting",
".",
"KeyValueTable",
"(",
"[",
"'ID'"... | List routing types. | [
"List",
"routing",
"types",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/routing_methods.py#L13-L25 |
softlayer/softlayer-python | SoftLayer/CLI/dedicatedhost/cancel_guests.py | cli | def cli(env, identifier):
"""Cancel all virtual guests of the dedicated host immediately.
Use the 'slcli vs cancel' command to cancel an specific guest
"""
dh_mgr = SoftLayer.DedicatedHostManager(env.client)
host_id = helpers.resolve_id(dh_mgr.resolve_ids, identifier, 'dedicated host')
if... | python | def cli(env, identifier):
"""Cancel all virtual guests of the dedicated host immediately.
Use the 'slcli vs cancel' command to cancel an specific guest
"""
dh_mgr = SoftLayer.DedicatedHostManager(env.client)
host_id = helpers.resolve_id(dh_mgr.resolve_ids, identifier, 'dedicated host')
if... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
")",
":",
"dh_mgr",
"=",
"SoftLayer",
".",
"DedicatedHostManager",
"(",
"env",
".",
"client",
")",
"host_id",
"=",
"helpers",
".",
"resolve_id",
"(",
"dh_mgr",
".",
"resolve_ids",
",",
"identifier",
",",
"'dedic... | Cancel all virtual guests of the dedicated host immediately.
Use the 'slcli vs cancel' command to cancel an specific guest | [
"Cancel",
"all",
"virtual",
"guests",
"of",
"the",
"dedicated",
"host",
"immediately",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dedicatedhost/cancel_guests.py#L16-L43 |
softlayer/softlayer-python | SoftLayer/CLI/file/list.py | cli | def cli(env, sortby, columns, datacenter, username, storage_type):
"""List file storage."""
file_manager = SoftLayer.FileStorageManager(env.client)
file_volumes = file_manager.list_file_volumes(datacenter=datacenter,
username=username,
... | python | def cli(env, sortby, columns, datacenter, username, storage_type):
"""List file storage."""
file_manager = SoftLayer.FileStorageManager(env.client)
file_volumes = file_manager.list_file_volumes(datacenter=datacenter,
username=username,
... | [
"def",
"cli",
"(",
"env",
",",
"sortby",
",",
"columns",
",",
"datacenter",
",",
"username",
",",
"storage_type",
")",
":",
"file_manager",
"=",
"SoftLayer",
".",
"FileStorageManager",
"(",
"env",
".",
"client",
")",
"file_volumes",
"=",
"file_manager",
".",... | List file storage. | [
"List",
"file",
"storage",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/list.py#L66-L81 |
softlayer/softlayer-python | SoftLayer/CLI/file/duplicate.py | cli | def cli(env, origin_volume_id, origin_snapshot_id, duplicate_size,
duplicate_iops, duplicate_tier, duplicate_snapshot_size, billing):
"""Order a duplicate file storage volume."""
file_manager = SoftLayer.FileStorageManager(env.client)
hourly_billing_flag = False
if billing.lower() == "hourly":
... | python | def cli(env, origin_volume_id, origin_snapshot_id, duplicate_size,
duplicate_iops, duplicate_tier, duplicate_snapshot_size, billing):
"""Order a duplicate file storage volume."""
file_manager = SoftLayer.FileStorageManager(env.client)
hourly_billing_flag = False
if billing.lower() == "hourly":
... | [
"def",
"cli",
"(",
"env",
",",
"origin_volume_id",
",",
"origin_snapshot_id",
",",
"duplicate_size",
",",
"duplicate_iops",
",",
"duplicate_tier",
",",
"duplicate_snapshot_size",
",",
"billing",
")",
":",
"file_manager",
"=",
"SoftLayer",
".",
"FileStorageManager",
... | Order a duplicate file storage volume. | [
"Order",
"a",
"duplicate",
"file",
"storage",
"volume",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/duplicate.py#L56-L88 |
softlayer/softlayer-python | SoftLayer/CLI/vpn/ipsec/subnet/remove.py | cli | def cli(env, context_id, subnet_id, subnet_type):
"""Remove a subnet from an IPSEC tunnel context.
The subnet id to remove must be specified.
Remote subnets are deleted upon removal from a tunnel context.
A separate configuration request should be made to realize changes on
network devices.
"... | python | def cli(env, context_id, subnet_id, subnet_type):
"""Remove a subnet from an IPSEC tunnel context.
The subnet id to remove must be specified.
Remote subnets are deleted upon removal from a tunnel context.
A separate configuration request should be made to realize changes on
network devices.
"... | [
"def",
"cli",
"(",
"env",
",",
"context_id",
",",
"subnet_id",
",",
"subnet_type",
")",
":",
"manager",
"=",
"SoftLayer",
".",
"IPSECManager",
"(",
"env",
".",
"client",
")",
"# ensure context can be retrieved by given id",
"manager",
".",
"get_tunnel_context",
"(... | Remove a subnet from an IPSEC tunnel context.
The subnet id to remove must be specified.
Remote subnets are deleted upon removal from a tunnel context.
A separate configuration request should be made to realize changes on
network devices. | [
"Remove",
"a",
"subnet",
"from",
"an",
"IPSEC",
"tunnel",
"context",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/vpn/ipsec/subnet/remove.py#L25-L51 |
softlayer/softlayer-python | SoftLayer/CLI/ticket/list.py | cli | def cli(env, is_open):
"""List tickets."""
ticket_mgr = SoftLayer.TicketManager(env.client)
table = formatting.Table([
'id', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority'
])
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open)
for ... | python | def cli(env, is_open):
"""List tickets."""
ticket_mgr = SoftLayer.TicketManager(env.client)
table = formatting.Table([
'id', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority'
])
tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open)
for ... | [
"def",
"cli",
"(",
"env",
",",
"is_open",
")",
":",
"ticket_mgr",
"=",
"SoftLayer",
".",
"TicketManager",
"(",
"env",
".",
"client",
")",
"table",
"=",
"formatting",
".",
"Table",
"(",
"[",
"'id'",
",",
"'assigned_user'",
",",
"'title'",
",",
"'last_edit... | List tickets. | [
"List",
"tickets",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ticket/list.py#L15-L38 |
softlayer/softlayer-python | SoftLayer/CLI/securitygroup/detail.py | cli | def cli(env, identifier):
"""Get details about a security group."""
mgr = SoftLayer.NetworkManager(env.client)
secgroup = mgr.get_securitygroup(identifier)
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] = 'r'
table.align['value'] = 'l'
table.add_row(['id', secgro... | python | def cli(env, identifier):
"""Get details about a security group."""
mgr = SoftLayer.NetworkManager(env.client)
secgroup = mgr.get_securitygroup(identifier)
table = formatting.KeyValueTable(['name', 'value'])
table.align['name'] = 'r'
table.align['value'] = 'l'
table.add_row(['id', secgro... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"NetworkManager",
"(",
"env",
".",
"client",
")",
"secgroup",
"=",
"mgr",
".",
"get_securitygroup",
"(",
"identifier",
")",
"table",
"=",
"formatting",
".",
"KeyValueTable... | Get details about a security group. | [
"Get",
"details",
"about",
"a",
"security",
"group",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/securitygroup/detail.py#L14-L73 |
softlayer/softlayer-python | SoftLayer/CLI/dns/record_add.py | cli | def cli(env, record, record_type, data, zone, ttl, priority, protocol, port, service, weight):
"""Add resource record.
Each resource record contains a RECORD and DATA property, defining a resource's name and it's target data.
Domains contain multiple types of resource records so it can take one of the foll... | python | def cli(env, record, record_type, data, zone, ttl, priority, protocol, port, service, weight):
"""Add resource record.
Each resource record contains a RECORD and DATA property, defining a resource's name and it's target data.
Domains contain multiple types of resource records so it can take one of the foll... | [
"def",
"cli",
"(",
"env",
",",
"record",
",",
"record_type",
",",
"data",
",",
"zone",
",",
"ttl",
",",
"priority",
",",
"protocol",
",",
"port",
",",
"service",
",",
"weight",
")",
":",
"manager",
"=",
"SoftLayer",
".",
"DNSManager",
"(",
"env",
"."... | Add resource record.
Each resource record contains a RECORD and DATA property, defining a resource's name and it's target data.
Domains contain multiple types of resource records so it can take one of the following values: A, AAAA, CNAME,
MX, SPF, SRV, and PTR.
About reverse records (PTR), the RECORD ... | [
"Add",
"resource",
"record",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/dns/record_add.py#L43-L90 |
softlayer/softlayer-python | SoftLayer/CLI/loadbal/cancel.py | cli | def cli(env, identifier):
"""Cancel an existing load balancer."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, loadbal_id = loadbal.parse_id(identifier)
if not (env.skip_confirmations or
formatting.confirm("This action will cancel a load balancer. "
"C... | python | def cli(env, identifier):
"""Cancel an existing load balancer."""
mgr = SoftLayer.LoadBalancerManager(env.client)
_, loadbal_id = loadbal.parse_id(identifier)
if not (env.skip_confirmations or
formatting.confirm("This action will cancel a load balancer. "
"C... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"LoadBalancerManager",
"(",
"env",
".",
"client",
")",
"_",
",",
"loadbal_id",
"=",
"loadbal",
".",
"parse_id",
"(",
"identifier",
")",
"if",
"not",
"(",
"env",
".",
... | Cancel an existing load balancer. | [
"Cancel",
"an",
"existing",
"load",
"balancer",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/loadbal/cancel.py#L16-L29 |
softlayer/softlayer-python | SoftLayer/CLI/order/preset_list.py | cli | def cli(env, package_keyname, keyword):
"""List package presets.
.. Note::
Presets are set CPU / RAM / Disk allotments. You still need to specify required items.
Some packages do not have presets.
::
# List the presets for Bare Metal servers
slcli order preset-list BARE_ME... | python | def cli(env, package_keyname, keyword):
"""List package presets.
.. Note::
Presets are set CPU / RAM / Disk allotments. You still need to specify required items.
Some packages do not have presets.
::
# List the presets for Bare Metal servers
slcli order preset-list BARE_ME... | [
"def",
"cli",
"(",
"env",
",",
"package_keyname",
",",
"keyword",
")",
":",
"table",
"=",
"formatting",
".",
"Table",
"(",
"COLUMNS",
")",
"manager",
"=",
"ordering",
".",
"OrderingManager",
"(",
"env",
".",
"client",
")",
"_filter",
"=",
"{",
"}",
"if... | List package presets.
.. Note::
Presets are set CPU / RAM / Disk allotments. You still need to specify required items.
Some packages do not have presets.
::
# List the presets for Bare Metal servers
slcli order preset-list BARE_METAL_SERVER
# List the Bare Metal serve... | [
"List",
"package",
"presets",
"."
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/preset_list.py#L20-L50 |
softlayer/softlayer-python | SoftLayer/CLI/user/permissions.py | cli | def cli(env, identifier):
"""User Permissions. TODO change to list all permissions, and which users have them"""
mgr = SoftLayer.UserManager(env.client)
user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
object_mask = "mask[id, permissions, isMasterUserFlag, roles]"
user = mgr.g... | python | def cli(env, identifier):
"""User Permissions. TODO change to list all permissions, and which users have them"""
mgr = SoftLayer.UserManager(env.client)
user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
object_mask = "mask[id, permissions, isMasterUserFlag, roles]"
user = mgr.g... | [
"def",
"cli",
"(",
"env",
",",
"identifier",
")",
":",
"mgr",
"=",
"SoftLayer",
".",
"UserManager",
"(",
"env",
".",
"client",
")",
"user_id",
"=",
"helpers",
".",
"resolve_id",
"(",
"mgr",
".",
"resolve_ids",
",",
"identifier",
",",
"'username'",
")",
... | User Permissions. TODO change to list all permissions, and which users have them | [
"User",
"Permissions",
".",
"TODO",
"change",
"to",
"list",
"all",
"permissions",
"and",
"which",
"users",
"have",
"them"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/permissions.py#L13-L28 |
softlayer/softlayer-python | SoftLayer/CLI/user/permissions.py | permission_table | def permission_table(user_permissions, all_permissions):
"""Creates a table of available permissions"""
table = formatting.Table(['Description', 'KeyName', 'Assigned'])
table.align['KeyName'] = 'l'
table.align['Description'] = 'l'
table.align['Assigned'] = 'l'
for perm in all_permissions:
... | python | def permission_table(user_permissions, all_permissions):
"""Creates a table of available permissions"""
table = formatting.Table(['Description', 'KeyName', 'Assigned'])
table.align['KeyName'] = 'l'
table.align['Description'] = 'l'
table.align['Assigned'] = 'l'
for perm in all_permissions:
... | [
"def",
"permission_table",
"(",
"user_permissions",
",",
"all_permissions",
")",
":",
"table",
"=",
"formatting",
".",
"Table",
"(",
"[",
"'Description'",
",",
"'KeyName'",
",",
"'Assigned'",
"]",
")",
"table",
".",
"align",
"[",
"'KeyName'",
"]",
"=",
"'l'"... | Creates a table of available permissions | [
"Creates",
"a",
"table",
"of",
"available",
"permissions"
] | train | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/user/permissions.py#L39-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.