Skip to content

Commit bcd0ca1

Browse files
lguerardehrenfeu
authored andcommitted
Add fix for \n and \t getting interpretated as new line and tabs
1 parent 139a3b5 commit bcd0ca1

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/imcflibs/pathtools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def parse_path(path, prefix=""):
101101
'path': '/path/to/some/'}
102102
"""
103103
path = str(path)
104+
path = path.replace("\n", "\\n").replace("\t", "\\t")
104105
if prefix:
105106
# remove leading slash, otherwise join() will discard the first path:
106107
if path.startswith("/"):

tests/test_pathtools.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
import pytest
54
from imcflibs.pathtools import parse_path
65
from imcflibs.pathtools import jython_fiji_exists
76
from imcflibs.pathtools import image_basename
@@ -44,6 +43,14 @@ def test_parse_path_windows():
4443
assert parsed['dname'] == 'foo'
4544

4645

46+
def test_parse_path_windows_tabs_and_lines():
47+
path = "C:\new_folder\test"
48+
parsed = parse_path(path)
49+
50+
assert parsed["full"] == r"C:\new_folder\test"
51+
assert parsed["fname"] == "test"
52+
53+
4754
def test_jython_fiji_exists(tmpdir):
4855
assert jython_fiji_exists(str(tmpdir)) == True
4956

0 commit comments

Comments
 (0)