本文整理汇总了Python中post.Post.publish方法的典型用法代码示例。如果您正苦于以下问题:Python Post.publish方法的具体用法?Python Post.publish怎么用?Python Post.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.publish方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import publish [as 别名]
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]