@@ -34,50 +34,57 @@ def list(keywords=None, dof=None, mtype=None):
3434 # module = importlib.import_module(
3535 # '.' + os.path.splitext(file)[0], package='bdsim.blocks')
3636
37- table = ANSITable (
38- Column ("class" , headalign = "^" , colalign = "<" ),
39- Column ("model" , headalign = "^" , colalign = "<" ),
40- Column ("manufacturer" , headalign = "^" , colalign = "<" ),
41- Column ("model type" , headalign = "^" , colalign = "<" ),
42- Column ("DoF" , colalign = "<" ),
43- Column ("config" , colalign = "<" ),
44- Column ("keywords" , headalign = "^" , colalign = "<" ),
45- border = "thin"
46- )
47-
48- if mtype is not None :
49- categories = [mtype ]
50- else :
51- categories = ['DH' , 'URDF' , 'ETS' ]
52- for category in categories :
53- group = m .__dict__ [category ]
54- for cls in group .__dict__ .values ():
55- if isinstance (cls , type ) and issubclass (cls , Robot ):
56- # we found a Robot subclass, instantiate it
57- robot = cls ()
58- try :
59- config = robot .config ()
60- except Exception : # pragma nocover
61- config = ""
62-
63- # apply filters
64- if keywords is not None :
65- if len (set (keywords ) & set (robot .keywords )) == 0 :
66- continue
67- if dof is not None and robot .n != dof :
68- continue # pragma nocover
69-
70- # add the row
71- table .row (
72- cls .__name__ ,
73- robot .name ,
74- robot .manufacturer ,
75- category ,
76- robot .n ,
77- config ,
78- ', ' .join (robot .keywords )
79- )
80- print (str (table ).encode ('utf8' , errors = 'replace' ).decode ('utf8' ))
37+ def make_table (border ):
38+ table = ANSITable (
39+ Column ("class" , headalign = "^" , colalign = "<" ),
40+ Column ("model" , headalign = "^" , colalign = "<" ),
41+ Column ("manufacturer" , headalign = "^" , colalign = "<" ),
42+ Column ("model type" , headalign = "^" , colalign = "<" ),
43+ Column ("DoF" , colalign = "<" ),
44+ Column ("config" , colalign = "<" ),
45+ Column ("keywords" , headalign = "^" , colalign = "<" ),
46+ border = border
47+ )
48+
49+ if mtype is not None :
50+ categories = [mtype ]
51+ else :
52+ categories = ['DH' , 'URDF' , 'ETS' ]
53+ for category in categories :
54+ group = m .__dict__ [category ]
55+ for cls in group .__dict__ .values ():
56+ if isinstance (cls , type ) and issubclass (cls , Robot ):
57+ # we found a Robot subclass, instantiate it
58+ robot = cls ()
59+ try :
60+ config = robot .config ()
61+ except Exception : # pragma nocover
62+ config = ""
63+
64+ # apply filters
65+ if keywords is not None :
66+ if len (set (keywords ) & set (robot .keywords )) == 0 :
67+ continue
68+ if dof is not None and robot .n != dof :
69+ continue # pragma nocover
70+
71+ # add the row
72+ table .row (
73+ cls .__name__ ,
74+ robot .name ,
75+ robot .manufacturer ,
76+ category ,
77+ robot .n ,
78+ config ,
79+ ', ' .join (robot .keywords )
80+ )
81+
82+ print (str (table ))
83+
84+ try :
85+ make_table ('thin' )
86+ except UnicodeEncodeError :
87+ make_table ('ascii' )
8188
8289
8390if __name__ == "__main__" : # pragma nocover
0 commit comments