|
4 | 4 | import platform |
5 | 5 | import importlib.metadata |
6 | 6 | from rich.logging import RichHandler |
| 7 | +from rich.console import Console |
| 8 | +from rich.panel import Panel |
| 9 | +from rich.text import Text |
7 | 10 | import logging |
| 11 | +import os |
| 12 | + |
| 13 | +__version__ = "Beta 0.1" |
| 14 | + |
8 | 15 |
|
9 | 16 | def main() -> int: |
10 | | - logging.basicConfig(level=logging.DEBUG, format="%(message)s", handlers=[RichHandler()]) |
| 17 | + console = Console() |
| 18 | + panel = Panel(Text("Welcome to the Python Tools application!", |
| 19 | + justify="center"), |
| 20 | + title="PTools", subtitle="Enjoy your using!", |
| 21 | + style="bold green") |
| 22 | + console.print(panel) |
| 23 | + logging.basicConfig(level=logging.DEBUG, format="%(message)s", |
| 24 | + handlers=[RichHandler()]) |
11 | 25 | logging.info("Starting main process.") |
| 26 | + logging.debug(f"Platform: {platform.platform()}") |
12 | 27 | logging.debug(f"Python version: {platform.python_version()}") |
13 | 28 | logging.debug(f"markdown module version: {markdown.__version__}") |
14 | 29 | logging.debug(f"rich module version: {importlib.metadata.version('rich')}") |
| 30 | + logging.debug(f"PTools module version: {__version__}") |
| 31 | + paths = console.input("Input your markdown file [bold]path[/bold] " |
| 32 | + '("|" to split): ') |
| 33 | + paths = paths.split("|") |
| 34 | + logging.debug(f"Input paths: {paths}") |
| 35 | + # Does the file exist? Is it a file? |
| 36 | + vpaths = [] |
| 37 | + for path in paths: |
| 38 | + if not os.path.exists(path): |
| 39 | + logging.warning(f"File not found: {path}") |
| 40 | + elif not os.path.isfile(path): |
| 41 | + logging.warning(f"Path is not a file: {path}") |
| 42 | + else: |
| 43 | + vpaths.append(path) |
| 44 | + logging.debug(f"Valid paths: {vpaths}") |
| 45 | + logging.info("Finished main process.") |
15 | 46 | return 0 |
16 | 47 |
|
| 48 | + |
17 | 49 | if __name__ == '__main__': |
18 | 50 | exit(main()) |
0 commit comments