<s> from __future__ import division <EOL> from PyQt4 import QtCore , QtGui <EOL> from vistrails . core . system import get_vistrails_basic_pkg_id <EOL> from vistrails . gui . modules . module_configure import StandardModuleConfigurationWidget <EOL> class StringFormatConfigurationWidget ( StandardModuleConfigurationWidget ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , module , controller , parent = None ) : <EOL> """<STR_LIT>""" <EOL> StandardModuleConfigurationWidget . __init__ ( self , module , <EOL> controller , parent ) <EOL> self . setWindowTitle ( "<STR_LIT>" ) <EOL> centralLayout = QtGui . QVBoxLayout ( ) <EOL> centralLayout . setMargin ( <NUM_LIT:0> ) <EOL> centralLayout . setSpacing ( <NUM_LIT:0> ) <EOL> self . setLayout ( centralLayout ) <EOL> self . button = QtGui . QPushButton ( "<STR_LIT>" ) <EOL> self . connect ( self . button , QtCore . SIGNAL ( '<STR_LIT>' ) , <EOL> self . saveTriggered ) <EOL> centralLayout . addWidget ( self . button ) <EOL> def activate ( self ) : <EOL> self . button . focusWidget ( QtCore . Qt . ActiveWindowFocusReason ) <EOL> def saveTriggered ( self , checked = False ) : <EOL> """<STR_LIT>""" <EOL> if self . updateVistrail ( ) : <EOL> self . emit ( QtCore . SIGNAL ( '<STR_LIT>' ) ) <EOL> self . emit ( QtCore . SIGNAL ( '<STR_LIT>' ) , self . module . id ) <EOL> def get_format ( self ) : <EOL> for i in xrange ( self . module . getNumFunctions ( ) ) : <EOL> func = self . module . functions [ i ] <EOL> if func . name == '<STR_LIT>' : <EOL> return func . params [ <NUM_LIT:0> ] . strValue <EOL> else : <EOL> return '<STR_LIT>' <EOL> def updateVistrail ( self ) : <EOL> """<STR_LIT>""" <EOL> from vistrails . core . modules . basic_modules import StringFormat <EOL> args , kwargs = StringFormat . list_placeholders ( self . get_format ( ) ) <EOL> wanted_ports = set ( '<STR_LIT>' % n for n in xrange ( args ) ) | kwargs <EOL> current_ports = set ( port_spec . name <EOL> for port_spec in self . module . input_port_specs ) <EOL> sigstring = '<STR_LIT>' <EOL> add_ports = [ ( '<STR_LIT:input>' , n , sigstring , - <NUM_LIT:1> ) <EOL> for n in ( wanted_ports - current_ports ) ] <EOL> delete_ports = [ ( '<STR_LIT:input>' , n ) <EOL> for n in ( current_ports - wanted_ports ) ] <EOL> self . controller . update_ports ( self . module . id , delete_ports , add_ports ) <EOL> return True </s>
