Skip to content

Commit

Permalink
Clean-up python API (#5521)
Browse files Browse the repository at this point in the history
* Simplified imports

* If the python command is missing, provide a default value

* Update WbLanguageTools.cpp

* Update WbLanguageTools.cpp
  • Loading branch information
omichel authored Nov 21, 2022
1 parent fb7251d commit 72eb950
Show file tree
Hide file tree
Showing 37 changed files with 116 additions and 110 deletions.
4 changes: 2 additions & 2 deletions lib/controller/python/controller/accelerometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
import ctypes
import typing

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/altimeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
import ctypes
import typing

Expand Down
2 changes: 1 addition & 1 deletion lib/controller/python/controller/ansi_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.constants import constant
from .constants import constant


class AnsiCodes:
Expand Down
10 changes: 5 additions & 5 deletions lib/controller/python/controller/brake.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.constants import constant
from controller.device import Device
from controller.wb import wb
from .constants import constant
from .device import Device
from .wb import wb
from typing import Union


Expand All @@ -42,13 +42,13 @@ def getPositionSensor(self):

@property
def motor(self):
from controller.motor import Motor
from .motor import Motor
tag = wb.wb_brake_get_motor(self._tag)
return None if tag == 0 else Motor(tag)

@property
def position_sensor(self):
from controller.position_sensor import PositionSensor
from .position_sensor import PositionSensor
tag = wb.wb_brake_get_position_sensor(self._tag)
return None if tag == 0 else PositionSensor(tag)

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import ctypes
from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
from typing import List, Union


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
import ctypes
import typing

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from controller.device import Device
from .wb import wb
from .device import Device
from typing import Union


Expand Down
2 changes: 1 addition & 1 deletion lib/controller/python/controller/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from .wb import wb


def constant(name, type=int):
Expand Down
2 changes: 1 addition & 1 deletion lib/controller/python/controller/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from .wb import wb
import ctypes
from typing import Union

Expand Down
6 changes: 3 additions & 3 deletions lib/controller/python/controller/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from controller.camera import Camera
from controller.device import Device
from .wb import wb
from .camera import Camera
from .device import Device
from typing import Union, List


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/distance_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from controller.sensor import Sensor
from .wb import wb
from .sensor import Sensor
from typing import Union, List


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import struct
import sys
from controller.wb import wb
from controller.device import Device
from .wb import wb
from .device import Device
import ctypes
from typing import Union, List

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from controller.constants import constant
from .wb import wb
from .constants import constant
import struct
import typing

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
import ctypes
import typing

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/gyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
import ctypes
import typing

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/inertial_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
import ctypes
import typing

Expand Down
2 changes: 1 addition & 1 deletion lib/controller/python/controller/joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from .wb import wb
import ctypes
from typing import Union

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from controller.constants import constant
from .wb import wb
from .constants import constant
from typing import Union


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from controller.device import Device
from .wb import wb
from .device import Device
from typing import Union


Expand Down
6 changes: 3 additions & 3 deletions lib/controller/python/controller/lidar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.sensor import Sensor
from controller.lidar_point import LidarPoint
from controller.wb import wb
from .sensor import Sensor
from .lidar_point import LidarPoint
from .wb import wb
from typing import List, Union


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/light_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from controller.sensor import Sensor
from .wb import wb
from .sensor import Sensor
from typing import Union, List


Expand Down
2 changes: 1 addition & 1 deletion lib/controller/python/controller/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from .wb import wb


class Motion:
Expand Down
10 changes: 5 additions & 5 deletions lib/controller/python/controller/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.constants import constant
from controller.device import Device
from controller.wb import wb
from .constants import constant
from .device import Device
from .wb import wb
from typing import Union


Expand Down Expand Up @@ -132,13 +132,13 @@ def getPositionSensor(self):

@property
def brake(self):
from controller.brake import Brake
from .brake import Brake
tag = wb.wb_motor_get_brake(self._tag)
return None if tag == 0 else Brake(tag)

@property
def position_sensor(self):
from controller.position_sensor import PositionSensor
from .position_sensor import PositionSensor
tag = wb.wb_motor_get_position_sensor(self._tag)
return None if tag == 0 else PositionSensor(tag)

Expand Down
2 changes: 1 addition & 1 deletion lib/controller/python/controller/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from .wb import wb
import ctypes
import struct
from typing import Union
Expand Down
6 changes: 3 additions & 3 deletions lib/controller/python/controller/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.wb import wb
from controller.constants import constant
from controller import Field
from .wb import wb
from .constants import constant
from .field import Field
import struct
import typing

Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from controller.wb import wb
from controller.device import Device
from .wb import wb
from .device import Device
import ctypes
from typing import Union

Expand Down
10 changes: 5 additions & 5 deletions lib/controller/python/controller/position_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.constants import constant
from controller.wb import wb
from controller.sensor import Sensor
from .constants import constant
from .wb import wb
from .sensor import Sensor
from typing import Union


Expand Down Expand Up @@ -44,13 +44,13 @@ def getType(self) -> int:

@property
def brake(self):
from controller.brake import Brake
from .brake import Brake
tag = wb.wb_position_sensor_get_brake(self._tag)
return None if tag == 0 else Brake(tag)

@property
def motor(self):
from controller.motor import Motor
from .motor import Motor
tag = wb.wb_brake_get_motor(self._tag)
return None if tag == 0 else Motor(tag)

Expand Down
6 changes: 3 additions & 3 deletions lib/controller/python/controller/radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import ctypes
from controller.sensor import Sensor
from controller.radar_target import RadarTarget
from controller.wb import wb
from .sensor import Sensor
from .radar_target import RadarTarget
from .wb import wb
from typing import List, Union


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/range_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import ctypes
from controller.sensor import Sensor
from controller.wb import wb
from .sensor import Sensor
from .wb import wb
from typing import List, Union


Expand Down
4 changes: 2 additions & 2 deletions lib/controller/python/controller/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import ctypes
import struct
import sys
from controller.wb import wb
from controller.sensor import Sensor
from .wb import wb
from .sensor import Sensor
from typing import Union, Tuple, List


Expand Down
Loading

0 comments on commit 72eb950

Please sign in to comment.