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

kit-data-manager / tomo_mapper / 16730063425

04 Aug 2025 05:35PM UTC coverage: 86.311%. Remained the same
16730063425

push

github

web-flow
Merge pull request #73 from kit-data-manager/fix_issue_61

expected_input_format now always returns proper mimetype string

2 of 4 new or added lines in 3 files covered. (50.0%)

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() == "text/xml":
1✔
36
            self.parsed_data = xmltodict.parse(payload)
1✔
37
            return self.parsed_data
1✔
NEW
38
        if self.expected_input_format() == "application/json":
×
39
            self.parsed_data = json.loads(payload)
×
40
            return self.parsed_data
×
41
        if self.expected_input_format() == "text/plain":
×
42
            self.parsed_data = {}
×
43
            config = configparser.ConfigParser(interpolation=configparser.Interpolation()) # disables interpolation explicitly
×
44
            config.optionxform = str # do this if you do not want to read in data as lowercase
×
45
            config.read_string(payload)
×
46
            for section in config.sections():
×
47
                items = config.items(section)
×
48
                self.parsed_data[section] = dict(items)
×
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