Yuvacodes 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yuvacodes-0.1.0/LICENSE +21 -0
- yuvacodes-0.1.0/PKG-INFO +443 -0
- yuvacodes-0.1.0/README.md +415 -0
- yuvacodes-0.1.0/pyproject.toml +47 -0
- yuvacodes-0.1.0/setup.cfg +4 -0
- yuvacodes-0.1.0/src/Yuvacodes.egg-info/PKG-INFO +443 -0
- yuvacodes-0.1.0/src/Yuvacodes.egg-info/SOURCES.txt +20 -0
- yuvacodes-0.1.0/src/Yuvacodes.egg-info/dependency_links.txt +1 -0
- yuvacodes-0.1.0/src/Yuvacodes.egg-info/entry_points.txt +2 -0
- yuvacodes-0.1.0/src/Yuvacodes.egg-info/requires.txt +6 -0
- yuvacodes-0.1.0/src/Yuvacodes.egg-info/top_level.txt +1 -0
- yuvacodes-0.1.0/src/mycodes/__init__.py +42 -0
- yuvacodes-0.1.0/src/mycodes/cli.py +137 -0
- yuvacodes-0.1.0/src/mycodes/client.py +174 -0
- yuvacodes-0.1.0/src/mycodes/config.py +192 -0
- yuvacodes-0.1.0/src/mycodes/exceptions.py +54 -0
- yuvacodes-0.1.0/src/mycodes/jupyter_extension.py +149 -0
- yuvacodes-0.1.0/src/mycodes/registry.py +272 -0
- yuvacodes-0.1.0/tests/test_cli.py +106 -0
- yuvacodes-0.1.0/tests/test_client.py +179 -0
- yuvacodes-0.1.0/tests/test_jupyter.py +81 -0
- yuvacodes-0.1.0/tests/test_registry.py +220 -0
yuvacodes-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MyCodes Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
yuvacodes-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Yuvacodes
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A personal cloud-based code library for Python and Jupyter Notebooks
|
|
5
|
+
Author: MyCodes Contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: code-library,jupyter,snippets,cloud-storage,github,ipython
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Framework :: IPython
|
|
18
|
+
Classifier: Framework :: Jupyter
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Provides-Extra: jupyter
|
|
24
|
+
Requires-Dist: ipython>=7.0.0; extra == "jupyter"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# MyCodes π
|
|
30
|
+
|
|
31
|
+
> **Your personal cloud-based Python code library.** Store code snippets online on GitHub, assign numeric IDs, and retrieve or inject them seamlessly into any computer or Jupyter Notebook over HTTPS with `pip install mycodes`.
|
|
32
|
+
|
|
33
|
+
[](https://opensource.org/licenses/MIT)
|
|
34
|
+
[](https://www.python.org/downloads/)
|
|
35
|
+
[](https://jupyter.org/)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 1. What is MyCodes?
|
|
40
|
+
|
|
41
|
+
When working across multiple computers, remote servers, Google Colab, or Jupyter notebooks, sharing reusable algorithms, helper routines, and starter templates is often clumsy.
|
|
42
|
+
|
|
43
|
+
**MyCodes** decouples your code library from local storage:
|
|
44
|
+
- **Zero local storage needed**: You don't have to keep a clone of your code library on every machine.
|
|
45
|
+
- **GitHub as Cloud Storage**: Store clean Python files (e.g. `101.py`, `102.py`) in a public GitHub repository with an `index.json` catalog.
|
|
46
|
+
- **Instant Retrieval**: Download source code strings or inject them directly into Jupyter cells using intuitive IDs (`get_code(101)` or `%load_code 101`).
|
|
47
|
+
- **No Hard-coded Usernames**: Easily configure your personal repository via Python, environment variables, or CLI.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 2. Architecture
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
ββββββββββββββββββββββββββββββββ
|
|
55
|
+
β GitHub β
|
|
56
|
+
β Cloud Code Storage β
|
|
57
|
+
β β
|
|
58
|
+
β codes/ β
|
|
59
|
+
β βββ 001.py β
|
|
60
|
+
β βββ 002.py β
|
|
61
|
+
β βββ 101.py β
|
|
62
|
+
β βββ ... β
|
|
63
|
+
β index.json β
|
|
64
|
+
ββββββββββββββββ¬ββββββββββββββββ
|
|
65
|
+
β
|
|
66
|
+
β HTTPS (raw.githubusercontent.com)
|
|
67
|
+
βΌ
|
|
68
|
+
ββββββββββββββββββββββββββββββββ
|
|
69
|
+
β MyCodes β
|
|
70
|
+
β Python Package β
|
|
71
|
+
β (from PyPI) β
|
|
72
|
+
ββββββββββββββββ¬ββββββββββββββββ
|
|
73
|
+
β
|
|
74
|
+
pip install
|
|
75
|
+
β
|
|
76
|
+
ββββββββββββββββββββΌβββββββββββββββββββ
|
|
77
|
+
βΌ βΌ βΌ
|
|
78
|
+
Workstation A Cloud Notebook Workstation B
|
|
79
|
+
β β β
|
|
80
|
+
Jupyter Jupyter Terminal
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 3. GitHub Repository Setup
|
|
86
|
+
|
|
87
|
+
To host your code library in the cloud:
|
|
88
|
+
|
|
89
|
+
1. Create a public repository on GitHub (e.g., `my-code-library`).
|
|
90
|
+
2. Add a `codes/` folder and an `index.json` file in the root:
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
my-code-library/
|
|
94
|
+
βββ codes/
|
|
95
|
+
β βββ 001.py
|
|
96
|
+
β βββ 002.py
|
|
97
|
+
β βββ 101.py
|
|
98
|
+
β βββ 102.py
|
|
99
|
+
βββ index.json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Example `codes/101.py`
|
|
103
|
+
```python
|
|
104
|
+
def hello():
|
|
105
|
+
print("Hello from Code 101")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Example `index.json`
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"001": {
|
|
112
|
+
"name": "Hello World",
|
|
113
|
+
"description": "Simple Hello World example",
|
|
114
|
+
"category": "Basics",
|
|
115
|
+
"language": "python",
|
|
116
|
+
"tags": ["hello", "basics", "starter"],
|
|
117
|
+
"file": "codes/001.py"
|
|
118
|
+
},
|
|
119
|
+
"002": {
|
|
120
|
+
"name": "Addition",
|
|
121
|
+
"description": "Simple addition function",
|
|
122
|
+
"category": "Math",
|
|
123
|
+
"language": "python",
|
|
124
|
+
"tags": ["math", "add", "arithmetic"],
|
|
125
|
+
"file": "codes/002.py"
|
|
126
|
+
},
|
|
127
|
+
"101": {
|
|
128
|
+
"name": "Greeting 101",
|
|
129
|
+
"description": "Greeting function for code 101",
|
|
130
|
+
"category": "Basics",
|
|
131
|
+
"language": "python",
|
|
132
|
+
"tags": ["hello", "101"],
|
|
133
|
+
"file": "codes/101.py"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Push these files to the `main` branch of your GitHub repository.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 4. Installation
|
|
143
|
+
|
|
144
|
+
Install the core package:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install mycodes
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Or install with optional Jupyter/IPython support:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pip install mycodes[jupyter]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 5. Configuration
|
|
159
|
+
|
|
160
|
+
Do not hard-code repository details. You can configure your repository in three convenient ways:
|
|
161
|
+
|
|
162
|
+
### Option A: Python API
|
|
163
|
+
```python
|
|
164
|
+
from mycodes import configure
|
|
165
|
+
|
|
166
|
+
configure(
|
|
167
|
+
username="YOUR_GITHUB_USERNAME",
|
|
168
|
+
repository="my-code-library", # Defaults to 'my-code-library'
|
|
169
|
+
branch="main", # Defaults to 'main'
|
|
170
|
+
persist=True # Optionally save to ~/.mycodes/config.json
|
|
171
|
+
)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Option B: Environment Variables
|
|
175
|
+
Add these to your shell profile (`.bashrc`, `.zshrc`, or Windows Environment Variables):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
export MYCODES_GITHUB_USER="YOUR_GITHUB_USERNAME"
|
|
179
|
+
export MYCODES_GITHUB_REPO="my-code-library"
|
|
180
|
+
export MYCODES_GITHUB_BRANCH="main"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Option C: Command Line Interface
|
|
184
|
+
```bash
|
|
185
|
+
mycodes config --username YOUR_GITHUB_USERNAME --repository my-code-library
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 6. Adding a New Code
|
|
191
|
+
|
|
192
|
+
Adding a new snippet to your cloud library takes three simple steps:
|
|
193
|
+
|
|
194
|
+
1. **Write your Python code** and save it as `codes/103.py`:
|
|
195
|
+
```python
|
|
196
|
+
def binary_search(arr, target):
|
|
197
|
+
low, high = 0, len(arr) - 1
|
|
198
|
+
while low <= high:
|
|
199
|
+
mid = (low + high) // 2
|
|
200
|
+
if arr[mid] == target:
|
|
201
|
+
return mid
|
|
202
|
+
elif arr[mid] < target:
|
|
203
|
+
low = mid + 1
|
|
204
|
+
else:
|
|
205
|
+
high = mid - 1
|
|
206
|
+
return -1
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
2. **Register it in `index.json`**:
|
|
210
|
+
```json
|
|
211
|
+
"103": {
|
|
212
|
+
"name": "Binary Search",
|
|
213
|
+
"description": "Binary search algorithm on sorted list",
|
|
214
|
+
"category": "DSA",
|
|
215
|
+
"language": "python",
|
|
216
|
+
"tags": ["search", "binary search", "dsa"],
|
|
217
|
+
"file": "codes/103.py"
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
3. **Commit & Push to GitHub**:
|
|
222
|
+
```bash
|
|
223
|
+
git add codes/103.py index.json
|
|
224
|
+
git commit -m "Add code 103: Binary Search"
|
|
225
|
+
git push origin main
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
It is instantly live and accessible from anywhere in the world!
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 7. Getting a Code
|
|
233
|
+
|
|
234
|
+
Retrieve code directly over HTTPS:
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
from mycodes import get_code
|
|
238
|
+
|
|
239
|
+
code = get_code(101)
|
|
240
|
+
print(code)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Output:**
|
|
244
|
+
```python
|
|
245
|
+
def hello():
|
|
246
|
+
print("Hello from Code 101")
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Both integer (`101`) and string (`"101"`, `"001"`) identifiers are supported.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## 8. Listing Codes
|
|
254
|
+
|
|
255
|
+
List all registered code snippets:
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from mycodes import list_codes
|
|
259
|
+
|
|
260
|
+
# Print formatted table
|
|
261
|
+
list_codes()
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Output:**
|
|
265
|
+
```text
|
|
266
|
+
ID NAME CATEGORY
|
|
267
|
+
001 Hello World Basics
|
|
268
|
+
002 Addition Math
|
|
269
|
+
101 Greeting 101 Basics
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
To retrieve Python data instead of printing:
|
|
273
|
+
```python
|
|
274
|
+
codes = list_codes(return_data=True)
|
|
275
|
+
for item in codes:
|
|
276
|
+
print(item["id"], item["name"])
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 9. Searching
|
|
282
|
+
|
|
283
|
+
Search across ID, name, description, category, and tags:
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
from mycodes import search
|
|
287
|
+
|
|
288
|
+
# Search by keyword
|
|
289
|
+
search("binary")
|
|
290
|
+
|
|
291
|
+
# Filter by category
|
|
292
|
+
search(category="DSA")
|
|
293
|
+
|
|
294
|
+
# Filter by language
|
|
295
|
+
search(language="python")
|
|
296
|
+
|
|
297
|
+
# Retrieve structured list
|
|
298
|
+
results = search("sort", return_data=True)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## 10. Jupyter Notebook Integration
|
|
304
|
+
|
|
305
|
+
MyCodes includes custom IPython magic commands tailored for Jupyter:
|
|
306
|
+
|
|
307
|
+
### Load Extension
|
|
308
|
+
```python
|
|
309
|
+
%load_ext mycodes
|
|
310
|
+
```
|
|
311
|
+
*(Alternatively, simply `import mycodes` in your notebookβit auto-registers magic commands!)*
|
|
312
|
+
|
|
313
|
+
### Cell Injection: `%load_code`
|
|
314
|
+
Type:
|
|
315
|
+
```python
|
|
316
|
+
%load_code 101
|
|
317
|
+
```
|
|
318
|
+
And execute the cell. Jupyter replaces `%load_code 101` with the actual code from your cloud library:
|
|
319
|
+
```python
|
|
320
|
+
def hello():
|
|
321
|
+
print("Hello from Code 101")
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Other Magic Commands
|
|
325
|
+
- **`%code_info <id>`**: Displays snippet metadata.
|
|
326
|
+
- **`%list_codes`**: Prints all snippets in your cloud library.
|
|
327
|
+
- **`%search_code <query>`**: Searches for snippets by keyword.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 11. Command Line Interface (CLI)
|
|
332
|
+
|
|
333
|
+
Use `mycodes` directly in your terminal:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# List all codes
|
|
337
|
+
mycodes list
|
|
338
|
+
|
|
339
|
+
# Retrieve and print code
|
|
340
|
+
mycodes get 101
|
|
341
|
+
|
|
342
|
+
# Inspect metadata
|
|
343
|
+
mycodes info 101
|
|
344
|
+
|
|
345
|
+
# Search codes
|
|
346
|
+
mycodes search binary
|
|
347
|
+
|
|
348
|
+
# Update or inspect configuration
|
|
349
|
+
mycodes config --username myusername
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 12. Caching
|
|
355
|
+
|
|
356
|
+
GitHub remains the authoritative source of truth. By default, code snippets are fetched fresh. You can enable local caching for offline or high-performance workflows:
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
# Cache locally in ~/.mycodes/cache/
|
|
360
|
+
code = get_code(101, cache=True)
|
|
361
|
+
|
|
362
|
+
# Force refresh from GitHub, bypassing cache
|
|
363
|
+
fresh_code = get_code(101, refresh=True)
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
The catalog `index.json` is cached in-memory for 5 minutes during active sessions to minimize unnecessary requests.
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## 13. Security
|
|
371
|
+
|
|
372
|
+
> β οΈ **IMPORTANT SECURITY NOTICE:**
|
|
373
|
+
> Executing remote code downloaded over the internet poses serious security risks.
|
|
374
|
+
|
|
375
|
+
- `get_code()` **ONLY** retrieves the source code as text. It **never** executes remote code.
|
|
376
|
+
- Remote execution is strictly opt-in via `run()`:
|
|
377
|
+
```python
|
|
378
|
+
from mycodes import run
|
|
379
|
+
|
|
380
|
+
# This raises ExecutionDisabledError:
|
|
381
|
+
run(101)
|
|
382
|
+
|
|
383
|
+
# Explicit permission is required:
|
|
384
|
+
run(101, allow_execution=True)
|
|
385
|
+
```
|
|
386
|
+
- Only connect MyCodes to GitHub repositories that you own and trust.
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 14. Publishing to PyPI
|
|
391
|
+
|
|
392
|
+
To build and publish `mycodes` to PyPI:
|
|
393
|
+
|
|
394
|
+
1. **Install build and twine**:
|
|
395
|
+
```bash
|
|
396
|
+
pip install --upgrade build twine
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
2. **Build distribution wheels**:
|
|
400
|
+
```bash
|
|
401
|
+
python -m build
|
|
402
|
+
```
|
|
403
|
+
This generates `dist/mycodes-0.1.0-py3-none-any.whl` and `dist/mycodes-0.1.0.tar.gz`.
|
|
404
|
+
|
|
405
|
+
3. **Upload to TestPyPI (recommended first)**:
|
|
406
|
+
```bash
|
|
407
|
+
python -m twine upload --repository testpypi dist/*
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
4. **Upload to Production PyPI**:
|
|
411
|
+
```bash
|
|
412
|
+
python -m twine upload dist/*
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## 15. Installing on Another Computer
|
|
418
|
+
|
|
419
|
+
On any new laptop, desktop, or cloud notebook:
|
|
420
|
+
|
|
421
|
+
1. Install the package:
|
|
422
|
+
```bash
|
|
423
|
+
pip install mycodes
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
2. Set your GitHub username once:
|
|
427
|
+
```bash
|
|
428
|
+
mycodes config --username YOUR_GITHUB_USERNAME
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
3. Open Jupyter or Python and start loading your code:
|
|
432
|
+
```python
|
|
433
|
+
from mycodes import get_code
|
|
434
|
+
print(get_code(101))
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Zero manual file copying, zero local git repositories required!
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## License
|
|
442
|
+
|
|
443
|
+
MIT License. See [LICENSE](LICENSE) for details.
|