Path: blob/main/tools/neteditTestFunctions/general/functions.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 functions.py14# @author Pablo Alvarez Lopez15# @date 28-05-251617# imports18import time19from ..constants import DELAY_RECOMPUTE, DELAY_RECOMPUTE_VOLATILE, DELAY_QUESTION20from ..input.keyboard import typeKey, typeTwoKeys212223def computeJunctions():24"""25@brief compute junctions (rebuild network)26"""27typeKey('F5')28# wait for output29time.sleep(DELAY_RECOMPUTE)303132def computeJunctionsVolatileOptions(question):33"""34@brief rebuild network with volatile options35"""36typeTwoKeys('shift', 'F5')37# confirm recompute38if question == "yes":39waitQuestion('y')40# wait for output41time.sleep(DELAY_RECOMPUTE_VOLATILE)42elif question == "no":43waitQuestion('n')44else:45waitQuestion('esc')464748def joinSelectedJunctions():49"""50@brief join selected junctions51"""52typeKey('F7')535455def focusOnFrame():56"""57@brief select focus on upper element of current frame58"""59typeTwoKeys('shift', 'F12')60time.sleep(1)616263def waitQuestion(answer):64"""65@brief wait question of Netedit and select a yes/no answer (by default yes)66"""67# wait some second to question dialog68time.sleep(DELAY_QUESTION)69# continue depending on answer70if (answer == 'esc'):71typeKey('esc')72else:73if (answer == 'n'):74typeKey('tab')75elif (answer == 'a'):76for _ in range(2):77typeKey('tab')78# press space to answer question79typeKey('space')808182def overwritte(value):83"""84@brief check if overwritte loaded elements85"""86if value == "yes":87typeKey('space')88elif value == "no":89typeKey('tab')90typeKey('space')91else:92typeKey('tab')93typeKey('tab')94typeKey('space')959697def openAboutDialog(waitingTime=DELAY_QUESTION):98"""99@brief open and close about dialog100"""101# type F12 to open about dialog102typeKey('F12')103# wait before closing104time.sleep(waitingTime)105# press enter to close dialog (Ok must be focused)106typeKey('space')107108109