From 2005b46c779f6ed8daa99f6005bb1ecfcca49e60 Mon Sep 17 00:00:00 2001 From: Tyler Starr Date: Sun, 14 Jul 2024 11:20:37 -0700 Subject: [PATCH] big updates to a package --- .gitignore | 2 ++ config.toml | 0 default.nix | 15 ++++++++++++ {templates => example}/default.md | 0 pyproject.toml | 24 ++++++++++++++++++++ src/z/__init__.py | 2 ++ src/z/__main__.py | 5 ++++ create.py => src/z/create.py | 2 +- template.py => src/z/template.py | 4 ++-- template_funcs.py => src/z/template_funcs.py | 0 z.py => src/z/z.py | 5 +--- 11 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 config.toml create mode 100644 default.nix rename {templates => example}/default.md (100%) create mode 100644 pyproject.toml create mode 100644 src/z/__init__.py create mode 100644 src/z/__main__.py rename create.py => src/z/create.py (97%) rename template.py => src/z/template.py (77%) rename template_funcs.py => src/z/template_funcs.py (100%) rename z.py => src/z/z.py (96%) diff --git a/.gitignore b/.gitignore index 670a936..d71c488 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ __pycache__/ .venv/ +*.egg-info/ +build/ diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..e69de29 diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ff38004 --- /dev/null +++ b/default.nix @@ -0,0 +1,15 @@ +with (import {}); + +mkShell { + buildInputs = with pkgs.python3Packages; [ + python + venvShellHook + ]; + venvDir = "./.venv"; + postVenvCreation = '' + unset SOURCE_DATE_EPOCH + ''; + postShellHook = '' + unset SOURCE_DATE_EPOCH + ''; +} diff --git a/templates/default.md b/example/default.md similarity index 100% rename from templates/default.md rename to example/default.md diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f90493f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,24 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" +[project] +name = "z-py" +version = "0.0.1" +authors = [ + {name = "Tyler Starr", email= "starrtyler88@gmail.com"} +] +description = "Personal note taking framework." +readme = "README.md" +requires-python = ">=3.10" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License (GPL)", + "Operating System :: OS Independent" +] +dependencies = [ +] +[project.urls] +"Homepage" = "https://github.com/starr-dusT/z-py" +"Repository" = "https://github.com/starr-dusT/z-py" +[project.scripts] +z = "z.z:main" diff --git a/src/z/__init__.py b/src/z/__init__.py new file mode 100644 index 0000000..3865423 --- /dev/null +++ b/src/z/__init__.py @@ -0,0 +1,2 @@ +from .z import * +from .create import * diff --git a/src/z/__main__.py b/src/z/__main__.py new file mode 100644 index 0000000..ee7ef39 --- /dev/null +++ b/src/z/__main__.py @@ -0,0 +1,5 @@ +from z.z import main +import sys + +if __name__ == "__main__": + sys.exit(main()) diff --git a/create.py b/src/z/create.py similarity index 97% rename from create.py rename to src/z/create.py index c5614fd..2819292 100644 --- a/create.py +++ b/src/z/create.py @@ -1,5 +1,5 @@ from argparse import ArgumentTypeError -from template import apply_template +from z.template import apply_template from pathlib import Path from typing import List import datetime diff --git a/template.py b/src/z/template.py similarity index 77% rename from template.py rename to src/z/template.py index d114e84..b529805 100644 --- a/template.py +++ b/src/z/template.py @@ -1,4 +1,4 @@ -import template_funcs as tf +from z import template_funcs from pathlib import Path from typing import List import re @@ -14,4 +14,4 @@ def split_template(s: str) -> (List[str], str): def apply_template(path: Path, name: str): fns, s = split_template(read_file(path, name)) - return s.format(*[eval("tf." + fn)() for fn in fns]) + return s.format(*[eval("template_funcs." + fn)() for fn in fns]) diff --git a/template_funcs.py b/src/z/template_funcs.py similarity index 100% rename from template_funcs.py rename to src/z/template_funcs.py diff --git a/z.py b/src/z/z.py similarity index 96% rename from z.py rename to src/z/z.py index da9128a..e900d19 100644 --- a/z.py +++ b/src/z/z.py @@ -1,10 +1,8 @@ from pathlib import Path import argparse -import create +from z import create import sys -folder = "dude2" - def init_parser(): parser = argparse.ArgumentParser(prog="z.py", description="top level prog") sub_parsers = parser.add_subparsers(help="subcommand help") @@ -19,7 +17,6 @@ def main(): z_file = Path("./.z") if not z_file.is_file(): raise Exception("You aren't in a z.py folder. Re-run in a z.py folder") - parser = init_parser() args = parser.parse_args() args.func(args)