Skip to content
Merged
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
Comment thread
rtobar marked this conversation as resolved.
if isinstance(tablename, pathlib.Path):
tablename = str(tablename)
if _oper == 1:
# This is the readascii constructor.
tabname = _remove_prefix(tablename)
Expand Down
3 changes: 3 additions & 0 deletions casacore/tables/tablehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# $Id: tableutil.py,v 1.6 2006/11/08 00:12:55 gvandiep Exp $

import numpy
import pathlib
import re
from ..quanta import quantity

Expand All @@ -51,6 +52,8 @@ def _remove_prefix(name):
"""Strip the possible prefix 'Table: ' from one or more table names."""
if isinstance(name, str):
return _do_remove_prefix(name)
elif isinstance(name, pathlib.Path):
return name
return [_do_remove_prefix(nm) for nm in 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_support(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)
Comment thread
rtobar marked this conversation as resolved.

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