Files
spark/tools/cpp_helper/Generate-Cpps.ps1
T
2018-08-16 10:33:53 -05:00

35 lines
1.3 KiB
PowerShell

# Dot sourcing the reqs file will make
. .\Generate-Cpps-reqs.ps1
$cme_file_url = "ftp://ftp.cmegroup.com/pub/fprf/csv/cmeg.fut.prf.csv"
$csv_save_path = ".\cmeg.fut.prf.csv"
$output_file = ".\cpp_config.conf"
# turn off console update progress while downloading
$CurrentProgressPref = $ProgressPreference;
$ProgressPreference = "SilentlyContinue";
Invoke-WebRequest -Uri $cme_file_url -OutFile $csv_save_path
$ProgressPreference = $CurrentProgressPref
$a = Import-Csv $csv_save_path
$b = $a | select Sym, Mult | Group Sym | Sort Name
@"
# Generated by automated script. DO NOT EDIT!
# source: tools/cpp_helper/generate-cpps.ps1
"@ | out-file -Encoding ascii $output_file
"CppConfig`n{`n`tvalue`n`t{" | out-file -Encoding ascii $output_file -Append
$b | % {
if ($known_good.ContainsKey($_.Group[0].Sym)) {
$cpp = $known_good[$_.Group[0].Sym]
} else {
$cpp = $_.Group[0].Mult
}
"`t`tcpp_entry {{ key: `"{0}`" value: {1} }}" -f $_.Group[0].Sym, $cpp } `
| out-file -Encoding ascii $output_file -Append
"`t}`n}" | out-file -Encoding ascii $output_file -Append
Remove-Item $csv_save_path -Force
# You can now copy the output file to defaults assuming all looks good
# Copy-Item .\cpp_config.conf ..\..\src\lib\config\defaults\ -Force
# Remove-Item cpp_config.conf