MCPcopy Create free account
hub / github.com/diffgram/diffgram / new_label_file

Method new_label_file

shared/database/source_control/file.py:857–908  ·  view source on GitHub ↗
(
        session,
        name = None,
        working_dir_id = None,
        colour = None,
        project = None,
        log = None,
        existing_file = None,
        schema = None,
        member = None
    )

Source from the content-addressed store, hash-verified

855
856 @staticmethod
857 def new_label_file(
858 session,
859 name = None,
860 working_dir_id = None,
861 colour = None,
862 project = None,
863 log = None,
864 existing_file = None,
865 schema = None,
866 member = None
867 ):
868 if schema is None:
869 raise Exception("schema Required")
870
871 if member is None:
872 raise Exception("member Required")
873
874 label = Label.new(
875 session = session,
876 name = name)
877
878 if not label:
879 return None
880 if existing_file is None:
881 file = File.new(session = session,
882 file_type = "label",
883 working_dir_id = working_dir_id,
884 label_id = label.id,
885 colour = colour,
886 project_id = project.id
887 )
888 session.flush()
889
890 schema.add_label_file(
891 session = session,
892 label_file_id = file.id,
893 member_created_id = member.id)
894
895 # In the future this could handle other label caching
896 # Things beyond id, so for now just hit this?
897 project.refresh_label_dict(session)
898
899 if not file:
900 log['error']['file'] = 'Error attaching labelfile to label'
901 return None
902
903 if project.directory_default.label_file_colour_map is None:
904 project.directory_default.label_file_colour_map = {}
905
906 project.directory_default.label_file_colour_map[file.id] = file.colour
907 session.add(project)
908 return file
909
910 @staticmethod
911 def new(session,

Callers 3

Calls 4

add_label_fileMethod · 0.80
refresh_label_dictMethod · 0.80
newMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected