text
stringlengths 0
828
|
|---|
list(six.itervalues(self._out_edges)) +
|
list(six.itervalues(self._in_edges))
|
)"
|
1109,"def find_by_typename(self, typename):
|
""""""
|
List of all objects whose type has the given name.
|
""""""
|
return self.find_by(lambda obj: type(obj).__name__ == typename)"
|
1110,"def set_input(self, key, value):
|
"""""" Sets the <key> to <value> """"""
|
if key not in self._inputs:
|
raise InputException(""Key {0} is not a valid input!"".format(key))
|
self._inputs[key].value = value"
|
1111,"def get_input(self, key, force=False):
|
"""""" Get the value of <key> if it already exists, or prompt for it if not """"""
|
if key not in self._inputs:
|
raise InputException(""Key {0} is not a valid input!"".format(key))
|
if self._inputs[key].prompt:
|
prompt = self._inputs[key].prompt
|
elif self._inputs[key].is_bool():
|
prompt = ""{0}?"".format(key)
|
else:
|
prompt = ""please enter your {0}"".format(key)
|
help_text = self._inputs[key].help if hasattr(self._inputs[key], 'help') else None
|
if self._inputs[key].value is EMPTY or force:
|
default_value = None
|
if self._inputs[key].default is not EMPTY:
|
default_value = self._inputs[key].default
|
if self._inputs[key].value is not EMPTY:
|
default_value = self._inputs[key].value
|
input_value = EMPTY
|
while input_value is EMPTY or input_value == '?':
|
if input_value == '?' and help_text:
|
print(help_text)
|
input_value = lib.prompt(
|
prompt,
|
default=default_value,
|
bool_type=self._inputs[key].in_type,
|
secret=self._inputs[key].is_secret)
|
self._inputs[key].value = input_value
|
return self._inputs[key].value"
|
1112,"def get_unset_inputs(self):
|
"""""" Return a set of unset inputs """"""
|
return set([k for k, v in self._inputs.items() if v.is_empty(False)])"
|
1113,"def prompt_unset_inputs(self, force=False):
|
"""""" Prompt for unset input values """"""
|
for k, v in self._inputs.items():
|
if force or v.is_empty(False):
|
self.get_input(k, force=force)"
|
1114,"def values(self, with_defaults=True):
|
"""""" Return the values dictionary, defaulting to default values """"""
|
return dict(((k, str(v)) for k, v in self._inputs.items() if not v.is_empty(with_defaults)))"
|
1115,"def write_values(self):
|
"""""" Return the dictionary with which to write values """"""
|
return dict(((k, v.value) for k, v in self._inputs.items() if not v.is_secret and not v.is_empty(False)))"
|
1116,"def add_inputs_from_inputstring(self, input_string):
|
""""""
|
Add inputs using the input string format:
|
gitroot==~/workspace
|
username
|
password?
|
main_branch==comp_main
|
""""""
|
raw_params = input_string.split('\n')
|
param_attributes = (self._parse_param_line(rp) for rp in raw_params if len(rp.strip(' \t')) > 0)
|
for param, attributes in param_attributes:
|
self.add_input(param, attributes)"
|
1117,"def _parse_param_line(self, line):
|
"""""" Parse a single param line. """"""
|
value = line.strip('\n \t')
|
if len(value) > 0:
|
i = Input()
|
if value.find('#') != -1:
|
value, extra_attributes = value.split('#')
|
try:
|
extra_attributes = eval(extra_attributes)
|
except SyntaxError:
|
raise InputException(""Incorrectly formatted input for {0}!"".format(value))
|
if not isinstance(extra_attributes, dict):
|
raise InputException(""Incorrectly formatted input for {0}!"".format(value))
|
if 'prompt' in extra_attributes:
|
i.prompt = extra_attributes['prompt']
|
if 'help' in extra_attributes:
|
i.help = extra_attributes['help']
|
if 'type' in extra_attributes:
|
i.in_type = extra_attributes['type']
|
if i.in_type.find('/') != -1:
|
i.in_type, i.out_type = i.in_type.split('/')
|
if 'cast' in extra_attributes:
|
i.out_type = extra_attributes['cast']
|
if value.find('==') != -1:
|
value, default = value.split('==')
|
i.default = default
|
if value.endswith('?'):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.