Exemplo n.º 1
0
def edit_help(file_edit: str, obj_name: str) -> None:
    """Takes a path to a Max patch and does a find and replace on object names"""
    d = read_json(file_edit)
    outer_boxes = d["patcher"]["boxes"][0]
    internal_boxes = outer_boxes["box"]["patcher"]["boxes"]

    for key in internal_boxes:
        if "jsarguments" in key["box"]:
            key["box"]["jsarguments"] = obj_name

    write_json(file_edit, d)
Exemplo n.º 2
0
def main(docs):
    """
    A simplified version of the qlookup used to display information about specific objects when hovered over in the umenu.
    """
    docs.interfaces_dir.mkdir(exist_ok=True)
    obj_lookup = docs.interfaces_dir / "FrameLib-obj-dlookup.json"

    worker = dParseAndBuild()

    refpages = [x for x in docs.refpages_dir.rglob("fl.*.xml")]

    for ref in refpages:
        worker.extract_from_refpage(ref)

    write_json(obj_lookup, worker.d_master_dict)
Exemplo n.º 3
0
def main(docs: Documentation):
    """
    Creates a dict for the Max Documentation system.
    This dict contains more detailed information displayed in real-time when hovering over a certain tutorial in the umenu.
    """

    obj_lookup = docs.interfaces_dir / "FrameLib-obj-jlookup.json"

    worker = jParseAndBuild()

    refpages = [x for x in docs.refpages_dir.rglob("fl.*.xml")]

    for ref in refpages:
        worker.extract_from_refpage(ref)

    write_json(obj_lookup, worker.j_master_dict)
def main():
    """
    Creates a category database in .json format.
    Used by edit_raw_XML.py to assign object categories to the xml files.
    """

    max_objects = package_root / "FrameLib_Max_Objects"
    d = {}

    for f in max_objects.rglob("fl.*.cpp"):
        category = f"FrameLib {str(f.parent.parts[-1])}"
        if category in d:
            d[category].append(f.stem)
        else:
            d[category] = [f.stem]
    write_json(category_database_path, d)
Exemplo n.º 5
0
def main():
    """
    Creates tutorial information and stores it in a dictionary format. 
    This information is displayed to the user in a umenu.
    """

    tutorial_index = (current_version / "FrameLib" / "docs" / "tutorials" /
                      "FrameLib-tut" / "00_fl_index.maxtut.xml")
    interfaces_dir.mkdir(exist_ok=True)

    obj_lookup = interfaces_dir / "FrameLib-obj-tlookup.json"

    worker = tParseAndBuild()

    worker.extract_from_refpage(tutorial_index)

    write_json(obj_lookup, worker.d_skeleton)
def main(root):
    """
    Creates a dict for the Max Documentation system.
    This dict contains is essential for maxObjectLauncher/Refpages to pull the right info.

    Args:
        arg1: passes the root of the python files from the master script. Creates relative directories.
    """

    yaml_file = os.path.join(root, "object_relationships.yaml")
    object_info = None

    with open(yaml_file, "r") as stream:
        try:
            object_info = yaml.safe_load(stream)
        except yaml.YAMLError as exc:
            print(exc)

    bad_entries = [".DS_Store", "_c74_ref_modules.xml"]

    dir_path = root
    dir_path = os.path.join(cd_up(root, 2), "Current Test Version", "FrameLib")
    ref_dir = os.path.join(dir_path, "docs", "refpages")
    obj_lookup = os.path.join(dir_path, "interfaces",
                              "FrameLib-obj-qlookup.json")

    worker = qParseAndBuild()

    # Make a list of file names and remove bad entries
    refpages = thin_list(os.listdir(ref_dir), bad_entries)

    # Check if any files were found and do your thing
    if refpages:
        for filename in refpages:
            current_category = filename
            source_file_name = os.path.join(ref_dir, filename)

            for filename in os.listdir(source_file_name):
                source_file = os.path.join(ref_dir, current_category, filename)
                worker.extract_from_refpage(source_file)
                worker.extract_keywords(object_info)
                worker.extract_seealso(object_info)
                worker.build_json_file()

            # Write out to JSON
        write_json(obj_lookup, worker.d_master_dict)
Exemplo n.º 7
0
def main(root):
    """
    This creates a category database in .json format.
    This is used by edit_raw_XML.py to assign object categories to the xml files.
    """
    dir_path = root
    object_path = os.path.join(cd_up(root, 2), "FrameLib_Max_Objects")
    output_path = os.path.join(dir_path, "__tmp__", "db",
                               "category_database.json")

    file_categories = os.listdir(object_path)

    try:
        file_categories.remove("_MaxSDK_")
    except ValueError:
        print("No _MaxSDK_ to delete")
        pass

    try:
        file_categories.remove(".DS_Store")
    except ValueError:
        print("No .DS_Store")
        pass

    try:
        file_categories.remove("Common")
    except ValueError:
        print("No common folder")
        pass

    file_categories.sort()
    category_dict = {}

    for item in file_categories:
        files = os.listdir(os.path.join(object_path, item))
        if "ibuffer" in files:
            files.remove("ibuffer")
        # some max categories already overlap with framelib categories (timing for example). This just maps Timing -> fl_timing to avoid any duplication issues
        item = f"FrameLib {item}"
        for i in range(len(files)):
            files[i] = strip_extension(files[i], 1)
        category_dict[item] = files

    ## Write dict into JSON file
    write_json(output_path, category_dict)
Exemplo n.º 8
0
def main():
    template_dir = help_dir / "templates"
    internal_dir = help_dir / "internal_tabs"
    external_dir = current_version / "FrameLib" / "externals"
    master_template = help_dir / "help_template.maxhelp"

    templates = [x for x in template_dir.rglob("fl.*.maxhelp")]
    for t in templates:
        try:
            template = read_json(t)
            tabs = read_json(internal_dir / t.name)
        except FileNotFoundError:
            print(f'Ignoring {t.stem} wthout internal tabs')
        else:
            tabs_boxes = tabs["patcher"]["boxes"]
            for box in tabs_boxes:
                template["patcher"]["boxes"].append(box)
                write_json(template_dir / t.name, template)
Exemplo n.º 9
0
def main():
    """
    Creates a dict for the Max Documentation system.
    This dict contains is essential for maxObjectLauncher/Refpages to pull the right info.
    """

    object_info = read_yaml(object_relationships_path)
    interfaces_dir.mkdir(exist_ok=True)
    obj_lookup = interfaces_dir / "FrameLib-obj-qlookup.json"

    worker = qParseAndBuild()

    refpages = [x for x in refpages_dir.rglob("fl.*.xml")]

    for ref in refpages:
        worker.extract_from_refpage(ref)
        worker.extract_keywords(object_info)
        worker.extract_seealso(object_info)
        worker.build_json_file()

    write_json(obj_lookup, worker.d_master_dict)
Exemplo n.º 10
0
def main():

    mismatch = open(help_dir / "mismatch_template.maxhelp", "r").read()
    trigger_ins = open(help_dir / "trigger_ins_template.maxhelp", "r").read()
    in_mode = open(help_dir / "input_mode_template.maxhelp").read()
    templates_dir = help_dir / "templates"
    templates = [x for x in templates_dir.rglob("fl.*.maxhelp")]
    max_objects_dir = package_root / "FrameLib_Max_Objects"
    max_objects = [x for x in max_objects_dir.rglob("fl.*.cpp")]

    binary = [x.stem for x in max_objects if x.parent.stem == "Binary"]
    ternary = [x.stem for x in max_objects if x.parent.stem == "Ternary"]
    complex_binary = [
        x.stem for x in max_objects if x.parent.stem == "Complex_Binary"
    ]
    generators = [x.stem for x in max_objects if x.parent.stem == "Generators"]

    # Now insert the necessary tabs
    for path in templates:
        template = read_json(path)
        if path.stem in ternary:
            append_tabs(mismatch, path.stem, template)

        if path.stem in binary:
            append_tabs(trigger_ins, path.stem, template)
            append_tabs(mismatch, path.stem, template)

        if path.stem in complex_binary:
            append_tabs(trigger_ins, path.stem, template)
            append_tabs(mismatch, path.stem, template)

        if path.stem in generators:
            append_tabs(in_mode, path.stem, template)

        write_json(path, template)

    # Now collect up and move all the templates to the dist
    # We could do this in the previous loop, but I think is clearer
    dest = current_version / "FrameLib" / "help"
    copy_tree(str(templates_dir), str(dest), update=1)
