-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
83,101 additions
and
3,468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
docs/source/_autosummary/mightstone.services.mtgjson.models.rst
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,6 @@ Models | |
:toctree: _autosummary | ||
|
||
Card | ||
CardAtomicGroup | ||
Set | ||
SetList | ||
Meta | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Configuration | ||
************* | ||
|
||
Mightstone behavior is defined by configuration. You can configure your mightstone by three means: | ||
|
||
* Programmatically with a ``MightstoneSettings`` instance passed to your ``Mightstone`` application instance | ||
* Through environment variables, for instance ``MIGHTSTONE_APPNAME`` to alter ``appname`` key | ||
* Through a configuration file, with 3 means of defining | ||
|
||
* In CLI by passing a ``--config`` parameter to the command line client | ||
* Via ``MIGHTSTONE_CONFIG_FILE`` environment variable | ||
* Passively, by storing your configuration file in an standard location. | ||
|
||
Configuration | ||
============= | ||
|
||
=========================== ====================================== ====== ======================== =========== | ||
Path Environment Variable Type default description | ||
=========================== ====================================== ====== ======================== =========== | ||
``appname`` ``MIGHTSTONE_APPNAME`` string ``mightstone`` Your application name, it will be used to build your storage and cache paths on the filesystem. | ||
=========================== ====================================== ====== ======================== =========== | ||
|
||
|
||
|
||
Storage | ||
------- | ||
|
||
=========================== ====================================== ====== ======================== =========== | ||
Path Environment Variable Type default description | ||
=========================== ====================================== ====== ======================== =========== | ||
``storage.implementation`` ``MIGHTSTONE_STORAGE_IMPLEMENTATION`` string ``beanita`` Either ``beanita`` for a local file base database, ``motor`` for a remote mongodb connection. | ||
``storage.uri`` ``MIGHTSTONE_STORAGE_URI`` string Mongodb dsn (``mongodb://login:password@host/db``...), only used if ``motor`` implementation | ||
``storage.directory`` ``MIGHTSTONE_STORAGE_DIRECTORY`` string ``<user_data>/mongita`` Data storage directory, only used if ``beanita`` implementation | ||
``storage.database`` ``MIGHTSTONE_STORAGE_DATABASE`` string ``mightstone`` The mongo (or beanita) database | ||
=========================== ====================================== ====== ======================== =========== | ||
|
||
Http | ||
---- | ||
|
||
=========================== ====================================== ============= ========================= =========== | ||
Path Environment Variable Type default description | ||
=========================== ====================================== ============= ========================= =========== | ||
``http.cache.persist`` ``MIGHTSTONE_CACHE_PERSIST`` bool ``True`` Use memory (transient) or filesystem (persistent) cache | ||
``http.cache.directory`` ``MIGHTSTONE_CACHE_DIRECTORY`` string ``<user_cache>/http`` The directory to store HTTP cache, only used of ``persist`` is ``true`` | ||
``http.cache.methods`` ``MIGHTSTONE_CACHE_METHODS`` list[string] ``[GET]`` HTTP verbs to cache | ||
``http.cache.status`` ``MIGHTSTONE_CACHE_STATUS`` list[int] ``[200,203,300,301,308]`` HTTP status code to cache | ||
=========================== ====================================== ============= ========================= =========== | ||
|
||
|
||
Where to store your configuration ? | ||
=================================== | ||
|
||
Mightstone will search configuration file in this order: | ||
|
||
* ``<current_directory>/mightstone.yaml`` | ||
* ``<current_directory>/mightstone.yml`` | ||
* ``<current_directory>/mightstone.json`` | ||
* ``<current_directory>/mightstone.toml`` | ||
* ``<user_config_directory>/mightstone.yaml`` | ||
* ``<user_config_directory>/mightstone.yml`` | ||
* ``<user_config_directory>/mightstone.json`` | ||
* ``<user_config_directory>/mightstone.toml`` | ||
|
||
Mighstone relies on `AppDirs <https://github.com/ActiveState/appdirs>`_ package to resolve user config directory: | ||
|
||
:: | ||
|
||
Mac OS X: ~/Library/Application Support/Mightstone | ||
Unix: ~/.config/Mightstone # or in $XDG_CONFIG_HOME, if defined | ||
Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\Mightstone\Mightstone | ||
Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\Mightstone\Mightstone | ||
Win 7 (not roaming): C:\Users\<username>\AppData\Local\Mightstone\Mightstone | ||
Win 7 (roaming): C:\Users\<username>\AppData\Roaming\Mightstone\Mightstone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Persistence | ||
*********** | ||
|
||
Mightstone uses `Beanie <https://beanie-odm.dev/>`_ as storage backend. This implies that you need to setup beanie backend before any instance of ``MightstoneDocument`` is created. | ||
|
||
``beanie.exceptions.CollectionWasNotInitialized`` exception are raised as soon as a ``MightstoneDocument`` class is instanced before ``init_beanie`` is called. Please check `Beanie Documentation <https://beanie-odm.dev/tutorial/initialization/>`_ to learn more. | ||
|
||
Automatic setup (recommended) | ||
============================= | ||
|
||
If you access to Mightstone content through the a ``Mightstone()`` this is done automatically. | ||
|
||
.. literalinclude:: ../../../examples/persistence.py | ||
:language: python | ||
|
||
This approach is recommended since our beanie implementation may evolved drastically. | ||
|
||
Manual setup | ||
============ | ||
|
||
If you wish to use base object, you’ll need to initialize beanie. | ||
|
||
.. literalinclude:: ../../../examples/persistence_minimal.py | ||
:language: python | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import asyncio | ||
|
||
from mightstone.services.cardconjurer import CardConjurer | ||
from mightstone.app import Mightstone | ||
|
||
cc = CardConjurer() | ||
|
||
|
||
async def run(): | ||
card = await cc.card("my_card.json") | ||
async def run(mightstone: Mightstone): | ||
cc = mightstone.card_conjurer | ||
card = await cc.card_async( | ||
"../tests/services/cardconjurer/samples/Dimirova Smiley.json" | ||
) | ||
# You might need to define the remote server if the card was | ||
# remotely built and no asset are present locally | ||
card.asset_root_url = "https://card-conjurer-assets.s3.us-east-1.amazonaws.com" | ||
await cc.render(card, "my_card.png") | ||
await cc.render_async(card, "my_card.png") | ||
|
||
|
||
asyncio.run(run()) | ||
mightstone = Mightstone() | ||
asyncio.run(run(mightstone)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
appname: my-stone | ||
|
||
storage: | ||
implementation: beanita | ||
directory: /tmp/my-stone/data | ||
database: mightstone | ||
|
||
# implementation: motor | ||
# uri: mongodb:///mongodsn for mongo database | ||
|
||
http: | ||
cache: | ||
directory: /tmp/my-stone/cache |
Oops, something went wrong.