jj Inline files - "not so pythonic" files inside your code
Project description
Inline Files
This Python package to allow inline files -- files inside the program.
An inline file is a file stored within another file. This parent file can be any kind of file, but a .py file is preferred due to how an inline file is defined.
Synopsis
from jjinline_files import *
print(message, message2)
"""ILF
==> message
Hello World!
==> message2
And this is all for now.
"""
Definition
We use the following syntax to define an inline file:
r"""ILF
==> ID1
Hello World!
==> ID2:json
{
"hello": "world"
}
"""
Inline files are defined inside a multiline comment or docstring.
Each "file" starts with ==> ID or ==> ID:type, where ID is the
inline file's name.
In the example above, there are two inline files, "ID1" and "ID2".
ID2 has a type json.
If a "file" has an explicit type, the "file" will be
processed accordingly. For example, a JSON file will be processed
using the json module importer. Default type is text file.
Currently, the module supports the following types:
- text files (default) -- a (multiline) string
- json -- any
- yaml -- any
- jj2 -- jinja2 template -- defines a function(dict, **args)
- f -- a f-string -- defines a function(dict, **args)
- csv, tsv -- list(list(str))
- lines -- list(str)
- pughtml -- str
- pugjj2 -- jinja2 template in pug -- defines a function(dict, **args)
File types and their importers
yaml and json
- typical uses: configuration files, knowledge representation
- perform yaml-parse(text);
- return a python value (list, dict, etc)
r"""ILF
from jjinline_files import *
print(f["filename"])
==> f:json
{
"filename": "calendar",
"extension": "json"
}
==> g:yaml
filename: file1
extension: yaml
"""
lines
- returns a list of strings -- text.splitlines()
csv and tsv
- performs csv-parse(txt)
- return a list(list(strings))
templates : f (fstrings) and jinja2 and pugjinja2
- return a function. Parameter:(d:dict or **args) → string
from jjinline_files import *
print( ppname(name="James Bont") )
"""ILF
==> ppname:f
surname {name.split()[-1]} fullname {name}
"""
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jjinline_files-0.1.6.tar.gz.
File metadata
- Download URL: jjinline_files-0.1.6.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fd67ff00bd9c5578ac3cb5abcb60aee921627dedf76dca3ccb123170b27de22
|
|
| MD5 |
e2ade3f72a9146413b645941eec01983
|
|
| BLAKE2b-256 |
f977f032bac6fff76cbdb4588cf0268f94c65c028ecfbc0af4e73d7ec244ea4c
|
File details
Details for the file jjinline_files-0.1.6-py2.py3-none-any.whl.
File metadata
- Download URL: jjinline_files-0.1.6-py2.py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d450dca12576b63e6a66587fbf78fc6ef4cb2cf932f75a9616f803b9d9604b8f
|
|
| MD5 |
a64396f64794487b18e10a849fea47eb
|
|
| BLAKE2b-256 |
a4c22fa688b997fd08b6304e45c2d0fa5fb83ef8eb9dfc6a3e8b6a262ffb922e
|