Skip to content

Commit

Permalink
When having a problem some use a thread, now they have two problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît HERVIER committed Apr 26, 2012
1 parent 940b6eb commit af1e69e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions khtsimpletext/__init__.py
Expand Up @@ -102,9 +102,9 @@ def load(self,path):
''' Load the document from a path in a thread'''
print 'def load:' + path
self._set_ready(False)
self.thread = threading.Thread(target=self._load, args= (path, ))
self.thread.start()

# self.thread = threading.Thread(target=self._load, args= (path, ))
# self.thread.start()
self._load(path)

def _load(self,path):
''' Load the document from a path '''
Expand Down Expand Up @@ -159,14 +159,14 @@ def fixup(m):
return unichr(int(text[3:-1], 16))
else:
return unichr(int(text[2:-1]))
except ValueError:
pass
except ValueError, e:
print e
else:
# named entity
try:
text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
except KeyError:
pass
except KeyError, e:
print e
return text # leave as is
return re.sub("&#?\w+;", fixup, text)

Expand Down Expand Up @@ -195,7 +195,10 @@ def _stripTags(self,content):
def write(self, data):
''' Write the document to a file '''
if self._colored:
print data
data = self._stripTags(data)


try:
with open(self.filepath, 'wb') as fh:
fh.write(data.encode('utf-8'))
Expand Down Expand Up @@ -325,4 +328,4 @@ def __init__(self):
self.view.showFullScreen()

if __name__ == '__main__':
sys.exit(KhtSimpleText().exec_())
sys.exit(KhtSimpleText().exec_())

0 comments on commit af1e69e

Please sign in to comment.