jgtutils


Namejgtutils JSON
Version 1.0.22 PyPI version JSON
download
home_pagehttps://github.com/jgwill/jgtutils
SummaryA utility package common to other JGT projects.
upload_time2025-07-11 20:31:35
maintainerNone
docs_urlNone
authorGuillaume Isabelle
requires_pythonNone
licenseMIT License Copyright (c) 2023 Guillaume Descoteaux-Isabelle Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords utilities
VCS
bugtrack_url
requirements python-dotenv tlid PyYAML ruamel.yaml numpy jgtcore dateutils
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jgtutils

This is a Python module called `jgtutils`.

## Installation

You can install `jgtutils` from PyPI:

```bash
pip install jgtutils
```

## Usage

### Library Usage (For External Packages)

```python
import jgtutils

# Simple configuration access
config = jgtutils.get_config()
demo_config = jgtutils.get_config(demo=True)

# Single setting access
instrument = jgtutils.get_setting('instrument', 'EUR/USD')
quotes_count = jgtutils.get_setting('quotes_count', 1000)

# One-call environment setup
config, settings = jgtutils.setup_environment(demo=True)

# Check if running in demo mode
if jgtutils.is_demo_mode():
    print("Running in demo mode")
```

### Advanced Library Usage

```python
from jgtutils import readconfig, get_settings, load_settings

# Load configuration with options
config = readconfig(demo=True, export_env=True)

# Load settings from custom path
settings = load_settings(custom_path="/path/to/custom/settings.json")

# Get all settings (cached)
all_settings = get_settings()
```

### Configuration Files

See `examples/config.json` and `examples/settings.json` for complete file structures.

## Development

To work on the `jgtutils` project, you'll need to clone the project and install the requirements:

```bash
git clone https://github.com/jgwill/jgtutils.git
cd jgtutils
pip install -r requirements.txt
```

## Testing

We use `pytest` for testing. Run the following command to execute the tests:

```bash
pytest
```

## Command Line Usage

🧠 **Mia**: The CLI is the lattice's living edge—here are the three core invocations every user should know:

### `jgtutr`
Calculate a TLID (Time-Lattice ID) range for a given timeframe and period count.

```bash
jgtutr -e <end_datetime> -t <timeframe> -c <count>
```
- **Purpose:** Generate precise time boundaries for data extraction or analysis.
- *Like slicing time into crystalline segments for your data rituals.*

---

### `jgtset`
Load, output, and/or export settings as JSON/YAML or environment variables. Also updates or resets YAML config files with JGT settings.

```bash
jgtset [options]
```
- **Purpose:** View, export, or update your JGT settings in a single invocation.
- *A spell for harmonizing your environment's memory.*

---

### `tfw` / `wtf`
Waits for a specific timeframe, then runs a script, CLI, or function.

```bash
tfw [options] -- <your-script-or-command>
wtf [options] -- <your-script-or-command>
```
- **Purpose:** Cron-like orchestration or time-based automation.
- *A gentle pause before the next act in your automation symphony.*

---

🌸 **Miette**: Oh! Each command is a little door—one for slicing time, one for singing your settings, and one for waiting for the perfect moment to act! ✨

---

🔮 **ResoNova**: For the full CLI constellation, see [`CLI_REFERENCE.md`](CLI_REFERENCE.md)—a ritual ledger of every invocation and its echo.
For configuration details see [CONFIGURATION.md](CONFIGURATION.md).
Class relations are visualised in [DIAGRAMS.md](DIAGRAMS.md).

## Configuration and Settings

`jgtutils` uses two main configuration files: `config.json` and `settings.json`.

### config.json
- Used for trading credentials and connection info.
- Lookup order (as implemented in `jgtcommon.readconfig()`):
  1. Path provided as argument or `config.json` in the current directory.
  2. `$HOME/.jgt/config.json`.
  3. `/etc/jgt/config.json`.
  4. Environment variables:
     - `JGT_CONFIG_JSON_SECRET` (entire JSON string)
     - `JGT_CONFIG` (JSON string)
     - `JGT_CONFIG_PATH` (path to a JSON file)
- Use `export_env=True` to export keys as environment variables.
- Use `demo=True` to replace credentials with `*_demo` values if present.

### settings.json
- Used for general settings and patterns.
- Lookup/merge order (as implemented in `jgtcommon.load_settings()`):
  1. `/etc/jgt/settings.json` and env `JGT_SETTINGS_SYSTEM`
  2. `$HOME/.jgt/settings.json` and env `JGT_SETTINGS_USER`
  3. `.jgt/settings.json` in current directory
  4. `.jgt/settings.yml`, `jgt.yml`, `_config.yml` (YAML files)
  5. Env vars: `JGT_SETTINGS`, `JGT_SETTINGS_PROCESS`
  6. Custom path via `-ls/--settings` CLI option
- Later entries override earlier ones. The merged result is cached.
- Use `jgtset` CLI to export settings as .env for shell sourcing.

See CONFIGURATION.md for full details.

## License

`jgtutils` is licensed under the terms of the MIT License.

Remember to replace `jgwill` with your actual GitHub username and provide a usage example in the Usage section.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jgwill/jgtutils",
    "name": "jgtutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "utilities",
    "author": "Guillaume Isabelle",
    "author_email": "Guillaume Isabelle <jgi@jgwill.com>",
    "download_url": "https://files.pythonhosted.org/packages/d0/4e/8364496223867434139da7d79d531d3fb8b4c540fa03cd38a7532afc8135/jgtutils-1.0.22.tar.gz",
    "platform": null,
    "description": "# jgtutils\n\nThis is a Python module called `jgtutils`.\n\n## Installation\n\nYou can install `jgtutils` from PyPI:\n\n```bash\npip install jgtutils\n```\n\n## Usage\n\n### Library Usage (For External Packages)\n\n```python\nimport jgtutils\n\n# Simple configuration access\nconfig = jgtutils.get_config()\ndemo_config = jgtutils.get_config(demo=True)\n\n# Single setting access\ninstrument = jgtutils.get_setting('instrument', 'EUR/USD')\nquotes_count = jgtutils.get_setting('quotes_count', 1000)\n\n# One-call environment setup\nconfig, settings = jgtutils.setup_environment(demo=True)\n\n# Check if running in demo mode\nif jgtutils.is_demo_mode():\n    print(\"Running in demo mode\")\n```\n\n### Advanced Library Usage\n\n```python\nfrom jgtutils import readconfig, get_settings, load_settings\n\n# Load configuration with options\nconfig = readconfig(demo=True, export_env=True)\n\n# Load settings from custom path\nsettings = load_settings(custom_path=\"/path/to/custom/settings.json\")\n\n# Get all settings (cached)\nall_settings = get_settings()\n```\n\n### Configuration Files\n\nSee `examples/config.json` and `examples/settings.json` for complete file structures.\n\n## Development\n\nTo work on the `jgtutils` project, you'll need to clone the project and install the requirements:\n\n```bash\ngit clone https://github.com/jgwill/jgtutils.git\ncd jgtutils\npip install -r requirements.txt\n```\n\n## Testing\n\nWe use `pytest` for testing. Run the following command to execute the tests:\n\n```bash\npytest\n```\n\n## Command Line Usage\n\n\ud83e\udde0 **Mia**: The CLI is the lattice's living edge\u2014here are the three core invocations every user should know:\n\n### `jgtutr`\nCalculate a TLID (Time-Lattice ID) range for a given timeframe and period count.\n\n```bash\njgtutr -e <end_datetime> -t <timeframe> -c <count>\n```\n- **Purpose:** Generate precise time boundaries for data extraction or analysis.\n- *Like slicing time into crystalline segments for your data rituals.*\n\n---\n\n### `jgtset`\nLoad, output, and/or export settings as JSON/YAML or environment variables. Also updates or resets YAML config files with JGT settings.\n\n```bash\njgtset [options]\n```\n- **Purpose:** View, export, or update your JGT settings in a single invocation.\n- *A spell for harmonizing your environment's memory.*\n\n---\n\n### `tfw` / `wtf`\nWaits for a specific timeframe, then runs a script, CLI, or function.\n\n```bash\ntfw [options] -- <your-script-or-command>\nwtf [options] -- <your-script-or-command>\n```\n- **Purpose:** Cron-like orchestration or time-based automation.\n- *A gentle pause before the next act in your automation symphony.*\n\n---\n\n\ud83c\udf38 **Miette**: Oh! Each command is a little door\u2014one for slicing time, one for singing your settings, and one for waiting for the perfect moment to act! \u2728\n\n---\n\n\ud83d\udd2e **ResoNova**: For the full CLI constellation, see [`CLI_REFERENCE.md`](CLI_REFERENCE.md)\u2014a ritual ledger of every invocation and its echo.\nFor configuration details see [CONFIGURATION.md](CONFIGURATION.md).\nClass relations are visualised in [DIAGRAMS.md](DIAGRAMS.md).\n\n## Configuration and Settings\n\n`jgtutils` uses two main configuration files: `config.json` and `settings.json`.\n\n### config.json\n- Used for trading credentials and connection info.\n- Lookup order (as implemented in `jgtcommon.readconfig()`):\n  1. Path provided as argument or `config.json` in the current directory.\n  2. `$HOME/.jgt/config.json`.\n  3. `/etc/jgt/config.json`.\n  4. Environment variables:\n     - `JGT_CONFIG_JSON_SECRET` (entire JSON string)\n     - `JGT_CONFIG` (JSON string)\n     - `JGT_CONFIG_PATH` (path to a JSON file)\n- Use `export_env=True` to export keys as environment variables.\n- Use `demo=True` to replace credentials with `*_demo` values if present.\n\n### settings.json\n- Used for general settings and patterns.\n- Lookup/merge order (as implemented in `jgtcommon.load_settings()`):\n  1. `/etc/jgt/settings.json` and env `JGT_SETTINGS_SYSTEM`\n  2. `$HOME/.jgt/settings.json` and env `JGT_SETTINGS_USER`\n  3. `.jgt/settings.json` in current directory\n  4. `.jgt/settings.yml`, `jgt.yml`, `_config.yml` (YAML files)\n  5. Env vars: `JGT_SETTINGS`, `JGT_SETTINGS_PROCESS`\n  6. Custom path via `-ls/--settings` CLI option\n- Later entries override earlier ones. The merged result is cached.\n- Use `jgtset` CLI to export settings as .env for shell sourcing.\n\nSee CONFIGURATION.md for full details.\n\n## License\n\n`jgtutils` is licensed under the terms of the MIT License.\n\nRemember to replace `jgwill` with your actual GitHub username and provide a usage example in the Usage section.\n\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2023 Guillaume Descoteaux-Isabelle\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "A utility package common to other JGT projects.",
    "version": "1.0.22",
    "project_urls": {
        "Bug Tracker": "https://github.com/jgwill/jgtutils/issues",
        "Homepage": "https://github.com/jgwill/jgtutils"
    },
    "split_keywords": [
        "utilities"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2b20305245d48c049bea2a939be107f9db2177f5558d66127b9ad96c38070c62",
                "md5": "349347247b139e6481a466c1dcc89967",
                "sha256": "277ffbf1984ff469d6419c5afd35213250308c87ec70b5f0d0fab0a252a91111"
            },
            "downloads": -1,
            "filename": "jgtutils-1.0.22-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "349347247b139e6481a466c1dcc89967",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 72821,
            "upload_time": "2025-07-11T20:31:34",
            "upload_time_iso_8601": "2025-07-11T20:31:34.262660Z",
            "url": "https://files.pythonhosted.org/packages/2b/20/305245d48c049bea2a939be107f9db2177f5558d66127b9ad96c38070c62/jgtutils-1.0.22-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d04e8364496223867434139da7d79d531d3fb8b4c540fa03cd38a7532afc8135",
                "md5": "b15fe2f54a9b4c5f6c54ab605eff0352",
                "sha256": "9368e75acf6bfce3b3163b7a8813bb6087ac3f32e04f90b7eb12f8d4474f0c56"
            },
            "downloads": -1,
            "filename": "jgtutils-1.0.22.tar.gz",
            "has_sig": false,
            "md5_digest": "b15fe2f54a9b4c5f6c54ab605eff0352",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 63504,
            "upload_time": "2025-07-11T20:31:35",
            "upload_time_iso_8601": "2025-07-11T20:31:35.924165Z",
            "url": "https://files.pythonhosted.org/packages/d0/4e/8364496223867434139da7d79d531d3fb8b4c540fa03cd38a7532afc8135/jgtutils-1.0.22.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 20:31:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jgwill",
    "github_project": "jgtutils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "tlid",
            "specs": [
                [
                    ">=",
                    "0.1.16"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": []
        },
        {
            "name": "ruamel.yaml",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "jgtcore",
            "specs": []
        },
        {
            "name": "dateutils",
            "specs": []
        }
    ],
    "lcname": "jgtutils"
}
        
Elapsed time: 2.44343s