MCPcopy Create free account
hub / github.com/celery/celery / parse

Method parse

celery/apps/multi.py:317–353  ·  view source on GitHub ↗
(self, p)

Source from the content-addressed store, hash-verified

315 self.range_prefix = range_prefix
316
317 def parse(self, p):
318 names = p.values
319 options = dict(p.options)
320 ranges = len(names) == 1
321 prefix = self.prefix
322 cmd = options.pop('--cmd', self.cmd)
323 append = options.pop('--append', self.append)
324 hostname = options.pop('--hostname', options.pop('-n', gethostname()))
325 prefix = options.pop('--prefix', prefix) or ''
326 suffix = options.pop('--suffix', self.suffix) or hostname
327 suffix = '' if suffix in ('""', "''") else suffix
328 range_prefix = options.pop('--range-prefix', '') or self.range_prefix
329 if ranges:
330 try:
331 names, prefix = self._get_ranges(names), range_prefix
332 except ValueError:
333 # The single argument isn't a node count, so it's a plain
334 # node name and dashes in it are not range separators.
335 ranges = False
336 if ranges:
337 # In range mode the node names *are* the indexes, so the mapping
338 # pass is an identity. Keep it first regardless: reordering would
339 # make out-of-range members of ``-c:1-5`` raise instead of being
340 # ignored, which is a behaviour change for the count form.
341 self._update_ns_opts(p, names)
342 self._update_ns_ranges(p, ranges)
343 else:
344 # Split lists such as ``-c:1,2`` first, so the indexes they
345 # contain are mapped to node names just like ``-c:1`` is.
346 self._update_ns_ranges(p, ranges)
347 self._update_ns_opts(p, names)
348
349 return (
350 self._node_from_options(
351 p, name, prefix, suffix, cmd, append, options)
352 for name in names
353 )
354
355 def _node_from_options(self, p, name, prefix,
356 suffix, cmd, append, options):

Calls 5

_get_rangesMethod · 0.95
_update_ns_optsMethod · 0.95
_update_ns_rangesMethod · 0.95
_node_from_optionsMethod · 0.95
popMethod · 0.45