示例#1
0
	def make_post(post_json):
		if post_json:
			id = post_json.get("id")
			
			timestamp = TimestampFactory.make_timestamp(post_json.get("created_time"))
			place = PlaceFactory.make_place(post_json.get("place"))

			from_ = UserFactory.make_user(post_json.get("from"))
			with_tags = PostFactory.get_users(post_json.get("with_tags"))
			msg_tags = PostFactory.get_message_tags(post_json)
			to_list = PostFactory.get_users(post_json.get("to"))
			to = PostFactory.extract_recipient(to_list,with_tags,msg_tags)
			users = PostUsers(from_,to,with_tags,msg_tags)

			message = asciify(post_json.get("message"))
			story = asciify(post_json.get("story"))
			photo = post_json.get("picture")
			video = post_json.get("source")
			link = LinkFactory.make_link(post_json)
			post_type = post_json.get("type")
			status_type = post_json.get("status_type")
			resources = PostResources(link,photo,video)
			contents = PostContents(message,story,resources,post_type,status_type)
			
			comments = PostFactory.get_comments(post_json)
			likes = PostFactory.get_likes(post_json)
			app = AppFactory.make_app(post_json.get("application"))
			metadata = PostMetadata(comments,likes,app)

			url = PostFactory._get_url(id,to,post_type,status_type)

			return Post(id,timestamp,place,url,users,contents,metadata)
		else:
			return None
示例#2
0
 def make_link(post_json):
     name = asciify(post_json.get("name"))
     url = post_json.get("link")
     caption = asciify(post_json.get("caption"))
     description = asciify(post_json.get("description"))
     if url:
         return Link(name, url, caption, description)
     else:
         return None
示例#3
0
	def make_link(post_json):
		name = asciify(post_json.get("name"))
		url = post_json.get("link")
		caption = asciify(post_json.get("caption"))
		description = asciify(post_json.get("description"))
		if url:
			return Link(name,url,caption,description)
		else:
			return None
示例#4
0
 def make_user(user_json):
     if user_json:
         id = int(user_json.get("id"))
         name = asciify(user_json.get("name"))
         return User(id, name)
     else:
         return None
示例#5
0
	def make_user(user_json):
		if user_json:
			id = int(user_json.get("id"))
			name = asciify(user_json.get("name"))
			return User(id,name)
		else:
			return None
示例#6
0
	def make_comment(comment_json):
		if comment_json:
			id = comment_json.get("id")
			timestamp = TimestampFactory.make_timestamp(comment_json.get("created_time"))
			from_ = UserFactory.make_user(comment_json.get("from"))
			message = asciify(comment_json.get("message"))
			tags = PostFactory.get_message_tags(comment_json)
			like_count = comment_json.get("like_count")
			return Comment(id,timestamp,from_,message,tags,like_count)
		else:
			return None
示例#7
0
 def make_comment(comment_json):
     if comment_json:
         id = comment_json.get("id")
         timestamp = TimestampFactory.make_timestamp(
             comment_json.get("created_time"))
         from_ = UserFactory.make_user(comment_json.get("from"))
         message = asciify(comment_json.get("message"))
         tags = PostFactory.get_message_tags(comment_json)
         like_count = comment_json.get("like_count")
         return Comment(id, timestamp, from_, message, tags, like_count)
     else:
         return None
示例#8
0
文件: bibtools.py 项目: langsci/225
 def addsortname(self,name):
   """
   add an additional field for sorting for names with diacritics
   """
   
   try:
       residue = name.translate({ord(i):None for i in string.ascii_letters+'- ,{}.'})
   except  TypeError: #python2
       residue = ''  
   if residue == '':
     pass
   else:
     self.fields['sortname']= asciify(dediacriticize(name))
示例#9
0
    def make_post(post_json):
        if post_json:
            id = post_json.get("id")

            timestamp = TimestampFactory.make_timestamp(
                post_json.get("created_time"))
            place = PlaceFactory.make_place(post_json.get("place"))

            from_ = UserFactory.make_user(post_json.get("from"))
            with_tags = PostFactory.get_users(post_json.get("with_tags"))
            msg_tags = PostFactory.get_message_tags(post_json)
            to_list = PostFactory.get_users(post_json.get("to"))
            to = PostFactory.extract_recipient(to_list, with_tags, msg_tags)
            users = PostUsers(from_, to, with_tags, msg_tags)

            message = asciify(post_json.get("message"))
            story = asciify(post_json.get("story"))
            photo = post_json.get("picture")
            video = post_json.get("source")
            link = LinkFactory.make_link(post_json)
            post_type = post_json.get("type")
            status_type = post_json.get("status_type")
            resources = PostResources(link, photo, video)
            contents = PostContents(message, story, resources, post_type,
                                    status_type)

            comments = PostFactory.get_comments(post_json)
            likes = PostFactory.get_likes(post_json)
            app = AppFactory.make_app(post_json.get("application"))
            metadata = PostMetadata(comments, likes, app)

            url = PostFactory._get_url(id, to, post_type, status_type)

            return Post(id, timestamp, place, url, users, contents, metadata)
        else:
            return None
示例#10
0
def asciify_api():
    try:
        fr = flask.request
        img = fr.files['file']
        if not img.filename:
            try:
                img = requests.get(fr.form['imagelink'], stream=True).raw
            except requests.exceptions.MissingSchema:
                return app.config['error_format'].format('Problem loading URL.')
        return asciify.asciify(img,
                               float(fr.form['charwidth']),
                               float(fr.form['brightness']),
                               to='html',
                               fontsize=float(fr.form['fontsize'])
                               )
    except Exception:
        return app.config['error_format'].format('Unknown error occured.')
示例#11
0
 def test_asciify(self):
     """ Test an isolated string
     """
     result = asciify.asciify("Nædéßoþ")
     self.assertEqual(result, "Naedessoth")
示例#12
0
from cv2 import VideoCapture, resize, flip
import asciify

cam = VideoCapture(0)
cam.set(3, 180)
cam.set(4, 240)

while True:

    s, img = cam.read()

    if s:
        img = flip(resize(img, (240, 87)), 1)
        asciify.asciify(img)

cam.release()
示例#13
0
文件: matrix.py 项目: Jackojc/Asciify
from asciify import asciify
import random
import time
import pygame

width, height = (60, 30)
add_per_frame = 5

render = asciify(width, height, "font", fontsize=16)
random.seed(time.time())

Particles = [
                [
                    random.randint(0, width),
                    random.randint(-1, height),
                    random.uniform(0.1, 1.5)
                ] for x in range(add_per_frame)
            ]
chars = list("abcdefghijklmnopqrstuvwxyz0123456789!\"$%^&*()_+-=[]{}:;@'~#|\<>?,./")

while True:
    render.checkexit()
    keys = render.listkeys()

    for num, part in enumerate(Particles):
        part[1] += part[2]
        if part[1] > height+1:
            del Particles[num]

        colorrand = (random.randint(60, 255), random.randint(150, 255), random.randint(1, 100))
        render.setString(part[0], part[1], random.choice(chars), color=colorrand)