Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
tmuxp ls: Do it without pathlib
This way only python 2.7 is needed
  • Loading branch information
tony committed Jul 10, 2020
commit 40a0cf1529407d8e7a82a43ea23d7eb2c6683224
3 changes: 1 addition & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import json
import os
import pathlib

import pytest

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

for filename in filenames:
location = tmpdir.join('.tmuxp/{}'.format(filename))
Expand Down
12 changes: 6 additions & 6 deletions tmuxp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging
import os
import sys
from pathlib import Path

import click
import kaptan
Expand Down Expand Up @@ -931,9 +930,10 @@ def command_convert(config):

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