Commit 5f42fc2b authored by John Douglas Veitch's avatar John Douglas Veitch
Browse files

Merge branch 'remove-lalinference-util' into 'master'

Remove lalinference.util, deprecated and moved to ligo.skymap

See merge request lscsoft/lalsuite!1293
parents 22780605 f7aed16a
......@@ -194,7 +194,6 @@ outputs:
- lalinference.tiger.make_injtimes
- lalinference.tiger.omegascans_dag
- lalinference.tiger.postproc
- lalinference.util.file
- lalinference.wrapper
about:
home: "https://wiki.ligo.org/Computing/LALSuite"
......
......@@ -22,7 +22,6 @@ AC_CONFIG_FILES([ \
python/lalinference/io/Makefile \
python/lalinference/plot/Makefile \
python/lalinference/tiger/Makefile \
python/lalinference/util/Makefile \
lib/LALInferenceVCSInfo.c \
lib/LALInferenceVCSInfo.h \
lib/Makefile \
......
......@@ -10,7 +10,6 @@ SUBDIRS = \
io \
plot \
tiger \
util \
$(END_OF_LIST)
vcs_info_sources = git_version.py
......
......@@ -73,7 +73,7 @@ def _find_table(group, tablename):
Check that we can find a file by name:
>>> import os.path
>>> from lalinference.util.file import TemporaryDirectory
>>> from tempfile import TemporaryDirectory
>>> table = Table(np.eye(3), names=['a', 'b', 'c'])
>>> with TemporaryDirectory() as dir:
... filename = os.path.join(dir, 'test.hdf5')
......@@ -148,7 +148,7 @@ def read_samples(filename, path=None, tablename=POSTERIOR_SAMPLES):
Test reading a file written using the Python API:
>>> import os.path
>>> from lalinference.util.file import TemporaryDirectory
>>> from tempfile import TemporaryDirectory
>>> table = Table([
... Column(np.ones(10), name='foo', meta={'vary': FIXED}),
... Column(np.arange(10), name='bar', meta={'vary': LINEAR}),
......@@ -230,7 +230,7 @@ def write_samples(table, filename, metadata=None, **kwargs):
And now try writing an arbitrary example to a temporary file.
>>> import os.path
>>> from lalinference.util.file import TemporaryDirectory
>>> from tempfile import TemporaryDirectory
>>> table = Table([
... Column(np.ones(10), name='foo', meta={'vary': FIXED}),
... Column(np.arange(10), name='bar', meta={'vary': LINEAR}),
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
if HAVE_PYTHON
pymoduledir = $(pkgpythondir)/util
pymodule_PYTHON = \
__init__.py \
file.py \
$(END_OF_LIST)
endif
#
# Copyright (C) 2018 Leo Singer
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""File tools"""
import contextlib
import errno
import os
import shutil
import tempfile
def rename(src, dst):
"""Like os.rename(src, dst), but works across different devices because it
catches and handles EXDEV ('Invalid cross-device link') errors."""
try:
os.rename(src, dst)
except OSError as e:
if e.errno == errno.EXDEV:
dir, suffix = os.path.split(dst)
tmpfid, tmpdst = tempfile.mkstemp(dir=dir, suffix=suffix)
try:
os.close(tmpfid)
shutil.copy2(src, tmpdst)
os.rename(tmpdst, dst)
except:
os.remove(tmpdst)
raise
else:
raise
def rm_f(filename):
"""Remove a file, or be silent if the file does not exist, like `rm -f`."""
try:
os.remove(filename)
except OSError as e:
if e.errno != errno.ENOENT:
raise
@contextlib.contextmanager
def TemporaryDirectory(suffix='', prefix='tmp', dir=None, delete=True):
try:
dir = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir)
yield dir
finally:
if delete:
shutil.rmtree(dir)
from lalinference.bayestar.deprecation import warn
warn('ligo.skymap.util.file')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment