当前位置: 首页>>代码示例>>Python>>正文


Python post.Post类代码示例

本文整理汇总了Python中post.Post的典型用法代码示例。如果您正苦于以下问题:Python Post类的具体用法?Python Post怎么用?Python Post使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Post类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_site

 def update_site(self):
     """Updates only the static pages"""
     files = os.listdir(self.datadir)
     for f in files:
         if f[0] != '.':  # leave out hidden files
             post = Post(self.datadir+f)
             post.write(self.posts, self.tags)
开发者ID:mapleoin,项目名称:blog,代码行数:7,代码来源:blog.py

示例2: print_post

def print_post(args):
    if 'all' in args.postid:
        posts = Post.load()
    else:
        try:
            ids = [int(x) for x in args.postid]
        except ValueError:
            print('Post IDs should be numbers')
            return
        posts = Post.load(ids)
    if not len(posts):
        print('Post ID(s) not found: {}'.format(' '.join(args.postid)))
        return
    if args.s:
        posts = order_by_date(posts)
    for postid in posts.keys():
        if len(posts[postid]['body']) > 74:
            body = '\n      '.join(trunc(posts[postid]['body'], 74))
        else:
            body = posts[postid]['body']
        print('Title: {}\nPost ID: {}, last modification date: {}\nBody: {}'
              .format(posts[postid]['title'],
                      postid,
                      posts[postid]['date'],
                      body))
        print('-' * 80)
开发者ID:gruzzin,项目名称:test-blog,代码行数:26,代码来源:blog.py

示例3: main

def main():	

	# READ TEMPATE HTML FILES
	base_html = open("templates/base.html")
	post_html = open("templates/post.html")

	# CREATE PAGE
	page = base_html.readlines()
	posts = []

	# OPEN POST TXT FILES
	postfiles = [ f for f in listdir("posts") if isfile(join("posts",f)) ]

	for postfile in postfiles:
		temp = open("posts/" + postfile, "r")
		postlines = temp.readlines()
		post_obj = Post(postlines[0], postlines[1], postlines[2:])
		posts.append("".join(post_obj.render(post_html)))
		post_html.seek(0)
		temp.close()

	# INSERT POSTS INTO PAGE
	for i in range(len(page)):
		page[i] = page[i].replace("[[posts]]", "\n\n".join(posts))

	# WRITE PAGE TO OUTPUT HTML FILE
	final = open("output/final.html", "a+")
	final.write("".join(page))

	# CLOSE FILES
	base_html.close()
	post_html.close()
开发者ID:Grayson112233,项目名称:website-parser,代码行数:32,代码来源:main.py

示例4: __init__

    def __init__(self, src_path, exclude=() ):
        post_list = []
        
        for file_path in os.listdir(src_path):
            if not file_path.endswith('.py') or file_path in SOURCE_EXCLUDE:
                # TODO convert to regex matching
                continue
            full_path = os.path.join(src_path, file_path)
            try:
                post = Post(full_path)
                post_list.append(post)
            except Exception as e:
                import traceback
                traceback.print_exc()
                print 'Error creating Post from '+str(full_path)+':'+str(e)
                continue

        self.posts = sorted(post_list, key=lambda p: p.updated)

        self._check_monotonic()
        self._resolve_links()
        
        for post in self.posts:
            errors = post.get_errors()
            for error in errors:
                print 'Error in',post.filename,'on line',str(error.line)+': ',error.message,
                if error.text: print '('+error.text+')'
                print
开发者ID:mahmoud,项目名称:PythonDoesBlog,代码行数:28,代码来源:blog.py

示例5: receive

 def receive(self, message):
     post = Post()
     html_bodies = message.bodies('text/html')
     img_links = []
     video_links = []
     for content_type, body in html_bodies:
         decoded_body = body.decode()
         img_links.extend(self.find_image_links(decoded_body))
         video_links.extend(self.find_video_links(decoded_body))
 
     if hasattr(message, "attachments") and message.attachments:
         post.attachments = []
         for attachment in message.attachments:
             post.attachments.append(db.Blob(attachment[1].decode()))
 
     plaintext_bodies = message.bodies('text/plain')
     allBodies = '';
     for body in plaintext_bodies:
         allBodies = allBodies + body[1].decode()
 
     if hasattr(message, "subject"):
         subject, encoding = decode_header(message.subject)[0]
         post.caption = unicode(subject)
     post.author = message.sender
     post.content = allBodies
     post.images = img_links
     post.videos = video_links
     post.source = "email"
     post.put()
开发者ID:sephiria,项目名称:sandbox,代码行数:29,代码来源:handle_kitten_mail.py

示例6: publish

def publish(post_meta):


    doc_id = Post.url_friendly_text(post_meta["title"])
    
    # Open the database
    couch = couchdb.Server()
    db = couch["mrvoxel_blog"]
    
    # Load the database settings
    blog_settings = settings.loadSettings(db)
    
    # Check to see if we have a valid category
    if not post_meta["category"] in blog_settings["blog_categories"]:
        raise ValueError("No such category: %s" % post_meta["category"])
    
    print "checking for [%s]" % doc_id
    
    # Load the post (if it exists in our database)
    post = Post.load(db, doc_id)
    
    # If it exists, warn the user
    if post:
        raw = raw_input("This will replace an existing post of the same title...\nContinue? (y/N)")
        
        # if the existing post is published but we're trying to preview
        if (post["published"] == False) and post_meta["published"]:
            raise ValueError("Cannot yet preview posts that are already published")
        
        if raw != "y":
            print "Canceling publish."
            return None
        else:
            for k, v in post_meta.iteritems():
                if k not in ["published", "title"]:
                    print k
                    post[k] = v
            
            print post
            
            """
            post.markdown = mdtext
            post.html = html
            post.author = author
            post.timestamp = timestamp
            post.published = not preview
            post.title = title
            post.tags = tags
            post.category = category
            """
            
            post.store(db)
    else:
        
        post = Post.create(**post_meta)
        print post["_id"]
        post.store(db)
        print post["_id"]
    return post["_id"]
开发者ID:cgibson,项目名称:titanium-flea,代码行数:59,代码来源:publish.py

示例7: new_post

 def new_post(self, title, content, date=datetime.datetime.utcnow()):
     post = Post(blog_id=self._id,
                 title=title,
                 content=content,
                 author=self.author,
                 # formats the date string object into datetime
                 date=date)
     post.save_to_mongo()
开发者ID:patalwell,项目名称:python,代码行数:8,代码来源:blog.py

示例8: load_post

 def load_post(self):
     """ load post
     """
     for post_source in glob.glob(self.post_path + self.post_pattern):
         post = Post()
         post.load_from_file(post_source)
         # self.posts.append(post)
         self.post_mapping[post.link] = post
开发者ID:luoluo,项目名称:luoluo.github.com,代码行数:8,代码来源:resources.py

示例9: post

 def post(self):
     user = users.get_current_user()
     
     if user:
         post = Post(parent = Post.post_db_key(), author = user, content = self.request.get("content"))
         post.put()
     
     self.redirect('/')
开发者ID:Dudy,项目名称:nonaco-toolbox,代码行数:8,代码来源:homepage.py

示例10: mod_post

def mod_post(args):
    posts = Post.load()
    if not args.title and not args.body:
        print('Either title or body are required for post modificaion')
    else:
        p = Post(args.title or posts[args.postid]['title'],
                 args.body or posts[args.postid]['body'],
                 postid=args.postid)
        p.save()
开发者ID:gruzzin,项目名称:test-blog,代码行数:9,代码来源:blog.py

示例11: render_latest_posts

    def render_latest_posts(self, limit):
        accu = ''
        for post_path in self.latest_posts(limit):
            post = Post(post_path)
            accu += post.render("short-post")

        output = open(os.path.join(
            self.__render_base_path, "latest_posts.rst"), "w", encoding='utf-8')
        output.write(accu)
        output.close()
开发者ID:mplayer2,项目名称:mplayer2.org,代码行数:10,代码来源:webblog.py

示例12: render_latest_posts

    def render_latest_posts(self, limit):
        accu = ''
        for post_path in self.latest_posts(limit):
            post = Post(post_path)
            accu += post.render('short-post')

        output = open(os.path.join(
            self.__render_base_path, 'latest_posts.rst'), 'w')
        output.write(accu)
        output.close()
开发者ID:Armada651,项目名称:mpc-hc.org,代码行数:10,代码来源:webblog.py

示例13: get

    def get(self):
        post_id = self.request.get('post_id')
        user_id = self.user.key().id()

        if user_id and post_id and not LikePostRelation.check_like_status(user_id,post_id):
            Post.updateLike(post_id)
            like_post_relation = LikePostRelation.create_like_post_relation(user_id,post_id)
            like_post_relation.put()

        self.redirect('/blog/%s' % post_id)
开发者ID:YouYue123,项目名称:Fullstack-Udacity,代码行数:10,代码来源:main.py

示例14: get_post

    def get_post(self, post_id):
        post = self.loaded_posts.get(post_id, None)
        if post is None:
            path = u"{0}/{1}.md".format(self.working_dir, post_id)
            if os.path.exists(path):
                post = Post(post_id, working_dir=self.working_dir)
                self.loaded_posts[post_id] = post
        else:
            post.refresh()

        return post
开发者ID:sakim,项目名称:Gollum-Press,代码行数:11,代码来源:posts.py

示例15: post

    def post(self):
        user = users.get_current_user()
        if not user or not users.is_current_user_admin():
            self.redirect(users.create_login_url(self.request.uri))
            return

        post = Post()
        post.title = self.request.POST['title']
        post.put()

        self.redirect('/admin/posts/edit/' + str(post.key.id()))
开发者ID:eholec,项目名称:jetpoweredblog,代码行数:11,代码来源:posts.py


注:本文中的post.Post类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。