Skip to content

Commit 8bf7ae9

Browse files
committed
Ensure that robot.py is the correct case
- Fixes robotpy/robotpy-installer#110
1 parent 24f0ae3 commit 8bf7ae9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

robotpy/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ def _load_robot_class():
4949
print(f"ERROR: {robot_py_path} is a directory", file=sys.stderr)
5050
sys.exit(1)
5151

52+
# Ensure that it's robot.py and not Robot.py or similar by checking the
53+
# directory entries of its parent
54+
lower_name = robot_py_path.name.lower()
55+
for entry in robot_py_path.parent.iterdir():
56+
if entry.name.lower() == lower_name and entry.name != robot_py_path.name:
57+
print(
58+
f"ERROR: {robot_py_path} must be {robot_py_path.name} (found '{entry.name}')",
59+
file=sys.stderr,
60+
)
61+
sys.exit(1)
62+
5263
# Add that directory to sys.path to ensure that imports work as expected
5364
sys.path.insert(0, str(robot_py_path.parent.absolute()))
5465

0 commit comments

Comments
 (0)