repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
xingjiepan/cylinder_fitting | cylinder_fitting/visualize.py | show_fit | def show_fit(w_fit, C_fit, r_fit, Xs):
'''Plot the fitting given the fitted axis direction, the fitted
center, the fitted radius and the data points.
'''
fig = plt.figure()
ax = fig.gca(projection='3d')
# Plot the data points
ax.scatter([X[0] for X in Xs], [X[1] for X in Xs], [X[2... | python | def show_fit(w_fit, C_fit, r_fit, Xs):
'''Plot the fitting given the fitted axis direction, the fitted
center, the fitted radius and the data points.
'''
fig = plt.figure()
ax = fig.gca(projection='3d')
# Plot the data points
ax.scatter([X[0] for X in Xs], [X[1] for X in Xs], [X[2... | [
"def",
"show_fit",
"(",
"w_fit",
",",
"C_fit",
",",
"r_fit",
",",
"Xs",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"ax",
"=",
"fig",
".",
"gca",
"(",
"projection",
"=",
"'3d'",
")",
"# Plot the data points",
"ax",
".",
"scatter",
"(",
"[... | Plot the fitting given the fitted axis direction, the fitted
center, the fitted radius and the data points. | [
"Plot",
"the",
"fitting",
"given",
"the",
"fitted",
"axis",
"direction",
"the",
"fitted",
"center",
"the",
"fitted",
"radius",
"and",
"the",
"data",
"points",
"."
] | f96d79732bc49cbc0cb4b39f008af7ce42aeb213 | https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/visualize.py#L27-L72 | train |
colab/colab | colab/utils/highlighting.py | ColabHighlighter.find_window | def find_window(self, highlight_locations):
"""Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting
to find how many characters before the first word found should
be removed from the window
"""
if len(self.text_block) <= self.max_length:
return (0, self.max_length)
... | python | def find_window(self, highlight_locations):
"""Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting
to find how many characters before the first word found should
be removed from the window
"""
if len(self.text_block) <= self.max_length:
return (0, self.max_length)
... | [
"def",
"find_window",
"(",
"self",
",",
"highlight_locations",
")",
":",
"if",
"len",
"(",
"self",
".",
"text_block",
")",
"<=",
"self",
".",
"max_length",
":",
"return",
"(",
"0",
",",
"self",
".",
"max_length",
")",
"num_chars_before",
"=",
"getattr",
... | Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting
to find how many characters before the first word found should
be removed from the window | [
"Getting",
"the",
"HIGHLIGHT_NUM_CHARS_BEFORE_MATCH",
"setting",
"to",
"find",
"how",
"many",
"characters",
"before",
"the",
"first",
"word",
"found",
"should",
"be",
"removed",
"from",
"the",
"window"
] | 2ad099231e620bec647363b27d38006eca71e13b | https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/utils/highlighting.py#L13-L38 | train |
colab/colab | colab/middlewares/cookie_middleware.py | CookieHandler.__set | def __set(self, key, real_value, coded_value):
"""Private method for setting a cookie's value"""
morse_set = self.get(key, StringMorsel())
morse_set.set(key, real_value, coded_value)
dict.__setitem__(self, key, morse_set) | python | def __set(self, key, real_value, coded_value):
"""Private method for setting a cookie's value"""
morse_set = self.get(key, StringMorsel())
morse_set.set(key, real_value, coded_value)
dict.__setitem__(self, key, morse_set) | [
"def",
"__set",
"(",
"self",
",",
"key",
",",
"real_value",
",",
"coded_value",
")",
":",
"morse_set",
"=",
"self",
".",
"get",
"(",
"key",
",",
"StringMorsel",
"(",
")",
")",
"morse_set",
".",
"set",
"(",
"key",
",",
"real_value",
",",
"coded_value",
... | Private method for setting a cookie's value | [
"Private",
"method",
"for",
"setting",
"a",
"cookie",
"s",
"value"
] | 2ad099231e620bec647363b27d38006eca71e13b | https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/middlewares/cookie_middleware.py#L67-L71 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.login | def login(self):
"""
Try to login and set the internal session id.
Please note:
- Any failed login resets all existing session ids, even of
other users.
- SIDs expire after some time
"""
response = self.session.get(self.base_url + '/login_sid.lua', time... | python | def login(self):
"""
Try to login and set the internal session id.
Please note:
- Any failed login resets all existing session ids, even of
other users.
- SIDs expire after some time
"""
response = self.session.get(self.base_url + '/login_sid.lua', time... | [
"def",
"login",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"base_url",
"+",
"'/login_sid.lua'",
",",
"timeout",
"=",
"10",
")",
"xml",
"=",
"ET",
".",
"fromstring",
"(",
"response",
".",
"text",
")",... | Try to login and set the internal session id.
Please note:
- Any failed login resets all existing session ids, even of
other users.
- SIDs expire after some time | [
"Try",
"to",
"login",
"and",
"set",
"the",
"internal",
"session",
"id",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L53-L81 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.calculate_response | def calculate_response(self, challenge, password):
"""Calculate response for the challenge-response authentication"""
to_hash = (challenge + "-" + password).encode("UTF-16LE")
hashed = hashlib.md5(to_hash).hexdigest()
return "{0}-{1}".format(challenge, hashed) | python | def calculate_response(self, challenge, password):
"""Calculate response for the challenge-response authentication"""
to_hash = (challenge + "-" + password).encode("UTF-16LE")
hashed = hashlib.md5(to_hash).hexdigest()
return "{0}-{1}".format(challenge, hashed) | [
"def",
"calculate_response",
"(",
"self",
",",
"challenge",
",",
"password",
")",
":",
"to_hash",
"=",
"(",
"challenge",
"+",
"\"-\"",
"+",
"password",
")",
".",
"encode",
"(",
"\"UTF-16LE\"",
")",
"hashed",
"=",
"hashlib",
".",
"md5",
"(",
"to_hash",
")... | Calculate response for the challenge-response authentication | [
"Calculate",
"response",
"for",
"the",
"challenge",
"-",
"response",
"authentication"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L83-L87 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.get_actors | def get_actors(self):
"""
Returns a list of Actor objects for querying SmartHome devices.
This is currently the only working method for getting temperature data.
"""
devices = self.homeautoswitch("getdevicelistinfos")
xml = ET.fromstring(devices)
actors = []
... | python | def get_actors(self):
"""
Returns a list of Actor objects for querying SmartHome devices.
This is currently the only working method for getting temperature data.
"""
devices = self.homeautoswitch("getdevicelistinfos")
xml = ET.fromstring(devices)
actors = []
... | [
"def",
"get_actors",
"(",
"self",
")",
":",
"devices",
"=",
"self",
".",
"homeautoswitch",
"(",
"\"getdevicelistinfos\"",
")",
"xml",
"=",
"ET",
".",
"fromstring",
"(",
"devices",
")",
"actors",
"=",
"[",
"]",
"for",
"device",
"in",
"xml",
".",
"findall"... | Returns a list of Actor objects for querying SmartHome devices.
This is currently the only working method for getting temperature data. | [
"Returns",
"a",
"list",
"of",
"Actor",
"objects",
"for",
"querying",
"SmartHome",
"devices",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L93-L106 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.get_actor_by_ain | def get_actor_by_ain(self, ain):
"""
Return a actor identified by it's ain or return None
"""
for actor in self.get_actors():
if actor.actor_id == ain:
return actor | python | def get_actor_by_ain(self, ain):
"""
Return a actor identified by it's ain or return None
"""
for actor in self.get_actors():
if actor.actor_id == ain:
return actor | [
"def",
"get_actor_by_ain",
"(",
"self",
",",
"ain",
")",
":",
"for",
"actor",
"in",
"self",
".",
"get_actors",
"(",
")",
":",
"if",
"actor",
".",
"actor_id",
"==",
"ain",
":",
"return",
"actor"
] | Return a actor identified by it's ain or return None | [
"Return",
"a",
"actor",
"identified",
"by",
"it",
"s",
"ain",
"or",
"return",
"None"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L108-L114 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.homeautoswitch | def homeautoswitch(self, cmd, ain=None, param=None):
"""
Call a switch method.
Should only be used by internal library functions.
"""
assert self.sid, "Not logged in"
params = {
'switchcmd': cmd,
'sid': self.sid,
}
if param is not N... | python | def homeautoswitch(self, cmd, ain=None, param=None):
"""
Call a switch method.
Should only be used by internal library functions.
"""
assert self.sid, "Not logged in"
params = {
'switchcmd': cmd,
'sid': self.sid,
}
if param is not N... | [
"def",
"homeautoswitch",
"(",
"self",
",",
"cmd",
",",
"ain",
"=",
"None",
",",
"param",
"=",
"None",
")",
":",
"assert",
"self",
".",
"sid",
",",
"\"Not logged in\"",
"params",
"=",
"{",
"'switchcmd'",
":",
"cmd",
",",
"'sid'",
":",
"self",
".",
"si... | Call a switch method.
Should only be used by internal library functions. | [
"Call",
"a",
"switch",
"method",
".",
"Should",
"only",
"be",
"used",
"by",
"internal",
"library",
"functions",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L120-L138 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.get_switch_actors | def get_switch_actors(self):
"""
Get information about all actors
This needs 1+(5n) requests where n = number of actors registered
Deprecated, use get_actors instead.
Returns a dict:
[ain] = {
'name': Name of actor,
'state': Powerstate (boolean)... | python | def get_switch_actors(self):
"""
Get information about all actors
This needs 1+(5n) requests where n = number of actors registered
Deprecated, use get_actors instead.
Returns a dict:
[ain] = {
'name': Name of actor,
'state': Powerstate (boolean)... | [
"def",
"get_switch_actors",
"(",
"self",
")",
":",
"actors",
"=",
"{",
"}",
"for",
"ain",
"in",
"self",
".",
"homeautoswitch",
"(",
"\"getswitchlist\"",
")",
".",
"split",
"(",
"','",
")",
":",
"actors",
"[",
"ain",
"]",
"=",
"{",
"'name'",
":",
"sel... | Get information about all actors
This needs 1+(5n) requests where n = number of actors registered
Deprecated, use get_actors instead.
Returns a dict:
[ain] = {
'name': Name of actor,
'state': Powerstate (boolean)
'present': Connected to server? (boo... | [
"Get",
"information",
"about",
"all",
"actors"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L140-L168 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.get_devices | def get_devices(self):
"""
Return a list of devices.
Deprecated, use get_actors instead.
"""
url = self.base_url + '/net/home_auto_query.lua'
response = self.session.get(url, params={
'sid': self.sid,
'command': 'AllOutletStates',
'xhr'... | python | def get_devices(self):
"""
Return a list of devices.
Deprecated, use get_actors instead.
"""
url = self.base_url + '/net/home_auto_query.lua'
response = self.session.get(url, params={
'sid': self.sid,
'command': 'AllOutletStates',
'xhr'... | [
"def",
"get_devices",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'/net/home_auto_query.lua'",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
",",
"params",
"=",
"{",
"'sid'",
":",
"self",
".",
"sid",
",",
"'comm... | Return a list of devices.
Deprecated, use get_actors instead. | [
"Return",
"a",
"list",
"of",
"devices",
".",
"Deprecated",
"use",
"get_actors",
"instead",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L189-L211 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.get_consumption | def get_consumption(self, deviceid, timerange="10"):
"""
Return all available energy consumption data for the device.
You need to divice watt_values by 100 and volt_values by 1000
to get the "real" values.
:return: dict
"""
tranges = ("10", "24h", "month", "year"... | python | def get_consumption(self, deviceid, timerange="10"):
"""
Return all available energy consumption data for the device.
You need to divice watt_values by 100 and volt_values by 1000
to get the "real" values.
:return: dict
"""
tranges = ("10", "24h", "month", "year"... | [
"def",
"get_consumption",
"(",
"self",
",",
"deviceid",
",",
"timerange",
"=",
"\"10\"",
")",
":",
"tranges",
"=",
"(",
"\"10\"",
",",
"\"24h\"",
",",
"\"month\"",
",",
"\"year\"",
")",
"if",
"timerange",
"not",
"in",
"tranges",
":",
"raise",
"ValueError",... | Return all available energy consumption data for the device.
You need to divice watt_values by 100 and volt_values by 1000
to get the "real" values.
:return: dict | [
"Return",
"all",
"available",
"energy",
"consumption",
"data",
"for",
"the",
"device",
".",
"You",
"need",
"to",
"divice",
"watt_values",
"by",
"100",
"and",
"volt_values",
"by",
"1000",
"to",
"get",
"the",
"real",
"values",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L213-L268 | train |
DerMitch/fritzbox-smarthome | fritzhome/fritz.py | FritzBox.get_logs | def get_logs(self):
"""
Return the system logs since the last reboot.
"""
assert BeautifulSoup, "Please install bs4 to use this method"
url = self.base_url + "/system/syslog.lua"
response = self.session.get(url, params={
'sid': self.sid,
'stylemod... | python | def get_logs(self):
"""
Return the system logs since the last reboot.
"""
assert BeautifulSoup, "Please install bs4 to use this method"
url = self.base_url + "/system/syslog.lua"
response = self.session.get(url, params={
'sid': self.sid,
'stylemod... | [
"def",
"get_logs",
"(",
"self",
")",
":",
"assert",
"BeautifulSoup",
",",
"\"Please install bs4 to use this method\"",
"url",
"=",
"self",
".",
"base_url",
"+",
"\"/system/syslog.lua\"",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
",",
"para... | Return the system logs since the last reboot. | [
"Return",
"the",
"system",
"logs",
"since",
"the",
"last",
"reboot",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L270-L295 | train |
kumar303/hawkrest | hawkrest/__init__.py | seen_nonce | def seen_nonce(id, nonce, timestamp):
"""
Returns True if the Hawk nonce has been seen already.
"""
key = '{id}:{n}:{ts}'.format(id=id, n=nonce, ts=timestamp)
if cache.get(key):
log.warning('replay attack? already processed nonce {k}'
.format(k=key))
return True
... | python | def seen_nonce(id, nonce, timestamp):
"""
Returns True if the Hawk nonce has been seen already.
"""
key = '{id}:{n}:{ts}'.format(id=id, n=nonce, ts=timestamp)
if cache.get(key):
log.warning('replay attack? already processed nonce {k}'
.format(k=key))
return True
... | [
"def",
"seen_nonce",
"(",
"id",
",",
"nonce",
",",
"timestamp",
")",
":",
"key",
"=",
"'{id}:{n}:{ts}'",
".",
"format",
"(",
"id",
"=",
"id",
",",
"n",
"=",
"nonce",
",",
"ts",
"=",
"timestamp",
")",
"if",
"cache",
".",
"get",
"(",
"key",
")",
":... | Returns True if the Hawk nonce has been seen already. | [
"Returns",
"True",
"if",
"the",
"Hawk",
"nonce",
"has",
"been",
"seen",
"already",
"."
] | df4de1a068dc2624bf716ed244ab55e8ad4fef7e | https://github.com/kumar303/hawkrest/blob/df4de1a068dc2624bf716ed244ab55e8ad4fef7e/hawkrest/__init__.py#L187-L203 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | cli | def cli(context, host, username, password):
"""
FritzBox SmartHome Tool
\b
Provides the following functions:
- A easy to use library for querying SmartHome actors
- This CLI tool for testing
- A carbon client for pipeing data into graphite
"""
context.obj = FritzBox(host, username, ... | python | def cli(context, host, username, password):
"""
FritzBox SmartHome Tool
\b
Provides the following functions:
- A easy to use library for querying SmartHome actors
- This CLI tool for testing
- A carbon client for pipeing data into graphite
"""
context.obj = FritzBox(host, username, ... | [
"def",
"cli",
"(",
"context",
",",
"host",
",",
"username",
",",
"password",
")",
":",
"context",
".",
"obj",
"=",
"FritzBox",
"(",
"host",
",",
"username",
",",
"password",
")"
] | FritzBox SmartHome Tool
\b
Provides the following functions:
- A easy to use library for querying SmartHome actors
- This CLI tool for testing
- A carbon client for pipeing data into graphite | [
"FritzBox",
"SmartHome",
"Tool"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L25-L35 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | actors | def actors(context):
"""Display a list of actors"""
fritz = context.obj
fritz.login()
for actor in fritz.get_actors():
click.echo("{} ({} {}; AIN {} )".format(
actor.name,
actor.manufacturer,
actor.productname,
actor.actor_id,
))
i... | python | def actors(context):
"""Display a list of actors"""
fritz = context.obj
fritz.login()
for actor in fritz.get_actors():
click.echo("{} ({} {}; AIN {} )".format(
actor.name,
actor.manufacturer,
actor.productname,
actor.actor_id,
))
i... | [
"def",
"actors",
"(",
"context",
")",
":",
"fritz",
"=",
"context",
".",
"obj",
"fritz",
".",
"login",
"(",
")",
"for",
"actor",
"in",
"fritz",
".",
"get_actors",
"(",
")",
":",
"click",
".",
"echo",
"(",
"\"{} ({} {}; AIN {} )\"",
".",
"format",
"(",
... | Display a list of actors | [
"Display",
"a",
"list",
"of",
"actors"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L40-L62 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | energy | def energy(context, features):
"""Display energy stats of all actors"""
fritz = context.obj
fritz.login()
for actor in fritz.get_actors():
if actor.temperature is not None:
click.echo("{} ({}): {:.2f} Watt current, {:.3f} wH total, {:.2f} °C".format(
actor.name.encod... | python | def energy(context, features):
"""Display energy stats of all actors"""
fritz = context.obj
fritz.login()
for actor in fritz.get_actors():
if actor.temperature is not None:
click.echo("{} ({}): {:.2f} Watt current, {:.3f} wH total, {:.2f} °C".format(
actor.name.encod... | [
"def",
"energy",
"(",
"context",
",",
"features",
")",
":",
"fritz",
"=",
"context",
".",
"obj",
"fritz",
".",
"login",
"(",
")",
"for",
"actor",
"in",
"fritz",
".",
"get_actors",
"(",
")",
":",
"if",
"actor",
".",
"temperature",
"is",
"not",
"None",... | Display energy stats of all actors | [
"Display",
"energy",
"stats",
"of",
"all",
"actors"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L68-L92 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | graphite | def graphite(context, server, port, interval, prefix):
"""Display energy stats of all actors"""
fritz = context.obj
fritz.login()
sid_ttl = time.time() + 600
# Find actors and create carbon keys
click.echo(" * Requesting actors list")
simple_chars = re.compile('[^A-Za-z0-9]+')
actors = ... | python | def graphite(context, server, port, interval, prefix):
"""Display energy stats of all actors"""
fritz = context.obj
fritz.login()
sid_ttl = time.time() + 600
# Find actors and create carbon keys
click.echo(" * Requesting actors list")
simple_chars = re.compile('[^A-Za-z0-9]+')
actors = ... | [
"def",
"graphite",
"(",
"context",
",",
"server",
",",
"port",
",",
"interval",
",",
"prefix",
")",
":",
"fritz",
"=",
"context",
".",
"obj",
"fritz",
".",
"login",
"(",
")",
"sid_ttl",
"=",
"time",
".",
"time",
"(",
")",
"+",
"600",
"# Find actors a... | Display energy stats of all actors | [
"Display",
"energy",
"stats",
"of",
"all",
"actors"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L101-L157 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | switch_on | def switch_on(context, ain):
"""Switch an actor's power to ON"""
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
click.echo("Switching {} on".format(actor.name))
actor.switch_on()
else:
click.echo("Actor not found: {}".format(ain)) | python | def switch_on(context, ain):
"""Switch an actor's power to ON"""
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
click.echo("Switching {} on".format(actor.name))
actor.switch_on()
else:
click.echo("Actor not found: {}".format(ain)) | [
"def",
"switch_on",
"(",
"context",
",",
"ain",
")",
":",
"context",
".",
"obj",
".",
"login",
"(",
")",
"actor",
"=",
"context",
".",
"obj",
".",
"get_actor_by_ain",
"(",
"ain",
")",
"if",
"actor",
":",
"click",
".",
"echo",
"(",
"\"Switching {} on\""... | Switch an actor's power to ON | [
"Switch",
"an",
"actor",
"s",
"power",
"to",
"ON"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L163-L171 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | switch_state | def switch_state(context, ain):
"""Get an actor's power state"""
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
click.echo("State for {} is: {}".format(ain,'ON' if actor.get_state() else 'OFF'))
else:
click.echo("Actor not found: {}".format(ain)) | python | def switch_state(context, ain):
"""Get an actor's power state"""
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
click.echo("State for {} is: {}".format(ain,'ON' if actor.get_state() else 'OFF'))
else:
click.echo("Actor not found: {}".format(ain)) | [
"def",
"switch_state",
"(",
"context",
",",
"ain",
")",
":",
"context",
".",
"obj",
".",
"login",
"(",
")",
"actor",
"=",
"context",
".",
"obj",
".",
"get_actor_by_ain",
"(",
"ain",
")",
"if",
"actor",
":",
"click",
".",
"echo",
"(",
"\"State for {} is... | Get an actor's power state | [
"Get",
"an",
"actor",
"s",
"power",
"state"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L191-L198 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | switch_toggle | def switch_toggle(context, ain):
"""Toggle an actor's power state"""
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
if actor.get_state():
actor.switch_off()
click.echo("State for {} is now OFF".format(ain))
else:
actor.switch_o... | python | def switch_toggle(context, ain):
"""Toggle an actor's power state"""
context.obj.login()
actor = context.obj.get_actor_by_ain(ain)
if actor:
if actor.get_state():
actor.switch_off()
click.echo("State for {} is now OFF".format(ain))
else:
actor.switch_o... | [
"def",
"switch_toggle",
"(",
"context",
",",
"ain",
")",
":",
"context",
".",
"obj",
".",
"login",
"(",
")",
"actor",
"=",
"context",
".",
"obj",
".",
"get_actor_by_ain",
"(",
"ain",
")",
"if",
"actor",
":",
"if",
"actor",
".",
"get_state",
"(",
")",... | Toggle an actor's power state | [
"Toggle",
"an",
"actor",
"s",
"power",
"state"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L204-L216 | train |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | logs | def logs(context, format):
"""Show system logs since last reboot"""
fritz = context.obj
fritz.login()
messages = fritz.get_logs()
if format == "plain":
for msg in messages:
merged = "{} {} {}".format(msg.date, msg.time, msg.message.encode("UTF-8"))
click.echo(merged)... | python | def logs(context, format):
"""Show system logs since last reboot"""
fritz = context.obj
fritz.login()
messages = fritz.get_logs()
if format == "plain":
for msg in messages:
merged = "{} {} {}".format(msg.date, msg.time, msg.message.encode("UTF-8"))
click.echo(merged)... | [
"def",
"logs",
"(",
"context",
",",
"format",
")",
":",
"fritz",
"=",
"context",
".",
"obj",
"fritz",
".",
"login",
"(",
")",
"messages",
"=",
"fritz",
".",
"get_logs",
"(",
")",
"if",
"format",
"==",
"\"plain\"",
":",
"for",
"msg",
"in",
"messages",... | Show system logs since last reboot | [
"Show",
"system",
"logs",
"since",
"last",
"reboot"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L223-L238 | train |
DerMitch/fritzbox-smarthome | fritzhome/actor.py | Actor.get_power | def get_power(self):
"""
Returns the current power usage in milliWatts.
Attention: Returns None if the value can't be queried or is unknown.
"""
value = self.box.homeautoswitch("getswitchpower", self.actor_id)
return int(value) if value.isdigit() else None | python | def get_power(self):
"""
Returns the current power usage in milliWatts.
Attention: Returns None if the value can't be queried or is unknown.
"""
value = self.box.homeautoswitch("getswitchpower", self.actor_id)
return int(value) if value.isdigit() else None | [
"def",
"get_power",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"box",
".",
"homeautoswitch",
"(",
"\"getswitchpower\"",
",",
"self",
".",
"actor_id",
")",
"return",
"int",
"(",
"value",
")",
"if",
"value",
".",
"isdigit",
"(",
")",
"else",
"None... | Returns the current power usage in milliWatts.
Attention: Returns None if the value can't be queried or is unknown. | [
"Returns",
"the",
"current",
"power",
"usage",
"in",
"milliWatts",
".",
"Attention",
":",
"Returns",
"None",
"if",
"the",
"value",
"can",
"t",
"be",
"queried",
"or",
"is",
"unknown",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L83-L89 | train |
DerMitch/fritzbox-smarthome | fritzhome/actor.py | Actor.get_energy | def get_energy(self):
"""
Returns the consumed energy since the start of the statistics in Wh.
Attention: Returns None if the value can't be queried or is unknown.
"""
value = self.box.homeautoswitch("getswitchenergy", self.actor_id)
return int(value) if value.isdigit() e... | python | def get_energy(self):
"""
Returns the consumed energy since the start of the statistics in Wh.
Attention: Returns None if the value can't be queried or is unknown.
"""
value = self.box.homeautoswitch("getswitchenergy", self.actor_id)
return int(value) if value.isdigit() e... | [
"def",
"get_energy",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"box",
".",
"homeautoswitch",
"(",
"\"getswitchenergy\"",
",",
"self",
".",
"actor_id",
")",
"return",
"int",
"(",
"value",
")",
"if",
"value",
".",
"isdigit",
"(",
")",
"else",
"No... | Returns the consumed energy since the start of the statistics in Wh.
Attention: Returns None if the value can't be queried or is unknown. | [
"Returns",
"the",
"consumed",
"energy",
"since",
"the",
"start",
"of",
"the",
"statistics",
"in",
"Wh",
".",
"Attention",
":",
"Returns",
"None",
"if",
"the",
"value",
"can",
"t",
"be",
"queried",
"or",
"is",
"unknown",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L91-L97 | train |
DerMitch/fritzbox-smarthome | fritzhome/actor.py | Actor.get_temperature | def get_temperature(self):
"""
Returns the current environment temperature.
Attention: Returns None if the value can't be queried or is unknown.
"""
#raise NotImplementedError("This should work according to the AVM docs, but don't...")
value = self.box.homeautoswitch("get... | python | def get_temperature(self):
"""
Returns the current environment temperature.
Attention: Returns None if the value can't be queried or is unknown.
"""
#raise NotImplementedError("This should work according to the AVM docs, but don't...")
value = self.box.homeautoswitch("get... | [
"def",
"get_temperature",
"(",
"self",
")",
":",
"#raise NotImplementedError(\"This should work according to the AVM docs, but don't...\")",
"value",
"=",
"self",
".",
"box",
".",
"homeautoswitch",
"(",
"\"gettemperature\"",
",",
"self",
".",
"actor_id",
")",
"if",
"value... | Returns the current environment temperature.
Attention: Returns None if the value can't be queried or is unknown. | [
"Returns",
"the",
"current",
"environment",
"temperature",
".",
"Attention",
":",
"Returns",
"None",
"if",
"the",
"value",
"can",
"t",
"be",
"queried",
"or",
"is",
"unknown",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L99-L110 | train |
DerMitch/fritzbox-smarthome | fritzhome/actor.py | Actor.get_target_temperature | def get_target_temperature(self):
"""
Returns the actual target temperature.
Attention: Returns None if the value can't be queried or is unknown.
"""
value = self.box.homeautoswitch("gethkrtsoll", self.actor_id)
self.target_temperature = self.__get_temp(value)
ret... | python | def get_target_temperature(self):
"""
Returns the actual target temperature.
Attention: Returns None if the value can't be queried or is unknown.
"""
value = self.box.homeautoswitch("gethkrtsoll", self.actor_id)
self.target_temperature = self.__get_temp(value)
ret... | [
"def",
"get_target_temperature",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"box",
".",
"homeautoswitch",
"(",
"\"gethkrtsoll\"",
",",
"self",
".",
"actor_id",
")",
"self",
".",
"target_temperature",
"=",
"self",
".",
"__get_temp",
"(",
"value",
")",
... | Returns the actual target temperature.
Attention: Returns None if the value can't be queried or is unknown. | [
"Returns",
"the",
"actual",
"target",
"temperature",
".",
"Attention",
":",
"Returns",
"None",
"if",
"the",
"value",
"can",
"t",
"be",
"queried",
"or",
"is",
"unknown",
"."
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L125-L132 | train |
DerMitch/fritzbox-smarthome | fritzhome/actor.py | Actor.set_temperature | def set_temperature(self, temp):
"""
Sets the temperature in celcius
"""
# Temperature is send to fritz.box a little weird
param = 16 + ( ( temp - 8 ) * 2 )
if param < 16:
param = 253
logger.info("Actor " + self.name + ": Temperature control set t... | python | def set_temperature(self, temp):
"""
Sets the temperature in celcius
"""
# Temperature is send to fritz.box a little weird
param = 16 + ( ( temp - 8 ) * 2 )
if param < 16:
param = 253
logger.info("Actor " + self.name + ": Temperature control set t... | [
"def",
"set_temperature",
"(",
"self",
",",
"temp",
")",
":",
"# Temperature is send to fritz.box a little weird",
"param",
"=",
"16",
"+",
"(",
"(",
"temp",
"-",
"8",
")",
"*",
"2",
")",
"if",
"param",
"<",
"16",
":",
"param",
"=",
"253",
"logger",
".",... | Sets the temperature in celcius | [
"Sets",
"the",
"temperature",
"in",
"celcius"
] | 84cbd7c1b33e6256add041b0395ff5fccc01f103 | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L134-L150 | train |
projectatomic/osbs-client | osbs/conf.py | Configuration.get_openshift_base_uri | def get_openshift_base_uri(self):
"""
https://<host>[:<port>]/
:return: str
"""
deprecated_key = "openshift_uri"
key = "openshift_url"
val = self._get_value(deprecated_key, self.conf_section, deprecated_key)
if val is not None:
warnings.warn("... | python | def get_openshift_base_uri(self):
"""
https://<host>[:<port>]/
:return: str
"""
deprecated_key = "openshift_uri"
key = "openshift_url"
val = self._get_value(deprecated_key, self.conf_section, deprecated_key)
if val is not None:
warnings.warn("... | [
"def",
"get_openshift_base_uri",
"(",
"self",
")",
":",
"deprecated_key",
"=",
"\"openshift_uri\"",
"key",
"=",
"\"openshift_url\"",
"val",
"=",
"self",
".",
"_get_value",
"(",
"deprecated_key",
",",
"self",
".",
"conf_section",
",",
"deprecated_key",
")",
"if",
... | https://<host>[:<port>]/
:return: str | [
"https",
":",
"//",
"<host",
">",
"[",
":",
"<port",
">",
"]",
"/"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/conf.py#L130-L142 | train |
projectatomic/osbs-client | osbs/conf.py | Configuration.get_builder_openshift_url | def get_builder_openshift_url(self):
""" url of OpenShift where builder will connect """
key = "builder_openshift_url"
url = self._get_deprecated(key, self.conf_section, key)
if url is None:
logger.warning("%r not found, falling back to get_openshift_base_uri()", key)
... | python | def get_builder_openshift_url(self):
""" url of OpenShift where builder will connect """
key = "builder_openshift_url"
url = self._get_deprecated(key, self.conf_section, key)
if url is None:
logger.warning("%r not found, falling back to get_openshift_base_uri()", key)
... | [
"def",
"get_builder_openshift_url",
"(",
"self",
")",
":",
"key",
"=",
"\"builder_openshift_url\"",
"url",
"=",
"self",
".",
"_get_deprecated",
"(",
"key",
",",
"self",
".",
"conf_section",
",",
"key",
")",
"if",
"url",
"is",
"None",
":",
"logger",
".",
"w... | url of OpenShift where builder will connect | [
"url",
"of",
"OpenShift",
"where",
"builder",
"will",
"connect"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/conf.py#L363-L370 | train |
projectatomic/osbs-client | osbs/conf.py | Configuration.generate_nodeselector_dict | def generate_nodeselector_dict(self, nodeselector_str):
"""
helper method for generating nodeselector dict
:param nodeselector_str:
:return: dict
"""
nodeselector = {}
if nodeselector_str and nodeselector_str != 'none':
constraints = [x.strip() for x i... | python | def generate_nodeselector_dict(self, nodeselector_str):
"""
helper method for generating nodeselector dict
:param nodeselector_str:
:return: dict
"""
nodeselector = {}
if nodeselector_str and nodeselector_str != 'none':
constraints = [x.strip() for x i... | [
"def",
"generate_nodeselector_dict",
"(",
"self",
",",
"nodeselector_str",
")",
":",
"nodeselector",
"=",
"{",
"}",
"if",
"nodeselector_str",
"and",
"nodeselector_str",
"!=",
"'none'",
":",
"constraints",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"i... | helper method for generating nodeselector dict
:param nodeselector_str:
:return: dict | [
"helper",
"method",
"for",
"generating",
"nodeselector",
"dict",
":",
"param",
"nodeselector_str",
":",
":",
"return",
":",
"dict"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/conf.py#L565-L577 | train |
projectatomic/osbs-client | osbs/conf.py | Configuration.get_platform_node_selector | def get_platform_node_selector(self, platform):
"""
search the configuration for entries of the form node_selector.platform
:param platform: str, platform to search for, can be null
:return dict
"""
nodeselector = {}
if platform:
nodeselector_str = sel... | python | def get_platform_node_selector(self, platform):
"""
search the configuration for entries of the form node_selector.platform
:param platform: str, platform to search for, can be null
:return dict
"""
nodeselector = {}
if platform:
nodeselector_str = sel... | [
"def",
"get_platform_node_selector",
"(",
"self",
",",
"platform",
")",
":",
"nodeselector",
"=",
"{",
"}",
"if",
"platform",
":",
"nodeselector_str",
"=",
"self",
".",
"_get_value",
"(",
"\"node_selector.\"",
"+",
"platform",
",",
"self",
".",
"conf_section",
... | search the configuration for entries of the form node_selector.platform
:param platform: str, platform to search for, can be null
:return dict | [
"search",
"the",
"configuration",
"for",
"entries",
"of",
"the",
"form",
"node_selector",
".",
"platform",
":",
"param",
"platform",
":",
"str",
"platform",
"to",
"search",
"for",
"can",
"be",
"null",
":",
"return",
"dict"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/conf.py#L579-L591 | train |
thombashi/pytablereader | pytablereader/csv/core.py | CsvTableFileLoader.load | def load(self):
"""
Extract tabular data as |TableData| instances from a CSV file.
|load_source_desc_file|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier ... | python | def load(self):
"""
Extract tabular data as |TableData| instances from a CSV file.
|load_source_desc_file|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier ... | [
"def",
"load",
"(",
"self",
")",
":",
"self",
".",
"_validate",
"(",
")",
"self",
".",
"_logger",
".",
"logging_load",
"(",
")",
"self",
".",
"encoding",
"=",
"get_file_encoding",
"(",
"self",
".",
"source",
",",
"self",
".",
"encoding",
")",
"if",
"... | Extract tabular data as |TableData| instances from a CSV file.
|load_source_desc_file|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier Value after the replacement
... | [
"Extract",
"tabular",
"data",
"as",
"|TableData|",
"instances",
"from",
"a",
"CSV",
"file",
".",
"|load_source_desc_file|"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/csv/core.py#L145-L194 | train |
thombashi/pytablereader | pytablereader/csv/core.py | CsvTableTextLoader.load | def load(self):
"""
Extract tabular data as |TableData| instances from a CSV text object.
|load_source_desc_text|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format spec... | python | def load(self):
"""
Extract tabular data as |TableData| instances from a CSV text object.
|load_source_desc_text|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format spec... | [
"def",
"load",
"(",
"self",
")",
":",
"self",
".",
"_validate",
"(",
")",
"self",
".",
"_logger",
".",
"logging_load",
"(",
")",
"self",
".",
"_csv_reader",
"=",
"csv",
".",
"reader",
"(",
"six",
".",
"StringIO",
"(",
"self",
".",
"source",
".",
"s... | Extract tabular data as |TableData| instances from a CSV text object.
|load_source_desc_text|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier Value after the replacemen... | [
"Extract",
"tabular",
"data",
"as",
"|TableData|",
"instances",
"from",
"a",
"CSV",
"text",
"object",
".",
"|load_source_desc_text|"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/csv/core.py#L220-L258 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.set_params | def set_params(self, **kwargs):
"""
set parameters according to specification
these parameters are accepted:
:param pulp_secret: str, resource name of pulp secret
:param koji_target: str, koji tag with packages used to build the image
:param kojiroot: str, URL from whic... | python | def set_params(self, **kwargs):
"""
set parameters according to specification
these parameters are accepted:
:param pulp_secret: str, resource name of pulp secret
:param koji_target: str, koji tag with packages used to build the image
:param kojiroot: str, URL from whic... | [
"def",
"set_params",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Here we cater to the koji \"scratch\" build type, this will disable",
"# all plugins that might cause importing of data to koji",
"self",
".",
"scratch",
"=",
"kwargs",
".",
"pop",
"(",
"'scratch'",
","... | set parameters according to specification
these parameters are accepted:
:param pulp_secret: str, resource name of pulp secret
:param koji_target: str, koji tag with packages used to build the image
:param kojiroot: str, URL from which koji packages are fetched
:param kojihub: ... | [
"set",
"parameters",
"according",
"to",
"specification"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L72-L131 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.has_ist_trigger | def has_ist_trigger(self):
"""Return True if this BuildConfig has ImageStreamTag trigger."""
triggers = self.template['spec'].get('triggers', [])
if not triggers:
return False
for trigger in triggers:
if trigger['type'] == 'ImageChange' and \
t... | python | def has_ist_trigger(self):
"""Return True if this BuildConfig has ImageStreamTag trigger."""
triggers = self.template['spec'].get('triggers', [])
if not triggers:
return False
for trigger in triggers:
if trigger['type'] == 'ImageChange' and \
t... | [
"def",
"has_ist_trigger",
"(",
"self",
")",
":",
"triggers",
"=",
"self",
".",
"template",
"[",
"'spec'",
"]",
".",
"get",
"(",
"'triggers'",
",",
"[",
"]",
")",
"if",
"not",
"triggers",
":",
"return",
"False",
"for",
"trigger",
"in",
"triggers",
":",
... | Return True if this BuildConfig has ImageStreamTag trigger. | [
"Return",
"True",
"if",
"this",
"BuildConfig",
"has",
"ImageStreamTag",
"trigger",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L210-L219 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.set_secret_for_plugin | def set_secret_for_plugin(self, secret, plugin=None, mount_path=None):
"""
Sets secret for plugin, if no plugin specified
it will also set general secret
:param secret: str, secret name
:param plugin: tuple, (plugin type, plugin name, argument name)
:param mount_path: st... | python | def set_secret_for_plugin(self, secret, plugin=None, mount_path=None):
"""
Sets secret for plugin, if no plugin specified
it will also set general secret
:param secret: str, secret name
:param plugin: tuple, (plugin type, plugin name, argument name)
:param mount_path: st... | [
"def",
"set_secret_for_plugin",
"(",
"self",
",",
"secret",
",",
"plugin",
"=",
"None",
",",
"mount_path",
"=",
"None",
")",
":",
"has_plugin_conf",
"=",
"False",
"if",
"plugin",
"is",
"not",
"None",
":",
"has_plugin_conf",
"=",
"self",
".",
"dj",
".",
"... | Sets secret for plugin, if no plugin specified
it will also set general secret
:param secret: str, secret name
:param plugin: tuple, (plugin type, plugin name, argument name)
:param mount_path: str, mount path of secret | [
"Sets",
"secret",
"for",
"plugin",
"if",
"no",
"plugin",
"specified",
"it",
"will",
"also",
"set",
"general",
"secret"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L403-L445 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.set_secrets | def set_secrets(self, secrets):
"""
:param secrets: dict, {(plugin type, plugin name, argument name): secret name}
for example {('exit_plugins', 'koji_promote', 'koji_ssl_certs'): 'koji_ssl_certs', ...}
"""
secret_set = False
for (plugin, secret) in secrets.items():
... | python | def set_secrets(self, secrets):
"""
:param secrets: dict, {(plugin type, plugin name, argument name): secret name}
for example {('exit_plugins', 'koji_promote', 'koji_ssl_certs'): 'koji_ssl_certs', ...}
"""
secret_set = False
for (plugin, secret) in secrets.items():
... | [
"def",
"set_secrets",
"(",
"self",
",",
"secrets",
")",
":",
"secret_set",
"=",
"False",
"for",
"(",
"plugin",
",",
"secret",
")",
"in",
"secrets",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"plugin",
",",
"tuple",
")",
"or",
"len",... | :param secrets: dict, {(plugin type, plugin name, argument name): secret name}
for example {('exit_plugins', 'koji_promote', 'koji_ssl_certs'): 'koji_ssl_certs', ...} | [
":",
"param",
"secrets",
":",
"dict",
"{",
"(",
"plugin",
"type",
"plugin",
"name",
"argument",
"name",
")",
":",
"secret",
"name",
"}",
"for",
"example",
"{",
"(",
"exit_plugins",
"koji_promote",
"koji_ssl_certs",
")",
":",
"koji_ssl_certs",
"...",
"}"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L447-L467 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.remove_tag_and_push_registries | def remove_tag_and_push_registries(tag_and_push_registries, version):
"""
Remove matching entries from tag_and_push_registries (in-place)
:param tag_and_push_registries: dict, uri -> dict
:param version: str, 'version' to match against
"""
registries = [uri
... | python | def remove_tag_and_push_registries(tag_and_push_registries, version):
"""
Remove matching entries from tag_and_push_registries (in-place)
:param tag_and_push_registries: dict, uri -> dict
:param version: str, 'version' to match against
"""
registries = [uri
... | [
"def",
"remove_tag_and_push_registries",
"(",
"tag_and_push_registries",
",",
"version",
")",
":",
"registries",
"=",
"[",
"uri",
"for",
"uri",
",",
"regdict",
"in",
"tag_and_push_registries",
".",
"items",
"(",
")",
"if",
"regdict",
"[",
"'version'",
"]",
"==",... | Remove matching entries from tag_and_push_registries (in-place)
:param tag_and_push_registries: dict, uri -> dict
:param version: str, 'version' to match against | [
"Remove",
"matching",
"entries",
"from",
"tag_and_push_registries",
"(",
"in",
"-",
"place",
")"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L488-L500 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.adjust_for_registry_api_versions | def adjust_for_registry_api_versions(self):
"""
Enable/disable plugins depending on supported registry API versions
"""
versions = self.spec.registry_api_versions.value
if 'v2' not in versions:
raise OsbsValidationException('v1-only docker registry API is not support... | python | def adjust_for_registry_api_versions(self):
"""
Enable/disable plugins depending on supported registry API versions
"""
versions = self.spec.registry_api_versions.value
if 'v2' not in versions:
raise OsbsValidationException('v1-only docker registry API is not support... | [
"def",
"adjust_for_registry_api_versions",
"(",
"self",
")",
":",
"versions",
"=",
"self",
".",
"spec",
".",
"registry_api_versions",
".",
"value",
"if",
"'v2'",
"not",
"in",
"versions",
":",
"raise",
"OsbsValidationException",
"(",
"'v1-only docker registry API is no... | Enable/disable plugins depending on supported registry API versions | [
"Enable",
"/",
"disable",
"plugins",
"depending",
"on",
"supported",
"registry",
"API",
"versions"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L515-L544 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.adjust_for_triggers | def adjust_for_triggers(self):
"""Remove trigger-related plugins when needed
If there are no triggers defined, it's assumed the
feature is disabled and all trigger-related plugins
are removed.
If there are triggers defined, and this is a custom
base image, some trigger-... | python | def adjust_for_triggers(self):
"""Remove trigger-related plugins when needed
If there are no triggers defined, it's assumed the
feature is disabled and all trigger-related plugins
are removed.
If there are triggers defined, and this is a custom
base image, some trigger-... | [
"def",
"adjust_for_triggers",
"(",
"self",
")",
":",
"triggers",
"=",
"self",
".",
"template",
"[",
"'spec'",
"]",
".",
"get",
"(",
"'triggers'",
",",
"[",
"]",
")",
"remove_plugins",
"=",
"[",
"(",
"\"prebuild_plugins\"",
",",
"\"check_and_set_rebuild\"",
"... | Remove trigger-related plugins when needed
If there are no triggers defined, it's assumed the
feature is disabled and all trigger-related plugins
are removed.
If there are triggers defined, and this is a custom
base image, some trigger-related plugins do not apply.
Add... | [
"Remove",
"trigger",
"-",
"related",
"plugins",
"when",
"needed"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L546-L583 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.adjust_for_scratch | def adjust_for_scratch(self):
"""
Remove certain plugins in order to handle the "scratch build"
scenario. Scratch builds must not affect subsequent builds,
and should not be imported into Koji.
"""
if self.scratch:
self.template['spec'].pop('triggers', None)
... | python | def adjust_for_scratch(self):
"""
Remove certain plugins in order to handle the "scratch build"
scenario. Scratch builds must not affect subsequent builds,
and should not be imported into Koji.
"""
if self.scratch:
self.template['spec'].pop('triggers', None)
... | [
"def",
"adjust_for_scratch",
"(",
"self",
")",
":",
"if",
"self",
".",
"scratch",
":",
"self",
".",
"template",
"[",
"'spec'",
"]",
".",
"pop",
"(",
"'triggers'",
",",
"None",
")",
"remove_plugins",
"=",
"[",
"(",
"\"prebuild_plugins\"",
",",
"\"koji_paren... | Remove certain plugins in order to handle the "scratch build"
scenario. Scratch builds must not affect subsequent builds,
and should not be imported into Koji. | [
"Remove",
"certain",
"plugins",
"in",
"order",
"to",
"handle",
"the",
"scratch",
"build",
"scenario",
".",
"Scratch",
"builds",
"must",
"not",
"affect",
"subsequent",
"builds",
"and",
"should",
"not",
"be",
"imported",
"into",
"Koji",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L585-L622 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.adjust_for_custom_base_image | def adjust_for_custom_base_image(self):
"""
Disable plugins to handle builds depending on whether
or not this is a build from a custom base image.
"""
plugins = []
if self.is_custom_base_image():
# Plugins irrelevant to building base images.
plugin... | python | def adjust_for_custom_base_image(self):
"""
Disable plugins to handle builds depending on whether
or not this is a build from a custom base image.
"""
plugins = []
if self.is_custom_base_image():
# Plugins irrelevant to building base images.
plugin... | [
"def",
"adjust_for_custom_base_image",
"(",
"self",
")",
":",
"plugins",
"=",
"[",
"]",
"if",
"self",
".",
"is_custom_base_image",
"(",
")",
":",
"# Plugins irrelevant to building base images.",
"plugins",
".",
"append",
"(",
"(",
"\"prebuild_plugins\"",
",",
"\"pul... | Disable plugins to handle builds depending on whether
or not this is a build from a custom base image. | [
"Disable",
"plugins",
"to",
"handle",
"builds",
"depending",
"on",
"whether",
"or",
"not",
"this",
"is",
"a",
"build",
"from",
"a",
"custom",
"base",
"image",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L641-L660 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_koji | def render_koji(self):
"""
if there is yum repo specified, don't pick stuff from koji
"""
phase = 'prebuild_plugins'
plugin = 'koji'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
if self.spec.yum_repourls.value:
logger.in... | python | def render_koji(self):
"""
if there is yum repo specified, don't pick stuff from koji
"""
phase = 'prebuild_plugins'
plugin = 'koji'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
if self.spec.yum_repourls.value:
logger.in... | [
"def",
"render_koji",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'koji'",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"if",
"self",
".",
"spec",
".",
"... | if there is yum repo specified, don't pick stuff from koji | [
"if",
"there",
"is",
"yum",
"repo",
"specified",
"don",
"t",
"pick",
"stuff",
"from",
"koji"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L814-L841 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_bump_release | def render_bump_release(self):
"""
If the bump_release plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'bump_release'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
if self.spec.release.value:
logge... | python | def render_bump_release(self):
"""
If the bump_release plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'bump_release'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
if self.spec.release.value:
logge... | [
"def",
"render_bump_release",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'bump_release'",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"if",
"self",
".",
"s... | If the bump_release plugin is present, configure it | [
"If",
"the",
"bump_release",
"plugin",
"is",
"present",
"configure",
"it"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L843-L871 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_sendmail | def render_sendmail(self):
"""
if we have smtp_host and smtp_from, configure sendmail plugin,
else remove it
"""
phase = 'exit_plugins'
plugin = 'sendmail'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
if self.spec.smtp_host.... | python | def render_sendmail(self):
"""
if we have smtp_host and smtp_from, configure sendmail plugin,
else remove it
"""
phase = 'exit_plugins'
plugin = 'sendmail'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
if self.spec.smtp_host.... | [
"def",
"render_sendmail",
"(",
"self",
")",
":",
"phase",
"=",
"'exit_plugins'",
"plugin",
"=",
"'sendmail'",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"if",
"self",
".",
"spec",
".",... | if we have smtp_host and smtp_from, configure sendmail plugin,
else remove it | [
"if",
"we",
"have",
"smtp_host",
"and",
"smtp_from",
"configure",
"sendmail",
"plugin",
"else",
"remove",
"it"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L986-L1032 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_fetch_maven_artifacts | def render_fetch_maven_artifacts(self):
"""Configure fetch_maven_artifacts plugin"""
phase = 'prebuild_plugins'
plugin = 'fetch_maven_artifacts'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
koji_hub = self.spec.kojihub.value
koji_root = sel... | python | def render_fetch_maven_artifacts(self):
"""Configure fetch_maven_artifacts plugin"""
phase = 'prebuild_plugins'
plugin = 'fetch_maven_artifacts'
if not self.dj.dock_json_has_plugin_conf(phase, plugin):
return
koji_hub = self.spec.kojihub.value
koji_root = sel... | [
"def",
"render_fetch_maven_artifacts",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'fetch_maven_artifacts'",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"koji_hub... | Configure fetch_maven_artifacts plugin | [
"Configure",
"fetch_maven_artifacts",
"plugin"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1034-L1054 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_tag_from_config | def render_tag_from_config(self):
"""Configure tag_from_config plugin"""
phase = 'postbuild_plugins'
plugin = 'tag_from_config'
if not self.has_tag_suffixes_placeholder():
return
unique_tag = self.spec.image_tag.value.split(':')[-1]
tag_suffixes = {'unique': ... | python | def render_tag_from_config(self):
"""Configure tag_from_config plugin"""
phase = 'postbuild_plugins'
plugin = 'tag_from_config'
if not self.has_tag_suffixes_placeholder():
return
unique_tag = self.spec.image_tag.value.split(':')[-1]
tag_suffixes = {'unique': ... | [
"def",
"render_tag_from_config",
"(",
"self",
")",
":",
"phase",
"=",
"'postbuild_plugins'",
"plugin",
"=",
"'tag_from_config'",
"if",
"not",
"self",
".",
"has_tag_suffixes_placeholder",
"(",
")",
":",
"return",
"unique_tag",
"=",
"self",
".",
"spec",
".",
"imag... | Configure tag_from_config plugin | [
"Configure",
"tag_from_config",
"plugin"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1056-L1078 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_pulp_pull | def render_pulp_pull(self):
"""
If a pulp registry is specified, use pulp_pull plugin
"""
# pulp_pull is a multi-phase plugin
phases = ('postbuild_plugins', 'exit_plugins')
plugin = 'pulp_pull'
for phase in phases:
if not self.dj.dock_json_has_plugin_c... | python | def render_pulp_pull(self):
"""
If a pulp registry is specified, use pulp_pull plugin
"""
# pulp_pull is a multi-phase plugin
phases = ('postbuild_plugins', 'exit_plugins')
plugin = 'pulp_pull'
for phase in phases:
if not self.dj.dock_json_has_plugin_c... | [
"def",
"render_pulp_pull",
"(",
"self",
")",
":",
"# pulp_pull is a multi-phase plugin",
"phases",
"=",
"(",
"'postbuild_plugins'",
",",
"'exit_plugins'",
")",
"plugin",
"=",
"'pulp_pull'",
"for",
"phase",
"in",
"phases",
":",
"if",
"not",
"self",
".",
"dj",
"."... | If a pulp registry is specified, use pulp_pull plugin | [
"If",
"a",
"pulp",
"registry",
"is",
"specified",
"use",
"pulp_pull",
"plugin"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1080-L1105 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_pulp_sync | def render_pulp_sync(self):
"""
If a pulp registry is specified, use the pulp plugin as well as the
delete_from_registry to delete the image after sync
"""
if not self.dj.dock_json_has_plugin_conf('postbuild_plugins',
'pulp_sync'):... | python | def render_pulp_sync(self):
"""
If a pulp registry is specified, use the pulp plugin as well as the
delete_from_registry to delete the image after sync
"""
if not self.dj.dock_json_has_plugin_conf('postbuild_plugins',
'pulp_sync'):... | [
"def",
"render_pulp_sync",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"'postbuild_plugins'",
",",
"'pulp_sync'",
")",
":",
"return",
"pulp_registry",
"=",
"self",
".",
"spec",
".",
"pulp_registry",
".",
"value... | If a pulp registry is specified, use the pulp plugin as well as the
delete_from_registry to delete the image after sync | [
"If",
"a",
"pulp",
"registry",
"is",
"specified",
"use",
"the",
"pulp",
"plugin",
"as",
"well",
"as",
"the",
"delete_from_registry",
"to",
"delete",
"the",
"image",
"after",
"sync"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1134-L1213 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_pulp_tag | def render_pulp_tag(self):
"""
Configure the pulp_tag plugin.
"""
if not self.dj.dock_json_has_plugin_conf('postbuild_plugins',
'pulp_tag'):
return
pulp_registry = self.spec.pulp_registry.value
if pulp_registry... | python | def render_pulp_tag(self):
"""
Configure the pulp_tag plugin.
"""
if not self.dj.dock_json_has_plugin_conf('postbuild_plugins',
'pulp_tag'):
return
pulp_registry = self.spec.pulp_registry.value
if pulp_registry... | [
"def",
"render_pulp_tag",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"'postbuild_plugins'",
",",
"'pulp_tag'",
")",
":",
"return",
"pulp_registry",
"=",
"self",
".",
"spec",
".",
"pulp_registry",
".",
"value",... | Configure the pulp_tag plugin. | [
"Configure",
"the",
"pulp_tag",
"plugin",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1215-L1240 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_group_manifests | def render_group_manifests(self):
"""
Configure the group_manifests plugin. Group is always set to false for now.
"""
if not self.dj.dock_json_has_plugin_conf('postbuild_plugins', 'group_manifests'):
return
push_conf = self.dj.dock_json_get_plugin_conf('postbuild_plu... | python | def render_group_manifests(self):
"""
Configure the group_manifests plugin. Group is always set to false for now.
"""
if not self.dj.dock_json_has_plugin_conf('postbuild_plugins', 'group_manifests'):
return
push_conf = self.dj.dock_json_get_plugin_conf('postbuild_plu... | [
"def",
"render_group_manifests",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"dj",
".",
"dock_json_has_plugin_conf",
"(",
"'postbuild_plugins'",
",",
"'group_manifests'",
")",
":",
"return",
"push_conf",
"=",
"self",
".",
"dj",
".",
"dock_json_get_plugin_conf... | Configure the group_manifests plugin. Group is always set to false for now. | [
"Configure",
"the",
"group_manifests",
"plugin",
".",
"Group",
"is",
"always",
"set",
"to",
"false",
"for",
"now",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1269-L1301 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_import_image | def render_import_image(self, use_auth=None):
"""
Configure the import_image plugin
"""
# import_image is a multi-phase plugin
phases = ('postbuild_plugins', 'exit_plugins')
plugin = 'import_image'
for phase in phases:
if self.spec.imagestream_name.va... | python | def render_import_image(self, use_auth=None):
"""
Configure the import_image plugin
"""
# import_image is a multi-phase plugin
phases = ('postbuild_plugins', 'exit_plugins')
plugin = 'import_image'
for phase in phases:
if self.spec.imagestream_name.va... | [
"def",
"render_import_image",
"(",
"self",
",",
"use_auth",
"=",
"None",
")",
":",
"# import_image is a multi-phase plugin",
"phases",
"=",
"(",
"'postbuild_plugins'",
",",
"'exit_plugins'",
")",
"plugin",
"=",
"'import_image'",
"for",
"phase",
"in",
"phases",
":",
... | Configure the import_image plugin | [
"Configure",
"the",
"import_image",
"plugin"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1303-L1333 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_customizations | def render_customizations(self):
"""
Customize prod_inner for site specific customizations
"""
disable_plugins = self.customize_conf.get('disable_plugins', [])
if not disable_plugins:
logger.debug("No site-specific plugins to disable")
else:
for p... | python | def render_customizations(self):
"""
Customize prod_inner for site specific customizations
"""
disable_plugins = self.customize_conf.get('disable_plugins', [])
if not disable_plugins:
logger.debug("No site-specific plugins to disable")
else:
for p... | [
"def",
"render_customizations",
"(",
"self",
")",
":",
"disable_plugins",
"=",
"self",
".",
"customize_conf",
".",
"get",
"(",
"'disable_plugins'",
",",
"[",
"]",
")",
"if",
"not",
"disable_plugins",
":",
"logger",
".",
"debug",
"(",
"\"No site-specific plugins ... | Customize prod_inner for site specific customizations | [
"Customize",
"prod_inner",
"for",
"site",
"specific",
"customizations"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1375-L1420 | train |
projectatomic/osbs-client | osbs/build/build_request.py | BuildRequest.render_name | def render_name(self, name, image_tag, platform):
"""Sets the Build/BuildConfig object name"""
if self.scratch or self.isolated:
name = image_tag
# Platform name may contain characters not allowed by OpenShift.
if platform:
platform_suffix = '-{}'.for... | python | def render_name(self, name, image_tag, platform):
"""Sets the Build/BuildConfig object name"""
if self.scratch or self.isolated:
name = image_tag
# Platform name may contain characters not allowed by OpenShift.
if platform:
platform_suffix = '-{}'.for... | [
"def",
"render_name",
"(",
"self",
",",
"name",
",",
"image_tag",
",",
"platform",
")",
":",
"if",
"self",
".",
"scratch",
"or",
"self",
".",
"isolated",
":",
"name",
"=",
"image_tag",
"# Platform name may contain characters not allowed by OpenShift.",
"if",
"plat... | Sets the Build/BuildConfig object name | [
"Sets",
"the",
"Build",
"/",
"BuildConfig",
"object",
"name"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L1425-L1444 | train |
projectatomic/osbs-client | osbs/cli/capture.py | setup_json_capture | def setup_json_capture(osbs, os_conf, capture_dir):
"""
Only used for setting up the testing framework.
"""
try:
os.mkdir(capture_dir)
except OSError:
pass
finally:
osbs.os._con.request = ResponseSaver(capture_dir,
os_conf.get... | python | def setup_json_capture(osbs, os_conf, capture_dir):
"""
Only used for setting up the testing framework.
"""
try:
os.mkdir(capture_dir)
except OSError:
pass
finally:
osbs.os._con.request = ResponseSaver(capture_dir,
os_conf.get... | [
"def",
"setup_json_capture",
"(",
"osbs",
",",
"os_conf",
",",
"capture_dir",
")",
":",
"try",
":",
"os",
".",
"mkdir",
"(",
"capture_dir",
")",
"except",
"OSError",
":",
"pass",
"finally",
":",
"osbs",
".",
"os",
".",
"_con",
".",
"request",
"=",
"Res... | Only used for setting up the testing framework. | [
"Only",
"used",
"for",
"setting",
"up",
"the",
"testing",
"framework",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/capture.py#L96-L109 | train |
projectatomic/osbs-client | osbs/cli/render.py | get_terminal_size | def get_terminal_size():
"""
get size of console: rows x columns
:return: tuple, (int, int)
"""
try:
rows, columns = subprocess.check_output(['stty', 'size']).split()
except subprocess.CalledProcessError:
# not attached to terminal
logger.info("not attached to terminal")... | python | def get_terminal_size():
"""
get size of console: rows x columns
:return: tuple, (int, int)
"""
try:
rows, columns = subprocess.check_output(['stty', 'size']).split()
except subprocess.CalledProcessError:
# not attached to terminal
logger.info("not attached to terminal")... | [
"def",
"get_terminal_size",
"(",
")",
":",
"try",
":",
"rows",
",",
"columns",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'stty'",
",",
"'size'",
"]",
")",
".",
"split",
"(",
")",
"except",
"subprocess",
".",
"CalledProcessError",
":",
"# not attac... | get size of console: rows x columns
:return: tuple, (int, int) | [
"get",
"size",
"of",
"console",
":",
"rows",
"x",
"columns"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L18-L31 | train |
projectatomic/osbs-client | osbs/cli/render.py | TableFormatter._longest_val_in_column | def _longest_val_in_column(self, col):
"""
get size of longest value in specific column
:param col: str, column name
:return int
"""
try:
# +2 is for implicit separator
return max([len(x[col]) for x in self.table if x[col]]) + 2
except Key... | python | def _longest_val_in_column(self, col):
"""
get size of longest value in specific column
:param col: str, column name
:return int
"""
try:
# +2 is for implicit separator
return max([len(x[col]) for x in self.table if x[col]]) + 2
except Key... | [
"def",
"_longest_val_in_column",
"(",
"self",
",",
"col",
")",
":",
"try",
":",
"# +2 is for implicit separator",
"return",
"max",
"(",
"[",
"len",
"(",
"x",
"[",
"col",
"]",
")",
"for",
"x",
"in",
"self",
".",
"table",
"if",
"x",
"[",
"col",
"]",
"]... | get size of longest value in specific column
:param col: str, column name
:return int | [
"get",
"size",
"of",
"longest",
"value",
"in",
"specific",
"column"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L59-L71 | train |
projectatomic/osbs-client | osbs/cli/render.py | TablePrinter._init | def _init(self):
"""
initialize all values based on provided input
:return: None
"""
self.col_count = len(self.col_list)
# list of lengths of longest entries in columns
self.col_longest = self.get_all_longest_col_lengths()
self.data_length = sum(self.col_... | python | def _init(self):
"""
initialize all values based on provided input
:return: None
"""
self.col_count = len(self.col_list)
# list of lengths of longest entries in columns
self.col_longest = self.get_all_longest_col_lengths()
self.data_length = sum(self.col_... | [
"def",
"_init",
"(",
"self",
")",
":",
"self",
".",
"col_count",
"=",
"len",
"(",
"self",
".",
"col_list",
")",
"# list of lengths of longest entries in columns",
"self",
".",
"col_longest",
"=",
"self",
".",
"get_all_longest_col_lengths",
"(",
")",
"self",
".",... | initialize all values based on provided input
:return: None | [
"initialize",
"all",
"values",
"based",
"on",
"provided",
"input"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L95-L122 | train |
projectatomic/osbs-client | osbs/cli/render.py | TablePrinter._count_sizes | def _count_sizes(self):
"""
count all values needed to display whole table
<><---terminal-width-----------><>
<> HEADER | HEADER2 | HEADER3 <>
<>---------+----------+---------<>
kudos to PostgreSQL developers
:return: None
"""
format_list = [... | python | def _count_sizes(self):
"""
count all values needed to display whole table
<><---terminal-width-----------><>
<> HEADER | HEADER2 | HEADER3 <>
<>---------+----------+---------<>
kudos to PostgreSQL developers
:return: None
"""
format_list = [... | [
"def",
"_count_sizes",
"(",
"self",
")",
":",
"format_list",
"=",
"[",
"]",
"header_sepa_format_list",
"=",
"[",
"]",
"# actual widths of columns",
"self",
".",
"col_widths",
"=",
"{",
"}",
"for",
"col",
"in",
"self",
".",
"col_list",
":",
"col_length",
"=",... | count all values needed to display whole table
<><---terminal-width-----------><>
<> HEADER | HEADER2 | HEADER3 <>
<>---------+----------+---------<>
kudos to PostgreSQL developers
:return: None | [
"count",
"all",
"values",
"needed",
"to",
"display",
"whole",
"table"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L124-L157 | train |
projectatomic/osbs-client | osbs/cli/render.py | TablePrinter.get_all_longest_col_lengths | def get_all_longest_col_lengths(self):
"""
iterate over all columns and get their longest values
:return: dict, {"column_name": 132}
"""
response = {}
for col in self.col_list:
response[col] = self._longest_val_in_column(col)
return response | python | def get_all_longest_col_lengths(self):
"""
iterate over all columns and get their longest values
:return: dict, {"column_name": 132}
"""
response = {}
for col in self.col_list:
response[col] = self._longest_val_in_column(col)
return response | [
"def",
"get_all_longest_col_lengths",
"(",
"self",
")",
":",
"response",
"=",
"{",
"}",
"for",
"col",
"in",
"self",
".",
"col_list",
":",
"response",
"[",
"col",
"]",
"=",
"self",
".",
"_longest_val_in_column",
"(",
"col",
")",
"return",
"response"
] | iterate over all columns and get their longest values
:return: dict, {"column_name": 132} | [
"iterate",
"over",
"all",
"columns",
"and",
"get",
"their",
"longest",
"values"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L159-L168 | train |
projectatomic/osbs-client | osbs/cli/render.py | TablePrinter._separate | def _separate(self):
"""
get a width of separator for current column
:return: int
"""
if self.total_free_space is None:
return 0
else:
sepa = self.default_column_space
# we need to distribute remainders
if self.default_colu... | python | def _separate(self):
"""
get a width of separator for current column
:return: int
"""
if self.total_free_space is None:
return 0
else:
sepa = self.default_column_space
# we need to distribute remainders
if self.default_colu... | [
"def",
"_separate",
"(",
"self",
")",
":",
"if",
"self",
".",
"total_free_space",
"is",
"None",
":",
"return",
"0",
"else",
":",
"sepa",
"=",
"self",
".",
"default_column_space",
"# we need to distribute remainders",
"if",
"self",
".",
"default_column_space_remain... | get a width of separator for current column
:return: int | [
"get",
"a",
"width",
"of",
"separator",
"for",
"current",
"column"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L170-L186 | train |
projectatomic/osbs-client | osbs/cli/render.py | TablePrinter.render | def render(self):
"""
print provided table
:return: None
"""
print(self.format_str.format(**self.header), file=sys.stderr)
print(self.header_format_str.format(**self.header_data), file=sys.stderr)
for row in self.data:
print(self.format_str.format(**r... | python | def render(self):
"""
print provided table
:return: None
"""
print(self.format_str.format(**self.header), file=sys.stderr)
print(self.header_format_str.format(**self.header_data), file=sys.stderr)
for row in self.data:
print(self.format_str.format(**r... | [
"def",
"render",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"format_str",
".",
"format",
"(",
"*",
"*",
"self",
".",
"header",
")",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"print",
"(",
"self",
".",
"header_format_str",
".",
"format",
"... | print provided table
:return: None | [
"print",
"provided",
"table"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/render.py#L188-L197 | train |
thombashi/pytablereader | pytablereader/json/formatter.py | JsonConverter._validate_source_data | def _validate_source_data(self):
"""
:raises ValidationError:
"""
try:
jsonschema.validate(self._buffer, self._schema)
except jsonschema.ValidationError as e:
raise ValidationError(e) | python | def _validate_source_data(self):
"""
:raises ValidationError:
"""
try:
jsonschema.validate(self._buffer, self._schema)
except jsonschema.ValidationError as e:
raise ValidationError(e) | [
"def",
"_validate_source_data",
"(",
"self",
")",
":",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"self",
".",
"_buffer",
",",
"self",
".",
"_schema",
")",
"except",
"jsonschema",
".",
"ValidationError",
"as",
"e",
":",
"raise",
"ValidationError",
"(",
... | :raises ValidationError: | [
":",
"raises",
"ValidationError",
":"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L38-L46 | train |
thombashi/pytablereader | pytablereader/json/formatter.py | SingleJsonTableConverterC.to_table_data | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
self._loader.inc_table_count()
yield TableData(
self._make_table_name(),
["key", "value"],
[record ... | python | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
self._loader.inc_table_count()
yield TableData(
self._make_table_name(),
["key", "value"],
[record ... | [
"def",
"to_table_data",
"(",
"self",
")",
":",
"self",
".",
"_validate_source_data",
"(",
")",
"self",
".",
"_loader",
".",
"inc_table_count",
"(",
")",
"yield",
"TableData",
"(",
"self",
".",
"_make_table_name",
"(",
")",
",",
"[",
"\"key\"",
",",
"\"valu... | :raises ValueError:
:raises pytablereader.error.ValidationError: | [
":",
"raises",
"ValueError",
":",
":",
"raises",
"pytablereader",
".",
"error",
".",
"ValidationError",
":"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L139-L154 | train |
thombashi/pytablereader | pytablereader/json/formatter.py | MultipleJsonTableConverterA.to_table_data | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
attr_name_set = set()
for json_record in json_records:
... | python | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
attr_name_set = set()
for json_record in json_records:
... | [
"def",
"to_table_data",
"(",
"self",
")",
":",
"self",
".",
"_validate_source_data",
"(",
")",
"for",
"table_key",
",",
"json_records",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_buffer",
")",
":",
"attr_name_set",
"=",
"set",
"(",
")",
"for",
"j... | :raises ValueError:
:raises pytablereader.error.ValidationError: | [
":",
"raises",
"ValueError",
":",
":",
"raises",
"pytablereader",
".",
"error",
".",
"ValidationError",
":"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L186-L209 | train |
thombashi/pytablereader | pytablereader/json/formatter.py | MultipleJsonTableConverterB.to_table_data | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
headers = sorted(six.viewkeys(json_records))
self._loader.... | python | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
headers = sorted(six.viewkeys(json_records))
self._loader.... | [
"def",
"to_table_data",
"(",
"self",
")",
":",
"self",
".",
"_validate_source_data",
"(",
")",
"for",
"table_key",
",",
"json_records",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_buffer",
")",
":",
"headers",
"=",
"sorted",
"(",
"six",
".",
"view... | :raises ValueError:
:raises pytablereader.error.ValidationError: | [
":",
"raises",
"ValueError",
":",
":",
"raises",
"pytablereader",
".",
"error",
".",
"ValidationError",
":"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L227-L247 | train |
thombashi/pytablereader | pytablereader/json/formatter.py | MultipleJsonTableConverterC.to_table_data | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
self._loader.inc_table_count()
self._table_key = table_key
... | python | def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
for table_key, json_records in six.iteritems(self._buffer):
self._loader.inc_table_count()
self._table_key = table_key
... | [
"def",
"to_table_data",
"(",
"self",
")",
":",
"self",
".",
"_validate_source_data",
"(",
")",
"for",
"table_key",
",",
"json_records",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_buffer",
")",
":",
"self",
".",
"_loader",
".",
"inc_table_count",
"(... | :raises ValueError:
:raises pytablereader.error.ValidationError: | [
":",
"raises",
"ValueError",
":",
":",
"raises",
"pytablereader",
".",
"error",
".",
"ValidationError",
":"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/json/formatter.py#L265-L283 | train |
projectatomic/osbs-client | osbs/build/build_requestv2.py | BuildRequestV2.set_params | def set_params(self, **kwargs):
"""
set parameters in the user parameters
these parameters are accepted:
:param git_uri: str, uri of the git repository for the source
:param git_ref: str, commit ID of the branch to be pulled
:param git_branch: str, branch name of the bra... | python | def set_params(self, **kwargs):
"""
set parameters in the user parameters
these parameters are accepted:
:param git_uri: str, uri of the git repository for the source
:param git_ref: str, commit ID of the branch to be pulled
:param git_branch: str, branch name of the bra... | [
"def",
"set_params",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Here we cater to the koji \"scratch\" build type, this will disable",
"# all plugins that might cause importing of data to koji",
"self",
".",
"scratch",
"=",
"kwargs",
".",
"get",
"(",
"'scratch'",
")"... | set parameters in the user parameters
these parameters are accepted:
:param git_uri: str, uri of the git repository for the source
:param git_ref: str, commit ID of the branch to be pulled
:param git_branch: str, branch name of the branch to be pulled
:param base_image: str, nam... | [
"set",
"parameters",
"in",
"the",
"user",
"parameters"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_requestv2.py#L42-L109 | train |
projectatomic/osbs-client | osbs/build/build_requestv2.py | BuildRequestV2.set_data_from_reactor_config | def set_data_from_reactor_config(self):
"""
Sets data from reactor config
"""
reactor_config_override = self.user_params.reactor_config_override.value
reactor_config_map = self.user_params.reactor_config_map.value
data = None
if reactor_config_override:
... | python | def set_data_from_reactor_config(self):
"""
Sets data from reactor config
"""
reactor_config_override = self.user_params.reactor_config_override.value
reactor_config_map = self.user_params.reactor_config_map.value
data = None
if reactor_config_override:
... | [
"def",
"set_data_from_reactor_config",
"(",
"self",
")",
":",
"reactor_config_override",
"=",
"self",
".",
"user_params",
".",
"reactor_config_override",
".",
"value",
"reactor_config_map",
"=",
"self",
".",
"user_params",
".",
"reactor_config_map",
".",
"value",
"dat... | Sets data from reactor config | [
"Sets",
"data",
"from",
"reactor",
"config"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_requestv2.py#L166-L208 | train |
projectatomic/osbs-client | osbs/build/build_requestv2.py | BuildRequestV2._set_required_secrets | def _set_required_secrets(self, required_secrets, token_secrets):
"""
Sets required secrets
"""
if self.user_params.build_type.value == BUILD_TYPE_ORCHESTRATOR:
required_secrets += token_secrets
if not required_secrets:
return
secrets = self.temp... | python | def _set_required_secrets(self, required_secrets, token_secrets):
"""
Sets required secrets
"""
if self.user_params.build_type.value == BUILD_TYPE_ORCHESTRATOR:
required_secrets += token_secrets
if not required_secrets:
return
secrets = self.temp... | [
"def",
"_set_required_secrets",
"(",
"self",
",",
"required_secrets",
",",
"token_secrets",
")",
":",
"if",
"self",
".",
"user_params",
".",
"build_type",
".",
"value",
"==",
"BUILD_TYPE_ORCHESTRATOR",
":",
"required_secrets",
"+=",
"token_secrets",
"if",
"not",
"... | Sets required secrets | [
"Sets",
"required",
"secrets"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_requestv2.py#L210-L237 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsTemplate.remove_plugin | def remove_plugin(self, phase, name, reason=None):
"""
if config contains plugin, remove it
"""
for p in self.template[phase]:
if p.get('name') == name:
self.template[phase].remove(p)
if reason:
logger.info('Removing {}:{}, ... | python | def remove_plugin(self, phase, name, reason=None):
"""
if config contains plugin, remove it
"""
for p in self.template[phase]:
if p.get('name') == name:
self.template[phase].remove(p)
if reason:
logger.info('Removing {}:{}, ... | [
"def",
"remove_plugin",
"(",
"self",
",",
"phase",
",",
"name",
",",
"reason",
"=",
"None",
")",
":",
"for",
"p",
"in",
"self",
".",
"template",
"[",
"phase",
"]",
":",
"if",
"p",
".",
"get",
"(",
"'name'",
")",
"==",
"name",
":",
"self",
".",
... | if config contains plugin, remove it | [
"if",
"config",
"contains",
"plugin",
"remove",
"it"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L55-L64 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsTemplate.add_plugin | def add_plugin(self, phase, name, args, reason=None):
"""
if config has plugin, override it, else add it
"""
plugin_modified = False
for plugin in self.template[phase]:
if plugin['name'] == name:
plugin['args'] = args
plugin_modified =... | python | def add_plugin(self, phase, name, args, reason=None):
"""
if config has plugin, override it, else add it
"""
plugin_modified = False
for plugin in self.template[phase]:
if plugin['name'] == name:
plugin['args'] = args
plugin_modified =... | [
"def",
"add_plugin",
"(",
"self",
",",
"phase",
",",
"name",
",",
"args",
",",
"reason",
"=",
"None",
")",
":",
"plugin_modified",
"=",
"False",
"for",
"plugin",
"in",
"self",
".",
"template",
"[",
"phase",
"]",
":",
"if",
"plugin",
"[",
"'name'",
"]... | if config has plugin, override it, else add it | [
"if",
"config",
"has",
"plugin",
"override",
"it",
"else",
"add",
"it"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L66-L80 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsTemplate.get_plugin_conf | def get_plugin_conf(self, phase, name):
"""
Return the configuration for a plugin.
Raises KeyError if there are no plugins of that type.
Raises IndexError if the named plugin is not listed.
"""
match = [x for x in self.template[phase] if x.get('name') == name]
re... | python | def get_plugin_conf(self, phase, name):
"""
Return the configuration for a plugin.
Raises KeyError if there are no plugins of that type.
Raises IndexError if the named plugin is not listed.
"""
match = [x for x in self.template[phase] if x.get('name') == name]
re... | [
"def",
"get_plugin_conf",
"(",
"self",
",",
"phase",
",",
"name",
")",
":",
"match",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"template",
"[",
"phase",
"]",
"if",
"x",
".",
"get",
"(",
"'name'",
")",
"==",
"name",
"]",
"return",
"match",
"["... | Return the configuration for a plugin.
Raises KeyError if there are no plugins of that type.
Raises IndexError if the named plugin is not listed. | [
"Return",
"the",
"configuration",
"for",
"a",
"plugin",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L82-L90 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsTemplate.has_plugin_conf | def has_plugin_conf(self, phase, name):
"""
Check whether a plugin is configured.
"""
try:
self.get_plugin_conf(phase, name)
return True
except (KeyError, IndexError):
return False | python | def has_plugin_conf(self, phase, name):
"""
Check whether a plugin is configured.
"""
try:
self.get_plugin_conf(phase, name)
return True
except (KeyError, IndexError):
return False | [
"def",
"has_plugin_conf",
"(",
"self",
",",
"phase",
",",
"name",
")",
":",
"try",
":",
"self",
".",
"get_plugin_conf",
"(",
"phase",
",",
"name",
")",
"return",
"True",
"except",
"(",
"KeyError",
",",
"IndexError",
")",
":",
"return",
"False"
] | Check whether a plugin is configured. | [
"Check",
"whether",
"a",
"plugin",
"is",
"configured",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L92-L100 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.adjust_for_scratch | def adjust_for_scratch(self):
"""
Remove certain plugins in order to handle the "scratch build"
scenario. Scratch builds must not affect subsequent builds,
and should not be imported into Koji.
"""
if self.user_params.scratch.value:
remove_plugins = [
... | python | def adjust_for_scratch(self):
"""
Remove certain plugins in order to handle the "scratch build"
scenario. Scratch builds must not affect subsequent builds,
and should not be imported into Koji.
"""
if self.user_params.scratch.value:
remove_plugins = [
... | [
"def",
"adjust_for_scratch",
"(",
"self",
")",
":",
"if",
"self",
".",
"user_params",
".",
"scratch",
".",
"value",
":",
"remove_plugins",
"=",
"[",
"(",
"\"prebuild_plugins\"",
",",
"\"koji_parent\"",
")",
",",
"(",
"\"postbuild_plugins\"",
",",
"\"compress\"",... | Remove certain plugins in order to handle the "scratch build"
scenario. Scratch builds must not affect subsequent builds,
and should not be imported into Koji. | [
"Remove",
"certain",
"plugins",
"in",
"order",
"to",
"handle",
"the",
"scratch",
"build",
"scenario",
".",
"Scratch",
"builds",
"must",
"not",
"affect",
"subsequent",
"builds",
"and",
"should",
"not",
"be",
"imported",
"into",
"Koji",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L149-L173 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.adjust_for_isolated | def adjust_for_isolated(self):
"""
Remove certain plugins in order to handle the "isolated build"
scenario.
"""
if self.user_params.isolated.value:
remove_plugins = [
("prebuild_plugins", "check_and_set_rebuild"),
("prebuild_plugins", "... | python | def adjust_for_isolated(self):
"""
Remove certain plugins in order to handle the "isolated build"
scenario.
"""
if self.user_params.isolated.value:
remove_plugins = [
("prebuild_plugins", "check_and_set_rebuild"),
("prebuild_plugins", "... | [
"def",
"adjust_for_isolated",
"(",
"self",
")",
":",
"if",
"self",
".",
"user_params",
".",
"isolated",
".",
"value",
":",
"remove_plugins",
"=",
"[",
"(",
"\"prebuild_plugins\"",
",",
"\"check_and_set_rebuild\"",
")",
",",
"(",
"\"prebuild_plugins\"",
",",
"\"s... | Remove certain plugins in order to handle the "isolated build"
scenario. | [
"Remove",
"certain",
"plugins",
"in",
"order",
"to",
"handle",
"the",
"isolated",
"build",
"scenario",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L175-L187 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.adjust_for_flatpak | def adjust_for_flatpak(self):
"""
Remove plugins that don't work when building Flatpaks
"""
if self.user_params.flatpak.value:
remove_plugins = [
("prebuild_plugins", "resolve_composes"),
# We'll extract the filesystem anyways for a Flatpak ins... | python | def adjust_for_flatpak(self):
"""
Remove plugins that don't work when building Flatpaks
"""
if self.user_params.flatpak.value:
remove_plugins = [
("prebuild_plugins", "resolve_composes"),
# We'll extract the filesystem anyways for a Flatpak ins... | [
"def",
"adjust_for_flatpak",
"(",
"self",
")",
":",
"if",
"self",
".",
"user_params",
".",
"flatpak",
".",
"value",
":",
"remove_plugins",
"=",
"[",
"(",
"\"prebuild_plugins\"",
",",
"\"resolve_composes\"",
")",
",",
"# We'll extract the filesystem anyways for a Flatp... | Remove plugins that don't work when building Flatpaks | [
"Remove",
"plugins",
"that",
"don",
"t",
"work",
"when",
"building",
"Flatpaks"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L189-L210 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_customizations | def render_customizations(self):
"""
Customize template for site user specified customizations
"""
disable_plugins = self.pt.customize_conf.get('disable_plugins', [])
if not disable_plugins:
logger.debug('No site-user specified plugins to disable')
else:
... | python | def render_customizations(self):
"""
Customize template for site user specified customizations
"""
disable_plugins = self.pt.customize_conf.get('disable_plugins', [])
if not disable_plugins:
logger.debug('No site-user specified plugins to disable')
else:
... | [
"def",
"render_customizations",
"(",
"self",
")",
":",
"disable_plugins",
"=",
"self",
".",
"pt",
".",
"customize_conf",
".",
"get",
"(",
"'disable_plugins'",
",",
"[",
"]",
")",
"if",
"not",
"disable_plugins",
":",
"logger",
".",
"debug",
"(",
"'No site-use... | Customize template for site user specified customizations | [
"Customize",
"template",
"for",
"site",
"user",
"specified",
"customizations"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L239-L266 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_koji | def render_koji(self):
"""
if there is yum repo in user params, don't pick stuff from koji
"""
phase = 'prebuild_plugins'
plugin = 'koji'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.yum_repourls.value:
self.pt... | python | def render_koji(self):
"""
if there is yum repo in user params, don't pick stuff from koji
"""
phase = 'prebuild_plugins'
plugin = 'koji'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.yum_repourls.value:
self.pt... | [
"def",
"render_koji",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'koji'",
"if",
"not",
"self",
".",
"pt",
".",
"has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"if",
"self",
".",
"user_params",
".",
"yum... | if there is yum repo in user params, don't pick stuff from koji | [
"if",
"there",
"is",
"yum",
"repo",
"in",
"user",
"params",
"don",
"t",
"pick",
"stuff",
"from",
"koji"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L285-L298 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_bump_release | def render_bump_release(self):
"""
If the bump_release plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'bump_release'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.release.value:
self.pt.... | python | def render_bump_release(self):
"""
If the bump_release plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'bump_release'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.release.value:
self.pt.... | [
"def",
"render_bump_release",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'bump_release'",
"if",
"not",
"self",
".",
"pt",
".",
"has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"if",
"self",
".",
"user_params... | If the bump_release plugin is present, configure it | [
"If",
"the",
"bump_release",
"plugin",
"is",
"present",
"configure",
"it"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L300-L317 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_check_and_set_platforms | def render_check_and_set_platforms(self):
"""
If the check_and_set_platforms plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'check_and_set_platforms'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.ko... | python | def render_check_and_set_platforms(self):
"""
If the check_and_set_platforms plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'check_and_set_platforms'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.ko... | [
"def",
"render_check_and_set_platforms",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'check_and_set_platforms'",
"if",
"not",
"self",
".",
"pt",
".",
"has_plugin_conf",
"(",
"phase",
",",
"plugin",
")",
":",
"return",
"if",
"self",... | If the check_and_set_platforms plugin is present, configure it | [
"If",
"the",
"check_and_set_platforms",
"plugin",
"is",
"present",
"configure",
"it"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L319-L330 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_import_image | def render_import_image(self, use_auth=None):
"""
Configure the import_image plugin
"""
# import_image is a multi-phase plugin
if self.user_params.imagestream_name.value is None:
self.pt.remove_plugin('exit_plugins', 'import_image',
'... | python | def render_import_image(self, use_auth=None):
"""
Configure the import_image plugin
"""
# import_image is a multi-phase plugin
if self.user_params.imagestream_name.value is None:
self.pt.remove_plugin('exit_plugins', 'import_image',
'... | [
"def",
"render_import_image",
"(",
"self",
",",
"use_auth",
"=",
"None",
")",
":",
"# import_image is a multi-phase plugin",
"if",
"self",
".",
"user_params",
".",
"imagestream_name",
".",
"value",
"is",
"None",
":",
"self",
".",
"pt",
".",
"remove_plugin",
"(",... | Configure the import_image plugin | [
"Configure",
"the",
"import_image",
"plugin"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L332-L342 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_tag_from_config | def render_tag_from_config(self):
"""Configure tag_from_config plugin"""
phase = 'postbuild_plugins'
plugin = 'tag_from_config'
if not self.has_tag_suffixes_placeholder():
return
unique_tag = self.user_params.image_tag.value.split(':')[-1]
tag_suffixes = {'un... | python | def render_tag_from_config(self):
"""Configure tag_from_config plugin"""
phase = 'postbuild_plugins'
plugin = 'tag_from_config'
if not self.has_tag_suffixes_placeholder():
return
unique_tag = self.user_params.image_tag.value.split(':')[-1]
tag_suffixes = {'un... | [
"def",
"render_tag_from_config",
"(",
"self",
")",
":",
"phase",
"=",
"'postbuild_plugins'",
"plugin",
"=",
"'tag_from_config'",
"if",
"not",
"self",
".",
"has_tag_suffixes_placeholder",
"(",
")",
":",
"return",
"unique_tag",
"=",
"self",
".",
"user_params",
".",
... | Configure tag_from_config plugin | [
"Configure",
"tag_from_config",
"plugin"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L459-L483 | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | PluginsConfiguration.render_pull_base_image | def render_pull_base_image(self):
"""Configure pull_base_image"""
phase = 'prebuild_plugins'
plugin = 'pull_base_image'
if self.user_params.parent_images_digests.value:
self.pt.set_plugin_arg(phase, plugin, 'parent_images_digests',
self.use... | python | def render_pull_base_image(self):
"""Configure pull_base_image"""
phase = 'prebuild_plugins'
plugin = 'pull_base_image'
if self.user_params.parent_images_digests.value:
self.pt.set_plugin_arg(phase, plugin, 'parent_images_digests',
self.use... | [
"def",
"render_pull_base_image",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'pull_base_image'",
"if",
"self",
".",
"user_params",
".",
"parent_images_digests",
".",
"value",
":",
"self",
".",
"pt",
".",
"set_plugin_arg",
"(",
"pha... | Configure pull_base_image | [
"Configure",
"pull_base_image"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L485-L492 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.get_user | def get_user(self, username="~"):
"""
get info about user (if no user specified, use the one initiating request)
:param username: str, name of user to get info about, default="~"
:return: dict
"""
url = self._build_url("users/%s/" % username, _prepend_namespace=False)
... | python | def get_user(self, username="~"):
"""
get info about user (if no user specified, use the one initiating request)
:param username: str, name of user to get info about, default="~"
:return: dict
"""
url = self._build_url("users/%s/" % username, _prepend_namespace=False)
... | [
"def",
"get_user",
"(",
"self",
",",
"username",
"=",
"\"~\"",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"\"users/%s/\"",
"%",
"username",
",",
"_prepend_namespace",
"=",
"False",
")",
"response",
"=",
"self",
".",
"_get",
"(",
"url",
")",
... | get info about user (if no user specified, use the one initiating request)
:param username: str, name of user to get info about, default="~"
:return: dict | [
"get",
"info",
"about",
"user",
"(",
"if",
"no",
"user",
"specified",
"use",
"the",
"one",
"initiating",
"request",
")"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L233-L243 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.create_build | def create_build(self, build_json):
"""
:return:
"""
url = self._build_url("builds/")
logger.debug(build_json)
return self._post(url, data=json.dumps(build_json),
headers={"Content-Type": "application/json"}) | python | def create_build(self, build_json):
"""
:return:
"""
url = self._build_url("builds/")
logger.debug(build_json)
return self._post(url, data=json.dumps(build_json),
headers={"Content-Type": "application/json"}) | [
"def",
"create_build",
"(",
"self",
",",
"build_json",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"\"builds/\"",
")",
"logger",
".",
"debug",
"(",
"build_json",
")",
"return",
"self",
".",
"_post",
"(",
"url",
",",
"data",
"=",
"json",
".",
... | :return: | [
":",
"return",
":"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L296-L303 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.get_all_build_configs_by_labels | def get_all_build_configs_by_labels(self, label_selectors):
"""
Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results.
"""
labels = ['%s=%s' % (field, value) for field, value in label_selectors]
labels = ','.joi... | python | def get_all_build_configs_by_labels(self, label_selectors):
"""
Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results.
"""
labels = ['%s=%s' % (field, value) for field, value in label_selectors]
labels = ','.joi... | [
"def",
"get_all_build_configs_by_labels",
"(",
"self",
",",
"label_selectors",
")",
":",
"labels",
"=",
"[",
"'%s=%s'",
"%",
"(",
"field",
",",
"value",
")",
"for",
"field",
",",
"value",
"in",
"label_selectors",
"]",
"labels",
"=",
"','",
".",
"join",
"("... | Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results. | [
"Returns",
"all",
"builds",
"matching",
"a",
"given",
"set",
"of",
"label",
"selectors",
".",
"It",
"is",
"up",
"to",
"the",
"calling",
"function",
"to",
"filter",
"the",
"results",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L326-L334 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.get_build_config_by_labels | def get_build_config_by_labels(self, label_selectors):
"""
Returns a build config matching the given label
selectors. This method will raise OsbsException
if not exactly one build config is found.
"""
items = self.get_all_build_configs_by_labels(label_selectors)
... | python | def get_build_config_by_labels(self, label_selectors):
"""
Returns a build config matching the given label
selectors. This method will raise OsbsException
if not exactly one build config is found.
"""
items = self.get_all_build_configs_by_labels(label_selectors)
... | [
"def",
"get_build_config_by_labels",
"(",
"self",
",",
"label_selectors",
")",
":",
"items",
"=",
"self",
".",
"get_all_build_configs_by_labels",
"(",
"label_selectors",
")",
"if",
"not",
"items",
":",
"raise",
"OsbsException",
"(",
"\"Build config not found for labels:... | Returns a build config matching the given label
selectors. This method will raise OsbsException
if not exactly one build config is found. | [
"Returns",
"a",
"build",
"config",
"matching",
"the",
"given",
"label",
"selectors",
".",
"This",
"method",
"will",
"raise",
"OsbsException",
"if",
"not",
"exactly",
"one",
"build",
"config",
"is",
"found",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L336-L353 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.get_build_config_by_labels_filtered | def get_build_config_by_labels_filtered(self, label_selectors, filter_key, filter_value):
"""
Returns a build config matching the given label selectors, filtering against
another predetermined value. This method will raise OsbsException
if not exactly one build config is found after filt... | python | def get_build_config_by_labels_filtered(self, label_selectors, filter_key, filter_value):
"""
Returns a build config matching the given label selectors, filtering against
another predetermined value. This method will raise OsbsException
if not exactly one build config is found after filt... | [
"def",
"get_build_config_by_labels_filtered",
"(",
"self",
",",
"label_selectors",
",",
"filter_key",
",",
"filter_value",
")",
":",
"items",
"=",
"self",
".",
"get_all_build_configs_by_labels",
"(",
"label_selectors",
")",
"if",
"filter_value",
"is",
"not",
"None",
... | Returns a build config matching the given label selectors, filtering against
another predetermined value. This method will raise OsbsException
if not exactly one build config is found after filtering. | [
"Returns",
"a",
"build",
"config",
"matching",
"the",
"given",
"label",
"selectors",
"filtering",
"against",
"another",
"predetermined",
"value",
".",
"This",
"method",
"will",
"raise",
"OsbsException",
"if",
"not",
"exactly",
"one",
"build",
"config",
"is",
"fo... | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L355-L379 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.create_build_config | def create_build_config(self, build_config_json):
"""
:return:
"""
url = self._build_url("buildconfigs/")
return self._post(url, data=build_config_json,
headers={"Content-Type": "application/json"}) | python | def create_build_config(self, build_config_json):
"""
:return:
"""
url = self._build_url("buildconfigs/")
return self._post(url, data=build_config_json,
headers={"Content-Type": "application/json"}) | [
"def",
"create_build_config",
"(",
"self",
",",
"build_config_json",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"\"buildconfigs/\"",
")",
"return",
"self",
".",
"_post",
"(",
"url",
",",
"data",
"=",
"build_config_json",
",",
"headers",
"=",
"{",
... | :return: | [
":",
"return",
":"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L381-L387 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.stream_logs | def stream_logs(self, build_id):
"""
stream logs from build
:param build_id: str
:return: iterator
"""
kwargs = {'follow': 1}
# If connection is closed within this many seconds, give up:
min_idle_timeout = 60
# Stream logs, but be careful of the... | python | def stream_logs(self, build_id):
"""
stream logs from build
:param build_id: str
:return: iterator
"""
kwargs = {'follow': 1}
# If connection is closed within this many seconds, give up:
min_idle_timeout = 60
# Stream logs, but be careful of the... | [
"def",
"stream_logs",
"(",
"self",
",",
"build_id",
")",
":",
"kwargs",
"=",
"{",
"'follow'",
":",
"1",
"}",
"# If connection is closed within this many seconds, give up:",
"min_idle_timeout",
"=",
"60",
"# Stream logs, but be careful of the connection closing",
"# due to idl... | stream logs from build
:param build_id: str
:return: iterator | [
"stream",
"logs",
"from",
"build"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L434-L483 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.logs | def logs(self, build_id, follow=False, build_json=None, wait_if_missing=False):
"""
provide logs from build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param build_json: dict, to save one get-build query
:param wait_if_missing: bool, if build does... | python | def logs(self, build_id, follow=False, build_json=None, wait_if_missing=False):
"""
provide logs from build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param build_json: dict, to save one get-build query
:param wait_if_missing: bool, if build does... | [
"def",
"logs",
"(",
"self",
",",
"build_id",
",",
"follow",
"=",
"False",
",",
"build_json",
"=",
"None",
",",
"wait_if_missing",
"=",
"False",
")",
":",
"# does build exist?",
"try",
":",
"build_json",
"=",
"build_json",
"or",
"self",
".",
"get_build",
"(... | provide logs from build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param build_json: dict, to save one get-build query
:param wait_if_missing: bool, if build doesn't exist, wait
:return: None, str or iterator | [
"provide",
"logs",
"from",
"build"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L485-L520 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.list_builds | def list_builds(self, build_config_id=None, koji_task_id=None,
field_selector=None, labels=None):
"""
List builds matching criteria
:param build_config_id: str, only list builds created from BuildConfig
:param koji_task_id: str, only list builds for Koji Task ID
... | python | def list_builds(self, build_config_id=None, koji_task_id=None,
field_selector=None, labels=None):
"""
List builds matching criteria
:param build_config_id: str, only list builds created from BuildConfig
:param koji_task_id: str, only list builds for Koji Task ID
... | [
"def",
"list_builds",
"(",
"self",
",",
"build_config_id",
"=",
"None",
",",
"koji_task_id",
"=",
"None",
",",
"field_selector",
"=",
"None",
",",
"labels",
"=",
"None",
")",
":",
"query",
"=",
"{",
"}",
"selector",
"=",
"'{key}={value}'",
"label",
"=",
... | List builds matching criteria
:param build_config_id: str, only list builds created from BuildConfig
:param koji_task_id: str, only list builds for Koji Task ID
:param field_selector: str, field selector for query
:return: HttpResponse | [
"List",
"builds",
"matching",
"criteria"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L522-L553 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.create_resource_quota | def create_resource_quota(self, name, quota_json):
"""
Prevent builds being scheduled and wait for running builds to finish.
:return:
"""
url = self._build_k8s_url("resourcequotas/")
response = self._post(url, data=json.dumps(quota_json),
h... | python | def create_resource_quota(self, name, quota_json):
"""
Prevent builds being scheduled and wait for running builds to finish.
:return:
"""
url = self._build_k8s_url("resourcequotas/")
response = self._post(url, data=json.dumps(quota_json),
h... | [
"def",
"create_resource_quota",
"(",
"self",
",",
"name",
",",
"quota_json",
")",
":",
"url",
"=",
"self",
".",
"_build_k8s_url",
"(",
"\"resourcequotas/\"",
")",
"response",
"=",
"self",
".",
"_post",
"(",
"url",
",",
"data",
"=",
"json",
".",
"dumps",
... | Prevent builds being scheduled and wait for running builds to finish.
:return: | [
"Prevent",
"builds",
"being",
"scheduled",
"and",
"wait",
"for",
"running",
"builds",
"to",
"finish",
"."
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L577-L593 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.wait | def wait(self, build_id, states):
"""
:param build_id: wait for build to finish
:return:
"""
logger.info("watching build '%s'", build_id)
for changetype, obj in self.watch_resource("builds", build_id):
try:
obj_name = obj["metadata"]["name"]
... | python | def wait(self, build_id, states):
"""
:param build_id: wait for build to finish
:return:
"""
logger.info("watching build '%s'", build_id)
for changetype, obj in self.watch_resource("builds", build_id):
try:
obj_name = obj["metadata"]["name"]
... | [
"def",
"wait",
"(",
"self",
",",
"build_id",
",",
"states",
")",
":",
"logger",
".",
"info",
"(",
"\"watching build '%s'\"",
",",
"build_id",
")",
"for",
"changetype",
",",
"obj",
"in",
"self",
".",
"watch_resource",
"(",
"\"builds\"",
",",
"build_id",
")"... | :param build_id: wait for build to finish
:return: | [
":",
"param",
"build_id",
":",
"wait",
"for",
"build",
"to",
"finish"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L654-L694 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.adjust_attributes_on_object | def adjust_attributes_on_object(self, collection, name, things, values, how):
"""
adjust labels or annotations on object
labels have to match RE: (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? and
have at most 63 chars
:param collection: str, object collection e.g. 'builds'
... | python | def adjust_attributes_on_object(self, collection, name, things, values, how):
"""
adjust labels or annotations on object
labels have to match RE: (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? and
have at most 63 chars
:param collection: str, object collection e.g. 'builds'
... | [
"def",
"adjust_attributes_on_object",
"(",
"self",
",",
"collection",
",",
"name",
",",
"things",
",",
"values",
",",
"how",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"\"%s/%s\"",
"%",
"(",
"collection",
",",
"name",
")",
")",
"response",
"="... | adjust labels or annotations on object
labels have to match RE: (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? and
have at most 63 chars
:param collection: str, object collection e.g. 'builds'
:param name: str, name of object
:param things: str, 'labels' or 'annotations'
:... | [
"adjust",
"labels",
"or",
"annotations",
"on",
"object"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L727-L749 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.update_annotations_on_build | def update_annotations_on_build(self, build_id, annotations):
"""
set annotations on build object
:param build_id: str, id of build
:param annotations: dict, annotations to set
:return:
"""
return self.adjust_attributes_on_object('builds', build_id,
... | python | def update_annotations_on_build(self, build_id, annotations):
"""
set annotations on build object
:param build_id: str, id of build
:param annotations: dict, annotations to set
:return:
"""
return self.adjust_attributes_on_object('builds', build_id,
... | [
"def",
"update_annotations_on_build",
"(",
"self",
",",
"build_id",
",",
"annotations",
")",
":",
"return",
"self",
".",
"adjust_attributes_on_object",
"(",
"'builds'",
",",
"build_id",
",",
"'annotations'",
",",
"annotations",
",",
"self",
".",
"_update_metadata_th... | set annotations on build object
:param build_id: str, id of build
:param annotations: dict, annotations to set
:return: | [
"set",
"annotations",
"on",
"build",
"object"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L771-L781 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.import_image | def import_image(self, name, stream_import, tags=None):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name).json()
logger... | python | def import_image(self, name, stream_import, tags=None):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name).json()
logger... | [
"def",
"import_image",
"(",
"self",
",",
"name",
",",
"stream_import",
",",
"tags",
"=",
"None",
")",
":",
"# Get the JSON for the ImageStream",
"imagestream_json",
"=",
"self",
".",
"get_image_stream",
"(",
"name",
")",
".",
"json",
"(",
")",
"logger",
".",
... | Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported | [
"Import",
"image",
"tags",
"from",
"a",
"Docker",
"registry",
"into",
"an",
"ImageStream"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L872-L922 | train |
projectatomic/osbs-client | osbs/core.py | Openshift.import_image_tags | def import_image_tags(self, name, stream_import, tags, repository, insecure):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name)... | python | def import_image_tags(self, name, stream_import, tags, repository, insecure):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name)... | [
"def",
"import_image_tags",
"(",
"self",
",",
"name",
",",
"stream_import",
",",
"tags",
",",
"repository",
",",
"insecure",
")",
":",
"# Get the JSON for the ImageStream",
"imagestream_json",
"=",
"self",
".",
"get_image_stream",
"(",
"name",
")",
".",
"json",
... | Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported | [
"Import",
"image",
"tags",
"from",
"a",
"Docker",
"registry",
"into",
"an",
"ImageStream"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L926-L986 | train |
projectatomic/osbs-client | osbs/cli/main.py | str_on_2_unicode_on_3 | def str_on_2_unicode_on_3(s):
"""
argparse is way too awesome when doing repr() on choices when printing usage
:param s: str or unicode
:return: str on 2, unicode on 3
"""
if not PY3:
return str(s)
else: # 3+
if not isinstance(s, str):
return str(s, encoding="u... | python | def str_on_2_unicode_on_3(s):
"""
argparse is way too awesome when doing repr() on choices when printing usage
:param s: str or unicode
:return: str on 2, unicode on 3
"""
if not PY3:
return str(s)
else: # 3+
if not isinstance(s, str):
return str(s, encoding="u... | [
"def",
"str_on_2_unicode_on_3",
"(",
"s",
")",
":",
"if",
"not",
"PY3",
":",
"return",
"str",
"(",
"s",
")",
"else",
":",
"# 3+",
"if",
"not",
"isinstance",
"(",
"s",
",",
"str",
")",
":",
"return",
"str",
"(",
"s",
",",
"encoding",
"=",
"\"utf-8\"... | argparse is way too awesome when doing repr() on choices when printing usage
:param s: str or unicode
:return: str on 2, unicode on 3 | [
"argparse",
"is",
"way",
"too",
"awesome",
"when",
"doing",
"repr",
"()",
"on",
"choices",
"when",
"printing",
"usage"
] | 571fe035dab3a7c02e1dccd5d65ffd75be750458 | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/cli/main.py#L534-L547 | train |
thombashi/pytablereader | pytablereader/jsonlines/core.py | JsonLinesTableFileLoader.load | def load(self):
"""
Extract tabular data as |TableData| instances from a Line-delimited JSON file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
:rtype: |TableData| iterator
:raises pytablereader.DataError:
... | python | def load(self):
"""
Extract tabular data as |TableData| instances from a Line-delimited JSON file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
:rtype: |TableData| iterator
:raises pytablereader.DataError:
... | [
"def",
"load",
"(",
"self",
")",
":",
"formatter",
"=",
"JsonLinesTableFormatter",
"(",
"self",
".",
"load_dict",
"(",
")",
")",
"formatter",
".",
"accept",
"(",
"self",
")",
"return",
"formatter",
".",
"to_table_data",
"(",
")"
] | Extract tabular data as |TableData| instances from a Line-delimited JSON file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
:rtype: |TableData| iterator
:raises pytablereader.DataError:
If the data is invalid Li... | [
"Extract",
"tabular",
"data",
"as",
"|TableData|",
"instances",
"from",
"a",
"Line",
"-",
"delimited",
"JSON",
"file",
".",
"|load_source_desc_file|"
] | bc3c057a2cc775bcce690e0e9019c2907b638101 | https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/jsonlines/core.py#L75-L94 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.