Commit 08cc2a10f58bc6c9f1868a5c349d4af9b8e543c3

Authored by Jürgen Knödlseder
1 parent 9bde7753

Replace compact csv header writing that is not supported on Python 2.3 by a more explicit syntax.

cscripts/__init__.py.in
@@ -50,20 +50,6 @@ if cur_version > req_version: @@ -50,20 +50,6 @@ if cur_version > req_version:
50 50
51 51
52 # Import 52 # Import
53 -#from @PYTHON_RELATIVE_IMPORT@cscaldb import cscaldb  
54 -#from @PYTHON_RELATIVE_IMPORT@csinfo import csinfo  
55 -#from @PYTHON_RELATIVE_IMPORT@cslightcrv import cslightcrv  
56 -#from @PYTHON_RELATIVE_IMPORT@csmodelinfo import csmodelinfo  
57 -#from @PYTHON_RELATIVE_IMPORT@csmodelmerge import csmodelmerge  
58 -#from @PYTHON_RELATIVE_IMPORT@csobs2caldb import csobs2caldb  
59 -#from @PYTHON_RELATIVE_IMPORT@csobsdef import csobsdef  
60 -#from @PYTHON_RELATIVE_IMPORT@csobsinfo import csobsinfo  
61 -#from @PYTHON_RELATIVE_IMPORT@cspull import cspull  
62 -#from @PYTHON_RELATIVE_IMPORT@csresmap import csresmap  
63 -#from @PYTHON_RELATIVE_IMPORT@cssens import cssens  
64 -#from @PYTHON_RELATIVE_IMPORT@csspec import csspec  
65 -#from @PYTHON_RELATIVE_IMPORT@cstsdist import cstsdist  
66 -#from @PYTHON_RELATIVE_IMPORT@cstsmapmerge import cstsmapmerge  
67 import cscaldb 53 import cscaldb
68 import csinfo 54 import csinfo
69 import cslightcrv 55 import cslightcrv
@@ -80,10 +66,6 @@ import cstsdist @@ -80,10 +66,6 @@ import cstsdist
80 import cstsmapmerge 66 import cstsmapmerge
81 import obsutils 67 import obsutils
82 if cur_version > req_version: 68 if cur_version > req_version:
83 - #from @PYTHON_RELATIVE_IMPORT@csfindobs import csfindobs  
84 - #from @PYTHON_RELATIVE_IMPORT@csiactcopy import csiactcopy  
85 - #from @PYTHON_RELATIVE_IMPORT@csiactdata import csiactdata  
86 - #from @PYTHON_RELATIVE_IMPORT@csiactobs import csiactobs  
87 import csfindobs 69 import csfindobs
88 import csiactcopy 70 import csiactcopy
89 import csiactdata 71 import csiactdata
cscripts/cspull.py
@@ -321,7 +321,11 @@ class cspull(ctools.cscript): @@ -321,7 +321,11 @@ class cspull(ctools.cscript):
321 if seed == 0: 321 if seed == 0:
322 file = open(self.m_outfile.url(), 'w') 322 file = open(self.m_outfile.url(), 'w')
323 writer = csv.DictWriter(file, result['colnames']) 323 writer = csv.DictWriter(file, result['colnames'])
324 - writer.writerow(dict((_,_) for _ in result['colnames'])) 324 + headers = {}
  325 + for n in result['colnames']:
  326 + headers[n] = n
  327 + writer.writerow(headers)
  328 + #writer.writerow(dict((_,_) for _ in result['colnames']))
325 else: 329 else:
326 file = open(self.m_outfile.url(), 'a') 330 file = open(self.m_outfile.url(), 'a')
327 writer = csv.DictWriter(file, result['colnames']) 331 writer = csv.DictWriter(file, result['colnames'])
cscripts/cssens.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # This script computes the CTA sensitivity. 3 # This script computes the CTA sensitivity.
4 # 4 #
5 -# Copyright (C) 2011-2015 Juergen Knoedlseder 5 +# Copyright (C) 2011-2016 Juergen Knoedlseder
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify 7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by 8 # it under the terms of the GNU General Public License as published by
@@ -251,7 +251,11 @@ class cssens(ctools.cscript): @@ -251,7 +251,11 @@ class cssens(ctools.cscript):
251 if ieng == 0: 251 if ieng == 0:
252 f = open(self.m_outfile.url(), 'w') 252 f = open(self.m_outfile.url(), 'w')
253 writer = csv.DictWriter(f, colnames) 253 writer = csv.DictWriter(f, colnames)
254 - writer.writerow(dict((_,_) for _ in colnames)) 254 + headers = {}
  255 + for n in colnames:
  256 + headers[n] = n
  257 + writer.writerow(headers)
  258 + #writer.writerow(dict((_,_) for _ in colnames))
255 writer.writerow(result) 259 writer.writerow(result)
256 f.close() 260 f.close()
257 else: 261 else:
cscripts/cstsdist.py
@@ -251,7 +251,11 @@ class cstsdist(ctools.cscript): @@ -251,7 +251,11 @@ class cstsdist(ctools.cscript):
251 if seed == 0: 251 if seed == 0:
252 file = open(self.m_outfile.url(), 'w') 252 file = open(self.m_outfile.url(), 'w')
253 writer = csv.DictWriter(file, result['colnames']) 253 writer = csv.DictWriter(file, result['colnames'])
254 - writer.writerow(dict((_,_) for _ in result['colnames'])) 254 + headers = {}
  255 + for n in result['colnames']:
  256 + headers[n] = n
  257 + writer.writerow(headers)
  258 + #writer.writerow(dict((_,_) for _ in result['colnames']))
255 else: 259 else:
256 file = open(self.m_outfile.url(), 'a') 260 file = open(self.m_outfile.url(), 'a')
257 writer = csv.DictWriter(file, result['colnames']) 261 writer = csv.DictWriter(file, result['colnames'])