def _run_swig(self): """ Do everything that needs doing in the subdir 'swig'. - Edit main *.i file """ if self._get_mainswigfile() is None: print 'Warning: No main swig file found.' return print "Editing %s..." % self._file['swig'] mod_block_sep = '/' if self._info['version'] == '36': mod_block_sep = '_' swig_block_magic_str = get_template('swig_block_magic', **self._info) open(self._file['swig'], 'a').write(swig_block_magic_str) include_str = '#include "%s%s%s.h"' % ( {True: 'gnuradio/' + self._info['modname'], False: self._info['modname']}[self._info['is_component']], mod_block_sep, self._info['blockname']) if re.search('#include', open(self._file['swig'], 'r').read()): append_re_line_sequence(self._file['swig'], '^#include.*\n', include_str) else: # I.e., if the swig file is empty oldfile = open(self._file['swig'], 'r').read() regexp = re.compile('^%\{\n', re.MULTILINE) oldfile = regexp.sub('%%{\n%s\n' % include_str, oldfile, count=1) open(self._file['swig'], 'w').write(oldfile) self.scm.mark_files_updated((self._file['swig'],))
def setup_choose_license(self): """ Select a license by the following rules, in this order: 1) The contents of the file given by --license-file 2) The contents of the file LICENSE or LICENCE in the modules top directory 3) The default license. """ if self._license_file is not None \ and os.path.isfile(self._license_file): return open(self._license_file).read() elif os.path.isfile('LICENSE'): return open('LICENSE').read() elif os.path.isfile('LICENCE'): return open('LICENCE').read() elif self._info['is_component']: return Templates['grlicense'] return get_template('defaultlicense', **self._info)
def _write_tpl(self, tpl, path, fname): """ Shorthand for writing a substituted template to a file""" print "Adding file '%s'..." % fname open(os.path.join(path, fname), 'w').write(get_template(tpl, **self._info))
def _write_tpl(self, tpl, path, fname): """ Shorthand for writing a substituted template to a file""" path_to_file = os.path.join(path, fname) print "Adding file '%s'..." % path_to_file open(path_to_file, 'w').write(get_template(tpl, **self._info)) self.scm.add_files((path_to_file,))