File: mkpkgindex.py

package info (click to toggle)
graphviz 14.0.5-2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 139,388 kB
  • sloc: ansic: 141,938; cpp: 11,957; python: 7,766; makefile: 4,043; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,388; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (48 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download
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
#!/usr/bin/env python3

"""
Make TCL package index
"""

import argparse
import sys
from pathlib import Path
from typing import List


def main(args: List[str]) -> int:
    """entry point"""

    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        "--file",
        type=Path,
        required=True,
        help="final shared object file to be loaded (doesn't need to be installed)",
    )
    parser.add_argument(
        "--name",
        type=str,
        required=True,
        help="name of extension",
    )
    parser.add_argument(
        "--version",
        type=str,
        required=True,
        help="version of extension",
    )
    options = parser.parse_args(args[1:])

    # for non-release versions, convert the '~dev.' portion into something compliant
    # with TCL’s version number rules
    version = options.version.replace("~dev.", "b")
    with open("pkgIndex.tcl", "wt", encoding="utf-8") as f:
        f.write(f'package ifneeded {options.name} {version} "\n')
        if "tk" in str(options.file):
            f.write("\tpackage require Tk 8.3\n")
        f.write(f'\tload [file join $dir {options.file}] {options.name}"\n')


if __name__ == "__main__":
    sys.exit(main(sys.argv))