Coverage for appr/formats/helm/manifest_chart.py: 40%

# Coverage for appr/formats/helm/manifest_chart.py : 40%

## 48 statements 19 run 29 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | from __future__ import absolute_import, division, print_function import os.path import sys import yaml __all__ = ['ManifestChart'] MANIFEST_FILES = ["Chart.yaml", "Chart.yml"] class ManifestChart(dict): def __init__(self, package=None, values=None): def __init__(self): super(ManifestChart, self).__init__() self.values = values if package is None: self._load_from_path() else: self._load_yaml(package.manifest) def _load_yaml(self, yamlstr): try: self.update(yaml.load(yamlstr)) except yaml.YAMLError as exc: print("Error in configuration file:", sys.stderr) if hasattr(exc, 'problem_mark'): mark = exc.problem_mark # pylint: disable=no-member print("Error position: (%s:%s)" % (mark.line + 1, mark.column + 1), sys.stderr) raise exc def _load_from_path(self): for f in MANIFEST_FILES: if os.path.exists(f): mfile = f break with open(mfile) as f: self._load_yaml(f.read()) @property def keywords(self): return self.get("keywords", []) @property def engine(self): return self.get("engine", "gotpl") @property def home(self): return self.get("home", "") @property def description(self): return self.get("description", "") @property def version(self): return self.get("version", "") @property def maintainers(self): return self.get("maintainers", []) @property def sources(self): return self.get("sources", []) @property def name(self): return self.get("name", "") def metadata(self): return {"maintainers": self.maintainers, "source": self.sources}