• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kit-data-manager / tomo_mapper / 21944637261

12 Feb 2026 11:24AM UTC coverage: 86.453% (+0.1%) from 86.341%
21944637261

push

github

web-flow
Merge pull request #77 from kit-data-manager/improv_code_cleanup

Various code fixes and cleanups
Cleaner type hints
Cleaner inheritance
More None checks

parse functions (parse_setup, parse_run, parse) do not return raw parse result anymore (was never used anywhere anyway)

Code now passes a static code check such as pyright.

159 of 198 new or added lines in 30 files covered. (80.3%)

3 existing lines in 3 files now uncovered.

2425 of 2805 relevant lines covered (86.45%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.29
/src/parser/MetadataParser.py
1
from abc import ABC, abstractmethod
1✔
2
from typing import List, Optional
1✔
3
from io import StringIO
1✔
4

5
import xmltodict
1✔
6
import json
1✔
7
import logging
1✔
8

9
import configparser
1✔
10

11
from src.util import configparser_keep_keystring
1✔
12

13

14
#from configparser import ConfigParser, NoInterpolation
15

16
class MetadataParser(ABC):
1✔
17

18
    @staticmethod
1✔
19
    @abstractmethod
1✔
20
    def expected_input_format() -> str:
1✔
21
        pass
×
22

23
    @staticmethod
1✔
24
    @abstractmethod
1✔
25
    def supported_input_sources() -> List[str]:
1✔
26
        """
27
        Provides informative output about the input sources that are supported by implementation of this parser.
28
        The output is not specified and should only be used for informative reasons (such as logging and printing)
29
        :return:
30
        """
31
        pass
×
32
    
33
    def _read_input(self, payload) -> Optional[dict]:
1✔
34
        """
35
        creates metadata dictionary from payload
36
        :param payload: input String
37
        :return: metadata dict
38
        """
39
        if self.expected_input_format() == "text/xml":
1✔
40
            self.parsed_data = xmltodict.parse(payload)
1✔
41
            return self.parsed_data
1✔
42
        if self.expected_input_format() == "application/json":
×
43
            self.parsed_data = json.loads(payload)
×
44
            return self.parsed_data
×
45
        if self.expected_input_format() == "text/plain":
×
46
            
47
            self.parsed_data = {}
×
48
            config = configparser.ConfigParser(interpolation=configparser.Interpolation()) # disables interpolation explicitly
×
NEW
49
            config.optionxform = configparser_keep_keystring # do this if you do not want to read in data as lowercase
×
50
            config.read_string(payload)
×
51
            for section in config.sections():
×
52
                items = config.items(section)
×
53
                self.parsed_data[section] = dict(items)
×
54
            return self.parsed_data
×
55
        logging.error("Parsing of input format not implemented: {}",format(self.expected_input_format()))
×
56
        return None
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc