def ImportExes(self, event=None): event_id = event.GetId() if event_id == btnid.IMPORT: # First clear the Auto-Link display and the executable list self.Executables.Reset() # Get executables from "files" tab file_list = GetField(pgid.FILES, inputid.LIST) for INDEX in range(file_list.GetItemCount()): # Get the filename from the source file_name = file_list.GetFilename(INDEX, basename=True) file_path = file_list.GetPath(INDEX) # Where the file linked to will be installed file_target = file_list.GetItem(INDEX, 1) # Walk directory to find executables if file_list.IsDirectory(INDEX): for EXE in GetFiles(file_path, os.X_OK): self.Executables.Append(FileItem(EXE, file_target)) # Search for executables (distinguished by red text) elif file_list.IsExecutable(INDEX): try: # If destination doesn't start with "/" do not include executable if file_target.GetText()[0] == u'/': if file_target.GetText()[-1] == u'/' or file_target.GetText()[-1] == u' ': # In case the full path of the destination is "/" keep going if len(file_target.GetText()) == 1: dest_path = u'' else: search = True # Set the number of spaces to remove from dest path in case of multiple "/" slashes = 1 while search: # Find the number of slashes/spaces at the end of the filename endline = slashes - 1 if file_target.GetText()[-slashes] == u'/' or file_target.GetText()[-slashes] == u' ': slashes += 1 else: dest_path = file_target.GetText()[:-endline] search = False else: dest_path = file_target.GetText() self.Executables.Append(file_name, dest_path) else: Logger.Warn(__name__, u'{}: The executables destination is not valid'.format(__name__)) except IndexError: Logger.Warn(__name__, u'{}: The executables destination is not available'.format(__name__)) elif event_id in (btnid.REMOVE, wx.WXK_DELETE): self.Executables.RemoveSelected()
def GetCtrlInfo(self): pg_depends = GetPage(pgid.DEPENDS) ctrl_list = [] synopsis = None description = None # Email will be set if maintainer changed to True maintainer = False # Text input fields for field in self.grp_input: field_name = field.GetName().title() field_value = field.GetValue() if FieldEnabled(field) and not TextIsEmpty(field_value): Logger.Debug(__name__, GT(u'Exporting {} field').format(field_name)) # Strip leading & trailing spaces, tabs, & newlines field_value = field_value.strip(u' \t\n') if field_name == u'Synopsis': synopsis = u'{}: {}'.format(u'Description', field_value) continue if field_name == u'Description': description = field_value.split(u'\n') for line_index in range(len(description)): # Remove trailing whitespace description[line_index] = description[ line_index].rstrip() if TextIsEmpty(description[line_index]): # Empty lines are formatted with one space indentation & a period description[line_index] = u' .' else: # All other lines are formatted with one space indentation description[line_index] = u' {}'.format( description[line_index]) description = u'\n'.join(description) continue if field_name in (u'Package', u'Version'): # Don't allow whitespace in package name & version ctrl_list.append(u'{}: {}'.format( field_name, u'-'.join(field_value.split(u' ')))) continue if field_name == u'Email': if maintainer and ctrl_list: # Append email to end of maintainer string for ctrl_index in range(len(ctrl_list)): if ctrl_list[ctrl_index].startswith( u'Maintainer: '): Logger.Debug(__name__, u'Found maintainer') ctrl_list[ctrl_index] = u'{} <{}>'.format( ctrl_list[ctrl_index], field_value) break continue # Don't use 'continue' on this statement if field_name == u'Maintainer': maintainer = True # The rest of the fields ctrl_list.append(u'{}: {}'.format(field_name, field_value)) # Selection box fields for field in self.grp_select: field_name = field.GetName().title() field_value = field.GetStringSelection() if FieldEnabled(field) and not TextIsEmpty(field_value): Logger.Debug(__name__, GT(u'Exporting {} field').format(field_name)) # Strip leading & trailing spaces, tabs, & newlines field_value = field_value.strip(u' \t\n') ctrl_list.append(u'{}: {}'.format(field_name, field_value)) if self.chk_essential.GetValue(): ctrl_list.append(u'Essential: yes') # Dependencies & conflicts dep_list = [] # Depends pre_list = [] # Pre-Depends rec_list = [] # Recommends sug_list = [] # Suggests enh_list = [] # Enhances con_list = [] # Conflicts rep_list = [] # Replaces brk_list = [] # Breaks all_deps = { u'Depends': dep_list, u'Pre-Depends': pre_list, u'Recommends': rec_list, u'Suggests': sug_list, u'Enhances': enh_list, u'Conflicts': con_list, u'Replaces': rep_list, u'Breaks': brk_list, } # Get amount of items to add dep_area = GetField(pg_depends, inputid.LIST) dep_count = dep_area.GetItemCount() count = 0 while count < dep_count: # Get each item from dependencies page dep_type = dep_area.GetItem(count, 0).GetText() dep_val = dep_area.GetItem(count, 1).GetText() for item in all_deps: if dep_type == item: all_deps[item].append(dep_val) count += 1 for item in all_deps: if len(all_deps[item]) != 0: ctrl_list.append(u'{}: {}'.format(item, u', '.join(all_deps[item]))) if synopsis: ctrl_list.append(synopsis) # Long description is only added if synopsis is not empty if description: ctrl_list.append(description) # dpkg requires empty newline at end of file return u'\n'.join(ctrl_list).strip(u'\n') + u'\n'