Exemplo n.º 11
0
def main(root):
    """
    Creates tutorial information and stores it in a dictionary format. 
    This information is displayed to the user in a umenu.

    Args:
        arg1: passes the root of the python files from the master script. Creates relative directories.
    """

    # Directory stuff #
    dir_path = root
    dir_path = os.path.join(cd_up(root, 2), "Current Test Version", "FrameLib")
    ref_dir = os.path.join(dir_path, "docs", "tutorials", "FrameLib-tut",
                           "00_fl_index.maxtut.xml")
    obj_lookup = os.path.join(dir_path, "interfaces",
                              "FrameLib-obj-tlookup.json")

    worker = tParseAndBuild()

    worker.extract_from_refpage(ref_dir)

    write_json(obj_lookup, worker.d_skeleton)
Exemplo n.º 12
0
def main(root):
    """
    Creates a dict for the Max Documentation system.
    This dict contains more detailed information displayed in real-time when hovering over a certain tutorial in the umenu.

    Args:
        arg1: passes the root of the python files from the master script. Creates relative directories.
    """

    bad_entries = [".DS_Store", "_c74_ref_modules.xml"]

    dir_path = root
    dir_path = os.path.join(cd_up(root, 2), "Current Test Version", "FrameLib")
    ref_dir = os.path.join(dir_path, "docs", "refpages")
    obj_lookup = os.path.join(dir_path, "interfaces",
                              "FrameLib-obj-jlookup.json")

    worker = jParseAndBuild()  # make an instance of the class

    # Make a list of file names and remove bad entries
    refpages = os.listdir(ref_dir)
    for badness in bad_entries:
        if badness in refpages:
            refpages.remove(badness)

    # Check if any files were found and do your thing
    if refpages:
        for filename in refpages:
            current_category = filename
            source_file_name = os.path.join(ref_dir, filename)

            for filename in os.listdir(source_file_name):
                if filename != ".DS_Store":
                    source_file = os.path.join(ref_dir, current_category,
                                               filename)
                    worker.extract_from_refpage(source_file)

        write_json(obj_lookup, worker.j_master_dict)
Exemplo n.º 13
0
def main(root):
    """
    A simplified version of the qlookup used to display information about specific objects when hovered over in the umenu.
    The qlookup might replace this entire script.

    Args:
        arg1: passes the root of the python files from the master script. Creates relative directories.
    """
    bad_entries = [".DS_Store", "_c74_ref_modules.xml"]
    # Directory stuff #
    dir_path = root
    dir_path = os.path.join(cd_up(root, 2), "Current Test Version", "FrameLib")
    ref_dir = os.path.join(dir_path, "docs", "refpages")
    obj_lookup = os.path.join(dir_path, "interfaces",
                              "FrameLib-obj-dlookup.json")

    worker = dParseAndBuild()

    # Make a list of file names and remove bad entries
    refpages = remove_ds(os.listdir(ref_dir))
    for badness in bad_entries:
        if badness in refpages:
            refpages.remove(badness)

    # Check if any files were found and do your thing
    if refpages:
        for filename in refpages:
            current_category = filename
            source_file_name = os.path.join(ref_dir, filename)

            for filename in os.listdir(source_file_name):
                source_file = os.path.join(ref_dir, current_category, filename)
                worker.extract_from_refpage(source_file)

        write_json(obj_lookup, worker.d_master_dict)
    else:
        print("Found no XML files to parse. Moving on to next stage.")