<commit_before>"""
Project management classes and functions
"""

import os
from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
import time
import datetime
from shutil import copy
try:
    from PIL import Image
except:
    import Image
import cvutils
import numpy as np
import subprocess
import uuid

from app_config import get_project_path, get_project_config_path, config_section_exists, update_config_without_sections
from video import get_framerate

def create_project(identifier, video_dict):
    config_dict = {}
    _update_config_dict_with_defaults(config_dict)

    _translate_config_dict(config_dict)
    _create_project_dir(identifier, config_dict, video_dict)

def update_homography(identifier, homography_path, unitpixelratio):
    pass

def update_project_config(identifier, config_dict):
    _update_config_dict_with_defaults(config_dict)
    _translate_config_dict(config_dict) 

    project_path = get_project_path(identifier)
    tracking_path = os.path.join(project_path, "tracking.cfg")
    update_config_without_sections(tracking_path, config_dict)

def default_config_dict():
    return {
        'max_features_per_frame': 1000,
        'num_displacement_frames': 10,
        'min_feature_displacement': 0.0001,
        'max_iterations_to_persist': 200,
        'min_feature_frames': 15,
        'max_connection_distance': 1.0,
        'max_segmentation_distance': 0.7,
    }
def _translate_config_dict(config_dict):
    translate_dict = \
    {   'max_features_per_frame': "max-nfeatures",
        'num_displacement_frames': "ndisplacements",
        'min_feature_displacement': "min-feature-displacement",
        'max_iterations_to_persist': "max-number-iterations",
        'min_feature_frames': "min-feature-time",<commit_msg>ADD: StatusHelper initialized on project creation<commit_after>"""
Project management classes and functions
"""

import os
from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
import time
import datetime
from shutil import copy
try:
    from PIL import Image
except:
    import Image
import cvutils
import numpy as np
import subprocess
import uuid

from app_config import get_project_path, get_project_config_path, config_section_exists, update_config_without_sections
from video import get_framerate
from statusHelper import StatusHelper

def create_project(identifier, video_dict):
    config_dict = {}

    _update_config_dict_with_defaults(config_dict)
    _translate_config_dict(config_dict)
    _create_project_dir(identifier, config_dict, video_dict)
    StatusHelper.initalize_project(identifier) # This must be called after the config path has been created

def update_homography(identifier, homography_path, unitpixelratio):
    pass

def update_project_config(identifier, config_dict):
    _update_config_dict_with_defaults(config_dict)
    _translate_config_dict(config_dict) 

    project_path = get_project_path(identifier)
    tracking_path = os.path.join(project_path, "tracking.cfg")
    update_config_without_sections(tracking_path, config_dict)

def default_config_dict():
    return {
        'max_features_per_frame': 1000,
        'num_displacement_frames': 10,
        'min_feature_displacement': 0.0001,
        'max_iterations_to_persist': 200,
        'min_feature_frames': 15,
        'max_connection_distance': 1.0,
        'max_segmentation_distance': 0.7,
    }
def _translate_config_dict(config_dict):
    translate_dict = \
    {   'max_features_per_frame': "max-nfeatures",
        'num_displacement_frames': "ndisplacements",
        'min_feature_displacement': "min-feature-displacement",
        'max_iterations_to_persist': "max-number-iterations",
        'min_feature_frames': "min-feature-time",
{'fraction_non_alphanumeric': 0.07537553648068669, 'fraction_numerical': 0.01072961373390558, 'mean_word_length': 5.0732899022801305, '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': '1979672', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1105, 'n_words': 234}