lpschedule-generator

libreplanet schedule generator - ricketyspace.net/lpschedule-generator
git clone git://git.ricketyspace.net/lpschedule-generator.git
Log | Files | Refs

commit 97a922a541dedd5c59f909d423c38a5acb25664f
parent c25a3ab9da8262ffb89e50326ea7dde0ca564f4e
Author: rsiddharth <rsd@gnu.org>
Date:   Sun,  7 Feb 2016 13:56:43 -0500

updated LPSpeakersRenederer class.

Changed the way speaker' bio are parsed into the lpspeakers_dict
dictionary.

As a side effect, there is no need to put a placeholder (NO_IMAGE) when
the image for a speaker is not available.

Addresses issue #1.

Diffstat:
lps_gen.py | 9+++++----
tests/files/lp-speakers.md | 6------
tests/test_lps_gen.py | 26+++++++++++++-------------
3 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/lps_gen.py b/lps_gen.py @@ -176,12 +176,14 @@ class LPSpeakersRenderer(Renderer): lpspeakers_dict[self.speaker_type][-1]['speaker'] = text lpspeakers_dict[self.speaker_type][-1]['id'] = self.mk_uid(text) + lpspeakers_dict[self.speaker_type][-1]['bio'] = [] elif level == 2: self.speaker_type = 'speakers' lpspeakers_dict[self.speaker_type].append(OrderedDict()) lpspeakers_dict[self.speaker_type][-1]['speaker'] = text.split(', ')[0] lpspeakers_dict[self.speaker_type][-1]['id'] = self.mk_uid(text) + lpspeakers_dict[self.speaker_type][-1]['bio'] = [] return super(LPSpeakersRenderer, self).header(text, level, raw) @@ -200,12 +202,11 @@ class LPSpeakersRenderer(Renderer): p = super(LPSpeakersRenderer, self).paragraph(text) - if not lpspeakers_dict[self.speaker_type][-1].has_key('bio'): - lpspeakers_dict[self.speaker_type][-1]['bio'] = [] + if text.startswith('<img'): + # ignore return p - lpspeakers_dict[self.speaker_type][-1]['bio'].append(p) - + lpspeakers_dict[self.speaker_type][-1]['bio'].append(text) return p diff --git a/tests/files/lp-speakers.md b/tests/files/lp-speakers.md @@ -55,8 +55,6 @@ system. # Ludovic Court├Ęs -NO_IMAGE - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis @@ -98,8 +96,6 @@ issues. ## Richard Fontana, Red Hat -NO_IMAGE - Richard Fontana is a lawyer at Red Hat. He leads support for Red Hat's engineering and research and development units and is Red Hat's lead counsel for legal issues relating to free software. Richard is also a @@ -133,8 +129,6 @@ years, in France and now in Canada. ## M. C. McGrath -NO_IMAGE - M. C. is the founder of Transparency Toolkit, a free software project that helps people use open data to expose surveillance and human rights abuses. He is also a Thiel Fellow and an Echoing Green diff --git a/tests/test_lps_gen.py b/tests/test_lps_gen.py @@ -298,14 +298,14 @@ class TestLPSpeakers(object): """ - keynote_speaker_bios = [['<p>Daniel Kahn Gillmor is a technologist with the ACLU\'s Speech, Privacy'], - ['<p>Edward Snowden is a former intelligence officer who served the CIA,'], - ['<p>Richard is a software developer and software freedom activist. In 1983', - '<p>Since the mid-1990s, Richard has spent most of his time in political',], + keynote_speaker_bios = [['Daniel Kahn Gillmor is a technologist with the ACLU\'s Speech, Privacy'], + ['Edward Snowden is a former intelligence officer who served the CIA,'], + ['Richard is a software developer and software freedom activist. In 1983', + 'Since the mid-1990s, Richard has spent most of his time in political',], [], - ['<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam', - '<p>Ut turpis felis, pulvinar a semper sed, adipiscing id']] + ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam', + 'Ut turpis felis, pulvinar a semper sed, adipiscing id']] i = 0 @@ -409,16 +409,16 @@ class TestLPSpeakers(object): """Testing LPSpeakersMarkdown speakers' bio. """ - speaker_bios = [['<p>Emmanuel is a Division III student at Hampshire College, studying how'], + speaker_bios = [['Emmanuel is a Division III student at Hampshire College, studying how'], [], - ['<p>Marianne Corvellec has been a Free Software activist with April'], - ['<p>Richard Fontana is a lawyer at Red Hat. He leads support for Red Hat\'s'], + ['Marianne Corvellec has been a Free Software activist with April'], + ['Richard Fontana is a lawyer at Red Hat. He leads support for Red Hat\'s'], [], - ['<p>Bassam is a 3D animator/filmmaker whose 2006 short, Elephants Dream,'], - ['<p>Jonathan has been involved with the Free Software Movement for ten'], - ['<p>M. C. is the founder of Transparency Toolkit, a free software project'], + ['Bassam is a 3D animator/filmmaker whose 2006 short, Elephants Dream,'], + ['Jonathan has been involved with the Free Software Movement for ten'], + ['M. C. is the founder of Transparency Toolkit, a free software project'], [], - ['<p>Stefano Zacchiroli is Associate Professor of Computer Science at']] + ['Stefano Zacchiroli is Associate Professor of Computer Science at']] i = 0 for kspeaker in self.lpspeakers_dict['speakers']: