Skip to content

Commit 534c5d8

Browse files
author
facu.r
committed
minor layout changes to script
1 parent da81217 commit 534c5d8

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,23 +405,24 @@ def generateScript(self, metadata):
405405
def convert2bool(string):
406406
return string.replace('true', 'True').replace('false', 'False')
407407

408-
def header(title):
409-
sep = (76-len(title))//2
410-
return '\n# ' + '-'*sep + ' ' + title.upper() + ' ' + '-'*sep + '\n'
408+
def header(title, spacer='-'):
409+
return '\n# ' + title.upper() + ' ' + spacer*(77-len(title)) + '\n'
411410

412411
try :
413412
params = ['popParams' , 'cellParams', 'synMechParams']
414413
params += ['connParams', 'stimSourceParams', 'stimTargetParams']
415414

416-
with open(metadata['scriptName']+'.py', 'w') as script:
415+
fname = metadata['scriptName'] if metadata['scriptName'][-3:]=='.py' else metadata['scriptName']+'.py'
416+
417+
with open(fname, 'w') as script:
417418
script.write('from netpyne import specs, sim\n')
418-
script.write(header('documentation '))
419+
script.write(header('documentation'))
419420
script.write("''' Script generated with NetPyNE-UI. Please visit:\n")
420421
script.write(" - https://www.netpyne.org\n - https://github.com/MetaCell/NetPyNE-UI\n'''\n")
421-
script.write(header('script'))
422+
script.write(header('script', spacer='='))
422423
script.write('netParams = specs.NetParams()\n')
423424
script.write('simConfig = specs.SimConfig()\n')
424-
script.write(header('single value attributes'))
425+
script.write(header('single value attributes'))
425426
for attr, value in netParams.__dict__.items():
426427
if attr not in params:
427428
if value!=getattr(specs.NetParams(), attr):
@@ -434,7 +435,7 @@ def header(title):
434435
script.write("netParams." + param + "['" + key + "'] = ")
435436
script.write(convert2bool(json.dumps(value, indent=4))+'\n')
436437

437-
script.write(header('network configuration'))
438+
script.write(header('network configuration'))
438439
for attr, value in simConfig.__dict__.items():
439440
if value!=getattr(specs.SimConfig(), attr):
440441
script.write('netParams.' + attr + ' = ')
@@ -443,7 +444,7 @@ def header(title):
443444
script.write(header('create simulate analyze network'))
444445
script.write('sim.createSimulateAnalyze(netParams=netParams, simConfig=simConfig)\n')
445446

446-
script.write(header('end script'))
447+
script.write(header('end script', spacer='='))
447448

448449
return self.getJSONReply()
449450

0 commit comments

Comments
 (0)