Commit 5dd9060f authored by Chris Pankow's avatar Chris Pankow Committed by Karl Wette
Browse files

Enable lalmetaio to be imported as a python module.

Original: 756598b4b7ddd82973edbc8454c30450eb04b7c8
parent ee19815c
......@@ -21,6 +21,8 @@ lalmetaio-*.tar.gz
lalmetaio.pc
lalmetaio.spec
libtool
python/__init__.py
python/git_version.py
src/LALMetaIOConfig.h
src/LALMetaIOVCSInfo.h
src/git_version
......
......@@ -18,7 +18,8 @@ SUBDIRS = \
debian \
include \
src \
swig
swig \
python
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = lalmetaio.pc
......
......@@ -12,6 +12,8 @@ AC_CONFIG_FILES([ \
debian/Makefile \
include/Makefile \
include/lal/Makefile \
python/Makefile \
python/__init__.py \
src/Makefile \
swig/Makefile \
swig/octave/Makefile \
......
pkgpython_PYTHON = \
__init__.py \
git_version.py
EXTRA_DIST = \
git_version.py
BUILT_SOURCES =
MOSTLYCLEANFILES =
if HAVE_GIT_REPO
BUILT_SOURCES += git_version.py
MOSTLYCLEANFILES += git_version.py
git_version.py .PHONY : gen-git_version.py
gen-git_version.py :
$(AM_V_at)$(GENERATE_VCS_INFO) git_version.py $(srcdir)/git_version.py.git
endif
# Import SWIG wrappings, if available
@SWIG_BUILD_PYTHON_TRUE@from lalmetaio import *
# git_version.py - vcs information module
#
# Copyright (C) 2010 Nickolas Fotopoulos
# Copyright (C) 2012-2013 Adam Mercer
#
# 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 with program; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
id = "@ID@"
date = "@DATE@"
branch = "@BRANCH@"
tag = "@TAG@"
if tag == "None":
tag = None
author = "@AUTHOR@"
builder = "@BUILDER@"
committer = "@COMMITTER@"
status = "@STATUS@"
version = id
verbose_msg = """Branch: @BRANCH@
Tag: @TAG@
Id: @ID@
Builder: @BUILDER@
Repository status: @STATUS@"""
import warnings
class VersionMismatchError(ValueError):
pass
def check_match(foreign_id, onmismatch="raise"):
"""
If foreign_id != id, perform an action specified by the onmismatch
kwarg. This can be useful for validating input files.
onmismatch actions:
"raise": raise a VersionMismatchError, stating both versions involved
"warn": emit a warning, stating both versions involved
"""
if onmismatch not in ("raise", "warn"):
raise ValueError, onmismatch + " is an unrecognized value of onmismatch"
if foreign_id == "@ID@":
return
msg = "Program id (@ID@) does not match given id (%s)." % foreign_id
if onmismatch == "raise":
raise VersionMismatchError, msg
# in the backtrace, show calling code
warnings.warn(msg, UserWarning)
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