<commit_before>import datetime, xmlrpclib
from modules.channel import Channel
from exception import *

wp_url = "http://students.thelycaeum.in/blog/xmlrpc.php"
wp_username = "beingshahul"
wp_password = "<PASSWORD>"
wp_blogid = ""

status_draft = 0
status_published = 1

server = xmlrpclib.ServerProxy(wp_url)

title = "Instantaneous post"
content = "Testing from publish application."
categories = ["Uncategorized"]
tags = ["sometag", "othertag"]
data = {'title': title, 'description': content, 'categories': categories, 'mt_keywords': tags}

post_id = server.metaWeblog.newPost(wp_blogid, wp_username, wp_password, data, status_published)

 
__cname__ = "blog"      #or whichever channel
 
class Blog(Channel):
        ''' Implements an Blog Api '''
        def __init__(self):
                self.__fields__ = ["Message","Title"]   # and whatever the plugin requires for sending a message
 
        def VerifyCredentials(self):
                self.GetAuthInfo()

        def GetAuthInfo(self):
        ''' Read Keys from Config file '''
        cfg = ConfigParser.RawConfigParser()
        cfg.read('.publish')
        
        if cfg.has_section('Twitter'):
            self.TOKEN = unhexlify(cfg.get('Twitter', 'Token Key'))
            self.TOKEN_SEC = unhexlify(cfg.get('Twitter', 'Token Secret'))
        else:
            cfg.add_section('Twitter')
            cfg.set('Twitter', 'Token Key', '')
            cfg.set('Twitter', 'Token Secret', '')
            with open('.publish', 'wb') as configfile:
                cfg.write(configfile)

            self.TOKEN = self.TOKEN_SEC = ''        

 
        def GetKeys(self):
                # You can look at this function from any other plugin, u'll just need to make a few changes
                # which are channel specific
 
        def Authorize(self):
                # here ask user for authentication info and save it in the .publish file
                # how to do that can be seen if u look at any existing plugins
                # Finally after saving the auth info
                # call VerifyCredentials and check if the given info is worth it
                # if it fails do :
                # raise AuthorizationError({'Wordpress':'Authorization Failed'})<commit_msg>Code for config section for  user credentials<commit_after>import datetime, xmlrpclib
from modules.channel import Channel
from exception import *
from binascii import hexlify, unhexlify

wp_url = "http://students.thelycaeum.in/blog/xmlrpc.php"
wp_username = "beingshahul"
wp_password = "<PASSWORD>"
wp_blogid = ""

status_draft = 0
status_published = 1

server = xmlrpclib.ServerProxy(wp_url)

title = "Instantaneous post"
content = "Testing from publish application."
categories = ["Uncategorized"]
tags = ["sometag", "othertag"]
data = {'title': title, 'description': content, 'categories': categories, 'mt_keywords': tags}

post_id = server.metaWeblog.newPost(wp_blogid, wp_username, wp_password, data, status_published)

 
__cname__ = "blog"      #or whichever channel
 
class Blog(Channel):
        ''' Implements an Blog Api '''
        def __init__(self):
                self.__fields__ = ["Message","Title"]   # and whatever the plugin requires for sending a message
 
        def VerifyCredentials(self):
                self.GetAuthInfo()

        def GetAuthInfo(self):
        ''' Read Keys from Config file '''
        cfg = ConfigParser.RawConfigParser()
        cfg.read('.publish')
        
        if cfg.has_section('Blog'):
            self.URL = unhexlify(cfg.get('Blog', 'URL'))
            self.USER = unhexlify(cfg.get('Blog', 'Username'))
            self.PWD = unhexlify(cfg.get('Blog', 'Password'))
            self.BID = unhexlify(cfg.get('Blog', 'Blog ID'))
        else:
            cfg.add_section('Blog')
            cfg.set('Blog', 'URL', '')
            cfg.set('Blog', 'Username', '')
            cfg.set('Blog', 'Password', '')
            cfg.set('Blog', 'ID', '')
            
            with open('.publish', 'wb') as configfile:
                cfg.write(configfile)

           # self.URL = self.USER = ''        

 
        def GetKeys(self):
                # You can look at this function from any other plugin, u'll just need to make a few changes
                # which are channel specific
 
        def Authorize(self):
                # here ask user for authentication info and save it in the .publish file
                # how to do that can be seen if u look at any existing plugins
                # Finally after saving the auth info
                # call VerifyCredentials and check if the given info is worth it
                # if it fails do :
                # raise AuthorizationError({'Wordpress':'Authorization Failed'})
{'fraction_non_alphanumeric': 0.10939809926082365, 'fraction_numerical': 0.0008447729672650475, 'mean_word_length': 2.404744787922358, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2078040', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1274, 'n_words': 399}