Best Python code snippet using avocado_python
ninja_syntax.py
Source:ninja_syntax.py
...27 if depfile:28 self.variable('depfile', depfile, indent=1)29 def build(self, outputs, rule, inputs=None, implicit=None, order_only=None,30 variables=None):31 outputs = self._as_list(outputs)32 all_inputs = self._as_list(inputs)[:]33 if implicit:34 all_inputs.append('|')35 all_inputs.extend(self._as_list(implicit))36 if order_only:37 all_inputs.append('||')38 all_inputs.extend(self._as_list(order_only))39 self._line('build %s: %s %s' % (' '.join(outputs),40 rule,41 ' '.join(all_inputs)))42 if variables:43 for key, val in variables:44 self.variable(key, val, indent=1)45 return outputs46 def include(self, path):47 self._line('include %s' % path)48 def subninja(self, path):49 self._line('subninja %s' % path)50 def _line(self, text, indent=0):51 """Write 'text' word-wrapped at self.width characters."""52 leading_space = ' ' * indent53 while len(text) > self.width:54 # The text is too wide; wrap if possible.55 # Find the rightmost space that would obey our width constraint.56 available_space = self.width - len(leading_space) - len(' $')57 space = text.rfind(' ', 0, available_space)58 if space < 0:59 # No such space; just use the first space we can find.60 space = text.find(' ', available_space)61 if space < 0:62 # Give up on breaking.63 break64 self.output.write(leading_space + text[0:space] + ' $\n')65 text = text[space+1:]66 # Subsequent lines are continuations, so indent them.67 leading_space = ' ' * (indent+2)68 self.output.write(leading_space + text + '\n')69 def _as_list(self, input):70 if input is None:71 return []72 if isinstance(input, list):73 return input74 return [input]75def escape(string):76 """Escape a string such that it can be embedded into a Ninja file without77 further interpretation."""78 assert '\n' not in string, 'Ninja syntax does not allow newlines'79 # We only have one special metacharacter: '$'....
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!