MCPcopy Index your code
hub / github.com/diffgram/diffgram / validate_file_list

Method validate_file_list

shared/database/source_control/file.py:599–633  ·  view source on GitHub ↗

TODO compare performance of this vs using a 'get where id matches list' method in sql alchemy Assumes that file_list is a dict of objects where the id key is available ie [{id: 1}, {id: 2}] return_modes: id, object

(
        session,
        project_id,
        file_list: list,
        return_mode: str = "id")

Source from the content-addressed store, hash-verified

597
598 @staticmethod
599 def validate_file_list(
600 session,
601 project_id,
602 file_list: list,
603 return_mode: str = "id") -> list:
604 """
605 TODO compare performance of this
606 vs using a 'get where id matches list' method in sql alchemy
607
608 Assumes that file_list is a dict of objects where the id key is available
609 ie
610 [{id: 1}, {id: 2}]
611
612 return_modes: id, object
613
614 """
615
616 trusted_file_list = []
617
618 for file_untrusted in file_list:
619
620 untrusted_file_id = file_untrusted.get('id')
621
622 file = File.get_by_id_and_project(
623 session, project_id, untrusted_file_id)
624
625 if file is None:
626 raise Forbidden(f"File id not in project {str(untrusted_file_id)}")
627
628 if return_mode == "id":
629 trusted_file_list.append(file.id)
630 elif return_mode == "object":
631 trusted_file_list.append(file)
632
633 return trusted_file_list
634
635 # copy_file file copy
636 # TODO rename this copy file ?

Callers 1

build_label_file_listFunction · 0.80

Calls 2

get_by_id_and_projectMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected