Metadata-Version: 2.4
Name: sisujs-cbot
Version: 0.12.0
Summary: SisuJS CBOT serialization library for Python
Author-email: Marko Lavikainen <sisujs@sisujs.fi>
License-Expression: ISC
Project-URL: Homepage, https://cbot.sisujs.fi
Project-URL: Repository, https://gitlab.com/sisujs/sisujs.git
Project-URL: Documentation, https://cbot.sisujs.fi
Project-URL: Issues, https://gitlab.com/sisujs/sisujs/-/issues
Keywords: cbot,serialization,binary,sisujs
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.12.5
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: flake8>=6.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: pytest-xdist>=3.8.0; extra == "dev"
Requires-Dist: deepdiff>=9.1.0; extra == "dev"
Dynamic: license-file

# SisuJs CBOT (Character Based Object Transport)

[![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-ISC-green.svg)](LICENSE)

CBOT (Character Based Object Transport) protocol is a character-based data transfer protocol designed to replace JSON in web development. Its primary goal is to provide a more robust and richer model for transporting structured data between server and browser.

This protocol is not intended to compete with or replace any binary protocols used in server-to-server communications, but rather to create a better alternative. Therefore, the design goals are always aligned with the JavaScript environment in browsers, even when implemented on other platforms.

## Quick links

  - [Homepage](https://cbot.sisujs.fi/)
  - [Tutorial](https://cbot.sisujs.fi/tutorial/python-tutorial/)
 
 ### Java Support
  
  - [Tutorial](https://cbot.sisujs.fi/tutorial/java-tutorial/)
  - [API Documentation](https://www.javadoc.io/doc/fi.sisujs/cbot/0.11.0/index.html)
   
 ### TypeScript/JavaScript Support

  - [JavaScript Tutorial](https://cbot.sisujs.fi/tutorial/javascript-tutorial/)
  - [TypeScript Tutorial](https://cbot.sisujs.fi/tutorial/typescript-tutorial/)
  - [API documentation](https://gitlab.com/sisujs/sisujs/-/tree/main/js/meta-cbot/typedoc)
  
## Installation

### Prerequisites

- Python 3.8+
- pip (Python package manager)
- virtualenv (recommended for isolation)

### Create and Activate Virtual Environment

```bash
# Create a virtual environment
python3 -m venv venv

# Activate the virtual environment
# On Linux/macOS:
source venv/bin/activate

# On Windows:
venv\Scripts\activate
```

### From source (local development)

```bash
# Clone the repository
git clone https://gitlab.com/sisujs/sisujs.git
cd sisujs/cbot/python

# Install in development mode (recommended)
pip install -e .
```

### As a local package

```bash
# Install the package locally
pip install .
```

### For development with dependencies

```bash
pip install -e ".[dev]"
```

### Using in Other Projects

```bash
# In your other project's virtual environment:
# Option 1: Install development version (recommended)
pip install -e /path/to/sisujs-cbot/python

# Option 2: Use PYTHONPATH temporarily
export PYTHONPATH=/path/to/sisujs-cbot/python/src:$PYTHONPATH
python your_script.py

# Option 3: Build and install wheel
cd /path/to/sisujs-cbot/python
python -m build
pip install dist/sisujs_cbot-*.whl
```

## Usage

```python
from sisujs_cbot import Cbot, CbotOptions
from datetime import datetime

# Create a CBOT instance
cbot = Cbot(CbotOptions())

# Serialize data
data = {
  "name": "John Smith",
  "age": 41.0,
  "birthday": date(1985, 9, 16),
  "address": {
    "street": "Second Avenue",
    "postalCode": "1356-A",
    "city": "Yorkistan"
  },
  "isNiceGuy": True,
  "hobbies": [
    "Playing cards",
    "Shopping",
    "Asking odd questions"
  ]
}
serialized = cbot.serialize(data)

# Deserialize data
deserialized = cbot.deserialize(serialized)
assert data == deserialized
```

## Features

- Supports primitive types (strings, numbers, booleans, null)
- Date and time support
- Collections (arrays, sets)
- Custom object support
- Efficient binary format

## Development

```bash
# Run tests
pytest

# Format code
black src/ tests/

# Lint code
flake8 src/ tests/

# Type checking
mypy src/
```

## Using CBOT in Other Local Projects

To use this development version of CBOT as a dependency in another local project:

### Option 1: Install in Development Mode (Recommended)

```bash
# In this CBOT project directory
cd /path/to/sisujs-cbot/python
pip install -e .

# In your other project
# The CBOT package is now available system-wide
python3 -c "from sisujs_cbot import Cbot; print('CBOT imported successfully')"
```

### Option 2: Direct Local Path Reference

Add this to your other project's `requirements.txt`:
```
-e /path/to/sisujs-cbot/python
```

Then install with:
```bash
pip install -r requirements.txt
```

### Option 3: Using PYTHONPATH

```bash
# In your other project
export PYTHONPATH=/path/to/sisujs-cbot/python/src:$PYTHONPATH
python3 your_script.py
```

## Important Notes for Local Development

- **Use virtual environments** to avoid conflicts between projects
- **Development mode** (`pip install -e`) reflects code changes immediately
- **Version compatibility** ensures your projects use the same Python version
- **Dependency management** keeps your environment consistent

## License

This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
