(modules, options, mutaData=None)
| 127 | |
| 128 | |
| 129 | def exportModules(modules, options, mutaData=None): |
| 130 | if mutaData is None: |
| 131 | mutaData = MutationExportData() |
| 132 | modsBySlotType = {} |
| 133 | for module in modules: |
| 134 | modsBySlotType.setdefault(module.slot, []).append(module) |
| 135 | modSection = [] |
| 136 | for slotType in SLOT_ORDER: |
| 137 | rackLines = [] |
| 138 | rackModules = modsBySlotType.get(slotType, ()) |
| 139 | for module in rackModules: |
| 140 | if module.item: |
| 141 | # if module was mutated, use base item name for export |
| 142 | if module.isMutated: |
| 143 | modName = module.baseItem.typeName |
| 144 | else: |
| 145 | modName = module.item.typeName |
| 146 | if module.isMutated and options[PortEftOptions.MUTATIONS]: |
| 147 | mutaData.mutants[mutaData.reference] = module |
| 148 | mutationSuffix = ' [{}]'.format(mutaData.reference) |
| 149 | mutaData.reference += 1 |
| 150 | else: |
| 151 | mutationSuffix = '' |
| 152 | modOfflineSuffix = ' {}'.format(OFFLINE_SUFFIX) if module.state == FittingModuleState.OFFLINE else '' |
| 153 | if module.charge and options[PortEftOptions.LOADED_CHARGES]: |
| 154 | rackLines.append('{}, {}{}{}'.format( |
| 155 | modName, module.charge.typeName, modOfflineSuffix, mutationSuffix)) |
| 156 | else: |
| 157 | rackLines.append('{}{}{}'.format(modName, modOfflineSuffix, mutationSuffix)) |
| 158 | else: |
| 159 | rackLines.append('[Empty {} slot]'.format( |
| 160 | FittingSlot(slotType).name.capitalize() if slotType is not None else '')) |
| 161 | if rackLines: |
| 162 | modSection.append('\n'.join(rackLines)) |
| 163 | return '\n\n'.join(modSection) |
| 164 | |
| 165 | |
| 166 | def exportDrones(drones, exportMutants=True, mutaData=None, standAlone=True): |
no test coverage detected