Path: blob/main/tools/neteditTestFunctions/files/load.py
169678 views
# -*- coding: utf-8 -*-1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file load.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18import time19from ..enums.attributesEnum import attrs20from ..enums.viewPositions import positions21from ..constants import TEXTTEST_SANDBOX22from ..input.keyboard import typeKey, typeTwoKeys, typeThreeKeys, updateText23from ..input.mouse import moveMouse242526def loadFile(referencePosition, type: str, file: str, extension: str, extensionIndex: int):27"""28@brief load file config using dialog29"""30# continue depending of type31if (type == "neteditConfig"):32typeTwoKeys('ctrl', 'e')33elif (type == "sumoConfig"):34typeTwoKeys('ctrl', 'm')35elif (type == "netconvertConfig"):36typeThreeKeys('ctrl', 'shift', 'o')37elif (type == "network"):38typeTwoKeys('ctrl', 'o')39elif (type == "trafficLights"):40typeTwoKeys('ctrl', 'k')41elif (type == "edgeTypes"):42typeTwoKeys('ctrl', 'h')43elif (type == "additional"):44typeTwoKeys('ctrl', 'a')45elif (type == "demand"):46typeTwoKeys('ctrl', 'd')47elif (type == "data"):48typeTwoKeys('ctrl', 'b')49elif (type == "meanData"):50# move mouse (to avoid problems with file menu)51moveMouse(referencePosition, positions.reference, 200, 0, False)52# open load mean data dialog (because doesn't have shortcut)53typeTwoKeys('alt', 'f')54for _ in range(attrs.toolbar.file.meanDataElements.menu):55typeKey('down')56typeKey('space')57for _ in range(attrs.toolbar.file.meanDataElements.load):58typeKey('down')59typeKey('space')60# jump to filename TextField61typeTwoKeys('alt', 'f')62# wait for dialog63time.sleep(2)64# set folder65updateText(TEXTTEST_SANDBOX)66typeKey('enter')67# set extension68typeKey('tab')69for _ in range(0, extensionIndex):70typeKey('down')71typeTwoKeys('shift', 'tab')72# set file73updateText(file + "." + extension)74typeKey('enter')75# wait for load76time.sleep(2)777879