File: __init__.py

package info (click to toggle)
idjc 0.9.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,796 kB
  • sloc: python: 21,706; ansic: 16,528; sh: 5,639; makefile: 206; sed: 16
file content (48 lines) | stat: -rw-r--r-- 1,612 bytes parent folder | download | duplicates (2)
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
"""Backend test stuff.

To run this code simply launch idjc with:
$ idjcdev=1 idjc run -T"""

#   Copyright (C) 2022 Stephen Fairchild (s-fairchild@users.sourceforge.net)
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program in the file entitled COPYING.
#   If not, see <http://www.gnu.org/licenses/>.

__all__ = ["main"]

import importlib
import os
import re


def main():
    options = {}

    print("\nTest Mode\n")
    ptn = re.compile("^(_(\S))\.py[a-z]?$")
    path = os.path.dirname(__file__)
    for each in sorted(os.listdir(path)):
        if match:= ptn.match(each):
            module = importlib.import_module('.' + match.group(1),
                                             package=__name__)
            if hasattr(module, "_description_"):
                options[match.group(2)] = module
                print(f"{match.group(2)}\t{module._description_}")

    try:
        option = options[input("\nPick an option: ").strip()]
    except KeyError:
        print("unsupported option -- quitting")
        return 5

    return option.main()