File: devtools.py

package info (click to toggle)
python-polsarpro 2026.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 17,024 kB
  • sloc: python: 3,830; xml: 293; sh: 91; javascript: 18; makefile: 3
file content (16 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from collections import OrderedDict
import re

def parse_psp_parameter_string(input_string):
    """Convenience development function to make cli parameters from strings copied from parameter files."""
    ordered_dict = OrderedDict()
    
    for line in input_string.strip().split("\n"):
        key, value = re.split(r':\s*', line, maxsplit=1)
        if value.isdigit():
            value = int(value)
        elif value.replace('.', '', 1).isdigit():  # Check for float
            value = float(value)
        ordered_dict[key] = value
    str_param = " ".join([f"-{it[0]} {it[1]}" for it in ordered_dict.items()])
    return str_param