skilleter-modules 0.0.6__tar.gz → 0.0.8__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.
- {skilleter_modules-0.0.6/src/skilleter_modules.egg-info → skilleter_modules-0.0.8}/PKG-INFO +1 -1
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/pyproject.toml +1 -1
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/git.py +19 -81
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/popup.py +4 -4
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8/src/skilleter_modules.egg-info}/PKG-INFO +1 -1
- skilleter_modules-0.0.8/tests/test_git.py +73 -0
- skilleter_modules-0.0.8/tests/test_popup.py +4 -0
- skilleter_modules-0.0.6/tests/test_git.py +0 -6
- skilleter_modules-0.0.6/tests/test_popup.py +0 -70
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/LICENSE +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/README.md +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/setup.cfg +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/__init__.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/colour.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/dc_curses.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/dc_defaults.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/dc_util.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/dircolors.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/docker.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/files.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/gitlab.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/path.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/run.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/tidy.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules/venv_template.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/SOURCES.txt +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/dependency_links.txt +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/requires.txt +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/top_level.txt +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_colour.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_dircolors.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_docker.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_files.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_gitlab.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_path.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_run.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_tfm_pane.py +0 -0
- {skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/tests/test_tidy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: skilleter_modules
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: Modules used by my various Python projects (and hopefully useful to other people)
|
|
5
5
|
Author-email: John Skilleter <john@skilleter.org.uk>
|
|
6
6
|
Project-URL: Home, https://skilleter.org.uk
|
|
@@ -27,6 +27,7 @@ import re
|
|
|
27
27
|
import logging
|
|
28
28
|
import fnmatch
|
|
29
29
|
import subprocess
|
|
30
|
+
from functools import cache
|
|
30
31
|
|
|
31
32
|
import pygit2
|
|
32
33
|
|
|
@@ -873,6 +874,7 @@ def reset(sha1, path=None):
|
|
|
873
874
|
|
|
874
875
|
################################################################################
|
|
875
876
|
|
|
877
|
+
@cache
|
|
876
878
|
def config_get(section, key, source=None, defaultvalue=None, path=None):
|
|
877
879
|
""" Return the specified configuration entry
|
|
878
880
|
Returns a default value if no matching configuration entry exists """
|
|
@@ -900,6 +902,8 @@ def config_get(section, key, source=None, defaultvalue=None, path=None):
|
|
|
900
902
|
def config_set(section, key, value, source=None, path=None):
|
|
901
903
|
""" Set a configuration entry """
|
|
902
904
|
|
|
905
|
+
config_get.cache_clear()
|
|
906
|
+
|
|
903
907
|
cmd = ['config']
|
|
904
908
|
|
|
905
909
|
if source == GLOBAL:
|
|
@@ -1212,6 +1216,18 @@ def isbranch(branchname, path=None):
|
|
|
1212
1216
|
|
|
1213
1217
|
################################################################################
|
|
1214
1218
|
|
|
1219
|
+
def is_default_branch(branchname=None):
|
|
1220
|
+
""" Return True if the specified branch is a default branch """
|
|
1221
|
+
|
|
1222
|
+
if not branchname:
|
|
1223
|
+
branchname = branch()
|
|
1224
|
+
|
|
1225
|
+
default_branches = config_get('skilleter-thingy', 'defaultBranches', defaultvalue=DEFAULT_DEFAULT_BRANCHES, path=path).split(',')
|
|
1226
|
+
|
|
1227
|
+
return branchname in default_branches
|
|
1228
|
+
|
|
1229
|
+
################################################################################
|
|
1230
|
+
|
|
1215
1231
|
def default_branch(path=None):
|
|
1216
1232
|
""" Return the name of the default branch, attempting to interrogate GitLab
|
|
1217
1233
|
if the repo appears to have been cloned from there and falling back to
|
|
@@ -1238,11 +1254,10 @@ def default_branch(path=None):
|
|
|
1238
1254
|
return None
|
|
1239
1255
|
|
|
1240
1256
|
git_branches = branches(path=path)
|
|
1241
|
-
default_branches = config_get('skilleter-thingy', 'defaultBranches', defaultvalue=DEFAULT_DEFAULT_BRANCHES, path=path).split(',')
|
|
1242
1257
|
|
|
1243
|
-
for
|
|
1244
|
-
if
|
|
1245
|
-
return
|
|
1258
|
+
for branchname in git_branches:
|
|
1259
|
+
if is_default_branch(branchname):
|
|
1260
|
+
return branchname
|
|
1246
1261
|
|
|
1247
1262
|
raise GitError('Unable to determine default branch in the repo')
|
|
1248
1263
|
|
|
@@ -1423,80 +1438,3 @@ def clean(recurse=False, force=False, dry_run=False, quiet=False,
|
|
|
1423
1438
|
cmd.append('-X')
|
|
1424
1439
|
|
|
1425
1440
|
return git(cmd, path=path)
|
|
1426
|
-
|
|
1427
|
-
################################################################################
|
|
1428
|
-
|
|
1429
|
-
def run_tests():
|
|
1430
|
-
"""Test suite for the module"""
|
|
1431
|
-
|
|
1432
|
-
print('Creating local git repo')
|
|
1433
|
-
|
|
1434
|
-
init('test-repo')
|
|
1435
|
-
os.chdir('test-repo')
|
|
1436
|
-
|
|
1437
|
-
try:
|
|
1438
|
-
print('Initial status:')
|
|
1439
|
-
print(' User name: %s' % config_get('user', 'name'))
|
|
1440
|
-
print(' Project: %s' % project())
|
|
1441
|
-
print(' Remotes: %s' % remotes())
|
|
1442
|
-
print(' Current branch: %s' % branch())
|
|
1443
|
-
print(' Current working tree: %s' % working_tree())
|
|
1444
|
-
print(' Rebasing? %s' % rebasing())
|
|
1445
|
-
print(' Status: %s' % status())
|
|
1446
|
-
print()
|
|
1447
|
-
|
|
1448
|
-
print('Adding a removing a configuration value')
|
|
1449
|
-
|
|
1450
|
-
config_set('user', 'size', 'medium')
|
|
1451
|
-
|
|
1452
|
-
print(' User size config: %s' % config_get('user', 'size'))
|
|
1453
|
-
|
|
1454
|
-
config_rm('user', 'size')
|
|
1455
|
-
|
|
1456
|
-
value = config_get('user', 'size')
|
|
1457
|
-
if value is None:
|
|
1458
|
-
print(' Successfully failed to read the newly-deleted config data')
|
|
1459
|
-
else:
|
|
1460
|
-
raise GitError('Unexpected lack of error reading configuration data', 1)
|
|
1461
|
-
|
|
1462
|
-
config_set('user', 'email', 'user@localhost')
|
|
1463
|
-
config_set('user', 'name', 'User Name')
|
|
1464
|
-
|
|
1465
|
-
print('')
|
|
1466
|
-
|
|
1467
|
-
with open('newfile.txt', 'w', encoding='utf8') as newfile:
|
|
1468
|
-
newfile.write('THIS IS A TEST')
|
|
1469
|
-
|
|
1470
|
-
print('Adding and committing "newfile.txt"')
|
|
1471
|
-
|
|
1472
|
-
add(['newfile.txt'])
|
|
1473
|
-
|
|
1474
|
-
commit(['newfile.txt'], 'Test the add and commit functionality')
|
|
1475
|
-
|
|
1476
|
-
print('Removing and committing "newfile.txt"')
|
|
1477
|
-
|
|
1478
|
-
rm(['newfile.txt'])
|
|
1479
|
-
|
|
1480
|
-
commit(None, 'Removed "newfile.txt"')
|
|
1481
|
-
|
|
1482
|
-
print('Removing the last commit')
|
|
1483
|
-
|
|
1484
|
-
reset('HEAD~1')
|
|
1485
|
-
|
|
1486
|
-
print('Commit info for HEAD %s' % commit_info('HEAD'))
|
|
1487
|
-
|
|
1488
|
-
except GitError as exc:
|
|
1489
|
-
sys.stderr.write(f'ERROR: {exc.msg}')
|
|
1490
|
-
sys.exit(1)
|
|
1491
|
-
|
|
1492
|
-
finally:
|
|
1493
|
-
# If anything fails, then clean up afterwards
|
|
1494
|
-
|
|
1495
|
-
os.chdir('..')
|
|
1496
|
-
shutil.rmtree('test-repo')
|
|
1497
|
-
|
|
1498
|
-
################################################################################
|
|
1499
|
-
# Entry point
|
|
1500
|
-
|
|
1501
|
-
if __name__ == '__main__':
|
|
1502
|
-
run_tests()
|
|
@@ -21,7 +21,7 @@ import curses.panel
|
|
|
21
21
|
class PopUp():
|
|
22
22
|
""" Class to enable popup windows to be used via with statements """
|
|
23
23
|
|
|
24
|
-
def __init__(self, screen, msg, colour, waitkey=False, sleep=
|
|
24
|
+
def __init__(self, screen, msg, colour, waitkey=False, sleep=1, centre=True, refresh=True):
|
|
25
25
|
""" Initialisation - just save the popup parameters """
|
|
26
26
|
|
|
27
27
|
self.panel = None
|
|
@@ -30,7 +30,7 @@ class PopUp():
|
|
|
30
30
|
self.centre = centre
|
|
31
31
|
self.colour = curses.color_pair(colour)
|
|
32
32
|
self.refresh = refresh
|
|
33
|
-
self.sleep =
|
|
33
|
+
self.sleep = 0 if waitkey else sleep
|
|
34
34
|
self.waitkey = waitkey
|
|
35
35
|
self.start_time = 0
|
|
36
36
|
|
|
@@ -81,8 +81,8 @@ class PopUp():
|
|
|
81
81
|
if self.sleep:
|
|
82
82
|
elapsed = time.monotonic() - self.start_time
|
|
83
83
|
|
|
84
|
-
if elapsed <
|
|
85
|
-
time.sleep(
|
|
84
|
+
if elapsed < self.sleep:
|
|
85
|
+
time.sleep(self.sleep - elapsed)
|
|
86
86
|
|
|
87
87
|
del self.panel
|
|
88
88
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: skilleter_modules
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: Modules used by my various Python projects (and hopefully useful to other people)
|
|
5
5
|
Author-email: John Skilleter <john@skilleter.org.uk>
|
|
6
6
|
Project-URL: Home, https://skilleter.org.uk
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
git = pytest.importorskip('skilleter_modules.git', reason='pygit2 not installed')
|
|
4
|
+
|
|
5
|
+
def test_git():
|
|
6
|
+
"""Test suite for the module"""
|
|
7
|
+
|
|
8
|
+
print('Creating local git repo')
|
|
9
|
+
|
|
10
|
+
init('test-repo')
|
|
11
|
+
os.chdir('test-repo')
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
print('Initial status:')
|
|
15
|
+
print(' User name: %s' % config_get('user', 'name'))
|
|
16
|
+
print(' Project: %s' % project())
|
|
17
|
+
print(' Remotes: %s' % remotes())
|
|
18
|
+
print(' Current branch: %s' % branch())
|
|
19
|
+
print(' Current working tree: %s' % working_tree())
|
|
20
|
+
print(' Rebasing? %s' % rebasing())
|
|
21
|
+
print(' Status: %s' % status())
|
|
22
|
+
print(' Default branch?: %s' % is_default_branch())
|
|
23
|
+
print()
|
|
24
|
+
|
|
25
|
+
print('Adding a removing a configuration value')
|
|
26
|
+
|
|
27
|
+
config_set('user', 'size', 'medium')
|
|
28
|
+
|
|
29
|
+
print(' User size config: %s' % config_get('user', 'size'))
|
|
30
|
+
|
|
31
|
+
config_rm('user', 'size')
|
|
32
|
+
|
|
33
|
+
value = config_get('user', 'size')
|
|
34
|
+
if value is None:
|
|
35
|
+
print(' Successfully failed to read the newly-deleted config data')
|
|
36
|
+
else:
|
|
37
|
+
raise GitError('Unexpected lack of error reading configuration data', 1)
|
|
38
|
+
|
|
39
|
+
config_set('user', 'email', 'user@localhost')
|
|
40
|
+
config_set('user', 'name', 'User Name')
|
|
41
|
+
|
|
42
|
+
print('')
|
|
43
|
+
|
|
44
|
+
with open('newfile.txt', 'w', encoding='utf8') as newfile:
|
|
45
|
+
newfile.write('THIS IS A TEST')
|
|
46
|
+
|
|
47
|
+
print('Adding and committing "newfile.txt"')
|
|
48
|
+
|
|
49
|
+
add(['newfile.txt'])
|
|
50
|
+
|
|
51
|
+
commit(['newfile.txt'], 'Test the add and commit functionality')
|
|
52
|
+
|
|
53
|
+
print('Removing and committing "newfile.txt"')
|
|
54
|
+
|
|
55
|
+
rm(['newfile.txt'])
|
|
56
|
+
|
|
57
|
+
commit(None, 'Removed "newfile.txt"')
|
|
58
|
+
|
|
59
|
+
print('Removing the last commit')
|
|
60
|
+
|
|
61
|
+
reset('HEAD~1')
|
|
62
|
+
|
|
63
|
+
print('Commit info for HEAD %s' % commit_info('HEAD'))
|
|
64
|
+
|
|
65
|
+
except GitError as exc:
|
|
66
|
+
sys.stderr.write(f'ERROR: {exc.msg}')
|
|
67
|
+
sys.exit(1)
|
|
68
|
+
|
|
69
|
+
finally:
|
|
70
|
+
# If anything fails, then clean up afterwards
|
|
71
|
+
|
|
72
|
+
os.chdir('..')
|
|
73
|
+
shutil.rmtree('test-repo')
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
from types import SimpleNamespace
|
|
2
|
-
|
|
3
|
-
import skilleter_modules.popup as popup
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class FakePanel:
|
|
7
|
-
def __init__(self):
|
|
8
|
-
self.update_calls = 0
|
|
9
|
-
self.new_calls = []
|
|
10
|
-
|
|
11
|
-
def new_panel(self, window):
|
|
12
|
-
self.new_calls.append(window)
|
|
13
|
-
return SimpleNamespace(top=lambda: None)
|
|
14
|
-
|
|
15
|
-
def update_panels(self):
|
|
16
|
-
self.update_calls += 1
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class FakeWindow:
|
|
20
|
-
def __init__(self):
|
|
21
|
-
self.add_calls = []
|
|
22
|
-
self.bkgd_calls = []
|
|
23
|
-
|
|
24
|
-
def bkgd(self, ch, colour):
|
|
25
|
-
self.bkgd_calls.append((ch, colour))
|
|
26
|
-
|
|
27
|
-
def addstr(self, y_pos, x_pos, line, colour):
|
|
28
|
-
self.add_calls.append((y_pos, x_pos, line, colour))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class FakeScreen:
|
|
32
|
-
def __init__(self, keys):
|
|
33
|
-
self.keys = list(keys)
|
|
34
|
-
self.getch_calls = 0
|
|
35
|
-
self.refresh_calls = 0
|
|
36
|
-
|
|
37
|
-
def getmaxyx(self):
|
|
38
|
-
return (24, 80)
|
|
39
|
-
|
|
40
|
-
def refresh(self):
|
|
41
|
-
self.refresh_calls += 1
|
|
42
|
-
|
|
43
|
-
def getch(self):
|
|
44
|
-
self.getch_calls += 1
|
|
45
|
-
return self.keys.pop(0)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_waitkey_occurs_on_exit(monkeypatch):
|
|
49
|
-
fake_panel = FakePanel()
|
|
50
|
-
|
|
51
|
-
fake_curses = SimpleNamespace(
|
|
52
|
-
KEY_RESIZE=999,
|
|
53
|
-
panel=fake_panel,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
fake_curses.color_pair = lambda colour: f'colour-{colour}'
|
|
57
|
-
fake_curses.newwin = lambda h, w, y, x: FakeWindow()
|
|
58
|
-
|
|
59
|
-
monkeypatch.setattr(popup, 'curses', fake_curses)
|
|
60
|
-
|
|
61
|
-
keys = [fake_curses.KEY_RESIZE, ord('a')]
|
|
62
|
-
screen = FakeScreen(keys)
|
|
63
|
-
|
|
64
|
-
with popup.PopUp(screen, 'hello', 3, waitkey=True):
|
|
65
|
-
enter_updates = fake_panel.update_calls
|
|
66
|
-
assert screen.getch_calls == 0
|
|
67
|
-
|
|
68
|
-
assert fake_panel.update_calls == enter_updates + 1
|
|
69
|
-
assert screen.getch_calls == 2
|
|
70
|
-
assert screen.refresh_calls >= 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/requires.txt
RENAMED
|
File without changes
|
{skilleter_modules-0.0.6 → skilleter_modules-0.0.8}/src/skilleter_modules.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|