def media_comments(self, media_id):
     comments = memcache.get("media_comments_%s" % (media_id))
     if not comments:
         converter = emoji.factory("softbank", "utf-8")
         converter.prefix = '<span class="emoji emoji_'
         converter.suffix = '"></span>'
         comments = self.api.media_comments(media_id)
         for comment in comments:
             comment["text"] = escape(comment["text"].encode("utf-8"))
             comment["text"] = self._convert_emoji(comment["text"])
             comment["text"] = self._convert_tag_to_link(comment["text"])
         memcache.add("media_comments_%s" % (media_id), comments, 300)
     return comments
示例#2
0
    def test_factory(self):
        dcm = emoji.factory('docomo', 'sjis')
        assert dcm
        ez = emoji.factory('ezweb', 'sjis')
        assert ez
        soft = emoji.factory('softbank', 'sjis')
        assert soft
        pc = emoji.factory('pc', 'sjis')
        assert pc

        assert dcm != ez
        assert dcm != soft
        assert ez != soft

        assert dcm == emoji.factory('docomo', 'sjis')
        assert ez == emoji.factory('ezweb', 'sjis')
        assert soft == emoji.factory('softbank', 'sjis')
示例#3
0
 def test_factory(self):
   dcm = emoji.factory('docomo', 'sjis')
   assert dcm
   ez = emoji.factory('ezweb', 'sjis')
   assert ez
   soft = emoji.factory('softbank', 'sjis')
   assert soft
   pc = emoji.factory('pc', 'sjis')
   assert pc
   
   assert dcm != ez
   assert dcm != soft
   assert ez != soft
   
   assert dcm == emoji.factory('docomo', 'sjis')
   assert ez == emoji.factory('ezweb', 'sjis')
   assert soft == emoji.factory('softbank', 'sjis')
示例#4
0
 def test_restore_ezweb_utf8(self):
   obj = emoji.factory('ezweb', 'utf-8')
   ret = obj.restore('hello [e1] world')
   assert 'hello \xEE\xBD\x99 world' == ret, ret
示例#5
0
 def test_restore_docomo_utf8(self):
   obj = emoji.factory('docomo', 'utf-8')
   ret = obj.restore('hello [d1] world')
   assert 'hello \xEE\x98\xBE world' == ret, ret
示例#6
0
 def test_restore_softbank_sjis(self):
   obj = emoji.factory('softbank', 'sjis')
   ret = obj.restore('hello [s1] world')
   assert 'hello \xF9\x41 world' == ret, ret
示例#7
0
 def test_restore_ezweb_sjis(self):
   obj = emoji.factory('ezweb', 'sjis')
   ret = obj.restore('hello [e1] world')
   assert 'hello \xF6\x59 world' == ret, ret
示例#8
0
 def test_restore_docomo_sjis(self):
   obj = emoji.factory('docomo', 'sjis')
   ret = obj.restore('hello [d1] world')
   assert 'hello \xF8\x9F world' == ret, ret
示例#9
0
 def test_convert_ezweb_jis(self):
   obj = emoji.factory('ezweb', 'jis-email')
   ret = obj.convert('hello \x1B\x24\x42\x75\x3A\x1B\x28\x42 world')
   ret = ret.decode('iso2022-jp')
   assert 'hello [e1] world' == ret, ret
示例#10
0
 def test_restore_ezweb_sjis(self):
     obj = emoji.factory('ezweb', 'sjis')
     ret = obj.restore('hello [e1] world')
     assert 'hello \xF6\x59 world' == ret, ret
示例#11
0
 def test_convert_ezweb_jis(self):
     obj = emoji.factory('ezweb', 'jis-email')
     ret = obj.convert('hello \x1B\x24\x42\x75\x3A\x1B\x28\x42 world')
     ret = ret.decode('iso2022-jp')
     assert 'hello [e1] world' == ret, ret
示例#12
0
 def _convert_emoji(self, text):
     converter = emoji.factory("softbank", "utf-8")
     converter.prefix = '<span class="emoji emoji_'
     converter.suffix = '"></span>'
     text = converter.convert(text)
     return text
示例#13
0
 def test_restore_ezweb_jis(self):
     obj = emoji.factory('ezweb', 'jis-email')
     ret = obj.restore('hello [e1] world')
     assert 'hello \x1B\x24\x42\x75\x3A\x1B\x28\x42 world' == ret, ret
示例#14
0
 def test_restore_softbank_utf8(self):
     obj = emoji.factory('softbank', 'utf-8')
     ret = obj.restore('hello [s1] world')
     assert 'hello \xEE\x80\x81 world' == ret, ret
示例#15
0
 def test_restore_ezweb_utf8(self):
     obj = emoji.factory('ezweb', 'utf-8')
     ret = obj.restore('hello [e1] world')
     assert 'hello \xEE\xBD\x99 world' == ret, ret
示例#16
0
 def test_restore_docomo_utf8(self):
     obj = emoji.factory('docomo', 'utf-8')
     ret = obj.restore('hello [d1] world')
     assert 'hello \xEE\x98\xBE world' == ret, ret
示例#17
0
 def test_restore_softbank_sjis(self):
     obj = emoji.factory('softbank', 'sjis')
     ret = obj.restore('hello [s1] world')
     assert 'hello \xF9\x41 world' == ret, ret
示例#18
0
 def test_restore_softbank_utf8(self):
   obj = emoji.factory('softbank', 'utf-8')
   ret = obj.restore('hello [s1] world')
   assert 'hello \xEE\x80\x81 world' == ret, ret
示例#19
0
 def test_restore_ezweb_jis(self):
   obj = emoji.factory('ezweb', 'jis-email')
   ret = obj.restore('hello [e1] world')
   assert 'hello \x1B\x24\x42\x75\x3A\x1B\x28\x42 world' == ret, ret
示例#20
0
 def test_restore_docomo_sjis(self):
     obj = emoji.factory('docomo', 'sjis')
     ret = obj.restore('hello [d1] world')
     assert 'hello \xF8\x9F world' == ret, ret