Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/files/load.py
169678 views
1
# -*- coding: utf-8 -*-
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file load.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
from ..enums.attributesEnum import attrs
21
from ..enums.viewPositions import positions
22
from ..constants import TEXTTEST_SANDBOX
23
from ..input.keyboard import typeKey, typeTwoKeys, typeThreeKeys, updateText
24
from ..input.mouse import moveMouse
25
26
27
def loadFile(referencePosition, type: str, file: str, extension: str, extensionIndex: int):
28
"""
29
@brief load file config using dialog
30
"""
31
# continue depending of type
32
if (type == "neteditConfig"):
33
typeTwoKeys('ctrl', 'e')
34
elif (type == "sumoConfig"):
35
typeTwoKeys('ctrl', 'm')
36
elif (type == "netconvertConfig"):
37
typeThreeKeys('ctrl', 'shift', 'o')
38
elif (type == "network"):
39
typeTwoKeys('ctrl', 'o')
40
elif (type == "trafficLights"):
41
typeTwoKeys('ctrl', 'k')
42
elif (type == "edgeTypes"):
43
typeTwoKeys('ctrl', 'h')
44
elif (type == "additional"):
45
typeTwoKeys('ctrl', 'a')
46
elif (type == "demand"):
47
typeTwoKeys('ctrl', 'd')
48
elif (type == "data"):
49
typeTwoKeys('ctrl', 'b')
50
elif (type == "meanData"):
51
# move mouse (to avoid problems with file menu)
52
moveMouse(referencePosition, positions.reference, 200, 0, False)
53
# open load mean data dialog (because doesn't have shortcut)
54
typeTwoKeys('alt', 'f')
55
for _ in range(attrs.toolbar.file.meanDataElements.menu):
56
typeKey('down')
57
typeKey('space')
58
for _ in range(attrs.toolbar.file.meanDataElements.load):
59
typeKey('down')
60
typeKey('space')
61
# jump to filename TextField
62
typeTwoKeys('alt', 'f')
63
# wait for dialog
64
time.sleep(2)
65
# set folder
66
updateText(TEXTTEST_SANDBOX)
67
typeKey('enter')
68
# set extension
69
typeKey('tab')
70
for _ in range(0, extensionIndex):
71
typeKey('down')
72
typeTwoKeys('shift', 'tab')
73
# set file
74
updateText(file + "." + extension)
75
typeKey('enter')
76
# wait for load
77
time.sleep(2)
78
79