<commit_before>###########################################################
#
# Copyright (c) 2011, Southpaw Technology
#                     All Rights Reserved
#
# PROPRIETARY INFORMATION.  This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
#


__all__ = ['CheckinDirListWdg']

from pyasm.common import Environment, Common, FormatValue
from pyasm.search import SearchKey, Search
from pyasm.biz import Snapshot, File
from pyasm.web import DivWdg, SpanWdg
from pyasm.widget import IconWdg

from tactic.ui.common import BaseRefreshWdg
from tactic.ui.widget import DirListWdg
from tactic.ui.container import DialogWdg, Menu, MenuItem, SmartMenu

import os


class CheckinDirListWdg(DirListWdg):


    def preprocess(my):
        # find out if there is a snapshot associated with this path
        #print "sobject: ", my.sobject

        #context = "design/%s" % basename
        #search = Search("sthpw/snapshot")
        #search.add_filter("context", context)
        #my.sobject = search.get_sobject()

        search_key = my.kwargs.get("search_key")
        my.sobject = Search.get_by_search_key(search_key)

        md5s = my.kwargs.get("md5s")
        sizes = my.kwargs.get("sizes")

        # bit of a hack get the file system paths
        spaths = []
        my.md5s = {}
        my.sizes = {}
        for i, path in enumerate(my.paths):
            #path = Common.get_filesystem_name(path)
            #new_path = path.replace(" ", "_")
            new_path = path
            spaths.append(new_path)

            my.md5s[new_path] = md5s[path]
            my.sizes[new_path] = sizes[path]


        process = my.kwargs.get("process")

        # need to match up files 
        search = Search("sthpw/file")
        search.add_sobject_filter(my.sobject)
        snapshots = []
        if process:
            search2 = Search("sthpw/snapshot")
            search2.add_filter("process", process)
            search2.add_filter("is_latest", True)
            search2.add_sobject_filter(my.sobject)
            snapshots = search2.get_sobjects()
            search.add_relationship_search_filter(search2)
        #search.add_filters("source_path", spaths)
        sobjects = search.get_sobjects()

        my.snapshots_dict = {}
        for snapshot in snapshots:
            my.snapshots_dict[snapshot.get_code()] = snapshot

<commit_msg>BRANCH 4.1:   fixed a stacktrace bug in CheckinWdg where the number of paths doesn't match the number of md5 values for newly created folder in sandbox<commit_after>###########################################################
#
# Copyright (c) 2011, Southpaw Technology
#                     All Rights Reserved
#
# PROPRIETARY INFORMATION.  This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
#


__all__ = ['CheckinDirListWdg']

from pyasm.common import Environment, Common, FormatValue
from pyasm.search import SearchKey, Search
from pyasm.biz import Snapshot, File
from pyasm.web import DivWdg, SpanWdg
from pyasm.widget import IconWdg

from tactic.ui.common import BaseRefreshWdg
from tactic.ui.widget import DirListWdg
from tactic.ui.container import DialogWdg, Menu, MenuItem, SmartMenu

import os


class CheckinDirListWdg(DirListWdg):


    def preprocess(my):
        # find out if there is a snapshot associated with this path
        #print "sobject: ", my.sobject

        #context = "design/%s" % basename
        #search = Search("sthpw/snapshot")
        #search.add_filter("context", context)
        #my.sobject = search.get_sobject()

        search_key = my.kwargs.get("search_key")
        my.sobject = Search.get_by_search_key(search_key)

        md5s = my.kwargs.get("md5s")
        sizes = my.kwargs.get("sizes")

        # bit of a hack get the file system paths
        spaths = []
        my.md5s = {}
        my.sizes = {}
        for i, path in enumerate(my.paths):
            #path = Common.get_filesystem_name(path)
            #new_path = path.replace(" ", "_")
            new_path = path
            spaths.append(new_path)

            my.md5s[new_path] = md5s.get(path)
            my.sizes[new_path] = sizes.get(path)


        process = my.kwargs.get("process")

        # need to match up files 
        search = Search("sthpw/file")
        search.add_sobject_filter(my.sobject)
        snapshots = []
        if process:
            search2 = Search("sthpw/snapshot")
            search2.add_filter("process", process)
            search2.add_filter("is_latest", True)
            search2.add_sobject_filter(my.sobject)
            snapshots = search2.get_sobjects()
            search.add_relationship_search_filter(search2)
        #search.add_filters("source_path", spaths)
        sobjects = search.get_sobjects()

        my.snapshots_dict = {}
        for snapshot in snapshots:
            my.snapshots_dict[snapshot.get_code()] = snapshot


{'fraction_non_alphanumeric': 0.11686507936507937, 'fraction_numerical': 0.006547619047619048, 'mean_word_length': 2.6608569353667395, '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': '4245461', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1489, 'n_words': 373}