<commit_before>from __future__ import print_function

import os
import json
import requests # for POST

if __name__=='__main__':
    import sys
    CURRENT_DIR = os.path.dirname(os.path.dirname(__file__))
    sys.path.append(os.path.join(CURRENT_DIR, '../'))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geoconnect.settings.local")

from geo_utils.key_checker import KeyChecker 
from geo_utils.json_field_reader import MessageHelperJSON

from django.conf import settings 
from apps.dv_notify.models import DATAVERSE_REQUIRED_KEYS
import logging
logger = logging.getLogger(__name__)


class MetadataUpdater:
    """Send a metadata update to Dataverse.  Specifically, update the GIS Metadata block
    for a given file."""
    
    #METADATA_UPDATE_API_PATH = 'geo-api/singlefile/update-gis-metadata/'
    REQUIRED_PARAM_KEYS = DATAVERSE_REQUIRED_KEYS
    # ['datafile_id', 'layer_name', 'layer_link', 'embed_map_link', 'worldmap_username', 'dv_session_token']#, 'bbox_min_lng', 'bbox_min_lat', 'bbox_max_lng', 'bbox_max_lat']
    
    def __init__(self, dataverse_server_url, timeout_seconds=240, return_type_json=False):
        """
        Use data in a python dict to POST data to the Dataverse API, specifically the GeographicMetadataUpdateForm
        
        :param dv_metadata_params: dict containing information necessary for contacting dataverse<commit_msg>update for logger<commit_after>from __future__ import print_function

import os
import json
import requests # for POST

if __name__=='__main__':
    import sys
    CURRENT_DIR = os.path.dirname(os.path.dirname(__file__))
    sys.path.append(os.path.join(CURRENT_DIR, '../'))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geoconnect.settings.local")

from geo_utils.key_checker import KeyChecker 
from geo_utils.json_field_reader import MessageHelperJSON

from django.conf import settings 
from apps.dv_notify.models import DATAVERSE_REQUIRED_KEYS
import logging
logger = logging.getLogger('geoconnect')


class MetadataUpdater:
    """Send a metadata update to Dataverse.  Specifically, update the GIS Metadata block
    for a given file."""
    
    #METADATA_UPDATE_API_PATH = 'geo-api/singlefile/update-gis-metadata/'
    REQUIRED_PARAM_KEYS = DATAVERSE_REQUIRED_KEYS
    # ['datafile_id', 'layer_name', 'layer_link', 'embed_map_link', 'worldmap_username', 'dv_session_token']#, 'bbox_min_lng', 'bbox_min_lat', 'bbox_max_lng', 'bbox_max_lat']
    
    def __init__(self, dataverse_server_url, timeout_seconds=240, return_type_json=False):
        """
        Use data in a python dict to POST data to the Dataverse API, specifically the GeographicMetadataUpdateForm
        
        :param dv_metadata_params: dict containing information necessary for contacting dataverse
{'fraction_non_alphanumeric': 0.08853410740203194, 'fraction_numerical': 0.0021770682148040637, 'mean_word_length': 4.929032258064516, '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': '3391488', 'n_tokens_mistral': 882, 'n_tokens_neox': 867, 'n_words': 207}