MCPcopy
hub / github.com/benoitc/gunicorn / add_option

Method add_option

gunicorn/config.py:301–329  ·  view source on GitHub ↗
(self, parser)

Source from the content-addressed store, hash-verified

299 self.set(self.default)
300
301 def add_option(self, parser):
302 if not self.cli:
303 return
304 args = tuple(self.cli)
305
306 help_txt = "%s [%s]" % (self.short, self.default)
307 help_txt = help_txt.replace("%", "%%")
308
309 kwargs = {
310 "dest": self.name,
311 "action": self.action or "store",
312 "type": self.type or str,
313 "default": None,
314 "help": help_txt
315 }
316
317 if self.meta is not None:
318 kwargs['metavar'] = self.meta
319
320 if kwargs["action"] != "store":
321 kwargs.pop("type")
322
323 if self.nargs is not None:
324 kwargs["nargs"] = self.nargs
325
326 if self.const is not None:
327 kwargs["const"] = self.const
328
329 parser.add_argument(*args, **kwargs)
330
331 def copy(self):
332 return copy.copy(self)

Callers 1

parserMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected