Skip to content

Commit 57e8d29

Browse files
committed
format with autopep8 (default line length)
1 parent ee3e03f commit 57e8d29

29 files changed

Lines changed: 516 additions & 304 deletions

atest/robotMBT tests/03__parse_model_info/MyProcessor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ def process_test_suite(self, in_suite):
77
for scenario in in_suite.scenarios:
88
assert scenario.steps, msg
99
for step in scenario.steps:
10-
assert step.model_info['IN'] == ['Alfa'], f"{msg} in step {step.keyword}"
11-
assert step.model_info['OUT'] == ['Beta', 'Gamma delta', 'Epsilon'], f"{msg} in step {step.keyword}"
10+
assert step.model_info['IN'] == [
11+
'Alfa'], f"{msg} in step {step.keyword}"
12+
assert step.model_info['OUT'] == [
13+
'Beta', 'Gamma delta', 'Epsilon'], f"{msg} in step {step.keyword}"
1214
return in_suite
1315

1416
def _fail_on_step_errors(self):
1517
if self.in_suite.has_error():
1618
msg = "\n".join(["Error(s) detected in at least one step"] +
1719
[f"{step.kw_wo_gherkin} FAILED: {step.model_info['error']}"
18-
for step in self.in_suite.steps_with_errors()])
20+
for step in self.in_suite.steps_with_errors()])
1921
raise Exception(msg)

atest/robotMBT tests/07__processor_options/option_handling/suiterepeater.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
from robot.api.deco import library
44

5+
56
@library(auto_keywords=None, listener=True)
67
class SuiteRepeater:
78
"""
89
Given a test suite, repeats all scenarios 'repeat' times (default=1)
910
Setting bonus_scenario=${True} repeats 1 additional time
1011
sub-suites are ignored
1112
"""
13+
1214
def process_test_suite(self, in_suite, repeat=1, **kwargs):
1315
n_repeats = int(repeat)
1416
if kwargs.get('bonus_scenario', False):
15-
n_repeats +=1
17+
n_repeats += 1
1618
out_suite = copy.deepcopy(in_suite)
1719
out_suite.scenarios = n_repeats*out_suite.scenarios
1820
for i in range(len(out_suite.scenarios)):

atest/robotMBT tests/07__processor_options/random_seeds/01__generating_random_traces/traces.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from robot.api.deco import keyword
22

3+
34
class traces:
45
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
6+
57
def reset_traces(self):
68
self.traces = {}
79

810
@keyword("Trace '${trace}', scenario number ${test_id} is executed")
9-
def add_test(self, trace, test_id:str):
11+
def add_test(self, trace, test_id: str):
1012
"""*model info*
1113
:IN: None
1214
:OUT: None

demo/Titanic/domain_lib/JourneyLib.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from simulation.titanic_in_ocean import TitanicInOcean
1111
from simulation.journey import Journey
1212

13+
1314
class JourneyLib:
1415
_journey = None
1516

@@ -31,11 +32,13 @@ def map_lib(self) -> MapLib:
3132
def start_journey(self, date: str):
3233
date = datetime.strptime(date, "%Y-%m-%d")
3334
self.journey.start_date = date
34-
self.builtin.log(f"The journey has started at {self.journey.start_date.strftime('%Y-%m-%d')}")
35+
self.builtin.log(
36+
f"The journey has started at {self.journey.start_date.strftime('%Y-%m-%d')}")
3537

3638
@keyword("Current date of Journey")
3739
def journey_ondate(self):
38-
current_date = self.journey.start_date + timedelta(minutes=self.journey.time_in_journey)
40+
current_date = self.journey.start_date + \
41+
timedelta(minutes=self.journey.time_in_journey)
3942
return current_date.strftime('%Y-%m-%d')
4043

4144
@keyword("play out Journey for a duration of ${minutes} minutes")
@@ -46,21 +49,26 @@ def pass_time(self, minutes: int):
4649
"""
4750
self.journey.passed_time(minutes)
4851
if self.call_count % 100 == 0:
49-
map_animation.update_floating_objects(self.journey.ocean.floating_objects)
52+
map_animation.update_floating_objects(
53+
self.journey.ocean.floating_objects)
5054
self.call_count += 1
5155

5256
@keyword("Move Titanic out of current area")
5357
def move_titanic_out_of_current_area(self):
5458
titanic = TitanicInOcean.instance
55-
current_area = self.builtin.run_keyword("Area of location Titanic's position")
59+
current_area = self.builtin.run_keyword(
60+
"Area of location Titanic's position")
5661
self.builtin.log(f"Titanic moving out of {current_area}")
5762
while (new_area := self.map_lib.get_area_of_location(titanic)) == current_area:
5863
if not titanic.speed > 0:
59-
self.builtin.log(f"Titanic not moving. Still in area {new_area}")
64+
self.builtin.log(
65+
f"Titanic not moving. Still in area {new_area}")
6066
break
6167
self.pass_time(1)
6268
if titanic.fell_off_the_earth():
63-
raise Exception("Titanic at least did not sink. But where did it go?")
69+
raise Exception(
70+
"Titanic at least did not sink. But where did it go?")
6471
else:
6572
self.builtin.log(f"Titanic moved into {new_area}")
66-
map_animation.update_floating_objects(self.journey.ocean.floating_objects)
73+
map_animation.update_floating_objects(
74+
self.journey.ocean.floating_objects)

demo/Titanic/domain_lib/MapLib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def __init__(self):
3030
'Iceberg alley': AreaOnGrid(LocationOnGrid(latitude=43, longitude=-45), LocationOnGrid(latitude=48, longitude=-50))
3131
}
3232

33-
atlantic_area = AreaOnGrid(LocationOnGrid(latitude=35, longitude=-1.41), LocationOnGrid(latitude=65, longitude=-74))
33+
atlantic_area = AreaOnGrid(LocationOnGrid(
34+
latitude=35, longitude=-1.41), LocationOnGrid(latitude=65, longitude=-74))
3435

3536
LOCATION_AREA_THRESHOLD = 0.1
3637
ATLANTIC_AREA = 'Atlantic'

demo/Titanic/domain_lib/TitanicLib.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def point_titanic_towards(self, location):
2424
if titanic.sunk:
2525
self.builtin.log(f"Pointing towards Davy Jones' locker")
2626
return
27-
port_location = self.builtin.run_keyword(f"Location of port {location}")
27+
port_location = self.builtin.run_keyword(
28+
f"Location of port {location}")
2829
new_direction = titanic.calculate_direction(port_location)
2930

3031
titanic.direction = new_direction
@@ -34,7 +35,8 @@ def point_titanic_towards(self, location):
3435
def titanic_stops(self):
3536
titanic = TitanicInOcean.instance
3637
titanic.titanic.throttle = 0
37-
titanic.speed = 0 # TODO should happen over time (due to throttle being > 0)
38+
# TODO should happen over time (due to throttle being > 0)
39+
titanic.speed = 0
3840
self.builtin.log("Now it is time for Titanic to stop at new location")
3941

4042
@keyword("Titanic moves full speed ahead")
@@ -44,13 +46,16 @@ def titanic_full_speed(self):
4446
self.builtin.log(f"There seems to be an issue with the throttle")
4547
return
4648
titanic.titanic.throttle = 1
47-
titanic.speed = 700 # TODO Figure out what this speed means. Does time calculation make sense?!?!
48-
self.builtin.log(f"Here we go through the new location with speed {titanic.speed}")
49+
# TODO Figure out what this speed means. Does time calculation make sense?!?!
50+
titanic.speed = 700
51+
self.builtin.log(
52+
f"Here we go through the new location with speed {titanic.speed}")
4953

5054
@keyword("Titanic's position")
5155
def titanic_location(self):
5256
titanic = TitanicInOcean.instance
53-
loc = LocationOnGrid(longitude=titanic.longitude, latitude=titanic.latitude)
57+
loc = LocationOnGrid(longitude=titanic.longitude,
58+
latitude=titanic.latitude)
5459
self.builtin.log(f"Titanic's current position is: {loc}")
5560
return loc
5661

demo/Titanic/run_demo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
1717
OUTPUT_ROOT = os.path.join(THIS_DIR, 'results')
1818
SCENARIO_FOLDER = os.path.join(THIS_DIR, 'Titanic_scenarios')
19-
HIT_MISS_TAG = 'hit' if len(sys.argv) == 1 or sys.argv[1].casefold() != 'hit' else 'miss'
20-
EXTENDED_TAG = 'extended' if len(sys.argv) == 1 or sys.argv[1].casefold() != 'extended' else 'dummy'
19+
HIT_MISS_TAG = 'hit' if len(
20+
sys.argv) == 1 or sys.argv[1].casefold() != 'hit' else 'miss'
21+
EXTENDED_TAG = 'extended' if len(
22+
sys.argv) == 1 or sys.argv[1].casefold() != 'extended' else 'dummy'
2123

2224
# The base folder needs to be added to the python path to resolve the dependencies. You
2325
# will also need to add this path to your IDE options when running from there.
@@ -27,4 +29,4 @@
2729
'--exclude', EXTENDED_TAG,
2830
'--loglevel', 'DEBUG:INFO',
2931
SCENARIO_FOLDER],
30-
exit=False)
32+
exit=False)

demo/Titanic/run_game.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
'Iceberg alley': AreaOnGrid(LocationOnGrid(latitude=43, longitude=-45), LocationOnGrid(latitude=48, longitude=-50))
2323
}
2424

25-
atlantic_area = AreaOnGrid(LocationOnGrid(latitude=35, longitude=-1.41), LocationOnGrid(latitude=65, longitude=-74))
25+
atlantic_area = AreaOnGrid(LocationOnGrid(
26+
latitude=35, longitude=-1.41), LocationOnGrid(latitude=65, longitude=-74))
27+
2628

2729
def run_game(map_animation, journey, tio: TitanicInOcean, atlantic_area):
2830

@@ -35,7 +37,8 @@ def main_game_loop(stdscr):
3537
# Set up the window
3638
stdscr.nodelay(True) # Non-blocking input
3739
stdscr.timeout(100) # Refresh every 100 milliseconds
38-
stdscr.addstr(0, 0, "Q=Quit. 0=Stop Titanic. WASD-controls (WS control speed, AD control rotation, no need to press and hold)")
40+
stdscr.addstr(
41+
0, 0, "Q=Quit. 0=Stop Titanic. WASD-controls (WS control speed, AD control rotation, no need to press and hold)")
3942

4043
objective = 1
4144
iceberg_alley_reached = False
@@ -44,7 +47,8 @@ def main_game_loop(stdscr):
4447
while True:
4548
journey.passed_time(100)
4649

47-
map_animation.update_floating_objects(journey.ocean.floating_objects)
50+
map_animation.update_floating_objects(
51+
journey.ocean.floating_objects)
4852

4953
if not atlantic_area.is_location_within_area(tio):
5054
tio.direction -= 180
@@ -55,15 +59,19 @@ def main_game_loop(stdscr):
5559
if areas['Iceberg alley'].is_location_within_area(tio):
5660
iceberg_alley_reached = True
5761
elif iceberg_alley_reached:
58-
stdscr.addstr(objective, 0, "Objective 1: Safely cross Iceberg Alley [Achieved]")
62+
stdscr.addstr(
63+
objective, 0, "Objective 1: Safely cross Iceberg Alley [Achieved]")
5964
objective = 2
60-
stdscr.addstr(objective, 0, "Objective 2: Sail to New York")
65+
stdscr.addstr(
66+
objective, 0, "Objective 2: Sail to New York")
6167
elif objective == 2:
6268
if tio.distance_to(locations['New York']) < 0.5:
6369
tio.speed = 0
64-
stdscr.addstr(objective, 0, "Objective 2: Sail to New York [Achieved]")
70+
stdscr.addstr(
71+
objective, 0, "Objective 2: Sail to New York [Achieved]")
6572
objective = 4
66-
stdscr.addstr(objective, 0, "You made it to New York!! Press Q to exit.")
73+
stdscr.addstr(
74+
objective, 0, "You made it to New York!! Press Q to exit.")
6775

