<commit_before># Include the Dropbox SDK
import dropbox

class DropboxConnection(object):
    """DropboxConnection class"""
    def __init__(self, *arg):
        self._arg = arg
        self._client = self.reconnect()
    def reconnect(self):        
        # Get your app key and secret from the Dropbox developer website
        app_key = 'lf7drg20ucmhiga'
        app_secret = '<KEY>'

        flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)
        authorize_url = flow.start()

        # Have the user sign in and authorize this token
        authorize_url = flow.start()
        print ('1. Go to: \n%s' % authorize_url)
        print ('2. Click "Allow" (you might have to log in first)')
        print ('3. Copy the authorization code.')
        code = raw_input("Enter the authorization code here: ").strip()
        # This will fail if the user enters an invalid authorization code
        access_token, user_id = flow.finish(code)

        client = dropbox.client.DropboxClient(access_token)
        print 'linked account user: ', client.account_info()['display_name']
        # print 'linked account: ', client.account_info()
        return client
    def open_dropbox_file(self,fname):
        f, metadata = self._client.get_file_and_metadata(fname)
        return f

if __name__ == "__main__":
    dr_fname = '/othodi/cities.txt'
    print('reading file %s from dropbox' % dr_fname)
    dc = DropboxConnection()
    dr_f = dc.open_dropbox_file(dr_fname)
    out_fname = 'cities_from_dropbox.txt'
    with open(out_fname,'r'):
        for line in dr_f:
            print(line)<commit_msg>py3 fix<commit_after># Include the Dropbox SDK
import dropbox

class DropboxConnection(object):
    """DropboxConnection class"""
    def __init__(self, *arg):
        self._arg = arg
        self._client = self.reconnect()
    def reconnect(self):        
        # Get your app key and secret from the Dropbox developer website
        app_key = 'lf7drg20ucmhiga'
        app_secret = '<KEY>'

        flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)
        authorize_url = flow.start()

        # Have the user sign in and authorize this token
        authorize_url = flow.start()
        print ('1. Go to: \n%s' % authorize_url)
        print ('2. Click "Allow" (you might have to log in first)')
        print ('3. Copy the authorization code.')
        code = raw_input("Enter the authorization code here: ").strip()
        # This will fail if the user enters an invalid authorization code
        access_token, user_id = flow.finish(code)

        client = dropbox.client.DropboxClient(access_token)
        print('linked account user: %s' % client.account_info()['display_name'])
        # print 'linked account: ', client.account_info()
        return client
    def open_dropbox_file(self,fname):
        f, metadata = self._client.get_file_and_metadata(fname)
        return f

if __name__ == "__main__":
    dr_fname = '/othodi/cities.txt'
    print('reading file %s from dropbox' % dr_fname)
    dc = DropboxConnection()
    dr_f = dc.open_dropbox_file(dr_fname)
    out_fname = 'cities_from_dropbox.txt'
    with open(out_fname,'r'):
        for line in dr_f:
            print(line)
{'fraction_non_alphanumeric': 0.10080147965474723, 'fraction_numerical': 0.004623921085080148, 'mean_word_length': 2.782051282051282, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4384905', 'n_tokens_mistral': 1006, 'n_tokens_neox': 978, 'n_words': 278}