2 # Copyright 2008 Google Inc. All Rights Reserved.
5 If you need to change the default behavior of some atest commands, you
6 can create a site_<topic>.py file to subclass some of the classes from
9 The following example would prevent the creation of platform labels.
12 import inspect
, new
, sys
14 from autotest_lib
.cli
import topic_common
, label
17 class site_label(label
.label
):
21 class site_label_create(label
.label_create
):
22 """Disable the platform option
23 atest label create <labels>|--blist <file>"""
25 super(site_label_create
, self
).__init
__()
26 self
.parser
.remove_option("--platform")
30 (options
, leftover
) = super(site_label_create
, self
).parse()
31 self
.is_platform
= False
32 return (options
, leftover
)
35 # The following boiler plate code should be added at the end to create
36 # all the other site_<topic>_<action> classes that do not modify their
37 # <topic>_<action> super class.
39 # Any classes we don't override in label should be copied automatically
40 for cls
in [getattr(label
, n
) for n
in dir(label
) if not n
.startswith("_")]:
41 if not inspect
.isclass(cls
):
43 cls_name
= cls
.__name
__
44 site_cls_name
= 'site_' + cls_name
45 if hasattr(sys
.modules
[__name__
], site_cls_name
):
47 bases
= (site_label
, cls
)
48 members
= {'__doc__': cls
.__doc
__}
49 site_cls
= new
.classobj(site_cls_name
, bases
, members
)
50 setattr(sys
.modules
[__name__
], site_cls_name
, site_cls
)