Permalink
Browse files

fixed private methods and re-added imports

  • Loading branch information...
1 parent 1af045b commit 26399728f594b6fc259ddec93e1ee7f15f8c9542 jen committed Dec 10, 2009
Showing with 21 additions and 13 deletions.
  1. +3 −0 tapechat.py
  2. +6 −3 tapechat_generate.py
  3. +12 −10 tapechat_tag.py
View
@@ -1,3 +1,6 @@
+import web
+import urllib
+import re
import simplejson
from user import User
from feed import Feed
@@ -1,5 +1,9 @@
import feedparser
+import re
+import urllib
+from redis import Redis
from BeautifulSoup import BeautifulSoup
+from auto_tagify import AutoTagify
from tapechat_tag import TapeChatTag
from time import time
@@ -11,8 +15,7 @@
text_unique = []
feeds = r.sort("global:feeds",desc=True)
-clean_word = re.compile('[\[\],().:;"\'?!*+={}`~\r\n\s\t]')
-circle_sym = re.compile('(•)|(\\xe2\\x80\\xa2)')
+circle_sym = re.compile('(•)|(\xe2\x80\xa2)')
p_tags = re.compile('(<p>)|(</p>)')
for feed_id in feeds:
@@ -31,7 +34,7 @@
r.set("text:" + str(text_id) + ":timestamp",str(time()))
r.set("text:" + str(text_id) + ":uid", r.get("fid:" + str(feed_id) + ":uid"))
for tag_word in set(tag.tag_list()):
- tag_word = clean_word.sub('',circle_sym.sub('',str(tag_word)))
+ tag_word = circle_sym.sub('',str(tag_word))
if len(urllib.unquote(tag_word)) > 2:
tag_word = urllib.quote(str(tag_word))
if not r.exists("word:" + tag_word + ":tid"):
View
@@ -9,7 +9,7 @@
tag = AutoTagify()
tag.link = '/tags'
clean_word = re.compile('[\[\],().:"\'?!*<>/\+={}`~\n\r\t]')
-clean_quotes = re.compile('(%27)')
+clean_quotes = re.compile('(%27)|()')
r = Redis()
record_max_length = 50
@@ -63,14 +63,16 @@ def generate_stream(self,tag_counter):
def tag_text(self,tag_word,user_id):
self.text_entries = ''
tag_word = urllib.quote(tag_word.encode('utf-8','ignore'))
- # try:
- if user_id < 1:
- for text_id in r.lrange("word:" + tag_word + ":texts",0,record_max_length):
- self.text_entries += '<li><em>' + self.__format_date(r.get("text:" + str(text_id) + ":timestamp")) + '</em> ' + r.get("text:" + str(text_id)) + '</li>'
- else:
- for text_id in r.lrange("uid:" + str(web.config.session_parameters['user_id']) + ":" + tag_word + ":texts",0,record_max_length):
- self.text_entries += '<li><em>' + self.__format_date(r.get("text:" + str(text_id) + ":timestamp")) + '</em> ' + r.get("text:" + str(text_id)) + '</li>'
- # except: self.text_entries = '<li>No such tag found</li>'
+ try:
+ if user_id < 1:
+ for text_id in r.lrange("word:" + tag_word + ":texts",0,record_max_length):
+ self.text_entries += '<li><em>' + self.__format_date(r.get("text:" + str(text_id) + ":timestamp")) + '</em> ' + r.get("text:" + str(text_id)) + '</li>'
+ else:
+ for text_id in r.lrange("uid:" + str(web.config.session_parameters['user_id']) + ":" + tag_word + ":texts",0,record_max_length):
+ self.text_entries += '<li><em>' + self.__format_date(r.get("text:" + str(text_id) + ":timestamp")) + '</em> ' + r.get("text:" + str(text_id)) + '</li>'
+ except:
+ # self.text_entries = '<li>No such tag found</li>'
+ pass
return self.text_entries
def add(self,tag_word,feed_id):
@@ -92,4 +94,4 @@ def __format_time(self,time):
def __format_date(self,text):
date = datetime.utcfromtimestamp(float(text))
- return '<span>' + str(date.year) + '/' + str(date.month) + '/' + str(date.day) + ' ' + self.__format_time(date.hour) + ':' + self._format_time(date.minute) + ' </span> '
+ return '<span>' + str(date.year) + '/' + str(date.month) + '/' + str(date.day) + ' ' + self.__format_time(date.hour) + ':' + self.__format_time(date.minute) + ' </span> '

0 comments on commit 2639972

Please sign in to comment.