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

kit-data-manager / tomo_mapper / 16725814017

04 Aug 2025 02:09PM UTC coverage: 86.311% (-3.3%) from 89.629%
16725814017

push

github

web-flow
Release v1.1.0

350 of 449 new or added lines in 22 files covered. (77.95%)

9 existing lines in 2 files now uncovered.

2396 of 2776 relevant lines covered (86.31%)

0.86 hits per line

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

52.94
/src/parser/MetadataParser.py
1
from abc import ABC, abstractmethod
1✔
2
from typing import List
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
#from configparser import ConfigParser, NoInterpolation
11

12
class MetadataParser(ABC):
1✔
13

14
    @staticmethod
1✔
15
    @abstractmethod
1✔
16
    def expected_input_format() -> str:
1✔
17
        pass
×
18

19
    @staticmethod
1✔
20
    @abstractmethod
1✔
21
    def supported_input_sources() -> List[str]:
1✔
22
        """
23
        Provides informative output about the input sources that are supported by implementation of this parser.
24
        The output is not specified and should only be used for informative reasons (such as logging and printing)
25
        :return:
26
        """
27
        pass
×
28

29
    def _read_input(self, payload):
1✔
30
        """
31
        creates metadata dictionary from payload
32
        :param payload: input String
33
        :return: metadata dict
34
        """
35
        if self.expected_input_format() == "xml":
1✔
36
            self.parsed_data = xmltodict.parse(payload)
1✔
37
            return self.parsed_data
1✔
38
        if self.expected_input_format() == "json":
×
39
            self.parsed_data = json.loads(payload)
×
40
            return self.parsed_data
×
NEW
41
        if self.expected_input_format() == "text/plain":
×
NEW
42
            self.parsed_data = {}
×
NEW
43
            config = configparser.ConfigParser(interpolation=configparser.Interpolation()) # disables interpolation explicitly
×
NEW
44
            config.optionxform = str # do this if you do not want to read in data as lowercase
×
NEW
45
            config.read_string(payload)
×
NEW
46
            for section in config.sections():
×
NEW
47
                items = config.items(section)
×
NEW
48
                self.parsed_data[section] = dict(items)
×
NEW
49
            return self.parsed_data
×
50
        logging.error("Parsing of input format not implemented: {}",format(self.expected_input_format()))
×
51
        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