<commit_before>"""
RVT_fixme
things todo on workshared model
"""
import os.path as op
import json
from ConfigParser import ConfigParser
from scriptutils import this_script
from Autodesk.Revit.DB import BuiltInCategory, ElementId, WorksharingUtils


def get_tasks(user_name, fixme_task_list):
    doc = __revit__.ActiveUIDocument.Document
    uidoc = __revit__.ActiveUIDocument

    if fixme_task_list.endswith("ini"):
        ini_file = fixme_task_list
        config = ConfigParser()
        config.read(ini_file)
        presented_ids = 0
        for sec in config.sections():
            this_script.output.print_md("**{}**".format(sec))
            print("--- list of ids to fix:")
            for elem in config.items(sec):
                topic = elem[0]
                print("--- topic: {0}".format(topic))
                for str_id in elem[1].split(","):
                    # print(str_id)
                    elem_id = ElementId(int(str_id.strip()))
                    if doc.GetElement(elem_id):
                        # print(elem_id)
                        this_script.output.print_md("--- " + this_script.output.linkify(elem_id))
                        presented_ids += 1
                    if presented_ids == 5:
                        break

    elif fixme_task_list.endswith(".json"):
        json_file = fixme_task_list
        presented_ids = 0
        warn_id_dict = read_json_to_dict(json_file)
        for topic in warn_id_dict:
            this_script.output.print_md("**{}**".format(topic))
            for date in warn_id_dict[topic]:
                for str_id in warn_id_dict[topic][date]:
                    elem_id = ElementId(int(str_id))
                    print(str_id)
                    this_script.output.print_md("--- " + this_script.output.linkify(elem_id))
                    presented_ids += 1
                    if presented_ids == 5:
                        break

    print("-" * 59)
    print("| thank you, that is all I have for now,")
    print("| have a great day!")
    print("-" * 59)


def connect_to_rvt(fixme_task_list):
    user = __revit__.Application.Username
    get_tasks(user, fixme_task_list)


def read_json_to_dict(json_file):
    with open(json_file, 'r') as jsn:
        return json.load(jsn)


oc_path = op.dirname(__file__)
# print("-" + oc_path)
<commit_msg>on_ws_model_opened - element infos added<commit_after>"""
RVT_fixme
things todo on workshared model
"""
import os.path as op
import json
from ConfigParser import ConfigParser
from scriptutils import this_script
from Autodesk.Revit.DB import BuiltInCategory, ElementId, WorksharingUtils


def get_tasks(user_name, fixme_task_list):
    doc = __revit__.ActiveUIDocument.Document
    uidoc = __revit__.ActiveUIDocument

    if fixme_task_list.endswith("ini"):
        ini_file = fixme_task_list
        config = ConfigParser()
        config.read(ini_file)
        presented_ids = 0
        for sec in config.sections():
            this_script.output.print_md("**{}**".format(sec))
            print("--- list of ids to fix:")
            for elem in config.items(sec):
                topic = elem[0]
                print("--- topic: {0}".format(topic))
                for str_id in elem[1].split(","):
                    # print(str_id)
                    elem_id = ElementId(int(str_id.strip()))
                    if doc.GetElement(elem_id):
                        # print(elem_id)
                        this_script.output.print_md("--- " + this_script.output.linkify(elem_id))
                        presented_ids += 1
                    if presented_ids == 5:
                        break

    elif fixme_task_list.endswith(".json"):
        json_file = fixme_task_list
        presented_ids = 0
        warn_id_dict = read_json_to_dict(json_file)
        for topic in warn_id_dict:
            this_script.output.print_md("**{}**".format(topic))
            for date in warn_id_dict[topic]:
                for str_id in warn_id_dict[topic][date]:
                    elem_id = ElementId(int(str_id))
                    elem = doc.GetElement(elem_id)
                    elem_cat = elem.Category.Name.strip("<>")
                    if elem.ViewSpecific:
                        location = doc.GetElement(elem.OwnerViewId).Name
                    else:
                        location = doc.GetElement(elem.LevelId).Name

                    elem_info = " - {} - {}".format(elem_cat, location)

                    last_changer = WorksharingUtils.GetWorksharingTooltipInfo(doc, elem_id).LastChangedBy
                    if last_changer == user_name:
                        this_script.output.print_md("--- " + this_script.output.linkify(elem_id) + elem_info)
                    presented_ids += 1
            if presented_ids == 9:
                break

    print("-" * 59)
    print("| thank you, that is all I have for now,")
    this_script.output.print_md("| **have a great day!**")
    print("-" * 59)


def connect_to_rvt(fixme_task_list):
    user = __revit__.Application.Username
    get_tasks(user, fixme_task_list)


def read_json_to_dict(json_file):
    with open(json_file, 'r') as jsn:
        return json.load(jsn)


oc_path = op.dirname(__file__)
# print("-" + oc_path)

{'fraction_non_alphanumeric': 0.10583524027459955, 'fraction_numerical': 0.004958047292143402, 'mean_word_length': 1.9334451901565997, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4473173', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1533, 'n_words': 325}