def __init__(self, decoupled=True): self.wb = WorkBook() # Create two worksheets if decoupled: self.split = self.wb.get_active_sheet()\ .set_title('Split Assessments') self.group = self.wb.create_sheet('Grouped Assessments') else: self.split = None self.group = self.wb.get_active_sheet().set_title('Assessments') self.decoupled = decoupled # Cells to be merged self.merge_cells = {} # Initial titles self.lead_titles = [ 'Date of Lead Publication', 'Imported By', 'Lead Title', 'Source', ] self.titles = [*self.lead_titles] self.col_types = { 0: 'date', } self._titles_dict = {k: True for k in self.titles} self._headers_titles = OrderedDict() self._headers_added = False self._excel_rows = [] self._title_headers = [] self._headers_dict = {} self._flats = [] self._assessments = []
def __init__(self, analytical_statement_entries): self.wb = WorkBook() self.split = None self.analysis_sheet = self.wb.get_active_sheet().set_title('Analysis') self.titles = [ 'Analysis Pillar ID', 'Analysis Pillar', 'Assignee', 'Statement ID', 'Statement', 'Entry ID', 'Entry', 'Entry Link', 'Source Link' ]
def __init__(self, decoupled=True): self.wb = WorkBook() # Create two worksheets if decoupled: self.split = self.wb.get_active_sheet()\ .set_title('Split Entries') self.group = self.wb.create_sheet('Grouped Entries') else: self.split = None self.group = self.wb.get_active_sheet().set_title('Entries') self.decoupled = decoupled # Initial titles self.titles = [ 'Date of Lead Publication', 'Imported By', 'Date Imported', 'Lead Title', 'Source', 'Excerpt', ]
def __init__(self, decoupled=True): self.wb = WorkBook() # Create two worksheets if decoupled: self.split = self.wb.get_active_sheet()\ .set_title('Split Assessments') self.group = self.wb.create_sheet('Grouped Assessments') else: self.split = None self.group = self.wb.get_active_sheet().set_title('Assessments') self.decoupled = decoupled # Cells to be merged self.merge_cells = {} # Initial titles self.titles = [ 'Date of Lead Publication', 'Imported By', 'Lead Title', 'Source', ] self._titles_dict = {k: True for k in self.titles}
def __init__(self, sheets_data): """ sheets_data = { sheet1: { grouped_col: [ { col1: val1, col2: val2, col3: val3 }, { col1: val1, col2: val2, col3: val3 }, ... ], ungrouped_col: [ val1, val2, ... ], }, sheet2: { ... } } """ self.wb = WorkBook() self.sheets_data = sheets_data or {} self.wb_sheets = {} self.sheet_headers = {} # TODO: validate all data in each col, to see if each of them have same # structure(keys) for sheet, sheet_data in sheets_data.items(): self.wb_sheets[sheet] = self.wb.create_sheet( underscore_to_title(sheet)) self.sheet_headers[sheet] = {} for col, data in sheet_data.items(): if data and isinstance(data[0], dict): self.sheet_headers[sheet][col] = data[0].keys() else: self.sheet_headers[sheet][col] = []
def __init__(self, entries, decoupled=True, project_id=None, is_preview=False): self.is_preview = is_preview self.wb = WorkBook() # XXX: Limit memory usage? (Or use redis?) self.geoarea_data_cache = {} # Create worksheets(Main, Grouped, Entry Groups, Bibliography) if decoupled: self.split = self.wb.get_active_sheet()\ .set_title('Split Entries') self.group = self.wb.create_sheet('Grouped Entries') else: self.split = None self.group = self.wb.get_active_sheet().set_title('Entries') self.entry_groups_sheet = self.wb.create_sheet('Entry Groups') self.decoupled = decoupled self.bibliography_sheet = self.wb.create_sheet('Bibliography') self.bibliography_data = {} self.modified_exceprt_exists = entries.filter(excerpt_modified=True).exists() # Initial titles self.titles = [ 'Date of Lead Publication', 'Imported By', 'Date Imported', 'Verification Status', 'Lead Id', 'Lead Title', 'Lead URL', 'Authoring Organizations Type', 'Author', 'Source', 'Lead Priority', 'Assignee', 'Entry Id', 'Lead-Entry Id', *( [ 'Modified Excerpt', 'Original Excerpt', ] if self.modified_exceprt_exists else ['Excerpt'] ) ] self.lead_id_titles_map = {x.id: x.title for x in Lead.objects.filter(project_id=project_id)} project_entry_labels = ProjectEntryLabel.objects.filter( project_id=project_id ).order_by('order') self.label_id_title_map = {x.id: x.title for x in project_entry_labels} lead_groups = LeadEntryGroup.objects.filter(lead__project_id=project_id).order_by('order') self.group_id_title_map = {x.id: x.title for x in lead_groups} # Create matrix of labels and groups self.group_label_matrix = { (group.lead_id, group.id): {x.id: None for x in project_entry_labels} for group in lead_groups } self.entry_group_titles = [ 'Lead', 'Group', *self.label_id_title_map.values(), ] self.entry_groups_sheet.append([self.entry_group_titles]) self.col_types = { 0: 'date', 2: 'date', } # Keep track of sheet data present ''' tabular_sheets = { 'leadtitle-sheettitle': { 'field1_title': col_num_in_sheet, 'field2_title': col_num_in_sheet, } } ''' self.tabular_sheets = {} # Keep track of tabular fields self.tabular_fields = {} self.region_data = {} # mapping of original name vs truncated name self._sheets = {}