Coverage for moptipyapps / utils / shared.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-11 04:40 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-11 04:40 +0000
1"""Some shared variables and constants."""
3import argparse
4from typing import Any, Final, Iterable
6import moptipy.examples.jssp.instance as ins
7from pycommons.io.arguments import make_argparser, make_epilog
9from moptipyapps.version import __version__ as moptipyapps_version
11#: the instance scope
12SCOPE_INSTANCE: Final[str] = ins.SCOPE_INSTANCE
15def moptipyapps_argparser(file: str, description: str,
16 epilog: str) -> argparse.ArgumentParser:
17 """
18 Create an argument parser with default settings.
20 :param file: the `__file__` special variable of the calling script
21 :param description: the description string
22 :param epilog: the epilogue string
23 :returns: the argument parser
25 >>> ap = moptipyapps_argparser(
26 ... __file__, "This is a test program.", "This is a test.")
27 >>> isinstance(ap, argparse.ArgumentParser)
28 True
29 >>> "Copyright" in ap.epilog
30 True
31 """
32 return make_argparser(
33 file, description,
34 make_epilog(epilog, 2023, 2024, "Thomas Weise",
35 url="https://thomasweise.github.io/moptipyapps",
36 email="tweise@hfuu.edu.cn, tweise@ustc.edu.cn"),
37 moptipyapps_version)
40def motipyapps_footer_bottom_comments(
41 _: Any, additional: "str | None" = None) -> Iterable[str]:
42 """
43 Print the standard csv footer for moptipyapps.
45 :param _: the setup object, ignored
46 :param additional: any additional output string
47 :returns: the comments
49 >>> for s in motipyapps_footer_bottom_comments(None, "bla"):
50 ... print(s[:49])
51 This data has been generated with moptipyapps ver
52 bla
53 You can find moptipyapps at https://thomasweise.g
55 >>> for s in motipyapps_footer_bottom_comments(None, None):
56 ... print(s[:49])
57 This data has been generated with moptipyapps ver
58 You can find moptipyapps at https://thomasweise.g
59 """
60 yield ("This data has been generated with moptipyapps version "
61 f"{moptipyapps_version}.")
62 if (additional is not None) and (str.__len__(additional) > 0):
63 yield additional
64 yield ("You can find moptipyapps at "
65 "https://thomasweise.github.io/moptipyapps.")