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


Python Api.write_regular方法代码示例

本文整理汇总了Python中tumblr.Api.write_regular方法的典型用法代码示例。如果您正苦于以下问题:Python Api.write_regular方法的具体用法?Python Api.write_regular怎么用?Python Api.write_regular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tumblr.Api的用法示例。


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

示例1: post_to_tumblr

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
 def post_to_tumblr(self, title, url):
     api = Api(BLOG, USER, PASSWORD)
     try:
         html = '<img src="%s" alt="%s" />' % (url, title)
         api.write_regular(title, html)
     except TumblrError, e:
         logging.error(e)
开发者ID:calle,项目名称:fn,代码行数:9,代码来源:upload.py

示例2: testEdit

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
	def testEdit(self):
		api = Api(BLOG, USER, PASSWORD)

		newpost = api.write_regular('title','body')
		np = {} 
		np['post-id'] = newpost['id'] 
		np['regular-body'] = 'edited body'
		editedpost = api.write_regular(np)
		import pprint
		pp = pprint.PrettyPrinter(indent=4)
		pp.pprint(newpost)
		
		assert editedpost['regular-body'] == 'body' 
开发者ID:abhiomkar,项目名称:python-tumblr,代码行数:15,代码来源:tumblr-test.py

示例3: send_message

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def send_message(message):
    blog = settings.get('tumblr', 'blog')
    email = settings.get('tumblr', 'email')
    password = settings.get('tumblr', 'password')
    api = Api(blog, email, password)
    post = api.write_regular(title=None, body=message)
    print post['url']
开发者ID:cataska,项目名称:tweetplurk,代码行数:9,代码来源:mytumblr.py

示例4: testWrite

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
	def testWrite(self):
		api = Api(BLOG, USER, PASSWORD)

		newpost = api.write_regular('title','body')
		post = api.read(newpost['id'])
		assert newpost['id'] == post['id']

		newpost = api.write_link('http://www.google.com')
		post = api.read(newpost['id'])
		assert newpost['id'] == post['id']

		newpost = api.write_quote('it was the best of times...')
		post = api.read(newpost['id'])
		assert newpost['id'] == post['id']

		newpost = api.write_conversation('me: wow\nyou: double wow!')
		post = api.read(newpost['id'])
		assert newpost['id'] == post['id']

		newpost = api.write_video('http://www.youtube.com/watch?v=60og9gwKh1o')
		post = api.read(newpost['id'])
		assert newpost['id'] == post['id']

		newpost = api.write_photo('http://www.google.com/intl/en_ALL/images/logo.gif')
		post = api.read(newpost['id'])
		assert newpost['id'] == post['id']
开发者ID:mdocode,项目名称:hangTumblr,代码行数:28,代码来源:tumblr-test.py

示例5: tumblr_text

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
def tumblr_text(request):
    conversation_id = request.POST['conversation_id']
    title = request.POST['title']
    body = request.POST['body']
    
    # create a dictionary mapping names to random strings so they are unrecognizable but consistent
    replacements = generate_replacements()

    # strip credit card numbers
    credit_pattern = re.compile(r"\d{3,5}\D*\d{3,5}\D*\d{3,5}\D*\d{3,5}")
    body = credit_pattern.sub("XXXX-XXXX-XXXX-XXXX", body)

    # strip phone numbers
    phone_pattern = re.compile(r"(\d{3}\D*)?(\d{3})\D*(\d{4})")
    body = phone_pattern.sub("XXX-XXXX", body)

    # strip names
    #TODO: make sure names.txt is in correct directory relative to server
    names_path = os.path.dirname(__file__) + '/../names.txt'
    names = open(names_path, 'r')
    for name in names:
        name = name.rstrip() # remove newline
        name_pattern = re.compile(r"\b" + name + r"\b", re.IGNORECASE)
        body = name_pattern.sub(replacements[name], body)

    tumblr = Api(BLOG,USER,PASSWORD)
    post = tumblr.write_regular(title, body)

    return HttpResponse(title + "\n" + body)
开发者ID:mponizil,项目名称:LoCreep,代码行数:31,代码来源:util.py

示例6: Text

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
class Text(gui.CeFrame):
	def __init__(self, api):
		self.api = api
		gui.CeFrame.__init__(self, title="Opentumblr CE")
		
		self.l_text = gui.Label(self, "Add a Text Post", align = "center")
		self.l_title = gui.Label(self, "Title (optional)")
		self.tc_title = gui.Edit(self)
		self.l_post = gui.Label(self, "Post")
		self.tc_post = gui.Edit(self,multiline = True)
		
		self.b_create = gui.Button(self, "Create Post")
		self.b_cancel = gui.Button(self, "Cancel")
		
		self.b_create.bind(clicked = self.OnCreatePost)
		self.b_cancel.bind(clicked = self.OnCancel)
		
		self.__set_properties()
		self.__do_layout()
	
	def __set_properties(self):
		pass
	
	def __do_layout(self):
		s_text = gui.VBox(border = (5,5,5,5), spacing = 5)
		s_text.add(self.l_text)
		s_text.add(self.l_title)
		s_text.add(self.tc_title)
		s_text.add(self.l_post)
		s_text.add(self.tc_post)
		s_text.add(self.b_create)
		s_text.add(self.b_cancel)
		
		self.sizer = s_text
		
	def OnCreatePost(self, evt):
		self.title = self.tc_title.get_text()
		self.body = self.tc_post.get_text()
		
		if self.body:
			self.api = Api(self.api.name, self.api.email, self.api.password)
			try:
				self.post = self.api.write_regular(self.title, self.body)
			except:
				print "Posteado en el primario"
			self.close()
		else:
			gui.Message.ok(title = 'Warning', caption = 'Post is required')
		
	def OnCancel(self, evt):
		self.close()
		
#if __name__ == '__main__':
#	app = gui.Application(Text())
#	app.run()
开发者ID:jyr,项目名称:opentumblr-ce,代码行数:57,代码来源:text.py

示例7: Api

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
#!/usr/bin/env python

from tumblr import Api
import feedparser

BLOG='YOU.tumblr.com'
USER='YOUREMAIL'
PASSWORD='YOURPASSWORD'

api = Api(BLOG,USER,PASSWORD)
d = feedparser.parse('http://feeds.weatherbug.com/rss.aspx?zipcode=27702&feed=curr&zcode=z4641')
for e in d.entries:
    api.write_regular(e.title,e.summary)

开发者ID:abhiomkar,项目名称:python-tumblr,代码行数:15,代码来源:import.py

示例8: len

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
#!/usr/bin/env python

from tumblr import Api
import sys

BLOG='YOU.tumblr.com'
USER='YOUREMAIL'
PASSWORD='YOURPASSWORD'

if len(sys.argv) != 3:
	print "Usage: tumbl <title> <body>"
	sys.exit(-1)	

title = sys.argv[1]
body = sys.argv[2]

api = Api(BLOG,USER,PASSWORD)
post = api.write_regular(title,body)
print "Published: ", post['url']
开发者ID:abhiomkar,项目名称:python-tumblr,代码行数:21,代码来源:tumbl.py

示例9: Api

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
from tumblr import Api
import sys, random
from enpersonator import Enpersonator

BLOG='soniayuditskaya.tumblr.com'
USER='[email protected]'
PASSWORD='graphicdesign'

api = Api(BLOG,USER,PASSWORD)
enp = Enpersonator()
lines = []

title = enp.generateLine(2, 8)
for i in range(random.randint(3, 12)):
    lines.append(enp.generateLine(random.randint(2, 3), random.randint(50, 300)))

postBody = "\n\n".join(lines)

print "TITLE: ",title, "\n"
print postBody

post = api.write_regular(title, postBody)
print "Published: ", post['url']
开发者ID:t3db0t,项目名称:Enpersonator,代码行数:25,代码来源:tumblrPostWriter.py

示例10: upload_image_to_picasaweb

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
         if imgsrc.startswith('/') or imgsrc.startswith('resolveuid') or imgsrc.startswith('..') or imgsrc.startswith('/photo-album') or imgsrc.startswith('/images') or imgsrc.startswith('http://kokorice.org'):
             # Download the image & upload to picasaweb
             oldsrc = 'http://kokorice.org/'+imgsrc
             print "Downloading %s ..." % oldsrc
             downloadedimg = TMPDIR+slug+str(imgidx)
             content = subprocess.Popen(["wget",
                                         oldsrc,
                                         "--output-document="+downloadedimg],
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE).communicate()[0]
             print "Downloaded %s" % downloadedimg
             image = upload_image_to_picasaweb(gd_client, downloadedimg, entry.title+' '+str(imgidx), album)
             if image:
                 print "Uploaded image to %s" % image.content.src
                 # rewrite out the img src attributes
                 imgtag.set('src', image.content.src)
                 print "Rewrote IMG src attribute to %s" % imgtag.get('src')
                 processedimg = True
         imgidx = imgidx+1
     if processedimg:
         entrysummary = tostring(etsummary)
     else:
         entrysummary = entry.summary
     entrytags = '"%s"' % '","'.join(entrytags)
     importedpost = api.write_regular(entry.title, entrysummary, date=entry.date, tags=entrytags, slug=slug)
     print "Imported blog entry here: %s" % importedpost['url-with-slug']
     print "-------------------------"
 if len(unprocessedimgs) > 0:
     print "The following images couldn't be uploaded to picasaweb:\n"
     for unprocessedimg in unprocessedimgs:
         print "%s : %s\n" % (unprocessedimg[0], unprocessedimg[1])
开发者ID:duffyd,项目名称:kokorice.importer,代码行数:33,代码来源:importblog.py

示例11: testDelete

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_regular [as 别名]
	def testDelete(self):
		api = Api(BLOG, USER, PASSWORD)

		newpost = api.write_regular('title','body')
		post = api.read(newpost['id'])
		api.delete(post['id'])
开发者ID:abhiomkar,项目名称:python-tumblr,代码行数:8,代码来源:tumblr-test.py


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