def _generate_for_subfolder(self, sid): ''' Generate report for a subfolder. :param sid: The subfolder id; assumed valid ''' # TODO: the following assumes subfolder names can be constructed from a # subfolder id, which might not be the case in the future. name = self._sanitise_sheetname(uni(Folders.id_to_name(sid))) ws = self.workbook.add_worksheet(name) fmt = self.formats ws.write("A1", "Dossier report", fmt['title']) ws.write("A2", "%s | %s" % (uni(self.folder_name), name)) # Column dimensions ws.set_column('A:A', 37) ws.set_column('B:B', 37) ws.set_column('C:C', 37) ws.set_column('D:D', 8) ws.set_column('E:E', 30) ws.set_column('F:F', 37) # Header ws.write("A4", "Id", fmt['header']) ws.write("B4", "URL", fmt['header']) ws.write("C4", "Subtopic Id", fmt['header']) ws.write("D4", "Type", fmt['header']) ws.write("E4", "Content", fmt['header']) ws.write("F4", "Image URL", fmt['header']) # TODO: we probably want to wrap the following in a try-catch block, in # case the call to folders.subtopics fails. row = 4 for i in subtopics(self.store, self.folders, self.folder_id, sid, self.user): Item.construct(self, i).generate_to(ws, row) row += 1
def get_subfolder_queries(store, label_store, folders, fid, sid): '''Returns [unicode]. This returns a list of queries that can be passed on to "other" search engines. The list of queries is derived from the subfolder identified by ``fid/sid``. ''' queries = [] for cid, subid, url, stype, data in subtopics(store, folders, fid, sid): if stype in ('text', 'manual'): queries.append(data) return queries