Skip to content

Commit

Permalink
[Python 3] Format
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Oct 29, 2019
1 parent df0aeb6 commit 43f299d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
8 changes: 3 additions & 5 deletions src/dynamic_graph/ros/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from ros_publish import RosPublish
from ros_subscribe import RosSubscribe

# aliases, for retro compatibility
# flake8: noqa
from ros import RosPublish as RosImport
from ros import RosSubscribe as RosExport


from ros_publish import RosPublish
from ros_subscribe import RosSubscribe
32 changes: 12 additions & 20 deletions src/dynamic_graph/ros/dgcompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,36 @@
"""

import __builtin__
import __main__
import ast

__all__ = ["DGCompleter"]


class DGCompleter:
def __init__(self, client):
"""Create a new completer for the command line.
Completer([client]) -> completer instance.
Client is a ROS proxy to dynamic_graph run_command service.
Completer instances should be used as the completion mechanism of
readline via the set_completer() call:
readline.set_completer(Completer(client).complete)
"""
self.client=client
astr="import readline"
self.client = client
astr = "import readline"
self.client(astr)
astr="from rlcompleter import Completer"
astr = "from rlcompleter import Completer"
self.client(astr)
astr="aCompleter=Completer()"
astr = "aCompleter=Completer()"
self.client(astr)
astr="readline.set_completer(aCompleter.complete)"
astr = "readline.set_completer(aCompleter.complete)"
self.client(astr)
astr="readline.parse_and_bind(\"tab: complete\")"
astr = "readline.parse_and_bind(\"tab: complete\")"
self.client(astr)

def complete(self, text, state):
"""Return the next possible completion for 'text'. readline.parse_and_bind("tab: complete")
Expand All @@ -74,14 +73,7 @@ def complete(self, text, state):
returns None. The completion should begin with 'text'.
"""
astr="aCompleter.complete(\""+text+"\","+str(state)+")"
response=self.client(astr);
res2=ast.literal_eval(response.result)
astr = "aCompleter.complete(\"" + text + "\"," + str(state) + ")"
response = self.client(astr)
res2 = ast.literal_eval(response.result)
return res2







12 changes: 5 additions & 7 deletions src/dynamic_graph/ros/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from ros_subscribe import RosSubscribe
from ros_time import RosTime

from dynamic_graph import plug

class Ros(object):
device = None
Expand All @@ -13,15 +12,14 @@ class Ros(object):
rosImport = None
rosExport = None

def __init__(self, robot, suffix = ''):
def __init__(self, robot, suffix=''):
self.robot = robot
self.rosPublish = RosPublish('rosPublish{0}'.format(suffix))
self.rosSubscribe = RosSubscribe('rosSubscribe{0}'.format(suffix))
self.rosTime = RosTime ('rosTime{0}'.format(suffix))
self.rosTime = RosTime('rosTime{0}'.format(suffix))

self.robot.device.after.addSignal(
'{0}.trigger'.format(self.rosPublish.name))
self.robot.device.after.addSignal('{0}.trigger'.format(self.rosPublish.name))

# aliases, for retro compatibility
self.rosImport=self.rosPublish
self.rosExport=self.rosSubscribe
self.rosImport = self.rosPublish
self.rosExport = self.rosSubscribe
18 changes: 15 additions & 3 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

from dynamic_graph.ros import RosImport

Expand All @@ -9,7 +9,19 @@
ri.add('matrix', 'matrixS', 'matrixT')

ri.doubleS.value = 42.
ri.vectorS.value = (42., 42.,)
ri.matrixS.value = ((42., 42.,),(42., 42.,),)
ri.vectorS.value = (
42.,
42.,
)
ri.matrixS.value = (
(
42.,
42.,
),
(
42.,
42.,
),
)

ri.trigger.recompute(ri.trigger.time + 1)

0 comments on commit 43f299d

Please sign in to comment.