Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/frames/edit/files.py
169686 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 files.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
21
from ...constants import TEXTTEST_SANDBOX
22
from ...enums.attributesEnum import attrs
23
from ...general.functions import focusOnFrame
24
from ...frames.edit.basicAttribute import modifyAttribute, modifyAttributeOverlapped
25
from ...input.keyboard import typeKey, typeTwoKeys, updateText
26
27
28
def modifyFile(type: str, attributeIndex):
29
"""
30
@brief modify additional file
31
"""
32
if (type == "additional"):
33
file = "additionals2.add.xml"
34
elif (type == "demand"):
35
file = "routes2.rou.xml"
36
modifyAttribute(attributeIndex, TEXTTEST_SANDBOX + "/" + file)
37
38
39
def modifyFileOverlapped(type: str, attributeIndex):
40
"""
41
@brief modify additional file overlapped
42
"""
43
if (type == "additional"):
44
file = "additionals2.add.xml"
45
elif (type == "demand"):
46
file = "routes2.rou.xml"
47
modifyAttributeOverlapped(attributeIndex, TEXTTEST_SANDBOX + "/" + file)
48
49
50
def modifyFileDialog(type: str, attributeIndex, waitTime=2):
51
"""
52
@brief modify default file using dialog
53
"""
54
if (type == "additional"):
55
file = "additionals2.add.xml"
56
elif (type == "demand"):
57
file = "routes2.rou.xml"
58
# focus current frame
59
focusOnFrame()
60
# jump to attribute
61
for _ in range(attributeIndex):
62
typeKey('tab')
63
# Change current value
64
typeKey('space')
65
# wait for saving
66
time.sleep(waitTime)
67
# jump to filename TextField
68
typeTwoKeys('alt', 'f')
69
updateText(TEXTTEST_SANDBOX)
70
typeKey('enter')
71
updateText(file)
72
typeKey('enter')
73
74
75
def modifyFileDialogOverlapped(type: str, attributeIndex, waitTime=2):
76
"""
77
@brief modify default additional file using dialog
78
"""
79
if (type == "additional"):
80
file = "additionals2.add.xml"
81
elif (type == "demand"):
82
file = "routes2.rou.xml"
83
# focus current frame
84
focusOnFrame()
85
# jump to attribute
86
for _ in range(attributeIndex + attrs.editElements.overlapped):
87
typeKey('tab')
88
# Change current value
89
typeKey('space')
90
# wait for saving
91
time.sleep(waitTime)
92
# jump to filename TextField
93
typeTwoKeys('alt', 'f')
94
updateText(TEXTTEST_SANDBOX)
95
typeKey('enter')
96
updateText(file)
97
typeKey('enter')
98
99