Package glue :: Package ligolw :: Package utils :: Module coincs
[hide private]
[frames] | no frames]

Source Code for Module glue.ligolw.utils.coincs

 1  # Copyright (C) 2006-2010,2012-2013  Kipp Cannon 
 2  # 
 3  # This program is free software; you can redistribute it and/or modify it 
 4  # under the terms of the GNU General Public License as published by the 
 5  # Free Software Foundation; either version 2 of the License, or (at your 
 6  # option) any later version. 
 7  # 
 8  # This program is distributed in the hope that it will be useful, but 
 9  # WITHOUT ANY WARRANTY; without even the implied warranty of 
10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
11  # Public License for more details. 
12  # 
13  # You should have received a copy of the GNU General Public License along 
14  # with this program; if not, write to the Free Software Foundation, Inc., 
15  # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
16   
17   
18  # 
19  # ============================================================================= 
20  # 
21  #                                   Preamble 
22  # 
23  # ============================================================================= 
24  # 
25   
26   
27  """ 
28  A collection of utilities to assist with the use of coinc tables. 
29  """ 
30   
31   
32  from glue import git_version 
33  from .. import lsctables 
34   
35   
36  __author__ = "Kipp Cannon <kipp.cannon@ligo.org>" 
37  __version__ = "git id %s" % git_version.id 
38  __date__ = git_version.date 
39   
40   
41  # 
42  # ============================================================================= 
43  # 
44  #                                    Tables 
45  # 
46  # ============================================================================= 
47  # 
48   
49   
50 -def get_coinc_def_id(xmldoc, search, coinc_type, create_new = True, description = u""):
51 """ 52 Wrapper for the get_coinc_def_id() method of the CoincDefiner table 53 class in glue.ligolw.lsctables. This wrapper will optionally 54 create a new coinc_definer table in the document if one does not 55 already exist. 56 """ 57 try: 58 coincdeftable = lsctables.CoincDefTable.get_table(xmldoc) 59 except ValueError: 60 # table not found 61 if not create_new: 62 raise 63 # FIXME: doesn't work if the document is stored in a 64 # database. 65 coincdeftable = lsctables.New(lsctables.CoincDefTable) 66 xmldoc.childNodes[0].appendChild(coincdeftable) 67 # make sure the next_id attribute is correct 68 coincdeftable.sync_next_id() 69 # get the id 70 return coincdeftable.get_coinc_def_id(search, coinc_type, create_new = create_new, description = description)
71