• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python post.Post类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: get

 def get(self, post_id=None, action=None):
     if action is None:
         posts = Post.all()
         self.response.out.write(helper.render('admin/posts', { 'posts': posts }))
     elif action == "delete":
         Post.get_by_id(int(post_id)).delete()
         return self.redirect('/admin/posts')
     elif action == "confirm":
         post = Post.get_by_id(int(post_id))
         post.confirmed_at = datetime.datetime.today()
         post.put()
         return self.redirect('/admin/posts')
开发者ID:grunskis,项目名称:neperczagtu.lv,代码行数:12,代码来源:admin.py


示例17: post

def post(arg):
    """defines post command"""

    postTypes = ["text", "photo", "quote", "link", "chat", "audio", "video"]
    postStates = ["published", "draft", "queue", "private"]

    args = arg.split(" ")

    if args[0] in postTypes:
        if args[0] == "text":
            if '"' in args[1]:
                quote_text = re.findall('"([^"]*)"', arg)
                text = ""

                if len(quote_text) > 1:
                    text = quote_text[0]

                text_post = {"title": "", "state": "", "blog": "", "tags": []}

                if "--title" in args:
                    if len(quote_text) == 1:
                        text_post['title'] = quote_text[0]
                    else:
                        text_post['title'] = quote_text[1]

                if "-s" in args:
                    state = args[args.index('-s') + 1]
                    if state in postStates:
                        text_post['state'] = state
                    else:
                        print "Invalid state value found: " + state
                        print "Posting now"

                if "-b" in args:
                    text_post['blog'] = args[args.index('-b') + 1]
                else:
                    text_post['blog'] = USERNAME

                if "-t" in args:
                    for s in args[args.index("-t") + 1:]:
                        if s not in ["--title", "-b", "-s"]:
                            text_post['tags'].append(s)
                        else:
                            break

                print text_post
                newPost = Post(client, text_post['blog'], "text", text_post['tags'])
                newPost.publish(text_post['state'], title=text_post['title'], body=text)

            else:
                print "No text content found! Text must be in quotes."
    else:
        print "Invalid post type: " + args[0]
开发者ID:rfaulhaber,项目名称:TCL,代码行数:53,代码来源:main.py


示例18: run

    def run(self):
        while 1 == 1:
            try:
                for url in self.urls:
                    self.urls.remove(url)
                    print(url)

                    opener = urllib2.build_opener()
                    opener.addheaders = [('User-agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)')]
                    response = opener.open(url)

                    html = response.read()
                    soup = BeautifulSoup(html, 'html.parser')
                    text = soup.text
                    links = soup.find_all('a')
                    images = soup.find_all('img')

                    post = Post(self.connection, url, url, 'url')
                    post.save()

                    download_path = 'sites/' + url
                    if not os.path.exists(download_path):
                        os.makedirs(download_path)

                    for image in images:
                        print('image')
                        src = urljoin(url, image.get('src'))
                        if src.startswith("http") or src.startswith("https"):
                                fname = self.basename(src)
                                if fname != None:
                                    self.download_file(src, download_path + fname)

                    print('ok')

                    '''self.reset_config()
                    for p in self.config:
                        textElements = re.findall(p['regex'], text)

                        if textElements != None:
                            for element in textElements:
                                post = Post(self.connection, element, element, p['type'])
                                post.save()'''
                    
                    for link in links:
                        href = urljoin(url, link.get('href'))
                        if href.startswith("http") or href.startswith("https"):
                            fname = self.basename(href)
                            if fname in self.extensions:
                                self.download_file(href, download_path + fname)
                            self.urls.append(href)
            except:
                pass
开发者ID:sebbekarlsson,项目名称:python-scraper,代码行数:52,代码来源:parser.py


示例19: post

    def post(self,post_id):

        if not self.user:
            self.redirect('/blog/%s' % post_id)

        subject = self.request.get('subject')
        content = self.request.get('content')
        user_id = self.user.key().id()
        last_modified = datetime.datetime.now()
        post = Post.by_id(post_id)
        if post and post.created_by == user_id:
           Post.update(post_id,subject,content,last_modified)
        self.redirect('/blog/%s' % post_id)
开发者ID:YouYue123,项目名称:Fullstack-Udacity,代码行数:13,代码来源:main.py


示例20: create_post_with_bugs

def create_post_with_bugs(data, cur, bugs=None):
    post = Post(data)
    if bugs != None:
        post.populatebugs(bugs)
    else:
        cur.execute('''SELECT titles.title, bug.bugid, bug.status
                       FROM bugtitles AS titles, postbugs AS bug
                       WHERE bug.userid = ?
                         AND bug.postdate = ?
                         AND bug.bugid = titles.bugid''',
                    (post.userid, post.postdate.toordinal()))
        post.populatebugs([Bug(title, id, statusnum) for title, id, statusnum in cur.fetchall()])
    return post
开发者ID:Ms2ger,项目名称:mozilla-weekly-updates,代码行数:13,代码来源:model.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mail.send函数代码示例发布时间:2022-05-25
下一篇:
Python views.get_user函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap