Lines Matching +full:- +full:- +full:port
4 # Use of this source code is governed by a BSD-style license that can be
25 class Port(object): class
26 """Class for port definition in ini file.
30 index: an integer for port index.
31 definition: a string for the content after "=" in port definition line.
36 """Parses a port definition line in ini file and init a Port object.
39 line: A string possibly containing port definition line like
43 A Port object if input is a valid port definition line. Returns
44 None if input is not a valid port definition line.
52 return Port(io, index, definition)
57 """Initializes a port.
59 Initializes a port with io, index and definition. The definition will be
65 index: an integer for port index.
66 definition: a string for the content after "=" in port definition line.
78 """Returns a port definition line which is used in ini file."""
87 """Updates index of this port.
96 """Class for non-port definition in ini file.
99 name: A string representing the non-port name.
100 definition: A string representing the non-port definition.
104 """Parses a non-port definition line in ini file and init a NonPort object.
107 line: A string possibly containing non-port definition line like
111 A NonPort object if input is a valid non-port definition line. Returns
112 None if input is not a valid non-port definition line.
127 name: A string representing the non-port name.
128 definition: A string representing the non-port definition.
174 A Port or NonPort object if input line matches the format. Returns None
175 if input line does not match the format of Port nor NonPort.
179 parse_port = Port.ParsePortLine(line)
196 line: A line to be added to this section. If it matches port or non-port
197 format, a Port or NonPort will be added to this section. Otherwise,
203 if isinstance(to_add, Port):
218 def AppendPort(self, port): argument
219 """Appends a Port to ports.
222 port: A Port object to be appended. The port should be appended
223 in the order of index, so the index of port should equal to the current
227 SectionException if the index of port is not the current size of ports
230 if not port.index == len(self.ports):
232 'The port with index %r can not be appended to the end of ports'
233 ' of size' % (port.index, len(self.ports)))
235 self.ports.append(port)
240 Inserts a line containing port or non-port definition to this section.
241 If input line matches Port or NonPort format, the corresponding insert
249 SectionException if input line does not match the format of Port or
255 'The line %s does not match Port or NonPort syntax' % line)
256 if isinstance(to_insert, Port):
266 Currently there is no ordering for non-port definition. This method just
274 def InsertPort(self, port): argument
275 """Inserts a Port to ports list.
277 The index of port should not be greater than the current size of ports.
278 After insertion, the index of each port in ports should be updated to the
279 new index of that port in the ports list.
281 self.ports=[Port("input", 0, "foo0"),
282 Port("input", 1, "foo1"),
283 Port("output", 2, "foo2")]
284 Now we insert a Port with index 1 by invoking
285 InsertPort(Port("output, 1, "bar")),
287 self.ports=[Port("input", 0, "foo0"),
288 Port("output, 1, "bar"),
289 Port("input", 2, "foo1"),
290 Port("output", 3, "foo2")].
292 new port was inserted at index 1.
295 port: A Port object.
298 SectionException: If the port to be inserted does not have a valid index.
300 if port.index > len(self.ports):
301 raise SectionException('Inserting port index %d but'
302 ' currently there are only %d ports' % (port.index,
305 self.ports.insert(port.index, port)
309 """Updates the index property of each Port in ports.
311 Updates the index property of each Port in ports so the new index property
312 is the index of that Port in ports list.
314 for index, port in enumerate(self.ports):
315 port._UpdateIndex(index)
335 for port in self.ports:
336 output.write('%s\n' % port.FormatLine())
395 if index < len(self.section_names) - 1:
499 parser.add_argument('--input_file', '-i', default=None,
503 parser.add_argument('--config_dirs', '-c',
504 default='~/trunk/src/third_party/adhd/cras-config',
506 '~/trunk/src/third_party/adhd/cras-config.')
507 parser.add_argument('--board', '-b', default=None, nargs='*',
510 'Use --board <board_1> <board_2> to specify more '
512 parser.add_argument('--section', '-s', default=None,
514 parser.add_argument('--insert', '-n', default=None,
516 'Must be used with --section.')
517 parser.add_argument('--output-suffix', '-o', default='.new',
519 'want to apply the changes in-place.')
555 raise IniEditorException('--insert must be used with --section')
598 prompts and waits for user to confirm editing in-place.
614 'Writing output file in-place at %s ? [y/n]' % ini.file_path)