Add __slots__ to internal parser types
Dynamic properties are not used by these types, so using __slots__ is slightly more efficient. Public inherited properties are also included.
This commit is contained in:
parent
21ea715dd1
commit
50625cdc27
|
@ -18,6 +18,8 @@ def convert_to_enum(value):
|
||||||
return enum[split[1]]
|
return enum[split[1]]
|
||||||
|
|
||||||
class BlacklistAction(argparse.Action):
|
class BlacklistAction(argparse.Action):
|
||||||
|
__slots__ = '_nargs', 'option_strings', 'dest', 'nargs', 'const', 'default', 'type', 'choices', 'required', 'help', 'metavar'
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
nargs = kwargs.get('nargs')
|
nargs = kwargs.get('nargs')
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,8 @@ from argparse import ArgumentParser
|
||||||
|
|
||||||
class BoneMarketArgumentParser(ArgumentParser):
|
class BoneMarketArgumentParser(ArgumentParser):
|
||||||
"""An ArgumentParser with the ability to read files with any number of space-delimited arguments on a line."""
|
"""An ArgumentParser with the ability to read files with any number of space-delimited arguments on a line."""
|
||||||
|
|
||||||
|
__slots__ = 'description', 'argument_default', 'prefix_chars', 'conflict_handler', 'prog', 'usage', 'epilog', 'formatter_class', 'fromfile_prefix_chars', 'add_help', 'allow_abbrev', 'exit_on_error'
|
||||||
|
|
||||||
def convert_arg_line_to_args(self, arg_line):
|
def convert_arg_line_to_args(self, arg_line):
|
||||||
return arg_line.split()
|
return arg_line.split()
|
||||||
|
|
|
@ -4,6 +4,8 @@ __author__ = "Jeremy Saklad"
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
class EnumAction(argparse.Action):
|
class EnumAction(argparse.Action):
|
||||||
|
__slots__ = '_enum', '_nargs', 'option_strings', 'dest', 'nargs', 'const', 'default', 'type', 'choices', 'required', 'help', 'metavar'
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
# Pop off the type value
|
# Pop off the type value
|
||||||
enum = kwargs.pop('type', None)
|
enum = kwargs.pop('type', None)
|
||||||
|
|
|
@ -15,6 +15,8 @@ from ..data.torsos import Torso
|
||||||
class ListAction(argparse.Action):
|
class ListAction(argparse.Action):
|
||||||
"""Lists enumerations referenced by provided strings then exits"""
|
"""Lists enumerations referenced by provided strings then exits"""
|
||||||
|
|
||||||
|
__slots__ = '_nargs', '_default', 'option_strings', 'dest', 'nargs', 'const', 'default', 'type', 'choices', 'required', 'help', 'metavar'
|
||||||
|
|
||||||
list_options = [enum.__name__.lower() for enum in [
|
list_options = [enum.__name__.lower() for enum in [
|
||||||
Torso,
|
Torso,
|
||||||
Skull,
|
Skull,
|
||||||
|
|
Loading…
Reference in New Issue