Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# HOMELY

https://homely.readthedocs.io/


## Developing

Homely's `pyproject.toml` is managed using uv.

To create a virtualenv for development:

uv venv [ -p some_python ] --seed path/to/virtualenv
source path/to/virtualenv/bin/activate
pip install --upgrade pip # this may be required on older versions of python like 3.10
pip install -e . --group dev

To quickly run tests:

source path/to/virtualenv/bin/activate
pytest test/test_some_feature.py

# NOTE: the virtualenv must be manually activated because of the way that some tests use
# subprocesses.
7 changes: 3 additions & 4 deletions homely/_engine2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json
import os
from typing import Optional

import simplejson

from homely._errors import CleanupConflict, CleanupObstruction, HelperError
from homely._ui import note, warn
from homely._utils import (ENGINE2_CONFIG_PATH, FactConfig, RepoInfo,
Expand Down Expand Up @@ -219,7 +218,7 @@ def __init__(self, cfgpath, quick=False):
if os.path.isfile(cfgpath):
with open(cfgpath, 'r') as f:
raw = f.read()
data = simplejson.loads(raw)
data = json.loads(raw)
if not isinstance(data, dict):
raise Exception("Invalid json in %s" % cfgpath)
for item in data.get('cleaners', []):
Expand Down Expand Up @@ -251,7 +250,7 @@ def _savecfg(self):
paths_postponed=list(self._postponed),
paths_created=list(self._created),
)
dumped = simplejson.dumps(data, indent=' ' * 4)
dumped = json.dumps(data, indent=' ' * 4)
with open(self._cfgpath, 'w') as f:
f.write(dumped)

Expand Down
9 changes: 4 additions & 5 deletions homely/_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import json
import os
import re
import shutil
Expand All @@ -11,8 +12,6 @@
from os.path import exists, join
from typing import Union

import simplejson

from homely._asyncioutils import _runasync
from homely._errors import JsonError
from homely._vcs import Repo, fromdict
Expand Down Expand Up @@ -219,9 +218,9 @@ def __init__(self):
data = f.read()
if not len(data):
return
self.jsondata = simplejson.loads(data)
self.jsondata = json.loads(data)
self.checkjson()
except simplejson.JSONDecodeError:
except json.JSONDecodeError:
raise JsonError("%s does not contain valid JSON" % self.jsonpath)

def checkjson(self):
Expand All @@ -244,7 +243,7 @@ def writejson(self):
if not os.path.exists(parentdir):
os.makedirs(parentdir, mode=0o755)
# write the config file now
dumped = simplejson.dumps(self.jsondata, indent=' ' * 4)
dumped = json.dumps(self.jsondata, indent=' ' * 4)
with open(self.jsonpath, 'w') as f:
f.write(dumped)

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ version = "0.20.2"
dependencies = [
"python-daemon==2.3.0",
"requests==2.25.1",
"simplejson==3.17.2",
"click==7.1.2",
]

Expand Down
9 changes: 4 additions & 5 deletions test/test_engine2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json
import os
import sys

import simplejson

from homely._test import contents, gettmpfilepath


Expand Down Expand Up @@ -583,14 +582,14 @@ def test_writefile_usage(tmpdir):
data = {"z": [3, 4, 5, True], "y": "Hello world", "x": None}
with writefile(f3) as f:
if sys.version_info[0] < 3:
f.write(simplejson.dumps(data, ensure_ascii=False))
f.write(json.dumps(data, ensure_ascii=False))
else:
f.write(simplejson.dumps(data))
f.write(json.dumps(data))
e.cleanup(e.RAISE)
del e
assert os.path.exists(f3)
with open(f3, 'r') as f:
assert simplejson.loads(f.read()) == data
assert json.loads(f.read()) == data

# prove that the WriteFile() disappearing results in the file being removed
e = Engine(cfgpath)
Expand Down
8 changes: 0 additions & 8 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.