def __init__(self, parent=None):
        super(WizardDialog, self).__init__(parent)
        self.setWindowTitle('Workflow Step Wizard')
        self.setFixedSize(675, 550)

        self.setDefaultProperty('QComboBox', 'currentText',
                                'currentIndexChanged')
        self.setDefaultProperty('QLabel', 'pixmap', '')

        if platform.system() == 'Darwin':
            self.setWizardStyle(QtGui.QWizard.MacStyle)
        else:
            self.setWizardStyle(QtGui.QWizard.ModernStyle)
        # set pages
        self.addPage(createIntroPage())
        self.addPage(NameWizardPage())
        self.addPage(PortsWizardPage())
        self.addPage(ConfigWizardPage())
        self.addPage(MiscWizardPage())
        self.addPage(OutputWizardPage())

        # set images banner, logo, watermark and background
        self.setPixmap(QtGui.QWizard.LogoPixmap,
                       QtGui.QPixmap(':/wizard/images/logo.png'))
        self.setPixmap(QtGui.QWizard.BannerPixmap,
                       QtGui.QPixmap(':/wizard/images/banner.png'))
        #         self.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(':/wizard/images/watermark.png'))
        #         self.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizard/images/background.png'))
        self._options = SkeletonOptions()
    def __init__(self, parent=None):
        super(WizardDialog, self).__init__(parent)
        self.setWindowTitle('Workflow Step Wizard')
        self.setFixedSize(675, 550)

        if platform.system() == 'Darwin':
            self.setWizardStyle(QtGui.QWizard.MacStyle)
        else:
            self.setWizardStyle(QtGui.QWizard.ModernStyle)
        # set pages
        self.addPage(createIntroPage())
        self.addPage(NameWizardPage())
        self.addPage(PortsWizardPage())
        self.addPage(ConfigWizardPage())
        self.addPage(MiscWizardPage())
        self.addPage(OutputWizardPage())

        # set images banner, logo, watermark and background
        self.setPixmap(QtGui.QWizard.LogoPixmap, QtGui.QPixmap(':/wizard/images/logo.png'))
        self.setPixmap(QtGui.QWizard.BannerPixmap, QtGui.QPixmap(':/wizard/images/banner.png'))
#         self.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(':/wizard/images/watermark.png'))
#         self.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizard/images/background.png'))
        self._options = SkeletonOptions()
class WizardDialog(QtGui.QWizard):
    def __init__(self, parent=None):
        super(WizardDialog, self).__init__(parent)
        self.setWindowTitle('Workflow Step Wizard')
        self.setFixedSize(675, 550)

        self.setDefaultProperty('QComboBox', 'currentText',
                                'currentIndexChanged')
        self.setDefaultProperty('QLabel', 'pixmap', '')

        if platform.system() == 'Darwin':
            self.setWizardStyle(QtGui.QWizard.MacStyle)
        else:
            self.setWizardStyle(QtGui.QWizard.ModernStyle)
        # set pages
        self.addPage(createIntroPage())
        self.addPage(NameWizardPage())
        self.addPage(PortsWizardPage())
        self.addPage(ConfigWizardPage())
        self.addPage(MiscWizardPage())
        self.addPage(OutputWizardPage())

        # set images banner, logo, watermark and background
        self.setPixmap(QtGui.QWizard.LogoPixmap,
                       QtGui.QPixmap(':/wizard/images/logo.png'))
        self.setPixmap(QtGui.QWizard.BannerPixmap,
                       QtGui.QPixmap(':/wizard/images/banner.png'))
        #         self.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(':/wizard/images/watermark.png'))
        #         self.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizard/images/background.png'))
        self._options = SkeletonOptions()

    def setPreviousWriteStepLocation(self, location):
        page = self.page(5)
        page.setDirectory(location)

    def setPreviousIconLocation(self, location):
        page = self.page(1)
        page.setPreviousLocation(location)

    def getPreviousWriteStepLocation(self):
        return self.field(OUTPUT_DIRECTORY_FIELD)

    def getPreviousIconLocation(self):
        icon_file = self.field(IMAGE_FILE_FIELD)
        return os.path.dirname(icon_file)

    def getOptions(self):
        return self._options

    def accept(self):
        self._options.setOutputDirectory(self.field(OUTPUT_DIRECTORY_FIELD))
        self._options.setImageFile(self.field(IMAGE_FILE_FIELD))
        self._options.setName(self.field(NAME_FIELD))
        self._options.setPackageName(self.field(PACKAGE_NAME_FIELD))
        self._options.setPluginLocation(self.field(PLUGIN_LOCATION_FIELD))

        predefinedName = self.field(PREDEFINED_IMAGE_FIELD)
        predefined_filename = getPredefinedImageLocation(predefinedName)
        icon_filename = self.field(IMAGE_FILE_FIELD)
        if (predefined_filename == icon_filename and predefinedName != 'Default') or \
           (icon_filename and predefined_filename != icon_filename):
            (_, image_filename) = os.path.split(icon_filename)
            self._options.setImageFile(image_filename)
            self._options.setIcon(self.field(ICON_PICTURE_LABEL_FIELD))

        # Registered field failed to return table, may need to set up
        # default property for this to work.  Currently using workaround
        # by directly getting desired widget
        ports_table = self.page(2)._ui.portTableWidget
        row_index = 0
        while row_index < ports_table.rowCount():
            self._options.addPort(
                'http://physiomeproject.org/workflow/1.0/rdf-schema#' +
                ports_table.cellWidget(row_index, 0).currentText(),
                ports_table.item(row_index, 1).text() if ports_table.item(
                    row_index, 1) else '<not-set>')
            row_index += 1

        if self.page(3)._ui.identifierCheckBox.isChecked():
            self._options.addConfig('identifier', '')

        configs_table = self.page(3)._ui.configTableWidget
        row_index = 0
        while row_index < configs_table.rowCount():
            config_label = configs_table.item(row_index, 0)
            config_default_value = configs_table.item(row_index, 1)
            if config_label is not None:
                self._options.addConfig(
                    config_label.text(), '' if config_default_value is None
                    else config_default_value.text())
            row_index += 1

        self._options.setCategory(self.field(CATEGORY_FIELD))
        self._options.setAuthorName(self.field(AUTHOR_NAME_FIELD))

        super(WizardDialog, self).accept()
    def testSkeleton4(self):

        local_package_name = PLUGIN_PACKAGE_NAME
        package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME
        package_dir = os.path.join(self.working_dir, package_full_name)
        step_dir = os.path.join(package_dir, PLUGIN_NAMESPACE,
                                local_package_name)

        options = SkeletonOptions()
        options.setImageFile(IMAGE_FILE_NAME)
        options.setIcon(QtGui.QPixmap(PLUGIN_IMAGE_FILE))
        options.setName(PLUGIN_NAME + str(4))
        options.setPackageName(local_package_name)
        options.setOutputDirectory(self.working_dir)
        options.addPort(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#uses',
            'object')
        options.addPort(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#provides',
            'number')
        options.addPort(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#provides',
            'http://my.example.org/1.0/workflowstep#octopus')
        options.addPort(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'int')
        options.addConfig('Cabbage', 'Brown')
        options.addConfig('Path', '')
        options.addConfig('Carrot', 'tis a long way down')

        pyside_rcc = determinePysideURccExecutable()

        s = Skeleton(options, pyside_rcc)
        s.write()

        self.assertTrue(os.path.exists(package_dir))
        step_file = os.path.join(step_dir, 'step.py')
        self.assertTrue(os.path.exists(step_file))

        file_contents = open(step_file).read()
        self.assertIn('octopus', file_contents)
        self.assertIn(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#provides',
            file_contents)
        self.assertIn('Cabbage', file_contents)
        self.assertIn('Carrot', file_contents)
        self.assertNotIn('{setidentifiercontent}', file_contents)
        self.assertNotIn('{serializecontent}', file_contents)
        self.assertNotIn('{serializesetvalues}', file_contents)

        resources_file = os.path.join(step_dir, 'resources_rc.py')
        self.assertTrue(os.path.exists(resources_file))

        config_file = os.path.join(step_dir, 'configuredialog.py')
        self.assertTrue(os.path.exists(config_file))
    def testSkeleton1(self):

        local_package_name = PLUGIN_PACKAGE_NAME
        package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME
        package_dir = os.path.join(self.working_dir, package_full_name)
        step_dir = os.path.join(package_dir, PLUGIN_NAMESPACE,
                                local_package_name)

        options = SkeletonOptions()
        options.setImageFile(IMAGE_FILE_NAME)
        options.setIcon(QtGui.QPixmap(PLUGIN_IMAGE_FILE))
        options.setName(PLUGIN_NAME + str(1))
        options.setPackageName(local_package_name)
        options.setOutputDirectory(self.working_dir)
        options.addPort(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#uses',
            'object')
        options.addPort(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#provides',
            'http://my.example.org/1.0/workflowstep#octopus')
        options.addConfig('identifier', '')
        options.setAuthorName(AUTHOR_NAME)
        options.setCategory(CATEGORY)
        pyside_rcc = determinePysideURccExecutable()

        s = Skeleton(options, pyside_rcc)
        s.write()

        step_file = os.path.join(step_dir, 'step.py')
        self.assertTrue(os.path.exists(step_file))

        file_contents = open(step_file).read()
        self.assertIn('octopus', file_contents)
        self.assertIn(
            'http://physiomeproject.org/workflow/1.0/rdf-schema#provides',
            file_contents)
        self.assertIn('return self._config[', file_contents)
        self.assertIn('] = identifier', file_contents)
        self.assertIn('self._category = \'' + CATEGORY + '\'', file_contents)
        self.assertNotIn('{setidentifiercontent}', file_contents)
        self.assertNotIn('{serializecontent}', file_contents)
        self.assertNotIn('{serializesetvalues}', file_contents)

        resources_file = os.path.join(step_dir, 'resources_rc.py')
        self.assertTrue(os.path.exists(resources_file))

        config_file = os.path.join(step_dir, 'configuredialog.py')
        self.assertTrue(os.path.exists(config_file))

        config_contents = open(config_file).read()
        self.assertIn('validate', config_contents)
