Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
__SILENT_START__ = False
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
if os.sys.platform=='win32' and os.path.isdir(extra_dll_dir):
os.environ["PATH"] += os.pathsep + extra_dll_dir
if hasattr(os, 'add_dll_directory'):
os.add_dll_directory(extra_dll_dir)
if os.sys.platform == 'win32':
__PyscesConfigDefault = PyscesConfig.__DefaultWin
else:
__PyscesConfigDefault = PyscesConfig.__DefaultPosix
if DEBUG: print(time.strftime('1-%H:%M:%S'))
eggdir = 'pysces-%s-py%s.%s-%s.egg' %(__version__, os.sys.version_info[0],\
os.sys.version_info[1], get_build_platform())
for path in os.sys.path:
chkPath = path.split(os.path.sep)[-1]
if chkPath == 'pysces' and path != os.getcwd():
install_dir = path
inipath = os.path.join(install_dir, 'pyscfg.ini')
break
elif chkPath == eggdir:
install_dir = os.path.join(path, 'pysces')
inipath = os.path.join(install_dir, 'pyscfg.ini')
break
if inipath == None:
for k in os.sys.path_importer_cache:
if k.split(os.path.sep)[-1] == 'pysces':
install_dir = k
inipath = os.path.join(install_dir, 'pyscfg.ini')
Write a PSC file header to an open file object
Arguments:
=========
File: a writable open text file object
"""
try:
UseR = getuser()
except:
UseR = ''
header = ''
#header += '############################################################\n'
header += '# PySCeS (' + __version__ + ') model input file\n'
header += '# PySCeS can be found at http://pysces.sourceforge.net/\n'
#header += '###########################################################\n\n'
header += '# Original input file: ' + File.name.split('\\')[-1][:-4] + '\n'
header += '# This file generated: ' + strftime("%a, %d %b %Y %H:%M:%S") + ' by '+UseR+'\n\n'
File.write(header)
File.write('\n')
print('\nInvalid input')
except:
print('\nFile "' + filex + '" does not exist, proceeding...')
loop = 1
go = 1
if go == 1:
try:
UseR = getuser()
except:
UseR = ''
outFile = open(filex,'w')
header = ''
#header += '############################################################\n'
header += '# JWS model input file \n'
header += '# Generated by PySCeS (' + __version__ + ') (http://pysces.sourceforge.net) \n'
header += '# Pysces input file: ' + File + '\n'
header += '# This file generated: ' + strftime("%a, %d %b %Y %H:%M:%S") + ' by '+UseR+' \n'
header += '###########################################################\n\n'
outFile.write(header)
# modelname
modelname = File[:-4]
outFile.write('begin name\n' + modelname + '\nend name\n\n')
# reactions and rate equations
reaction_list = []
rateeq_list = []
nd = self.NetworkDict
reaclist = copy.copy(list(nd.keys())) # johann -- to sort self.ReactionIDs neatly ;-)
reaclist.sort()
def HTML_footer(self,File):
"""
HTML_footer(File)
Write an HTML page footer to file (use with HTML_header)
Arguments:
=========
File: an open, writable Python file object
"""
File.write('\n<p><a href="http://pysces.sourceforge.net"><font size="3">PySCeS '+__version__+\
'</font></a><font size="2"> output\n generated at ' + strftime("%H:%M:%S")+\
' by <i>')
try:
File.write(getuser())
except:
File.write('PySCeS')
File.write('</i>)</font></p>\n')
File.write('\n')
File.write('\n\n')
return File
*name*.dat.
- *name* the name of the GnuPlot plt and and datafile
- *directory* (optional) the directory to use (defaults to working directory)
- *dfmt* is ignored and uses the value of self.DATF_FORMAT
"""
if directory != None:
out_n = os.path.join(directory, name)
else:
out_n = os.path.join(self.__WORK_DIR__, name)
self.g_write('save "%s.plt"' % out_n)
shutil.copy(os.path.join(self.__WORK_DIR__, self.__DATA_FILE_NAME__), "%s.dat" % out_n)
F = open('%s.plt'% out_n, 'r')
fnew = F.read().replace('_gnuplot.dat','%s.dat' % name)
fnew = fnew.replace('noequal_axes','') # fixes the "noequal_axes" bug in gnuplot save
fnew = fnew.replace('#!/gnuplot','#!/gnuplot\n#\n# Plot created using PySCeS %s (http://pysces.sourceforge.net)' % __version__) # fixes the "noequal_axes" bug in gnuplot save
F.close()
F = open('%s.plt'% out_n, 'w')
F.write(fnew)
F.flush()
F.close()
File.write('<p align="center">\n')
File.write('<img border="2" height="480" width="640" src="'+imagename+'">\n')
if name != None:
File.write('<br><font size="3">' + str(name) + '</font>\n')
File.write('</p>\n\n')
if self.save_html_footer:
try:
File.write('<p><a href="http://pysces.sourceforge.net"><font size="3">PySCeS '+self.__version__+\
'</font></a><font size="2"> HTML output (image <i>'+imagename+\
'</i> produced at '+strftime("%H:%M:%S")+' by <i>'+getuser()+'</i>)</font></p>\n')
except:
File.write('<p><a href="http://pysces.sourceforge.net"><font size="3">PySCeS '+__version__+\
'</font></a><font size="2"> HTML output (model <i>'+imagename+\
'</i> produced at '+strftime("%H:%M:%S - %Z")+')</font></p>\n')
File.write('\n')
File.write('\n')
else:
File.write('\n')
if close_file:
File.close()