https://github.com/rainingcomputers/syncgit
Sync python dicts, strings and modules to files in git repository.
https://github.com/rainingcomputers/syncgit
Last synced: about 1 year ago
JSON representation
Sync python dicts, strings and modules to files in git repository.
- Host: GitHub
- URL: https://github.com/rainingcomputers/syncgit
- Owner: RainingComputers
- License: mit
- Created: 2021-06-13T09:41:02.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-31T09:19:49.000Z (over 4 years ago)
- Last Synced: 2025-03-18T06:49:33.959Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 144 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# syncgit
Sync python dicts, strings and modules to files in git repository.
NOTE: syncgit calls git using subprocess, setup git so it does not ask for username or password,
otherwise you will get a timeout exception.
### Installation
```
python -m pip install syncgit
```
### Documentation
https://syncgit.readthedocs.io/en/latest/
### Example
```python
from typing import List
import time
from syncgit import Repo, SyncConfig
# This callback is called when changes are pushed to the repo
def update_callback(repo: Repo, changes: List[SyncConfig]) -> None:
print(f"Updated to commit {repo.commit_hash}")
for change in changes:
print(f"Updated {change.name}")
# Create repo class and import files from repository
rp = Repo("example_repo", "git@github.com:RainingComputers/syncgit-test.git", "main")
rp.set_config([
SyncConfig("about_alice", "alice.json", "json"),
SyncConfig("about_bob", "bob.yml"),
SyncConfig("text", "text_file.txt", "text"),
SyncConfig("hello_module", "say_hello.py")
])
# Register call back
rp.set_update_callback(update_callback)
# Start sync
rp.start_sync()
# Imported files will be available as attributes on the repo class
# Changes are reflected immediately on these attributes real time
try:
while True:
time.sleep(1)
print(rp.about_alice)
print(rp.about_bob)
print(rp.text)
rp.hello_module.say_hello("Alice")
except KeyboardInterrupt:
print("Stopping sync")
rp.stop_sync()
```