<commit_before># -*- coding: utf-8 -*-
import os
import logging

from framework.sessions import session

from website.project.decorators import must_be_contributor_or_public, must_have_addon
from website.util import rubeus

from website.addons.dropbox.client import get_node_client
from website.addons.dropbox.utils import (
    clean_path, list_dropbox_files, metadata_to_hgrid,
    build_dropbox_urls, clean_path, list_dropbox_files, ensure_leading_slash,
)

logger = logging.getLogger(__name__)
debug = logger.debug


@must_be_contributor_or_public
@must_have_addon('dropbox', 'node')
def dropbox_hgrid_data_contents(**kwargs):
    node_settings = kwargs['node_addon']
    node = node_settings.owner
    auth = kwargs['auth']
    path = kwargs.get('path', node_settings.folder)
    permissions = {
        'edit': node.can_edit(auth) and not node.is_registration,
        'view': node.can_view(auth)
    }
    client = get_node_client(node)

    # TODO: store cursor
    prefix = ensure_leading_slash(path.lower())
    cursor = session.data.get('dropbox_cursor', None)
    result = client.delta(cursor=cursor, path_prefix=prefix)
    # Store the cursor
    session.data['dropbox_cursor'] = result['cursor']
    entries = result['entries']
    metadata = [meta for fpath, meta in entries if fpath != prefix]
    contents = [metadata_to_hgrid(file_dict, node, permissions) for
            file_dict in metadata]
    return contents


def dropbox_addon_folder(node_settings, auth, **kwargs):
    node = node_settings.owner<commit_msg>Revert to using metadata/ endpoint because it was breaking uploads<commit_after># -*- coding: utf-8 -*-
import os
import logging

from website.project.decorators import must_be_contributor_or_public, must_have_addon
from website.util import rubeus

from website.addons.dropbox.client import get_node_client
from website.addons.dropbox.utils import (
    clean_path, list_dropbox_files, metadata_to_hgrid,
    build_dropbox_urls, clean_path
)

logger = logging.getLogger(__name__)
debug = logger.debug


@must_be_contributor_or_public
@must_have_addon('dropbox', 'node')
def dropbox_hgrid_data_contents(**kwargs):
    node_settings = kwargs['node_addon']
    node = node_settings.owner
    auth = kwargs['auth']
    path = kwargs.get('path', node_settings.folder)
    permissions = {
        'edit': node.can_edit(auth) and not node.is_registration,
        'view': node.can_view(auth)
    }
    client = get_node_client(node)
    contents = [metadata_to_hgrid(file_dict, node, permissions) for
            file_dict in client.metadata(path)['contents']]
    return contents


def dropbox_addon_folder(node_settings, auth, **kwargs):
    node = node_settings.owner
{'fraction_non_alphanumeric': 0.09825732295142751, 'fraction_numerical': 0.0007415647015202076, 'mean_word_length': 4.609147609147609, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2633531', 'n_tokens_mistral': 851, 'n_tokens_neox': 847, 'n_words': 186}