<commit_before>googlespread
############

Simplify using oAuth2 to access Google Spreadsheets and provide easier access to selecting a spreadsheet/worksheet by-name as well ass for appending rows to the given worksheet.

StartClient() returns an oAuth authorized gdata client object which can be used directly with any gdata methods.

See the gdata python client for more info: https://code.google.com/p/gdata-python-client/
gdata python client wiki: https://code.google.com/p/gdata-python-client/w/list

Generating the oAuth2 data for your app
***************************************

Setup your project at the Google developer console:
    Start at https://console.developers.google.com/project
        - Create new project
            - Expand APIs & auth
                - Credentials
                    - Create new Client ID
                        - Web type
                            - Download JSON

Basic Usage
***********

To use simply do::

    >>> from googlespread import GoogleSpread
    >>> google = GoogleSpread()
    >>> google.auth(secret_json = SECRET,
                    scope = 'http://spreadsheets.google.com/feeds/',
                    user_agent = USER_AGENT,
                    redirect_uri = REDIRECT_URI)

    >>> client = google.StartClient(spreadsheet = "my spreadsheet",
                                    worksheet = "sheet2")

    >>> fields = {'timestamp': "This",
                  'temperature': "and",
                  'humidity': "That"}

    >>> result = google.AppendRow(fields)

Methods
*******

    def __init__(self, secret_json=None,
                 scope="",
                 redirect_uri="http://localhost",
                 user_agent="MyClient/1.0"):

    def auth(self, secret_json,
             scope="",
             redirect_uri="http://localhost",
             user_agent="MyClient/1.0"):

Setup the client connection to the correct worksheet and authorize it.
    def start_client(self,
                     spreadsheet=None, spreadsheet_id=None,
                     worksheet=None, worksheet_id=None):

Set/change the spreadsheet_id being used by the client using either the name or ID
    def set_spreadsheet(self,
                        spreadsheet=None, spreadsheet_id=None):

Set/channge the spreadsheet_id being used by the client using either the name or ID
    def set_worksheet(self,
                      spreadsheet=None, spreadsheet_id=None,
                      worksheet=None, worksheet_id=None):

Retrieve a spreadsheet's ID by its name
    def get_spreadsheet_id_by_name(self, spreadsheet):
        Returns:
            (string) spreadsheet-id

Retrieve a worksheet's ID given its name and either the name or ID of the parent spreadsheet
    def get_worksheet_id_by_name(self, worksheet, spreadsheet=None, spreadsheet_id=None):
        Returns:
            (string) worksheet-id

Simple method for appending a row to a worksheet
    def append_row(self, data):
        Append a row to a worksheet.

        Args:
            data (dict): The keys MUST be lowercase, alpha-only, and MUST be the first row of the worksheet.
        Returne:
            a gdata row object, if successful.
<commit_msg>Reformat the Method section<commit_after>googlespread
############

Simplify using oAuth2 to access Google Spreadsheets and provide easier access to selecting a spreadsheet/worksheet by-name as well ass for appending rows to the given worksheet.

StartClient() returns an oAuth authorized gdata client object which can be used directly with any gdata methods.

See the gdata python client for more info: https://code.google.com/p/gdata-python-client/
gdata python client wiki: https://code.google.com/p/gdata-python-client/w/list

Generating the oAuth2 data for your app
***************************************

Setup your project at the Google developer console:
    Start at https://console.developers.google.com/project
        - Create new project
            - Expand APIs & auth
                - Credentials
                    - Create new Client ID
                        - Web type
                            - Download JSON

Basic Usage
***********

To use simply do::

    >>> from googlespread import GoogleSpread
    >>> google = GoogleSpread()
    >>> google.auth(secret_json = SECRET,
                    scope = 'http://spreadsheets.google.com/feeds/',
                    user_agent = USER_AGENT,
                    redirect_uri = REDIRECT_URI)

    >>> client = google.StartClient(spreadsheet = "my spreadsheet",
                                    worksheet = "sheet2")

    >>> fields = {'timestamp': "This",
                  'temperature': "and",
                  'humidity': "That"}

    >>> result = google.AppendRow(fields)

Methods
*******

    def __init__(self, secret_json=None,
                 scope="",
                 redirect_uri="http://localhost",
                 user_agent="MyClient/1.0"):

    def auth(self, secret_json,
             scope="",
             redirect_uri="http://localhost",
             user_agent="MyClient/1.0"):

        Setup and authorize the connection using the data provided either at Class instantiation or the auth method.  Note, if the app does not have access to launch a web browser to complete the authorization to the user's account, then watch the console for offline instructions.

    def start_client(self,
                     spreadsheet=None, spreadsheet_id=None,
                     worksheet=None, worksheet_id=None):

        Setup the client connection to the correct worksheet and authorize it.

    def set_spreadsheet(self,
                        spreadsheet=None, spreadsheet_id=None):

        Set/change the spreadsheet_id being used by the client using either the name or ID

    def set_worksheet(self,
                      spreadsheet=None, spreadsheet_id=None,
                      worksheet=None, worksheet_id=None):

        Set/channge the spreadsheet_id being used by the client using either the name or ID
        
    def get_spreadsheet_id_by_name(self, spreadsheet):

        Retrieve a spreadsheet's ID by its name

        Returns:
            (string) spreadsheet-id

    def get_worksheet_id_by_name(self, worksheet, spreadsheet=None, spreadsheet_id=None):

        Retrieve a worksheet's ID given its name and either the name or ID of the parent spreadsheet

        Returns:
            (string) worksheet-id

    def append_row(self, data):

        Simple method for appending a row to a worksheet

        Args:
            data (dict): The keys MUST be lowercase, alpha-only, and MUST be the first row of the worksheet.
        Returns:
            a gdata row object, if successful.

{'fraction_non_alphanumeric': 0.09213281483697278, 'fraction_numerical': 0.0020939276099311995, 'mean_word_length': 2.2555988315481987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2513964', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1660, 'n_words': 592}