Coverage for /home/pradyumna/Languages/python/packages/pyprojstencil/pyprojstencil/read_templates.py: 48%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python3
2# -*- coding:utf-8; mode:python; -*-
3#
4# Copyright 2021 Pradyumna Paranjape
5# This file is part of pyprojstencil.
6#
7# pyprojstencil is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# pyprojstencil is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with pyprojstencil. If not, see <https://www.gnu.org/licenses/>.
19#
20"""
21Read templates
22"""
24from pathlib import Path
25from typing import List, Tuple
28class InfoBase:
29 """
30 InfoBase to construct the project
32 Attributes:
33 licenses: list of license paths
35 """
37 def __init__(self):
38 self._root = Path(__file__).parent
39 self.templates = self._root / 'templates'
40 self.licenses: List[Tuple[Path, Path]] = []
42 def _get_licenses(self):
43 """
44 parse known licenses
45 """
46 headers: List[Path] = []
47 licenses: List[Path] = []
48 for text_file in (self.templates / 'licenses').glob('*'):
49 if not text_file.is_file():
50 continue
51 if text_file.stem[-7:] == '_header':
52 headers.append(text_file)
53 else:
54 licenses.append(text_file)
55 for header_path in headers:
56 license_path = str(header_path).replace('_header', '')
57 if license_path in licenses:
58 self.licenses.append((header_path, license_path))
61INFO_BASE = InfoBase()
62"""
63Database-like Object that contains all necessary template information
64"""