skilleter-thingy 0.0.43__py3-none-any.whl → 0.0.45__py3-none-any.whl

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.

Potentially problematic release.


This version of skilleter-thingy might be problematic. Click here for more details.

@@ -14,7 +14,7 @@ import sys
14
14
  import argparse
15
15
  import os
16
16
 
17
- import thingy.git2 as git
17
+ import pygit2
18
18
 
19
19
  ################################################################################
20
20
 
@@ -24,21 +24,28 @@ def main():
24
24
  # Command line parameters
25
25
 
26
26
  parser = argparse.ArgumentParser(description='Report top-level directory of the current git working tree.')
27
- parser.add_argument('-p', '--parent', action='store_true',
27
+ parser.add_argument('--parent', '-p', action='store_true',
28
28
  help='If we are already at the top of the working tree, check if the parent directory is in a working tree and output the top-level directory of that tree.')
29
- parser.add_argument('-r', '--repo', action='store_true',
29
+ parser.add_argument('--repo', '-r', action='store_true',
30
30
  help='If we are already at the top of the working tree, look for a parent directory with a repo control file (.repo directory or .mrconfig file) and output that directory.')
31
+ parser.add_argument('--dir', '-d', action='store', default=os.getcwd(),
32
+ help='Find the location of the top-level directory in the working tree starting at the specified directory')
31
33
  parser.add_argument('level', nargs='?', type=int, default=0, help='Number of levels below the top-level directory to report')
32
34
  args = parser.parse_args()
33
- try:
34
- start_dir = os.getcwd()
35
- except FileNotFoundError:
36
- print('Unable to locate current directory')
35
+
36
+ if not os.path.isdir(args.dir):
37
+ print(f'Unable to locate directory {args.dir}')
37
38
  sys.exit(1)
38
39
 
39
40
  # Try to get the current working tree
40
41
 
41
- working_tree = git.working_tree(start_dir)
42
+ git_dir = pygit2.discover_repository(args.dir)
43
+
44
+ if not git_dir:
45
+ print(f'Directory {args.dir} is not in a Git working tree')
46
+ sys.exit(2)
47
+
48
+ working_tree = os.path.abspath(os.path.join(git_dir, os.pardir))
42
49
 
43
50
  # If we are in a working tree and also looking for the parent working
44
51
  # tree, check if we are at the top of the current tree, and, if so,
@@ -50,7 +57,7 @@ def main():
50
57
  if os.path.samefile(working_tree, current_directory):
51
58
  os.chdir('..')
52
59
 
53
- working_tree = git.working_tree()
60
+ working_tree = pygit2.discover_repository()
54
61
 
55
62
  # If we are also looking for a multi-repo control file or directory, and haven't
56
63
  # found the git working tree root scan up the tree until we find one.
@@ -70,7 +77,7 @@ def main():
70
77
  # Output the result, if we have one
71
78
 
72
79
  if args.level:
73
- start = start_dir.split('/')
80
+ start = args.dir.split('/')
74
81
  working = working_tree.split('/')
75
82
 
76
83
  working_tree = os.path.join(working_tree, '/'.join(start[len(working):len(working) + int(args.level)]))
@@ -0,0 +1,47 @@
1
+ TEMPLATE = \
2
+ """#!/usr/bin/env bash
3
+
4
+ set -e
5
+
6
+ ################################################################################
7
+
8
+ VENV_NAME=$(basename "$0")
9
+ VENV_DIR=__venv__
10
+
11
+ GREEN="\e[42m"
12
+ NORMAL="\e[0m"
13
+
14
+ ################################################################################
15
+
16
+ function box()
17
+ {
18
+ echo -e "${GREEN}################################################################################${NORMAL}"
19
+ echo -e "${GREEN}# $@${NORMAL}"
20
+ echo -e "${GREEN}################################################################################${NORMAL}"
21
+ }
22
+
23
+ ################################################################################
24
+
25
+ box "Creating & activating $VENV_NAME virtual environment"
26
+
27
+ python3 -m venv $VENV_DIR
28
+
29
+ source $VENV_DIR/bin/activate
30
+
31
+ if [[ -f requirements.txt ]]
32
+ then
33
+ box "Installing/Upgrading packages"
34
+
35
+ python3 -m pip install -r requirements.txt
36
+ fi
37
+
38
+ if [[ -f ${VENV_NAME} ]]
39
+ then
40
+ box "Running ${VENV_NAME} script"
41
+
42
+ python3 ./${VENV_NAME}.py "$@"
43
+
44
+ deactivate
45
+ fi
46
+ """
47
+
@@ -0,0 +1,41 @@
1
+ TEMPLATE = \
2
+ """#!/usr/bin/env fish
3
+
4
+ ################################################################################
5
+
6
+ set VENV_NAME $(basename "$0")
7
+ set VENV_DIR __venv__
8
+
9
+ set GREEN "\e[42m"
10
+ set NORMAL "\e[0m"
11
+
12
+ ################################################################################
13
+
14
+ function box
15
+ echo -e "$GREEN################################################################################$NORMAL"
16
+ echo -e "$GREEN# $argv$NORMAL"
17
+ echo -e "$GREEN################################################################################$NORMAL"
18
+ end
19
+
20
+ ################################################################################
21
+
22
+ box "Creating & activating $VENV_NAME virtual environment"
23
+
24
+ python3 -m venv $VENV_DIR
25
+
26
+ source $VENV_DIR/bin/activate.fish
27
+
28
+ if test -f requirements.txt
29
+ box "Installing/Upgrading packages"
30
+
31
+ python3 -m pip install -r requirements.txt
32
+ end
33
+
34
+ if test -f $VENV_NAME.py
35
+ box "Running $VENV_NAME script"
36
+
37
+ python3 ./$VENV_NAME.py $argv
38
+
39
+ deactivate
40
+ end
41
+ """
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import os
4
+ import stat
5
+ import argparse
6
+
7
+ import thingy.bash_venv as bash_venv
8
+ import thingy.fish_venv as fish_venv
9
+
10
+ ################################################################################
11
+
12
+ def main():
13
+ """Create the venv script and make it executable"""
14
+
15
+ parser = argparse.ArgumentParser(description='Create a script to run Python code in a virtual environment')
16
+ parser.add_argument('name', nargs=1, help='Name of the script to create')
17
+
18
+ args = parser.parse_args()
19
+
20
+ shell = os.getenv('SHELL').split('/')[-1]
21
+
22
+ if shell == 'fish':
23
+ template = fish_venv.TEMPLATE
24
+ else:
25
+ if shell != 'bash':
26
+ print(f'Warning: Unknown shell: {shell} - using Bash template by default')
27
+
28
+ template = bash_venv.TEMPLATE
29
+
30
+ with open(args.name[0], 'wt') as scriptfile:
31
+ scriptfile.write(template)
32
+
33
+ statinfo = os.stat(args.name[0])
34
+
35
+ os.chmod(args.name[0], statinfo.st_mode|stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
36
+
37
+ print(f'Created virtual environment: {args.name[0]}')
38
+
39
+ ################################################################################
40
+
41
+ def venv_create():
42
+ """Entry point"""
43
+
44
+ try:
45
+ main()
46
+
47
+ except KeyboardInterrupt:
48
+ sys.exit(1)
49
+ except BrokenPipeError:
50
+ sys.exit(2)
51
+
52
+ ################################################################################
53
+
54
+ if __name__ == '__main__':
55
+ venv_create()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: skilleter_thingy
3
- Version: 0.0.43
3
+ Version: 0.0.45
4
4
  Summary: A collection of useful utilities, mainly aimed at making Git more friendly
5
5
  Author-email: John Skilleter <john@skilleter.org.uk>
6
6
  Project-URL: Home, https://skilleter.org.uk
@@ -17,7 +17,7 @@ skilleter_thingy/git_mr.py,sha256=BCE68hhz2bV0zwHkEv5tyfRY0aXoUdb_aJ-yWYDu_Wo,30
17
17
  skilleter_thingy/git_parent.py,sha256=D47D01dPs6kActusA0ircJYTv8tBjDoe8MzMpJVWJpA,2683
18
18
  skilleter_thingy/git_review.py,sha256=1_vGcEgy6TvzoXIIDqsOeRZ4qeweDeNPuLwDQsEH08k,51769
19
19
  skilleter_thingy/git_update.py,sha256=2SAGeqL2LjdsXTYak3nvPtNfhSOWJdXZfAUx6bqC8Qw,13972
20
- skilleter_thingy/git_wt.py,sha256=pe2VNmNZTlc4su9I1-xnDcui7QVBQ7X3kOIJWQrrfic,3128
20
+ skilleter_thingy/git_wt.py,sha256=kMxA3f39-gMjXfhLH4DHw9klsgPbJzn1Ae4osehbtD8,3487
21
21
  skilleter_thingy/gitcmp_helper.py,sha256=_3ji-PyIF2oI6a4zyUPjLeCFgAtACykxPpOrbjD6-aw,11245
22
22
  skilleter_thingy/gitprompt.py,sha256=SzSMd0EGI7ftPko80Q2PipwbVA-qjU1jsmdpmTCM5GI,8912
23
23
  skilleter_thingy/gl.py,sha256=9zbGpKxw6lX9RghLkdy-Q5sZlqtbB3uGFO04qTu1dH8,5954
@@ -37,10 +37,12 @@ skilleter_thingy/sysmon.py,sha256=XRZG6EVSzoVYan_N16qVB1l1RaU51uvLWlRA0CDjC54,11
37
37
  skilleter_thingy/tfm.py,sha256=3ejKNI2P65lGz-50mxRMxW_o5NmoeMDcmhji_0uALhI,33703
38
38
  skilleter_thingy/tfparse.py,sha256=u1IZH2J_WH1aORyMozKSI2JKok7_S1MMJhiobzmhlUI,2988
39
39
  skilleter_thingy/trimpath.py,sha256=IJU3zl4Hg08g0eU24LZyDlGfNa-5k-TZM5s9zR4OIdA,2385
40
+ skilleter_thingy/venv_create.py,sha256=JZzOGbGJehNIGuumeZG0jrtU2M0ijvLE67NqjLXfxyg,1428
40
41
  skilleter_thingy/window_rename.py,sha256=dCBgZqih_3YKHt35hsOAhARFp3QxOi8w8huC63sqJK8,3128
41
42
  skilleter_thingy/xchmod.py,sha256=F9_lxKuLqVlHHr3oBI3dkMoFOuwRzYDlpQMTmDcjpBI,4590
42
43
  skilleter_thingy/yamlcheck.py,sha256=FXylZ5NtHirDlPVhVEUZUZkTugVR-g51BbjaN06akAc,2868
43
44
  skilleter_thingy/thingy/__init__.py,sha256=rVPTxm8L5w52U0YdTd7r_D44SBP7pS3JCJtsf0iIsow,110
45
+ skilleter_thingy/thingy/bash_venv.py,sha256=SsVNvSwojd8NnFeQaZPCRQYTNdwJRplpZpygbUEXRnY,1015
44
46
  skilleter_thingy/thingy/colour.py,sha256=D-RTYsND6Xm6m3xl0mOe9QSrTNYsyY0K_a8x3id2gvg,7031
45
47
  skilleter_thingy/thingy/dc_curses.py,sha256=fuuQPR11zV_akAhygL_cAhVLC5YAgKgowzlITVbETE8,8539
46
48
  skilleter_thingy/thingy/dc_defaults.py,sha256=ahcteQvoWZrO5iTU68zkIY1Zex6iX5uR5ubwI4CCYBk,6170
@@ -48,6 +50,7 @@ skilleter_thingy/thingy/dc_util.py,sha256=Df73imXhHx3HzcPHiRcHAoea0e3HURdLcrolUs
48
50
  skilleter_thingy/thingy/dircolors.py,sha256=5NbXMsGWdABLvvZfB70VPmN6N5HyyihfpgoQq1NRJbg,12264
49
51
  skilleter_thingy/thingy/docker.py,sha256=9EFatudoVPfB1UbDEtzdJDB3o6ToHiNHv8-oLsUeqiQ,2449
50
52
  skilleter_thingy/thingy/files.py,sha256=8wXUHEGALhHvYtJewjSNwHFw-hGHFYbWH9_40lJj5ZY,4257
53
+ skilleter_thingy/thingy/fish_venv.py,sha256=NKL9I5DKNyT7R6UpKRIiYmxg4kxzmywuuYO07uCBCrQ,1004
51
54
  skilleter_thingy/thingy/git.py,sha256=9y58KhFx6t9nNyqMbixM5cl8LBcD2sdCh9UgyVPv4bo,38043
52
55
  skilleter_thingy/thingy/git2.py,sha256=xfQrOpOk4SLdE6T-pr0FTuYGn0gSY92VMDpmqvX3gDM,35751
53
56
  skilleter_thingy/thingy/gitlab.py,sha256=uXAF918xnPk6qQyiwPQDbMZfqtJzhiRqDS7yEtJEIAg,6079
@@ -58,9 +61,9 @@ skilleter_thingy/thingy/process.py,sha256=88pKHQZXBP1m3Ja7t3DtKJ4Njn7HS2OtcI0Z0i
58
61
  skilleter_thingy/thingy/run.py,sha256=051lGahG4liYLckQFpmSaGuE9Chd-lFdmJO85LdmeXE,12607
59
62
  skilleter_thingy/thingy/tfm_pane.py,sha256=40DmQeLMEUPiKKIJkgN1MEpIen00V70I1HB7Q6git44,19814
60
63
  skilleter_thingy/thingy/tidy.py,sha256=wzkyxzCsHXyY46G3Rjqu4ZrqiL8QMbRXyJEeYOmpy-o,5402
61
- skilleter_thingy-0.0.43.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
62
- skilleter_thingy-0.0.43.dist-info/METADATA,sha256=JNXTCsuEenFxp_a2xM31w-P125GvfA6UJCAm4NQW348,5313
63
- skilleter_thingy-0.0.43.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
64
- skilleter_thingy-0.0.43.dist-info/entry_points.txt,sha256=IT6cZSbGHrd2UzIQbiMRotKiTJnYJBkESC4fAe8gjsE,2026
65
- skilleter_thingy-0.0.43.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
66
- skilleter_thingy-0.0.43.dist-info/RECORD,,
64
+ skilleter_thingy-0.0.45.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
65
+ skilleter_thingy-0.0.45.dist-info/METADATA,sha256=00YYxQOpeYPEng-K6B4hx-1WxPGu_pbnA55MVZ65wYs,5313
66
+ skilleter_thingy-0.0.45.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
67
+ skilleter_thingy-0.0.45.dist-info/entry_points.txt,sha256=IT6cZSbGHrd2UzIQbiMRotKiTJnYJBkESC4fAe8gjsE,2026
68
+ skilleter_thingy-0.0.45.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
69
+ skilleter_thingy-0.0.45.dist-info/RECORD,,