Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions casacore/tables/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True,
_columnnames=[], _datatypes=[],
_oper=0, _delete=False):
"""Open or create a table."""
import pathlib
if isinstance(tablename, pathlib.Path):
tablename = str(tablename)
if _oper == 1:
# This is the readascii constructor.
tabname = _remove_prefix(tablename)
Expand Down
4 changes: 3 additions & 1 deletion casacore/tables/tablehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def _remove_prefix(name):
"""Strip the possible prefix 'Table: ' from one or more table names."""
if isinstance(name, str):
return _do_remove_prefix(name)
return [_do_remove_prefix(nm) for nm in name]
elif hasattr(name, "__iter__"):
return [_do_remove_prefix(nm) for nm in name]
return name


def _check_index(key, name):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_table.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for tables module."""
import pathlib
import unittest
from casacore.tables import (makescacoldesc, makearrcoldesc, table,
maketabdesc, tableexists, tableiswritable,
Expand Down Expand Up @@ -58,6 +59,14 @@ def test_tableinfo(self):
t.close()
tabledelete("ttable.py_tmp.tab1")

def test_path_suppoert(self):
"""Test table names can be given as Path objects."""
c1 = makescacoldesc("col", 0)
path = pathlib.Path("ttable.py_tmp.tab1")
t = table(path, maketabdesc([c1]), ack=False)
t.close()
tabledelete(path)

def test_tableascii(self):
"""Testing ASCII table."""
c1 = makescacoldesc("coli", 0)
Expand Down
Loading