Skip to content

Commit 3d05622

Browse files
committed
Abstracted BACKUP_PATH
1 parent f949a26 commit 3d05622

14 files changed

Lines changed: 84 additions & 70 deletions

File tree

  • computer-languages/utils/lib
  • data-languages/utils/lib
  • find-project-root/utils/lib
  • get-min-py/utils/lib
  • is-legacy-terminal/utils/lib
  • is-unicode-supported/utils/lib
  • latin-locales/utils/lib
  • markup-languages/utils/lib
  • non-latin-locales/utils/lib
  • programming-languages/utils/lib
  • project-markers/utils/lib
  • prose-languages/utils/lib
  • remove-json-keys/utils/lib
  • translate-messages/utils/lib

computer-languages/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

data-languages/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

find-project-root/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

get-min-py/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

is-legacy-terminal/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

is-unicode-supported/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

latin-locales/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

markup-languages/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

non-latin-locales/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

programming-languages/utils/lib/git.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from pathlib import Path
22
import subprocess
33

4+
BACKUP_PATH = Path.home() / '.gitconfig.backup'
5+
46
def commit(files, msg, *args) : run('add', *files) ; run('commit', '-m', msg, *args)
57

68
def init_kudo_sync_bot(msgs):
79
import os
810
print(f'\n{msgs.log_SWITCHING_TO_KUDO_SYNC_BOT}...\n')
9-
with open(Path.home() / '.gitconfig.backup', 'w') as file: # back up git config
11+
with open(BACKUP_PATH, 'w') as file: # back up git config
1012
file.write(run('config', '--global', '--list'))
1113
gpg_keys_path = os.environ.get('GPG_KEYS_PATH')
1214
if gpg_keys_path:
@@ -25,14 +27,13 @@ def push() : run('push')
2527

2628
def restore_og_config(msgs):
2729
print(f'{msgs.log_RESTORING_OG_GIT_CONFIG}...')
28-
backup_path = Path.home() / '.gitconfig.backup'
29-
if backup_path.exists():
30-
with open(backup_path) as file:
30+
if BACKUP_PATH.exists():
31+
with open(BACKUP_PATH) as file:
3132
for line in file:
3233
if '=' in line:
3334
key, val = line.strip().split('=', 1)
3435
run('config', '--global', key, val)
35-
backup_path.unlink()
36+
BACKUP_PATH.unlink()
3637
else:
3738
print(msgs.warn_GIT_CONFIG_BACKUP_NOT_FOUND)
3839

0 commit comments

Comments
 (0)