File: Parser.py

package info (click to toggle)
python-pyqtlet2 0.9.3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,672 kB
  • sloc: python: 997; javascript: 88; makefile: 18; sh: 14
file content (24 lines) | stat: -rw-r--r-- 788 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Parser:
    @staticmethod
    def dict_for_js(object_to_parse: dict) -> dict:
        return_dict = {}
        for key, value in object_to_parse.items():
            if isinstance(value, bool):
                return_dict[key] = str(value).lower()
                continue

            return_dict[key] = value
        return return_dict

    @staticmethod
    def js_for_dict(object_to_parse: dict) -> dict:
        return_dict = {}
        for key, value in object_to_parse.items():
            if isinstance(value, str):
                value: str
                if value.lower() in ["true", "false"]:
                    return_dict[key] = True if value.lower() == "true" else False
                    continue

            return_dict[key] = value
        return return_dict