fix list method
@@ -34,7 +34,7 @@ def list(keywords=None, dof=None, mtype=None):
# module = importlib.import_module(
# '.' + os.path.splitext(file)[0], package='bdsim.blocks')
- try:
+ def make_table(border):
table = ANSITable(
Column("class", headalign="^", colalign="<"),
Column("model", headalign="^", colalign="<"),
@@ -45,17 +45,6 @@ def list(keywords=None, dof=None, mtype=None):
Column("keywords", headalign="^", colalign="<"),
border="thin"
)
- except UnicodeEncodeError:
- table = ANSITable(
- Column("class", headalign="^", colalign="<"),
- Column("model", headalign="^", colalign="<"),
- Column("manufacturer", headalign="^", colalign="<"),
- Column("model type", headalign="^", colalign="<"),
- Column("DoF", colalign="<"),
- Column("config", colalign="<"),
- Column("keywords", headalign="^", colalign="<"),
- border="ascii"
- )
if mtype is not None:
categories = [mtype]
@@ -89,8 +78,14 @@ def list(keywords=None, dof=None, mtype=None):
config,
', '.join(robot.keywords)
)
+
print(str(table).encode('utf8', errors='replace').decode('utf8'))
+ try:
+ make_table('thin')
+ except UnicodeEncodeError:
+ make_table('ascii')
+
if __name__ == "__main__": # pragma nocover
list()
