storypy 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- storypy-0.4.2/.gitattributes +29 -0
- storypy-0.4.2/.gitignore +216 -0
- storypy-0.4.2/.readthedocs.yml +18 -0
- storypy-0.4.2/LICENSE +19 -0
- storypy-0.4.2/PKG-INFO +22 -0
- storypy-0.4.2/README.rst +8 -0
- storypy-0.4.2/docs/Makefile +20 -0
- storypy-0.4.2/docs/make.bat +35 -0
- storypy-0.4.2/docs/requirements.txt +2 -0
- storypy-0.4.2/docs/source/_autosummary/storypy.main.rst +18 -0
- storypy-0.4.2/docs/source/_autosummary/storypy.rst +13 -0
- storypy-0.4.2/docs/source/_static/logo.png +0 -0
- storypy-0.4.2/docs/source/_static/logo.psd +0 -0
- storypy-0.4.2/docs/source/_static/stylesheet.css +4 -0
- storypy-0.4.2/docs/source/branding.rst +19 -0
- storypy-0.4.2/docs/source/conf.py +50 -0
- storypy-0.4.2/docs/source/guides.rst +39 -0
- storypy-0.4.2/docs/source/index.rst +23 -0
- storypy-0.4.2/docs/source/installation.rst +2 -0
- storypy-0.4.2/docs/source/modules.rst +8 -0
- storypy-0.4.2/pyproject.toml +24 -0
- storypy-0.4.2/src/.gitkeep +1 -0
- storypy-0.4.2/src/storypy/__init__.py +4 -0
- storypy-0.4.2/src/storypy/main.py +57 -0
- storypy-0.4.2/tests/.gitkeep +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[^.]*.* linguist-detectable=true linguist-generated=false linguist-vendored=false linguist-documentation=false
|
|
2
|
+
.* linguist-detectable=false
|
|
3
|
+
*.rst linguist-detectable=false
|
|
4
|
+
*.css linguist-detectable=false
|
|
5
|
+
|
|
6
|
+
# Source files
|
|
7
|
+
*.pxd text diff=python
|
|
8
|
+
*.py text diff=python
|
|
9
|
+
*.py3 text diff=python
|
|
10
|
+
*.pyw text diff=python
|
|
11
|
+
*.pyx text diff=python
|
|
12
|
+
*.pyz text diff=python
|
|
13
|
+
*.pyi text diff=python
|
|
14
|
+
|
|
15
|
+
# Binary files
|
|
16
|
+
*.db binary
|
|
17
|
+
*.p binary
|
|
18
|
+
*.pkl binary
|
|
19
|
+
*.pickle binary
|
|
20
|
+
*.pyc binary export-ignore
|
|
21
|
+
*.pyo binary export-ignore
|
|
22
|
+
*.pyd binary
|
|
23
|
+
|
|
24
|
+
# Jupyter notebook
|
|
25
|
+
*.ipynb text eol=lf
|
|
26
|
+
|
|
27
|
+
# Static files in documentation
|
|
28
|
+
*.png binary
|
|
29
|
+
*.psd binary
|
storypy-0.4.2/.gitignore
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
|
|
204
|
+
# Ruff stuff:
|
|
205
|
+
.ruff_cache/
|
|
206
|
+
|
|
207
|
+
# PyPI configuration file
|
|
208
|
+
.pypirc
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Streamlit
|
|
216
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Read the Docs configuration file
|
|
2
|
+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
3
|
+
|
|
4
|
+
version: 2
|
|
5
|
+
|
|
6
|
+
build:
|
|
7
|
+
os: ubuntu-24.04
|
|
8
|
+
tools:
|
|
9
|
+
python: "3.13"
|
|
10
|
+
|
|
11
|
+
# Build documentation in the "docs/" directory with Sphinx
|
|
12
|
+
sphinx:
|
|
13
|
+
configuration: docs/source/conf.py
|
|
14
|
+
|
|
15
|
+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
|
16
|
+
python:
|
|
17
|
+
install:
|
|
18
|
+
- requirements: docs/requirements.txt
|
storypy-0.4.2/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2026 Andras Baki
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
storypy-0.4.2/PKG-INFO
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: storypy
|
|
3
|
+
Version: 0.4.2
|
|
4
|
+
Summary: A Python module for metaprogramming
|
|
5
|
+
Project-URL: Homepage, https://github.com/storypy/storypy
|
|
6
|
+
Project-URL: Issues, https://github.com/storypy/storypy/issues
|
|
7
|
+
Author-email: Andras Baki <andrasbaki6@googlemail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/x-rst
|
|
14
|
+
|
|
15
|
+
StoryPy
|
|
16
|
+
=======
|
|
17
|
+
|
|
18
|
+
StoryPy is a Python module for metaprogramming.
|
|
19
|
+
|
|
20
|
+
----
|
|
21
|
+
|
|
22
|
+
Copyright (c) 2026 Andras Baki
|
storypy-0.4.2/README.rst
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Brand resources
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
StoryPy logo
|
|
5
|
+
------------
|
|
6
|
+
|
|
7
|
+
The StoryPy logo is available in PNG and Photoshop formats.
|
|
8
|
+
|
|
9
|
+
Download links: `PNG <_static/logo.png>`__ `PSD <_static/logo.psd>`__
|
|
10
|
+
|
|
11
|
+
Legal
|
|
12
|
+
^^^^^
|
|
13
|
+
|
|
14
|
+
The StoryPy logo is the exclusive property of Andras Baki and the StoryPy project. Unauthorized use, reproduction, distribution, or modification of the StoryPy logo without prior written permission from StoryPy is strictly prohibited.
|
|
15
|
+
|
|
16
|
+
For permission, contact `andrasbaki6+storypy@googlemail.com <mailto:andrasbaki6+storypy@googlemail.com>`__.
|
|
17
|
+
|
|
18
|
+
Copyright (c) The StoryPy logo 2026 Andras Baki
|
|
19
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
5
|
+
|
|
6
|
+
# -- Project information -----------------------------------------------------
|
|
7
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
sys.path.insert(0, os.path.abspath('../../src'))
|
|
12
|
+
|
|
13
|
+
project = 'StoryPy'
|
|
14
|
+
copyright = '2026, Andras Baki'
|
|
15
|
+
author = 'Andras Baki'
|
|
16
|
+
release = '0.4.2'
|
|
17
|
+
|
|
18
|
+
# -- General configuration ---------------------------------------------------
|
|
19
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
20
|
+
|
|
21
|
+
extensions = [
|
|
22
|
+
'sphinx.ext.autodoc',
|
|
23
|
+
'sphinx.ext.viewcode',
|
|
24
|
+
'sphinx.ext.autosummary',
|
|
25
|
+
'sphinx.ext.napoleon',
|
|
26
|
+
'notfound.extension',
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
autosummary_generate = True
|
|
30
|
+
autoclass_content = "both"
|
|
31
|
+
|
|
32
|
+
templates_path = ['_templates']
|
|
33
|
+
exclude_patterns = []
|
|
34
|
+
|
|
35
|
+
# -- Options for HTML output -------------------------------------------------
|
|
36
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
37
|
+
|
|
38
|
+
html_theme = 'furo'
|
|
39
|
+
html_static_path = ['_static']
|
|
40
|
+
html_logo = "_static/logo.png"
|
|
41
|
+
html_css_files = [
|
|
42
|
+
'stylesheet.css',
|
|
43
|
+
]
|
|
44
|
+
html_context = {
|
|
45
|
+
"github_user": "storypy",
|
|
46
|
+
"github_repo": "storypy",
|
|
47
|
+
"github_version": "main",
|
|
48
|
+
"doc_path": "docs",
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Using StoryPy
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
First of all, to use the StoryPy module in your project, you need to include it::
|
|
5
|
+
|
|
6
|
+
import StoryPy
|
|
7
|
+
|
|
8
|
+
After the module is included, all its objects will be available.
|
|
9
|
+
|
|
10
|
+
The ``declare`` function
|
|
11
|
+
------------------------
|
|
12
|
+
|
|
13
|
+
You can use the ``StoryPy.declare()`` function to declare variables in the main scope of your program (scope selection is not yet supported, but planned).
|
|
14
|
+
|
|
15
|
+
Note that if the specified entity already exists in the main scope, the ``declare`` function will override it without confirmation.
|
|
16
|
+
|
|
17
|
+
Usage
|
|
18
|
+
^^^^^
|
|
19
|
+
|
|
20
|
+
The ``declare`` function needs three inputs: ``category``, ``name``, and ``value``, as shown below::
|
|
21
|
+
|
|
22
|
+
StoryPy.declare(category: str, name: str, value: Any)
|
|
23
|
+
|
|
24
|
+
The ``category`` input specifies the category of the entity you are declaring (e.g. "variable", "function"). Must be a string.
|
|
25
|
+
|
|
26
|
+
For now, only the "variable" category can be entered, meaning you can only declare variables with the ``declare`` function. Other categories are planned to be added in the future.
|
|
27
|
+
|
|
28
|
+
The ``name`` input specifies the name of the entity you are declaring. If the "variable" category is set, this will be the name of the created variable. Must be a string.
|
|
29
|
+
|
|
30
|
+
The ``value`` input specifies the value of the entity you are declaring. If the "variable" category is set, this will be the value of the created variable. Can have any type.
|
|
31
|
+
|
|
32
|
+
Examples
|
|
33
|
+
^^^^^^^^
|
|
34
|
+
|
|
35
|
+
So we'd like to create a variable called "one", with the integer value of 1. We can do this by running::
|
|
36
|
+
|
|
37
|
+
StoryPy.declare("variable", "one", 1)
|
|
38
|
+
|
|
39
|
+
And that's it. Now, the ``one`` variable will be available in our program's main scope.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.. StoryPy documentation master file.
|
|
2
|
+
|
|
3
|
+
.. meta::
|
|
4
|
+
:description: StoryPy is a Python module for metaprogramming.
|
|
5
|
+
:keywords: StoryPy, Python, metaprogramming, programming
|
|
6
|
+
|
|
7
|
+
StoryPy documentation
|
|
8
|
+
=====================
|
|
9
|
+
|
|
10
|
+
StoryPy is a Python module for metaprogramming.
|
|
11
|
+
|
|
12
|
+
This documentation provides the following:
|
|
13
|
+
|
|
14
|
+
* guides for using StoryPy in your project
|
|
15
|
+
* source code documentation (autogenerated)
|
|
16
|
+
|
|
17
|
+
.. toctree::
|
|
18
|
+
:maxdepth: 2
|
|
19
|
+
:caption: Contents:
|
|
20
|
+
|
|
21
|
+
installation
|
|
22
|
+
guides
|
|
23
|
+
modules
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "storypy"
|
|
3
|
+
version = "0.4.2"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="Andras Baki", email="andrasbaki6@googlemail.com" },
|
|
6
|
+
]
|
|
7
|
+
description = "A Python module for metaprogramming"
|
|
8
|
+
readme = "README.rst"
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
]
|
|
14
|
+
license = "MIT"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/storypy/storypy"
|
|
19
|
+
Issues = "https://github.com/storypy/storypy/issues"
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
requires = ["hatchling >= 1.26"]
|
|
23
|
+
build-backend = "hatchling.build"
|
|
24
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitkeep
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
|
|
3
|
+
import keyword
|
|
4
|
+
import sys
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
|
|
7
|
+
class StoryPy_Core:
|
|
8
|
+
@staticmethod
|
|
9
|
+
def declare(category: Literal["variable"], name: str, value: Any) -> None:
|
|
10
|
+
"""
|
|
11
|
+
Declare a new entity inside the caller's global namespace.
|
|
12
|
+
|
|
13
|
+
Currently only ``"variable"`` declarations are supported.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
category (Literal["variable"]):
|
|
17
|
+
The type of entity to declare.
|
|
18
|
+
name (str):
|
|
19
|
+
The name of the variable to create.
|
|
20
|
+
value (Any):
|
|
21
|
+
The value assigned to the declared variable.
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
SyntaxError:
|
|
25
|
+
If ``name`` is not a valid Python identifier or is a reserved keyword.
|
|
26
|
+
ValueError:
|
|
27
|
+
If an unsupported ``category`` is provided.
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
>>> StoryPy_Core.declare("variable", "x", 42)
|
|
31
|
+
>>> x
|
|
32
|
+
42
|
|
33
|
+
|
|
34
|
+
See Also:
|
|
35
|
+
:mod:`sys`
|
|
36
|
+
:func:`keyword.iskeyword`
|
|
37
|
+
"""
|
|
38
|
+
if category.strip().lower() == "variable":
|
|
39
|
+
global valid
|
|
40
|
+
valid = lambda s: s.isidentifier() and not keyword.iskeyword(s) and all(c.isascii() for c in s)
|
|
41
|
+
|
|
42
|
+
if valid(name):
|
|
43
|
+
_caller = sys.modules["__main__"]
|
|
44
|
+
_caller.__dict__[name] = value
|
|
45
|
+
|
|
46
|
+
else:
|
|
47
|
+
raise SyntaxError(f"Illegal variable name {name}")
|
|
48
|
+
|
|
49
|
+
else:
|
|
50
|
+
raise ValueError(f"Unrecognized category {category}")
|
|
51
|
+
|
|
52
|
+
declare = StoryPy_Core.declare
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
print("The StoryPy module is not intended to be run standalone.")
|
|
56
|
+
print("Try importing StoryPy in your project.")
|
|
57
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitkeep
|