salomos


Namesalomos JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://python.dobyemail.com
SummarySalomos is a Python package that provides a domain-specific language (DSL) processor for executing commands based on sentences stored in a SQLite database.
upload_time2024-10-15 14:30:34
maintainerNone
docs_urlNone
authorTom Sapletta
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Salomos

Salomos is a Python package that provides utilities for processing domain-specific languages (DSLs) and managing associated data.

## Installation

To install Salomos, simply run:

```
pip install salomos
```

## Key Components

### DBManager

The `DBManager` class (`db_manager.py`) handles database operations for the Salomos package. It provides methods to:

- Initialize the database
- Load sentences and objects from the database
- Close the database connection

### DSLProcessor 

The `DSLProcessor` class (`dsl_processor.py`) is responsible for processing DSL sentences. It offers functionality to:

- Import modules and resolve class names
- Find matching elements based on a name
- Process a DSL sentence and execute corresponding actions
- Perform operations like print, add, concatenate

## Usage Example

Here's a basic example of how to use the Salomos package:

```python
from salomos.db_manager import DBManager
from salomos.dsl_processor import DSLProcessor
from dotenv import load_dotenv
import os

load_dotenv()

# Get the logger level from environment variable
LOGGER_LEVEL = os.getenv("LOGGER_LEVEL", "INFO")

# Initialize the database manager
db = DBManager("path/to/database.db")
db.init_database()

# Create a DSL processor instance
processor = DSLProcessor(db)

# Load a DSL sentence and objects from the database
sentence = db.load_sentence()
objects = db.load_objects()

# Process the DSL sentence
result = processor.process_sentence(sentence, objects)

# Print the result
processor.print(result)

# Close the database connection
db.close()
```

This example demonstrates the typical workflow of using Salomos:

1. Load environment variables from a `.env` file using `load_dotenv()`.

2. Get the logger level from the `LOGGER_LEVEL` environment variable, defaulting to "INFO" if not set.

3. Initialize a `DBManager` with the path to your database file and call `init_database()`.

4. Create a `DSLProcessor` instance, passing it the database manager. 

5. Load a DSL sentence and any associated objects from the database using the `load_sentence()` and `load_objects()` methods of the database manager.

6. Process the loaded sentence using the `process_sentence()` method of the DSL processor, passing the sentence and objects. This returns the result of executing the sentence.

7. Use the `print()` method of the DSL processor to display the result.

8. Close the database connection when finished using the `close()` method of the database manager.

## Running the Example Script

The `salomos.py` script provides an example of how to use the Salomos package. It demonstrates:

1. Creating instances of `DBManager` and `DSLProcessor`
2. Manually adding example functions and modules to the `imported_elements` of the processor
3. Populating the database with test data (DSL sentences and objects)
4. Running the processor to execute the DSL sentences
5. Handling keyboard interrupts and closing the database connection

To run the example script from the command line:

1. Ensure you have installed the Salomos package and its dependencies
2. Open a terminal or command prompt
3. Navigate to the directory containing `salomos.py`
4. Run the script using the command:

   ```
   python salomos.py
   ```

   Optionally, you can provide the path to a custom database file as a command-line argument:

   ```
   python salomos.py path/to/custom_database.db
   ```

   If no database file is specified, it will default to "dsl_database.db" in the current directory.

The script will process the test DSL sentences from the specified database and print the results. You can modify the test data or add your own DSL sentences and objects to experiment with the package.

Press `Ctrl+C` to interrupt the script and exit.

## Example DSL Sentences and Executed Functions/Methods/Classes

The `salomos.py` script populates the database with some test DSL sentences. Here's a table showing the example sentences and the corresponding functions, methods, or classes that are executed:

| DSL Sentence                                | Executed Function/Method/Class                                 |
|---------------------------------------------|----------------------------------------------------------------|
| print Hello World                           | `DSLProcessor.print("Hello", "World")`                         |
| add 5 10 15                                 | `DSLProcessor.add(5, 10, 15)`                                  |
| Example Module greet John Doe               | `ExampleModule.greet("John", "Doe")`                           |
| Example Module Math Operations multiply 2 3 4 | `ExampleModule.MathOperations.multiply(2, 3, 4)`               |
| example function 10 20                      | `example_function(10, 20)`                                     |
| concatenate Welcome to the DSL world        | `DSLProcessor.concatenate("Welcome", "to", "the", "DSL", "world")` |

These example sentences demonstrate how the DSL processor interprets and executes different types of commands, including standalone functions, class methods, and module functions.

## Contributing

Contributions are welcome! Please see the [contributing guidelines](CONTRIBUTING.md) for more details.

## License

This project is licensed under the [MIT License](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://python.dobyemail.com",
    "name": "salomos",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Tom Sapletta",
    "author_email": "info@softreck.dev",
    "download_url": "https://files.pythonhosted.org/packages/62/26/bceb91571db59ea6e2c514b20a1d662becaa3e162f507d2da58f19637960/salomos-0.2.2.tar.gz",
    "platform": null,
    "description": "# Salomos\n\nSalomos is a Python package that provides utilities for processing domain-specific languages (DSLs) and managing associated data.\n\n## Installation\n\nTo install Salomos, simply run:\n\n```\npip install salomos\n```\n\n## Key Components\n\n### DBManager\n\nThe `DBManager` class (`db_manager.py`) handles database operations for the Salomos package. It provides methods to:\n\n- Initialize the database\n- Load sentences and objects from the database\n- Close the database connection\n\n### DSLProcessor \n\nThe `DSLProcessor` class (`dsl_processor.py`) is responsible for processing DSL sentences. It offers functionality to:\n\n- Import modules and resolve class names\n- Find matching elements based on a name\n- Process a DSL sentence and execute corresponding actions\n- Perform operations like print, add, concatenate\n\n## Usage Example\n\nHere's a basic example of how to use the Salomos package:\n\n```python\nfrom salomos.db_manager import DBManager\nfrom salomos.dsl_processor import DSLProcessor\nfrom dotenv import load_dotenv\nimport os\n\nload_dotenv()\n\n# Get the logger level from environment variable\nLOGGER_LEVEL = os.getenv(\"LOGGER_LEVEL\", \"INFO\")\n\n# Initialize the database manager\ndb = DBManager(\"path/to/database.db\")\ndb.init_database()\n\n# Create a DSL processor instance\nprocessor = DSLProcessor(db)\n\n# Load a DSL sentence and objects from the database\nsentence = db.load_sentence()\nobjects = db.load_objects()\n\n# Process the DSL sentence\nresult = processor.process_sentence(sentence, objects)\n\n# Print the result\nprocessor.print(result)\n\n# Close the database connection\ndb.close()\n```\n\nThis example demonstrates the typical workflow of using Salomos:\n\n1. Load environment variables from a `.env` file using `load_dotenv()`.\n\n2. Get the logger level from the `LOGGER_LEVEL` environment variable, defaulting to \"INFO\" if not set.\n\n3. Initialize a `DBManager` with the path to your database file and call `init_database()`.\n\n4. Create a `DSLProcessor` instance, passing it the database manager. \n\n5. Load a DSL sentence and any associated objects from the database using the `load_sentence()` and `load_objects()` methods of the database manager.\n\n6. Process the loaded sentence using the `process_sentence()` method of the DSL processor, passing the sentence and objects. This returns the result of executing the sentence.\n\n7. Use the `print()` method of the DSL processor to display the result.\n\n8. Close the database connection when finished using the `close()` method of the database manager.\n\n## Running the Example Script\n\nThe `salomos.py` script provides an example of how to use the Salomos package. It demonstrates:\n\n1. Creating instances of `DBManager` and `DSLProcessor`\n2. Manually adding example functions and modules to the `imported_elements` of the processor\n3. Populating the database with test data (DSL sentences and objects)\n4. Running the processor to execute the DSL sentences\n5. Handling keyboard interrupts and closing the database connection\n\nTo run the example script from the command line:\n\n1. Ensure you have installed the Salomos package and its dependencies\n2. Open a terminal or command prompt\n3. Navigate to the directory containing `salomos.py`\n4. Run the script using the command:\n\n   ```\n   python salomos.py\n   ```\n\n   Optionally, you can provide the path to a custom database file as a command-line argument:\n\n   ```\n   python salomos.py path/to/custom_database.db\n   ```\n\n   If no database file is specified, it will default to \"dsl_database.db\" in the current directory.\n\nThe script will process the test DSL sentences from the specified database and print the results. You can modify the test data or add your own DSL sentences and objects to experiment with the package.\n\nPress `Ctrl+C` to interrupt the script and exit.\n\n## Example DSL Sentences and Executed Functions/Methods/Classes\n\nThe `salomos.py` script populates the database with some test DSL sentences. Here's a table showing the example sentences and the corresponding functions, methods, or classes that are executed:\n\n| DSL Sentence                                | Executed Function/Method/Class                                 |\n|---------------------------------------------|----------------------------------------------------------------|\n| print Hello World                           | `DSLProcessor.print(\"Hello\", \"World\")`                         |\n| add 5 10 15                                 | `DSLProcessor.add(5, 10, 15)`                                  |\n| Example Module greet John Doe               | `ExampleModule.greet(\"John\", \"Doe\")`                           |\n| Example Module Math Operations multiply 2 3 4 | `ExampleModule.MathOperations.multiply(2, 3, 4)`               |\n| example function 10 20                      | `example_function(10, 20)`                                     |\n| concatenate Welcome to the DSL world        | `DSLProcessor.concatenate(\"Welcome\", \"to\", \"the\", \"DSL\", \"world\")` |\n\nThese example sentences demonstrate how the DSL processor interprets and executes different types of commands, including standalone functions, class methods, and module functions.\n\n## Contributing\n\nContributions are welcome! Please see the [contributing guidelines](CONTRIBUTING.md) for more details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Salomos is a Python package that provides a domain-specific language (DSL) processor for executing commands based on sentences stored in a SQLite database.",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://python.dobyemail.com"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31c97eaee183aa763ba787d2b043b4bf6b2be28dde55e63e8f080178441a4f2b",
                "md5": "81c29d357c8259b0a5a1685eaadc741d",
                "sha256": "dc28782f2af8236a16aa92be3253e27c21da78e9a347a31b56f788ded6a62073"
            },
            "downloads": -1,
            "filename": "salomos-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "81c29d357c8259b0a5a1685eaadc741d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11539,
            "upload_time": "2024-10-15T14:30:33",
            "upload_time_iso_8601": "2024-10-15T14:30:33.184316Z",
            "url": "https://files.pythonhosted.org/packages/31/c9/7eaee183aa763ba787d2b043b4bf6b2be28dde55e63e8f080178441a4f2b/salomos-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6226bceb91571db59ea6e2c514b20a1d662becaa3e162f507d2da58f19637960",
                "md5": "80cf3496dbca1f26ebcdb71f4d8513b6",
                "sha256": "6b86ff59031c62d74fc5c41c57be1776fbdb0c31239c6558ff377f865630e040"
            },
            "downloads": -1,
            "filename": "salomos-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "80cf3496dbca1f26ebcdb71f4d8513b6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12552,
            "upload_time": "2024-10-15T14:30:34",
            "upload_time_iso_8601": "2024-10-15T14:30:34.365808Z",
            "url": "https://files.pythonhosted.org/packages/62/26/bceb91571db59ea6e2c514b20a1d662becaa3e162f507d2da58f19637960/salomos-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 14:30:34",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "salomos"
}
        
Elapsed time: 0.63291s