text stringlengths 0 828 |
|---|
errors should either be reported via self._log_error(), or raise an exception |
"""""" |
if self.target: |
for k in self.target.keys(): |
if k in self.deprecated_options: |
self.logger.warn( |
self.deprecated_options[k].format(option=k, feature=self.feature_name)) |
elif (k not in self.valid_options and k not in self.required_options and |
'*' not in self.valid_options): |
self.logger.warn(""Unused option %s in %s!"" % (k, self.feature_name)) |
for k in self.required_options: |
if not self.target.has(k): |
self._log_error( |
""Required option %s not present in feature %s!"" % (k, self.feature_name))" |
291,"def should_run(self): |
"""""" Returns true if the feature should run """""" |
should_run = True |
config = self.target or self.source |
if config.has('systems'): |
should_run = False |
valid_systems = [s.lower() for s in config.get('systems').split("","")] |
for system_type, param in [('is_osx', 'osx'), |
('is_debian', 'debian')]: |
if param in valid_systems and getattr(system, system_type)(): |
should_run = True |
return should_run" |
292,"def resolve(self): |
"""""" Resolve differences between the target and the source configuration """""" |
if self.source and self.target: |
for key in self.source.keys(): |
if (key not in self.dont_carry_over_options |
and not self.target.has(key)): |
self.target.set(key, self.source.get(key))" |
293,"def _log_error(self, message): |
"""""" Log an error for the feature """""" |
key = (self.feature_name, self.target.get('formula')) |
self.environment.log_feature_error(key, ""ERROR: "" + message)" |
294,"def _prompt_value(self, key, prompt_string, default=None, only_if_empty=True): |
""""""prompts the user for a value, and saves it to either the target or |
source manifest (whichever is appropriate for the phase) |
this method takes will default to the original value passed by |
the user in the case one exists. e.g. if a user already |
answered 'yes' to a question, it will use 'yes' as the default |
vs the one passed into this method. |
"""""" |
main_manifest = self.target or self.source |
if only_if_empty and main_manifest.has(key): |
return main_manifest.get(key) |
prompt_default = default |
if self.source and self.source.has(key): |
prompt_default = self.source.get(key) |
main_manifest.set(key, |
lib.prompt(prompt_string, |
default=prompt_default))" |
295,"def jinja_fragment_extension(tag, endtag=None, name=None, tag_only=False, allow_args=True, callblock_args=None): |
""""""Decorator to easily create a jinja extension which acts as a fragment. |
"""""" |
if endtag is None: |
endtag = ""end"" + tag |
def decorator(f): |
def parse(self, parser): |
lineno = parser.stream.next().lineno |
args = [] |
kwargs = [] |
if allow_args: |
args, kwargs = parse_block_signature(parser) |
call = self.call_method(""support_method"", args, kwargs, lineno=lineno) |
if tag_only: |
return nodes.Output([call], lineno=lineno) |
call_args = [] |
if callblock_args is not None: |
for arg in callblock_args: |
call_args.append(nodes.Name(arg, 'param', lineno=lineno)) |
body = parser.parse_statements(['name:' + endtag], drop_needle=True) |
return nodes.CallBlock(call, call_args, [], body, lineno=lineno) |
def support_method(self, *args, **kwargs): |
return f(*args, **kwargs) |
attrs = {""tags"": set([tag]), ""parse"": parse, ""support_method"": support_method} |
return type(name or f.__name__, (Extension,), attrs) |
return decorator" |
296,"def jinja_block_as_fragment_extension(name, tagname=None, classname=None): |
""""""Creates a fragment extension which will just act as a replacement of the |
block statement. |
"""""" |
if tagname is None: |
tagname = name |
if classname is None: |
classname = ""%sBlockFragmentExtension"" % name.capitalize() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.