Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 8926c936 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

added declaration data converter project

parent b4bc315c
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
"""
1) Copies the declaration files into the project resource directory.
2) Renames the mission files accordingly
3) Scales Pneumatic System from KW to W.
4) Renames the VCDV paramerters.csv to parameters.csv
5) Scales the WHTC-Weighting percentage values from 0-100 to 0-1
Prerequisites:
* Original declaration files accessible in "root/Declaration"
Usage:
python DeclarationConverter.py
"""
import os
import shutil
__author__ = "Michael Krisper"
__copyright__ = ""
__license__ = ""
__version__ = "1.0.0"
__email__ = "michael.krisper@tugraz.at"
SOURCE = "../Declaration"
DESTINATION = os.path.abspath("../VectoCore/Resources/Declaration")
def main(source_path, destination_path):
# Copy files from source to resource dir
shutil.rmtree(destination_path, onerror=lambda dir, path, err: print(dir, path, err))
shutil.copytree(source_path, destination_path, ignore=lambda src, names: names if "Reports" in src else [])
# Rename mission cycles
os.chdir(os.path.join(destination_path, "MissionCycles"))
for file in os.listdir():
os.rename(file, file.replace("_", "").replace(" ", "").replace("Citybus", "").replace("Bus", ""))
# Adjust PS table
os.chdir(os.path.join(destination_path, "VAUX"))
with open("PS-Table.csv", "r") as f:
lines = f.readlines()
with open("PS-Table.csv", "w") as f:
f.write(lines[0])
for line in lines[1:]:
values = line.split(",")
f.write("{},{}\n".format(values[0], ",".join(str(float(v)*1000) for v in values[1:])))
#VCDV
os.chdir(os.path.join(destination_path, "VCDV"))
os.rename("paramerters.csv", "parameters.csv")
# WHTC Weighting Factors
os.chdir(os.path.join(destination_path))
with open("WHTC-Weighting-Factors.csv", "r") as f:
lines = f.readlines()
with open("WHTC-Weighting-Factors.csv", "w") as f:
f.write(lines[0])
for line in lines[1:]:
values = line.split(",")
f.write("{},{}\n".format(values[0], ",".join(str(float(v) / 100) for v in values[1:])))
if __name__ == "__main__":
main(SOURCE, DESTINATION)
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>e23b3a9b-62e7-4476-849e-eef1c3804a2f</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>DeclarationConverter.py</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<Name>DeclarationConverter</Name>
<RootNamespace>DeclarationConverter</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="DeclarationConverter.py" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<PtvsTargetsFile>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
</PropertyGroup>
<Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" />
<Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<!-- Uncomment the CoreCompile target to enable the Build command in
Visual Studio and specify your pre- and post-build commands in
the BeforeBuild and AfterBuild targets below. -->
<!--<Target Name="CoreCompile" />-->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
</Project>
\ No newline at end of file
......@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectoCore", "VectoCore\Vect
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectoCoreTest", "VectoCoreTest\VectoCoreTest.csproj", "{6A27F93E-4A58-48F6-B00B-3908C5D3D5A2}"
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "DeclarationConverter", "DeclarationConverter\DeclarationConverter.pyproj", "{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -55,6 +57,12 @@ Global
{6A27F93E-4A58-48F6-B00B-3908C5D3D5A2}.Release|Any CPU.Build.0 = Release|Any CPU
{6A27F93E-4A58-48F6-B00B-3908C5D3D5A2}.Release|x64.ActiveCfg = Release|Any CPU
{6A27F93E-4A58-48F6-B00B-3908C5D3D5A2}.Release|x86.ActiveCfg = Release|Any CPU
{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}.Debug|x64.ActiveCfg = Debug|Any CPU
{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}.Debug|x86.ActiveCfg = Debug|Any CPU
{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}.Release|x64.ActiveCfg = Release|Any CPU
{E23B3A9B-62E7-4476-849E-EEF1C3804A2F}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment