fictus


Namefictus JSON
Version 0.2.0 PyPI version JSON
download
home_page
SummaryGenerate a fake file system to create documentation examples.
upload_time2023-09-08 19:01:33
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords documentation fake directory filesystem
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ### Fictus

Fictus allows a user to create and output a fictitious file system for sharing in a text driven environment.

```Text
🏑kitchen
└─ πŸ“drawer
   β”œβ”€ πŸ“forks
   β”‚  β”œβ”€ πŸ“old
   β”‚  β”‚  └─ πŸ“„pitchfork.bak
   β”‚  β”œβ”€ πŸ“„dinner.mp3
   β”‚  └─ πŸ“„salad.mov
   └─ πŸ“spoons
      └─ πŸ“„ladle.psd
```
Fictus use cases include creating output for a wiki page, communicating a folder structure to a colleague over chat, or
mocking a file/folder structure layout before committing to actual creation on disk.  Since Fictus mimics a File System,
calling code can create complex loops to build up as little or as much as required to get an idea across.

A code example:

```Python
from fictus import FictusFileSystem

# Create a FictusFileSystem.
ffs = FictusFileSystem("c")

# Create some files in the current working directory.
ffs.mkfile("README.md", "LICENSE.md", ".ignore")

# Create dir and files relative to the current working directory.
ffs.mkdir("./files/docs")
ffs.cd("./files/docs")
ffs.mkfile("resume.txt", "recipe.wrd")

# Create/Change dir to music. Start with a `/` to ensure traversal from _root.
ffs.mkdir("/files/music/folk")
ffs.cd("/files/music/folk")
ffs.mkfile("bing.mp3", "bang.mp3", "bop.wav")

# Generate a ffs structure to be printed to stdout as text.
ffs.cd("/")  # jump to _root; could have used "/" instead of "c:"
```

A FictusDisplay can output the FFS.

```Python
from fictus import FictusDisplay

display = FictusDisplay(ffs)
display.pprint()
```

Produces:

```Text
c:\
β”œβ”€ files\
β”‚  β”œβ”€ docs\
β”‚  β”‚  β”œβ”€ recipe.wrd
β”‚  β”‚  └─ resume.txt
β”‚  └─ music\
β”‚     └─ folk\
β”‚        β”œβ”€ bang.mp3
β”‚        β”œβ”€ bing.mp3
β”‚        └─ bop.wav
β”œβ”€ .ignore
β”œβ”€ LICENSE.md
└─ README.md
```

The display can also be generated in place:

```Python
FictusDisplay(ffs).pprint()
```

The tree displayed starts at current working directory. The same example
above with the current directory set to "c:/files/music" produces:

```Text
music\
└─ folk\
   β”œβ”€ bang.mp3
   β”œβ”€ bing.mp3
   └─ bop.wav
```

A FictusDisplay does allow the user to customize output for the DOC, ROOT, FOLDER, and 
FILE types.  The Renderer can be changed from default for the code lifetime using the 
`set_renderer` function. Here is an example that takes advantage of the built-in 
`emojiRenderer`.  The existing Display is updated and a pprint is called again.

```Python
from fictus.renderer import emojiRenderer
...
# FictusDisplay the ffs structure after a relative change of directory to files/music
ffs.cd("files/music")
display.renderer = emojiRenderer
display.pprint()
```

This produces:

```Text
πŸ“music
└─ πŸ“folk
   β”œβ”€ πŸ“„bang.mp3
   β”œβ”€ πŸ“„bing.mp3
   └─ πŸ“„bop.wav
```

In the above example the renderer was updated so that each call to print will now use
the emojiRenderer. If the main renderer is not required to be updated and its meant to
just showcase one call in a different way the pprint() has an optional `renderer` argument.

```Python
from fictus.renderer import defaultRenderer
# current renderer is the emojiRenderer

# uses defaultRenderer just this one time
display.pprint(renderer=defaultRenderer)  

# use the emojiRenderer that was setup in the previous example set.
display.pprint() 
```

Customization may be useful for creating HTML, Markdown, or other custom tags that are
not already provided.

For example:

```Python
from fictus.renderer import RenderTagEnum, RenderTag

# A customRenderer is created: adds special characters before a File or Folder.
customRenderer = Renderer()
customRenderer.register(RenderTagEnum.FILE, RenderTag("Β· ", ""))
customRenderer.register(RenderTagEnum.FOLDER, RenderTag("+ ", "\\"))

# Update display_model to the customRenderer
display.renderer = customRenderer
display.pprint()
```

Produces:

```Text
+ music\
└─ + folk\
   β”œβ”€ Β· bang.mp3
   β”œβ”€ Β· bing.mp3
   └─ Β· bop.wav
```

## Install Using Pip
>pip install fictus

## Building/installing the Wheel locally:
To build the package requires setuptools and build.
>python3 -m build

Once built:
>pip install dist/fictus-*.whl --force-reinstall

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fictus",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "documentation,fake,directory,filesystem",
    "author": "",
    "author_email": "Jason Brackman <brackman+fictus@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c9/ca/5c3e5f86e8bb5126149f0247b22f2d28c317f1cdbe7bf79ef76b10e20929/fictus-0.2.0.tar.gz",
    "platform": null,
    "description": "### Fictus\n\nFictus allows a user to create and output a fictitious file system for sharing in a text driven environment.\n\n```Text\n\ud83c\udfe1kitchen\n\u2514\u2500 \ud83d\udcc1drawer\n   \u251c\u2500 \ud83d\udcc1forks\n   \u2502  \u251c\u2500 \ud83d\udcc1old\n   \u2502  \u2502  \u2514\u2500 \ud83d\udcc4pitchfork.bak\n   \u2502  \u251c\u2500 \ud83d\udcc4dinner.mp3\n   \u2502  \u2514\u2500 \ud83d\udcc4salad.mov\n   \u2514\u2500 \ud83d\udcc1spoons\n      \u2514\u2500 \ud83d\udcc4ladle.psd\n```\nFictus use cases include creating output for a wiki page, communicating a folder structure to a colleague over chat, or\nmocking a file/folder structure layout before committing to actual creation on disk.  Since Fictus mimics a File System,\ncalling code can create complex loops to build up as little or as much as required to get an idea across.\n\nA code example:\n\n```Python\nfrom fictus import FictusFileSystem\n\n# Create a FictusFileSystem.\nffs = FictusFileSystem(\"c\")\n\n# Create some files in the current working directory.\nffs.mkfile(\"README.md\", \"LICENSE.md\", \".ignore\")\n\n# Create dir and files relative to the current working directory.\nffs.mkdir(\"./files/docs\")\nffs.cd(\"./files/docs\")\nffs.mkfile(\"resume.txt\", \"recipe.wrd\")\n\n# Create/Change dir to music. Start with a `/` to ensure traversal from _root.\nffs.mkdir(\"/files/music/folk\")\nffs.cd(\"/files/music/folk\")\nffs.mkfile(\"bing.mp3\", \"bang.mp3\", \"bop.wav\")\n\n# Generate a ffs structure to be printed to stdout as text.\nffs.cd(\"/\")  # jump to _root; could have used \"/\" instead of \"c:\"\n```\n\nA FictusDisplay can output the FFS.\n\n```Python\nfrom fictus import FictusDisplay\n\ndisplay = FictusDisplay(ffs)\ndisplay.pprint()\n```\n\nProduces:\n\n```Text\nc:\\\n\u251c\u2500 files\\\n\u2502  \u251c\u2500 docs\\\n\u2502  \u2502  \u251c\u2500 recipe.wrd\n\u2502  \u2502  \u2514\u2500 resume.txt\n\u2502  \u2514\u2500 music\\\n\u2502     \u2514\u2500 folk\\\n\u2502        \u251c\u2500 bang.mp3\n\u2502        \u251c\u2500 bing.mp3\n\u2502        \u2514\u2500 bop.wav\n\u251c\u2500 .ignore\n\u251c\u2500 LICENSE.md\n\u2514\u2500 README.md\n```\n\nThe display can also be generated in place:\n\n```Python\nFictusDisplay(ffs).pprint()\n```\n\nThe tree displayed starts at current working directory. The same example\nabove with the current directory set to \"c:/files/music\" produces:\n\n```Text\nmusic\\\n\u2514\u2500 folk\\\n   \u251c\u2500 bang.mp3\n   \u251c\u2500 bing.mp3\n   \u2514\u2500 bop.wav\n```\n\nA FictusDisplay does allow the user to customize output for the DOC, ROOT, FOLDER, and \nFILE types.  The Renderer can be changed from default for the code lifetime using the \n`set_renderer` function. Here is an example that takes advantage of the built-in \n`emojiRenderer`.  The existing Display is updated and a pprint is called again.\n\n```Python\nfrom fictus.renderer import emojiRenderer\n...\n# FictusDisplay the ffs structure after a relative change of directory to files/music\nffs.cd(\"files/music\")\ndisplay.renderer = emojiRenderer\ndisplay.pprint()\n```\n\nThis produces:\n\n```Text\n\ud83d\udcc1music\n\u2514\u2500 \ud83d\udcc1folk\n   \u251c\u2500 \ud83d\udcc4bang.mp3\n   \u251c\u2500 \ud83d\udcc4bing.mp3\n   \u2514\u2500 \ud83d\udcc4bop.wav\n```\n\nIn the above example the renderer was updated so that each call to print will now use\nthe emojiRenderer. If the main renderer is not required to be updated and its meant to\njust showcase one call in a different way the pprint() has an optional `renderer` argument.\n\n```Python\nfrom fictus.renderer import defaultRenderer\n# current renderer is the emojiRenderer\n\n# uses defaultRenderer just this one time\ndisplay.pprint(renderer=defaultRenderer)  \n\n# use the emojiRenderer that was setup in the previous example set.\ndisplay.pprint() \n```\n\nCustomization may be useful for creating HTML, Markdown, or other custom tags that are\nnot already provided.\n\nFor example:\n\n```Python\nfrom fictus.renderer import RenderTagEnum, RenderTag\n\n# A customRenderer is created: adds special characters before a File or Folder.\ncustomRenderer = Renderer()\ncustomRenderer.register(RenderTagEnum.FILE, RenderTag(\"\u00b7 \", \"\"))\ncustomRenderer.register(RenderTagEnum.FOLDER, RenderTag(\"+ \", \"\\\\\"))\n\n# Update display_model to the customRenderer\ndisplay.renderer = customRenderer\ndisplay.pprint()\n```\n\nProduces:\n\n```Text\n+ music\\\n\u2514\u2500 + folk\\\n   \u251c\u2500 \u00b7 bang.mp3\n   \u251c\u2500 \u00b7 bing.mp3\n   \u2514\u2500 \u00b7 bop.wav\n```\n\n## Install Using Pip\n>pip install fictus\n\n## Building/installing the Wheel locally:\nTo build the package requires setuptools and build.\n>python3 -m build\n\nOnce built:\n>pip install dist/fictus-*.whl --force-reinstall\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Generate a fake file system to create documentation examples.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/jasonbrackman/arborator",
        "Source": "https://github.com/jasonbrackman/arborator"
    },
    "split_keywords": [
        "documentation",
        "fake",
        "directory",
        "filesystem"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f5bc54d9c8dc27f522a46242897d31cc04bf745b735e295c757b80d59d56264",
                "md5": "0a31ea5298590365daefe09ec955ef75",
                "sha256": "066cec121ce05bd3a809a767e5545fdb79a42a2781f548ff1cf1c734dd022925"
            },
            "downloads": -1,
            "filename": "fictus-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0a31ea5298590365daefe09ec955ef75",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9248,
            "upload_time": "2023-09-08T19:01:31",
            "upload_time_iso_8601": "2023-09-08T19:01:31.800956Z",
            "url": "https://files.pythonhosted.org/packages/8f/5b/c54d9c8dc27f522a46242897d31cc04bf745b735e295c757b80d59d56264/fictus-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9ca5c3e5f86e8bb5126149f0247b22f2d28c317f1cdbe7bf79ef76b10e20929",
                "md5": "245a21ce941ae670b0fcc06f7821e46e",
                "sha256": "c5f8cd1c887f7b4a0391e8a1efed5d7458e3e92eadd9612aee7c5ee8f188c0e9"
            },
            "downloads": -1,
            "filename": "fictus-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "245a21ce941ae670b0fcc06f7821e46e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10753,
            "upload_time": "2023-09-08T19:01:33",
            "upload_time_iso_8601": "2023-09-08T19:01:33.442318Z",
            "url": "https://files.pythonhosted.org/packages/c9/ca/5c3e5f86e8bb5126149f0247b22f2d28c317f1cdbe7bf79ef76b10e20929/fictus-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-08 19:01:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jasonbrackman",
    "github_project": "arborator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fictus"
}
        
Elapsed time: 0.11560s