Skip to content
Snippets Groups Projects
Commit 45cf50d4 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Add client option; Add break-down by lighting condition

parent 4a550a66
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,7 @@ class Database(DatabaseBase): ...@@ -61,6 +61,7 @@ class Database(DatabaseBase):
'protocol': args.replay_protocol, 'protocol': args.replay_protocol,
'support' : args.replay_support, 'support' : args.replay_support,
'light' : args.replay_light, 'light' : args.replay_light,
'clients' : args.replay_client if args.replay_client else None,
} }
__init__.__doc__ = DatabaseBase.__init__.__doc__ __init__.__doc__ = DatabaseBase.__init__.__doc__
...@@ -87,6 +88,9 @@ class Database(DatabaseBase): ...@@ -87,6 +88,9 @@ class Database(DatabaseBase):
lights = ReplayFileModel.light_choices lights = ReplayFileModel.light_choices
p.add_argument('--light', type=str, choices=lights, dest='replay_light', help="Types of illumination conditions (if unset, the default, use all)") p.add_argument('--light', type=str, choices=lights, dest='replay_light', help="Types of illumination conditions (if unset, the default, use all)")
identities = [k.id for k in self.__db.clients()]
p.add_argument('--client', type=int, action='append', choices=identities, dest='replay_client', help="Client identifier (if unset, the default, use all)")
p.set_defaults(name=entry_point_name) p.set_defaults(name=entry_point_name)
p.set_defaults(cls=Database) p.set_defaults(cls=Database)
...@@ -146,7 +150,7 @@ class Database(DatabaseBase): ...@@ -146,7 +150,7 @@ class Database(DatabaseBase):
get_test_data.__doc__ = DatabaseBase.get_test_data.__doc__ get_test_data.__doc__ = DatabaseBase.get_test_data.__doc__
def get_test_filters(self): def get_test_filters(self):
return ('device', 'support') return ('device', 'support', 'light')
def get_filtered_test_data(self, filter): def get_filtered_test_data(self, filter):
...@@ -156,6 +160,9 @@ class Database(DatabaseBase): ...@@ -156,6 +160,9 @@ class Database(DatabaseBase):
def support_filter(obj, filter): def support_filter(obj, filter):
return obj.make_path().find(filter) != -1 return obj.make_path().find(filter) != -1
def light_filter(obj, filter):
return obj.make_path().find(filter) != -1
real, attack = self.get_test_data() real, attack = self.get_test_data()
if filter == 'device': if filter == 'device':
...@@ -169,6 +176,11 @@ class Database(DatabaseBase): ...@@ -169,6 +176,11 @@ class Database(DatabaseBase):
'hand': (real, [k for k in attack if support_filter(k, 'hand')]), 'hand': (real, [k for k in attack if support_filter(k, 'hand')]),
'fixed': (real, [k for k in attack if support_filter(k, 'fixed')]), 'fixed': (real, [k for k in attack if support_filter(k, 'fixed')]),
} }
elif filter == 'light':
return {
'controlled': (real, [k for k in attack if light_filter(k, 'controlled')]),
'adverse': (real, [k for k in attack if light_filter(k, 'adverse')]),
}
raise RuntimeError, \ raise RuntimeError, \
"filter parameter should specify a valid filter among `%s'" % \ "filter parameter should specify a valid filter among `%s'" % \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment