semvec/pypi-packages huggingface dataset:
handle-exception 1.0.1
A Python library for handling exceptions in a clean and organized way

# HandleException - Python Wrapper Class to Catch Exceptions

[![PyPI version](https://badge.fury.io/py/handle-exception.svg)](https://badge.fury.io/py/handle-exception)

HandleException is a Python wrapper class that helps to catch exceptions and raise them to an upper level. With HandleException, you can easily wrap any function that you want to monitor for exceptions and handle them as desired.

## Installation
```
pip install handle-exception
```
## Usage
To use HandleException, simply decorate the function that you want to wrap with the HandleException decorator. For example:

```
from handle_exception import HandleException

@HandleException
def my_function():
    raise ValueError("Test exception")
```
In this example, if the function my_function raises an exception, HandleException will catch it and raise it to the upper level. This way, you can handle exceptions in a centralized way, instead of having to write try-except blocks in multiple places.

## Custom Exceptions
HandleException also allows you to catch specific custom exceptions by passing a list of exception classes as an argument to the ExceptionRaiser decorator. For example:
```
from handle_exception import ExceptionRaiser

class CustomException(Exception):
    pass

@ExceptionRaiser(exceptions=[CustomException])
def my_function():
    raise CustomException("This is a custom exception.")
```
In this example, the function my_function raises a custom exception, CustomException, which will be caught by HandleException.

## Example
```
from handle_exception import HandleException

@HandleException
def divide(a, b):
    return a / b

result = divide(10, 0)
print(result)
```
In this example, the divide function is decorated with the HandleException decorator. This means that any exceptions raised in the divide function will be caught and handled by the HandleException class. The code is much cleaner and easier to understand, as it doesn't contain a try-except block or have to worry about handling exceptions manually.
## Contributing
We welcome contributions to HandleException! If you'd like to contribute, please follow these steps:

1. Fork the repository.
2. Create a new branch for your changes.
3. Make your changes and write tests for them.
4. Submit a pull request.

## License

HandleException is released under the MIT License.

We welcome contributions to this library. If you have an idea for a new feature or have found a bug, please open an issue on Github.

## Buy me a Coffee
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/dillibabukadati)
py-metarium-decoder 0.0.1.41
Python package for Metarium Decoder
Requires Python: >=3.9

# py-metarium-decoder

# Usage


## 1. Virtual environment

### 1.1. Install virtual environment

```
pip3 install virtualenv
```

### 1.2. Create virtual environment for metarium

```
python3 -m venv virtualenv ~/venv-metarium-decoder
```

### 1.3. Activate metarium virtual environment

```
source ~/.venv-py-metarium-decoder/bin/activate
```

## 2. Install

### 2.1. Install metarium-decoder

```
pip install py-metarium-decoder
```

### 2.2. Install metarium

```
pip install py-metarium
```

### 2.3. Install substrate client

```
pip install substrate-interface==1.4.0
```

## 3. Example usage

### 3.1. Create a simple Listener
Create a listener script called `simple-listener.py` with the following code block
```
from py_metarium import (PAST, FUTURE)
from py_metarium_decoder import Decoder


class Listener:

    def __init__(self, url=None) -> None:
        self.__decoder = Decoder(url)
    
    def info(self):
        return self.__decoder.info()

    def listen(self, direction, block_hash=None, block_count=None):
        return self.__decoder.decode_metarium(direction, block_hash=block_hash, block_count=block_count)


metarium_node_url = "ws://127.0.0.1:9944"

# listen to past events and print the blocks in reverse order
listener = Listener(metarium_node_url)
print("listening ...")

with open('metarium_blocks.txt', 'w') as f:
    for block, has_metarium_call in listener.listen(PAST, None, None):
        print(f"{block['header']['number']}")
        if has_metarium_call:
            f.write(f"\n{block}")
```
Run the listener script
```
python simple-listener.py
```

## 4. Teardown

Please remember to deactivate the virtual environment after usage

```
deactivate
```
py-metarium 0.0.2.51
Python package for Metarium
Requires Python: >=3.9

# py-metarium

Python SDK for Metarium

# Usage


## 1. Virtual environment

### 1.1. Install virtual environment

```
pip3 install virtualenv
```

### 1.2. Create virtual environment for metarium

```
python3 -m venv virtualenv ~/.metarium-venv
```

### 1.3. Activate metarium virtual environment

```
source ~/.metarium-venv/bin/activate
```

## 2. Install

### 2.1. Install metarium

```
pip install py-metarium
```

### 2.2. Install substrate client

```
pip install substrate-interface==1.4.0
```

## 3. Example usage

### 3.1. Create a simple Listener
Create a listener script called `simple-listener.py` with the following code block
```
from py_metarium import (
    Metarium,
    PAST, FUTURE, LABEL_SUBSTRATE
)

NODE_URL = "ws://127.0.0.1:9944"

class Listener:

    def __init__(self, url=None) -> None:
        url = url or None
        assert url is not None
        metarium_initialization_parameters = {
            "chain": {
                "type": LABEL_SUBSTRATE,
                "parameters": {
                    "url" : NODE_URL
                }
            }
        }

        m = Metarium(**metarium_initialization_parameters)

        self.metarium_node = m.chain
    
    def info(self):
        return self.metarium_node.info()

    def listen(self, direction, block_hash=None, block_count=None):
        return self.metarium_node.get_blocks(direction=direction, block_hash=block_hash, block_count=block_count)

listener = Listener(NODE_URL)
print("listening ...")

# listen to past events and print the blocks in reverse order
for block, has_metarium_call in listener.listen(PAST, None, None):
    print(f"\n{block}")
```
Run the listener script
```
python simple-listener.py
```

## 4. Teardown

Please remember to deactivate the virtual environment after usage

```
deactivate
```