Commit 2f3bf4f969593a7795c745f564886bcd27caf38a

Authored by Jürgen Knödlseder
1 parent 159db9e0

Add new instrument module to __init__.py.in in code generation

dev/codegen.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # GammaLib code generator
4 4 #
5   -# Copyright (C) 2017 Juergen Knoedlseder
  5 +# Copyright (C) 2017-2018 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -432,6 +432,13 @@ def adjust_python_config(name, instrument):
432 432 print(rule)
433 433 print line,
434 434  
  435 + # Adjust pyext/gammalib/__init__.py.in
  436 + module = ('from gammalib.%s import *' % name)
  437 + for line in fileinput.FileInput('pyext/gammalib/__init__.py.in',inplace=1):
  438 + if '# Insert new module here' in line:
  439 + print(module)
  440 + print line,
  441 +
435 442 # Return
436 443 return
437 444  
... ... @@ -479,13 +486,15 @@ def adjust_test_config(name, instrument):
479 486 ' has_%s = False\n' % \
480 487 (instrument, name.upper(), name, name)
481 488 data = ' os.environ[\'TEST_%s_DATA\'] = \'%s/data\'' % \
482   - (name.upper(), name)
  489 + (name.upper(), name)
483 490 suite = ' # Optionally handle %s suite\n' \
484 491 ' if has_%s:\n' \
485 492 ' suite_%s = test_%s.Test()\n' \
486 493 ' suite_%s.set()\n' \
487 494 ' suites.append(suite_%s)\n' % \
488 495 (instrument, name, name, name.upper(), name, name)
  496 + cpy = ' os.system(\'cp -r %%s %%s\' %% (head+\'/%s\', \'%s\'))' % \
  497 + (name, name)
489 498 for line in fileinput.FileInput('test/test_python.py',inplace=1):
490 499 if '# Insert new test here' in line:
491 500 print(test)
... ... @@ -493,6 +502,8 @@ def adjust_test_config(name, instrument):
493 502 print(data)
494 503 if '# Insert new suite here' in line:
495 504 print(suite)
  505 + if '# Copy over test data' in line:
  506 + print(cpy)
496 507 print line,
497 508  
498 509 # Return
... ...
pyext/gammalib/__init__.py.in
1 1 # ==========================================================================
2 2 # GammaLib Python module
3 3 #
4   -# Copyright (C) 2016 Juergen Knoedlseder
  4 +# Copyright (C) 2016-2018 Juergen Knoedlseder
5 5 #
6 6 # This program is free software: you can redistribute it and/or modify
7 7 # it under the terms of the GNU General Public License as published by
... ... @@ -36,6 +36,7 @@ from gammalib.mwl import *
36 36 from gammalib.cta import *
37 37 from gammalib.lat import *
38 38 from gammalib.com import *
  39 +# Insert new module here
39 40  
40 41 # Remove swig register stuff
41 42 bad_entries = [entry for entry in list(locals())
... ...