6876
if tio.sunk:
6977
stdscr.addstr(objective+2, 0,
@@ -97,7 +105,6 @@ def main_game_loop(stdscr):
97105

98106
# Continue with the rest of the game logic
99107

100-
101108
# Initialize curses
102109
stdscr = curses.initscr()
103110
curses.noecho() # Disable automatic echoing of pressed keys
@@ -127,7 +134,8 @@ def main_game_loop(stdscr):
127134
location = locations["Southampton"]
128135

129136
t = Titanic(0, steering_direction=0)
130-
tio = TitanicInOcean(t, longitude=location.longitude - 1, latitude=location.latitude, speed=0, direction=270)
137+
tio = TitanicInOcean(t, longitude=location.longitude - 1,
138+
latitude=location.latitude, speed=0, direction=270)
131139
ocean.floating_objects.append(tio)
132140

133141
iceberg = Iceberg(latitude=45.5, longitude=-47.5)
@@ -138,4 +146,3 @@ def main_game_loop(stdscr):
138146
map_animation.update_floating_objects(ocean.floating_objects)
139147

140148
run_game(map_animation, journey, tio, atlantic_area)
141-

demo/Titanic/simulation/journey.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class StatusOfJourney(Enum):
66
ON_THE_WAY = 2
77
ARRIVED = 3
88
SUNK = 4
9+
10+
911
class Journey:
1012

1113
_instance = None

demo/Titanic/simulation/map_animation.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@ def _import_dependencies(self):
1717
def plot_static_elements(self, areas, locations):
1818
# Plot the areas as squares
1919
if not self.plot_initialized:
20-
self._import_dependencies() # Import here, to avoid any missing dependency problems in case matplotlib is not installed
20+
# Import here, to avoid any missing dependency problems in case matplotlib is not installed
21+
self._import_dependencies()
2122

2223
self.fig, self.ax = plt.subplots()
2324
self.ax.set_aspect('equal')
2425

2526
for area_name, area in areas.items():
26-
width = abs(area.upper_left_bound.latitude - area.lower_right_bound.latitude)
27-
height = abs(area.upper_left_bound.longitude - area.lower_right_bound.longitude)
28-
rect = Rectangle((area.lower_right_bound.longitude, area.upper_left_bound.latitude), height, width, alpha=0.4)
27+
width = abs(area.upper_left_bound.latitude -
28+
area.lower_right_bound.latitude)
29+
height = abs(area.upper_left_bound.longitude -
30+
area.lower_right_bound.longitude)
31+
rect = Rectangle((area.lower_right_bound.longitude,
32+
area.upper_left_bound.latitude), height, width, alpha=0.4)
2933
self.ax.add_patch(rect)
30-
self.ax.annotate(area_name, (area.lower_right_bound.longitude, area.upper_left_bound.latitude), color='black')
31-
34+
self.ax.annotate(area_name, (area.lower_right_bound.longitude,
35+
area.upper_left_bound.latitude), color='black')
3236

3337
# Plot the locations
3438
colors = [
@@ -43,7 +47,8 @@ def plot_static_elements(self, areas, locations):
4347
]
4448
ci = 0
4549
for location_name, location in locations.items():
46-
self.ax.plot(location.longitude, location.latitude, colors[ci % len(colors)], label=location_name)
50+
self.ax.plot(location.longitude, location.latitude,
51+
colors[ci % len(colors)], label=location_name)
4752
ci += 1
4853

4954
# # Set the Atlantic area bounds atlantic_area = MapLib.atlantic_area width = abs(
@@ -85,7 +90,7 @@ def update_floating_objects(self, floating_objects):
8590

8691
# Plot the floating objects
8792
for obj in floating_objects:
88-
if isinstance(obj, TitanicInOcean):# Set the rotation angle in degrees
93+
if isinstance(obj, TitanicInOcean): # Set the rotation angle in degrees
8994
angle_degrees = obj.direction
9095

9196
# Convert angle to radians
@@ -98,18 +103,20 @@ def update_floating_objects(self, floating_objects):
98103

99104
# Draw the arrow
100105
self.ax.annotate("", xy=(obj.longitude + dx, obj.latitude + dy), xytext=(obj.longitude, obj.latitude),
101-
arrowprops=dict(arrowstyle="->"), gid='floating_object')
106+
arrowprops=dict(arrowstyle="->"), gid='floating_object')
102107

103108
if obj.sunk:
104109
icon = 'rs' # red square
105110
else:
106111
icon = 'ys' # yellow square
107112
# Draw the arrow
108113
self.ax.annotate("", xy=(obj.longitude + dx, obj.latitude + dy), xytext=(obj.longitude, obj.latitude),
109-
arrowprops=dict(arrowstyle='->'), gid='floating_object')
110-
self.ax.plot(obj.longitude, obj.latitude, icon, label='Titanic', gid='floating_object')
114+
arrowprops=dict(arrowstyle='->'), gid='floating_object')
115+
self.ax.plot(obj.longitude, obj.latitude, icon,
116+
label='Titanic', gid='floating_object')
111117
elif isinstance(obj, Iceberg):
112-
self.ax.plot(obj.longitude, obj.latitude, 'w^', label='Iceberg', gid='floating_object')
118+
self.ax.plot(obj.longitude, obj.latitude, 'w^',
119+
label='Iceberg', gid='floating_object')
113120

114121
# Redraw the plot
115122
plt.draw()

0 commit comments

Comments
 (0)