python wrapper for masscode
Project description
masscode.py
A Python wrapper for massCode - a free and open source code snippets manager for developers.
Install
pip install masscode-py
Features
- Full API client for massCode
- Direct file access to massCode database
- Rich query capabilities with Python expressions
- Command-line interface (CLI) for quick access
- Type-safe models with TypedDict
- Automatic file watching and reloading
Usage
API Client
from masscode import MasscodeApi
# Initialize API client
api = MasscodeApi()
api.start_masscode() # Start massCode if not running
# Create a new snippet
snippet = api.create_snippet(
name="Hello World",
content=[{"label": "Python", "language": "python", "value": "print('Hello World')"}]
)
# Query snippets
snippets = api.query_snippet(
name="*hello*",
isFavorites=True,
query='(x["name"].startswith("py") and len(x["content"]) > 1)'
)
File Access
from masscode import MasscodeDBFile
# Initialize file client
db = MasscodeDBFile("path/to/db.json")
# Access database
folders = db.folders
snippets = db.snippets
tags = db.tags
CLI Commands
The CLI provides easy access to massCode functionality from the command line:
# List all snippets
masscode snippets
# List all folders
masscode folders
# List all tags
masscode tags
# Query commands
masscode query tag --name "python" --query '(x["name"].startswith("py"))'
masscode query folder --name "*py*" --is-open
masscode query snippet --folder "python" --tags "web" "api"
Query Options
Tag Query
--name/-n: Tag name (supports wildcards)--query/-q: Python expression to evaluate--created-at/-c: Creation timestamp--updated-at/-u: Update timestamp
Folder Query
--name/-n: Folder name (supports wildcards)--default-language/-l: Default language--parent/-p: Parent folder name or ID--is-open/-o: Is folder open flag--is-system/-s: Is system folder flag--created-at/-c: Creation timestamp--updated-at/-u: Update timestamp--query/-q: Python expression to evaluate
Snippet Query
--name/-n: Snippet name (supports wildcards)--folder/-f: Folder name or ID--is-deleted/-d: Is deleted flag--is-favorites/-v: Is favorites flag--tags/-t: Tag names or IDs (can be specified multiple times)--created-at/-C: Creation timestamp--updated-at/-u: Update timestamp--query/-q: Python expression to evaluate
Query Expressions
Query expressions are Python expressions that get evaluated on the object (x) with access to all its fields. This allows for complex filtering:
# Find folders with Python in name and are open
masscode query folder -q '(x["name"].startswith("py") and x["isOpen"])'
# Find snippets with multiple content fragments
masscode query snippet -q '(len(x["content"]) > 1 and any(c["language"] == "python" for c in x["content"]))'
# Find tags created in the last hour
masscode query tag -q '(time.time() - x["createdAt"]/1000 < 3600)'
Development
Project Structure
masscode/
├── core/
│ ├── api.py # API client implementation
│ ├── i.py # Interface definitions
│ └── discovery.py # massCode discovery utilities
├── model/
│ ├── db.py # Database models
│ └── query.py # Query models
├── utils/
│ ├── prop.py # Property utilities
│ └── proc.py # Process utilities
└── cli.py # Command-line interface
Memory Bank
The project maintains a memory bank for documentation and context:
projectbrief.md: Core requirements and goalsproductContext.md: Project purpose and user experiencesystemPatterns.md: Architecture and design patternstechContext.md: Technical details and dependenciesactiveContext.md: Current work focus and decisionsprogress.md: Project status and evolution
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file masscode_py-1.0.0.tar.gz.
File metadata
- Download URL: masscode_py-1.0.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
812d1a63db5618a2d6c56cabe3f43d2d0fcf9c93f27512ac004b4915f15e8eb0
|
|
| MD5 |
db13baa3ec84574e6ded75c09e4eafbd
|
|
| BLAKE2b-256 |
41bfe5b0cde5d371add7e055dffbcd92af9317b16d98324fa92b7c10cb18a0f2
|
Provenance
The following attestation bundles were made for masscode_py-1.0.0.tar.gz:
Publisher:
python-publish.yml on ZackaryW/masscode.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
masscode_py-1.0.0.tar.gz -
Subject digest:
812d1a63db5618a2d6c56cabe3f43d2d0fcf9c93f27512ac004b4915f15e8eb0 - Sigstore transparency entry: 226927453
- Sigstore integration time:
-
Permalink:
ZackaryW/masscode.py@87dfd2c57d5e9314e5ed8111c61b7260bf0e3a01 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ZackaryW
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@87dfd2c57d5e9314e5ed8111c61b7260bf0e3a01 -
Trigger Event:
push
-
Statement type:
File details
Details for the file masscode_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: masscode_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbf2b09cc426a2a2828307e4f6bf2e93ec09da3d29d64fac555e6abd4ed47b76
|
|
| MD5 |
b556b176cf0786f422baefb56748380d
|
|
| BLAKE2b-256 |
6c0a06e8f6b2093ccc50ef51b1c06a8e3ea25106ac2a623ac6a507335df56f9f
|
Provenance
The following attestation bundles were made for masscode_py-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on ZackaryW/masscode.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
masscode_py-1.0.0-py3-none-any.whl -
Subject digest:
fbf2b09cc426a2a2828307e4f6bf2e93ec09da3d29d64fac555e6abd4ed47b76 - Sigstore transparency entry: 226927454
- Sigstore integration time:
-
Permalink:
ZackaryW/masscode.py@87dfd2c57d5e9314e5ed8111c61b7260bf0e3a01 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ZackaryW
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@87dfd2c57d5e9314e5ed8111c61b7260bf0e3a01 -
Trigger Event:
push
-
Statement type: