#NEWLINE# def save_link( self , link , author , message , tags = [ ] ) : #NEWLINE# #INDENT# '\n        Post a new link to snipt.net\n\n        :param link: Text to post\n        :param author: Author (will be added as a tag)\n        :param message: Full message\n        :param tags: Optional list of extra tags\n\n        ' #NEWLINE# if ( ( not API_USER ) or ( not API_KEY ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# snip_hash = hashlib . md5 ( link ) . hexdigest ( ) #NEWLINE# if self . get_snips_by_tag ( snip_hash ) : #NEWLINE# #INDENT# logging . debug ( 'Link already exists...' ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( 'nigel' not in tags ) : #NEWLINE# #INDENT# tags . append ( 'nigel' ) #NEWLINE# #UNINDENT# if author : #NEWLINE# #INDENT# tags . append ( author ) #NEWLINE# #UNINDENT# tags . append ( snip_hash ) #NEWLINE# suggested = self . get_suggested_tags ( [ self . _previous_message , message ] ) #NEWLINE# [ tags . append ( x ) for x in suggested ] #NEWLINE# tags . append ( 'tmp' ) #NEWLINE# snip = { #NEWLINE# #INDENT# 'title' : time . time ( ) , #NEWLINE# 'lexer' : 'markdown' , #NEWLINE# 'code' : '![{0}]({0})' . format ( suggested ) , #NEWLINE# 'tags' : ',' . join ( tags ) , #NEWLINE# #UNINDENT# } #NEWLINE# r = requests . post ( ( URL % 'snipt/' ) , headers = HEADERS , data = json . dumps ( snip ) ) #NEWLINE# if ( r . status_code != 201 ) : #NEWLINE# #INDENT# logging . debug ( 'Error saving: {0}' . format ( r . text ) )