Skip to content

Commit 40a0cf1

Browse files
committed
tmuxp ls: Do it without pathlib
This way only python 2.7 is needed
1 parent 77c45af commit 40a0cf1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

tests/test_cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import json
66
import os
7-
import pathlib
87

98
import pytest
109

@@ -599,7 +598,7 @@ def test_ls_cli(monkeypatch, tmpdir):
599598
# - directories should be ignored
600599
# - extensions not covered in VALID_CONFIG_DIR_FILE_EXTENSIONS
601600
ignored_filenames = ['.git/', '.gitignore/', 'session_4.txt']
602-
stems = [pathlib.PurePath(f).stem for f in filenames if f not in ignored_filenames]
601+
stems = [os.path.splitext(f)[0] for f in filenames if f not in ignored_filenames]
603602

604603
for filename in filenames:
605604
location = tmpdir.join('.tmuxp/{}'.format(filename))

tmuxp/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import logging
1111
import os
1212
import sys
13-
from pathlib import Path
1413

1514
import click
1615
import kaptan
@@ -931,9 +930,10 @@ def command_convert(config):
931930

932931
@cli.command(name='ls', short_help='List configured sessions in $HOME/.tmuxp dir.')
933932
def command_ls():
934-
tmuxp_dir = Path.home() / '.tmuxp'
935-
if tmuxp_dir.exists() and tmuxp_dir.is_dir():
936-
for f in sorted(tmuxp_dir.iterdir()):
937-
if f.is_dir() or f.suffix not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
933+
tmuxp_dir = get_config_dir()
934+
if os.path.exists(tmuxp_dir) and os.path.isdir(tmuxp_dir):
935+
for f in sorted(os.listdir(tmuxp_dir)):
936+
stem, ext = os.path.splitext(f)
937+
if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
938938
continue
939-
print(f.stem)
939+
print(stem)

0 commit comments

Comments
 (0)