def import_section(name, path): with open(os.path.join(path, name, 'data'), 'rb') as f: data = pickle.load(f) s = Section() copy_seo_data(s, data) if data.title_color == 'black': s.title_color = '#000000' else: s.title_color = '#ffffff' translation.activate('en') s.title = data.title_en translation.deactivate() translation.activate('fr') s.title = data.title_fr translation.deactivate() if hasattr(data, 'background'): img = make_master_image( path, data.background, '{}-background'.format(data.title_en) ) s.background = img s.save()