class WizardDialog(QtGui.QWizard):


    def __init__(self, parent=None):
        super(WizardDialog, self).__init__(parent)
        self.setWindowTitle('Workflow Step Wizard')
        self.setFixedSize(675, 550)

        if platform.system() == 'Darwin':
            self.setWizardStyle(QtGui.QWizard.MacStyle)
        else:
            self.setWizardStyle(QtGui.QWizard.ModernStyle)
        # set pages
        self.addPage(createIntroPage())
        self.addPage(NameWizardPage())
        self.addPage(PortsWizardPage())
        self.addPage(ConfigWizardPage())
        self.addPage(MiscWizardPage())
        self.addPage(OutputWizardPage())

        # set images banner, logo, watermark and background
        self.setPixmap(QtGui.QWizard.LogoPixmap, QtGui.QPixmap(':/wizard/images/logo.png'))
        self.setPixmap(QtGui.QWizard.BannerPixmap, QtGui.QPixmap(':/wizard/images/banner.png'))
#         self.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(':/wizard/images/watermark.png'))
#         self.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizard/images/background.png'))
        self._options = SkeletonOptions()

    def getOptions(self):
        return self._options

    def accept(self):
        self._options.setOutputDirectory(self.field(OUTPUT_DIRECTORY_FIELD))
        self._options.setImageFile(self.field(IMAGE_FILE_FIELD))
        self._options.setName(self.field(NAME_FIELD))
        self._options.setPackageName(self.field(PACKAGE_NAME_FIELD))

        # Registered field failed to return table, may need to set up
        # default property for this to work.  Currently using workaround
        # by directly getting desired widget
        ports_table = self.page(2)._ui.portTableWidget
        row_index = 0
        while row_index < ports_table.rowCount():
            self._options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#' + ports_table.cellWidget(row_index, 0).currentText(),
                                   ports_table.item(row_index, 1).text())
            row_index += 1

        if self.page(3)._ui.identifierCheckBox.isChecked():
            self._options.addConfig('identifier', '')

        configs_table = self.page(3)._ui.configTableWidget
        row_index = 0
        while row_index < configs_table.rowCount():
            config_label = configs_table.item(row_index, 0)
            config_default_value = configs_table.item(row_index, 1)
            if config_label is not None:
                self._options.addConfig(config_label.text(),
                                        '' if config_default_value is None else config_default_value.text())
            row_index += 1

        self._options.setCategory(self.field(CATEGORY_FIELD))
        self._options.setAuthorName(self.field(AUTHOR_NAME_FIELD))

        super(WizardDialog, self).accept()
    def testSkeleton4(self):

        local_package_name = PLUGIN_PACKAGE_NAME
        package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME
        package_dir = os.path.join(self.working_dir, package_full_name)
        step_dir = os.path.join(
            package_dir, PLUGIN_NAMESPACE, local_package_name)

        options = SkeletonOptions()
        options.setImageFile(PLUGIN_IMAGE_FILE)
        options.setName(PLUGIN_NAME + str(4))
        options.setPackageName(local_package_name)
        options.setOutputDirectory(self.working_dir)
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'number')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'int')
        options.addConfig('Cabbage', 'Brown')
        options.addConfig('Path', '')
        options.addConfig('Carrot', 'tis a long way down')


        s = Skeleton(options)
        s.write()

        self.assertTrue(os.path.exists(package_dir))
        step_file = os.path.join(step_dir, 'step.py')
        self.assertTrue(os.path.exists(step_file))

        file_contents = open(step_file).read()
        self.assertIn('octopus', file_contents)
        self.assertIn('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents)
        self.assertIn('Cabbage', file_contents)
        self.assertIn('Carrot', file_contents)
        self.assertNotIn('{setidentifiercontent}', file_contents)
        self.assertNotIn('{serializecontent}', file_contents)
        self.assertNotIn('{serializesetvalues}', file_contents)

        resources_file = os.path.join(step_dir, 'resources_rc.py')
        self.assertTrue(os.path.exists(resources_file))

        config_file = os.path.join(step_dir, 'configuredialog.py')
        self.assertTrue(os.path.exists(config_file))
    def testSkeleton2(self):

        local_package_name = PLUGIN_PACKAGE_NAME
        package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME
        package_dir = os.path.join(self.working_dir, package_full_name)
        step_dir = os.path.join(
            package_dir, PLUGIN_NAMESPACE, local_package_name)

        options = SkeletonOptions()
        options.setImageFile(PLUGIN_IMAGE_FILE)
        options.setName(PLUGIN_NAME + str(2))
        options.setPackageName(local_package_name)
        options.setOutputDirectory(self.working_dir)
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'number')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'int')

        s = Skeleton(options)
        s.write()

        step_file = os.path.join(step_dir, 'step.py')
        self.assertTrue(os.path.exists(step_file))

        file_contents = open(step_file).read()
        self.assertIn('octopus', file_contents)
        self.assertIn('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents)
        self.assertIn('# TODO: The string must be replaced with', file_contents)
        self.assertIn('# TODO: Must actually set the step', file_contents)
        self.assertNotIn('{setidentifiercontent}', file_contents)
        self.assertNotIn('{serializecontent}', file_contents)
        self.assertNotIn('{serializesetvalues}', file_contents)

        resources_file = os.path.join(step_dir, 'resources_rc.py')
        self.assertTrue(os.path.exists(resources_file))
    def testSkeleton1(self):

        local_package_name = PLUGIN_PACKAGE_NAME
        package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME
        package_dir = os.path.join(self.working_dir, package_full_name)
        step_dir = os.path.join(
            package_dir, PLUGIN_NAMESPACE, local_package_name)

        options = SkeletonOptions()
        options.setImageFile(PLUGIN_IMAGE_FILE)
        options.setName(PLUGIN_NAME + str(1))
        options.setPackageName(local_package_name)
        options.setOutputDirectory(self.working_dir)
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object')
        options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus')
        options.addConfig('identifier', '')
        options.setAuthorName(AUTHOR_NAME)
        options.setCategory(CATEGORY)

        s = Skeleton(options)
        s.write()

        step_file = os.path.join(step_dir, 'step.py')
        self.assertTrue(os.path.exists(step_file))

        file_contents = open(step_file).read()
        self.assertIn('octopus', file_contents)
        self.assertIn('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents)
        self.assertIn('return self._config[', file_contents)
        self.assertIn('] = identifier', file_contents)
        self.assertIn('self._category = \'' + CATEGORY + '\'', file_contents)
        self.assertNotIn('{setidentifiercontent}', file_contents)
        self.assertNotIn('{serializecontent}', file_contents)
        self.assertNotIn('{serializesetvalues}', file_contents)


        resources_file = os.path.join(step_dir, 'resources_rc.py')
        self.assertTrue(os.path.exists(resources_file))

        config_file = os.path.join(step_dir, 'configuredialog.py')
        self.assertTrue(os.path.exists(config_file))

        config_contents = open(config_file).read()
        self.assertIn('validate', config_contents)