My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
#
# Library: pyflowctrl
# Module: htmlspecials2
# Dependency: core3
# Examples:
#
# links: http://htmlhelp.com/reference/html40/entities/special.html
#

import re
from core3 import EmptyStream, Stream, Process
from core3 import WAITING, PROCESSING

class HTMLSpecialsRemover(Process):
''' HTML Specials Remover '''
def __init__(self, selectors={}):
''' __init__ '''
super(HTMLSpecialsRemover, self).__init__()
self.io = {
'input': Stream(),
'output': Stream(),
}

def main(self):
while True:
try:
(path, data) = self.io['input'].get()
except EmptyStream:
yield WAITING
continue

data = data.replace('\n', '')
data = data.replace('\r', '')
data = data.replace('\t', '')
data = data.replace('"', '"')
data = data.replace('&lt;', '<')
data = data.replace('&gt;', '>')
data = data.replace('&amp;', '&')
data = data.replace('&nbsp;', ' ')
data = data.replace('&laquo;', '')
data = data.replace('&raquo;', '')

self.io['output'].put((path, data))
yield PROCESSING

Change log

0c95c67ab88b by ownport <ownport> on Aug 14, 2011   Diff
pyflowctrl: processes FileReader,
HTMLSpecials, TextProcessing, TreeWalker
migrated to core3
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1323 bytes, 46 lines
Powered by Google Project Hosting