Skip to content

Commit

Permalink
Improve error handling and fix a bug in is_list utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
joowani committed Jan 15, 2016
1 parent 286a318 commit bbd643d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dtags/commands/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def main():
parsed = parser.parse_args()

if parsed.edit:
if parsed.search_terms:
raise parser.error('no arguments allowed with option -e/--edit')
edit_file_path = TAGS_FILE_PATH + '.edit'
shutil.copy2(TAGS_FILE_PATH, edit_file_path)
subprocess.call([os.environ.get('EDITOR', 'vi'), edit_file_path])
Expand Down
4 changes: 3 additions & 1 deletion dtags/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ def check_tags(tags):
raise ValueError('expecting a non-empty list for {}'.format(tag))
for path in paths:
if not (is_str(path) and os.path.isdir(expand_path(path))):
raise ValueError('invalid directory path for {}'.format(tag))
raise ValueError(
'invalid directory path {} for {}'.format(path, tag)
)
4 changes: 2 additions & 2 deletions dtags/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import importlib
from sys import stderr

from collections import Mapping, Iterable
from collections import Mapping
# Importing this way for python 2 and 3 compatibility
try:
urllib = importlib.import_module('urllib.parse')
Expand Down Expand Up @@ -34,7 +34,7 @@ def is_list(obj):
:param obj: object to check
:return: True if iterable, else False
"""
return isinstance(obj, Iterable)
return type(obj) == list


def is_dict(obj):
Expand Down

0 comments on commit bbd643d

Please sign in to comment.