예제 #1
0
    def show(self):
        endStates = [
            "DONE",
            "ABORTED",
            "SCHEDULER_ERROR",
            "COMPILER_ERROR",
            "WORKSTATION_ERROR",
            "PERMISSION_DENIED",
            "ERROR",
        ]

        print
        print "Getting Job results..."
        print "================================================"
        print
        Tables.showJobTable(self.pySchedUI, stateList=endStates)
        jobId = CommonUI.getTextInput("Please enter the job id")
        path = CommonUI.getPathInput(
            "Please select a path where the results should be stored")

        if not FileUtils.pathExists(path):
            print "Path {} does not exists! Would you like to create it? (y/n)".format(
                path)
            if CommonUI.showYesNo("> "):
                FileUtils.createDirectory(path)
            else:
                return

        if self.pySchedUI.getResultsByJobId([jobId], path):
            print "Results stored in {}".format(path)
        else:
            print "Could not retrieve the results of job {}".format(jobId)
def define_template_tables(file_path: Path, sheet_name: str, \
            tmpl_title: str, tmpl_offset='A1', tmpl_columns=2, \
            struc_title='Template Structures', struc_offset='D1', struc_columns=5):
    '''Create Table definitions for the template table and
    it's companion structure list required to build a structure template.
    '''
    #TODO define_template_tables is getting messy probably should get rid of it
    # values for all tables
    tmp_index = 'Attribute'
    str_index = 'ID'
    # Rows is not yet implemented not using
    template_table = tb.Table(file_path,
                              sheet_name,
                              tmpl_title,
                              tmp_index,
                              tmpl_offset,
                              columns=tmpl_columns)
    structures_dfn = define_structure_attributes()
    structures_table = tb.Table(file_path,
                                sheet_name,
                                struc_title,
                                str_index,
                                struc_offset,
                                struc_columns,
                                variables=structures_dfn)

    return (template_table, structures_table)
예제 #3
0
    def show(self):
        endStates = [
             "DONE",
             "ABORTED",
             "SCHEDULER_ERROR",
             "COMPILER_ERROR",
             "WORKSTATION_ERROR",
             "PERMISSION_DENIED",
             "ERROR",
        ]

        print
        print "Getting Job results..."
        print "================================================"
        print
        Tables.showJobTable(self.pySchedUI, stateList=endStates)
        jobId = CommonUI.getTextInput("Please enter the job id")
        path = CommonUI.getPathInput("Please select a path where the results should be stored")

        if not FileUtils.pathExists(path):
            print "Path {} does not exists! Would you like to create it? (y/n)".format(path)
            if CommonUI.showYesNo("> "):
                FileUtils.createDirectory(path)
            else:
                return

        if self.pySchedUI.getResultsByJobId([jobId], path):
            print "Results stored in {}".format(path)
        else:
            print "Could not retrieve the results of job {}".format(jobId)
예제 #4
0
 def show(self):
     print
     print "Pausing Job..."
     print "================================================"
     print
     Tables.showJobTable(self.pySchedUI, stateList=["PAUSED"])
     jobId = CommonUI.getTextInput("")
     self.pySchedUI.resumeJobs([jobId])
예제 #5
0
def callback_inline(call):
    if call.data == "mainmenu":
        keyboard_main = types.InlineKeyboardMarkup(row_width=2)

        # Buttons set
        tables_button = types.InlineKeyboardButton(text="Tables",
                                                   callback_data="tables")
        calc_button = types.InlineKeyboardButton(text="Calculations",
                                                 callback_data="calculations")
        generator_button = types.InlineKeyboardButton(
            text="Noize Generator", callback_data="generator")
        keyboard_main.add(tables_button, calc_button, generator_button)
        bot.edit_message_text(chat_id=call.message.chat.id,
                              message_id=call.message.message_id,
                              text="Choose your destiny...",
                              reply_markup=keyboard_main)
        call_log(call, "Main menu")

    elif call.data == "generator":
        Generator.call_handler(call, bot)
        call_log(call, "Generator")

    elif call.data == "tables":
        keyboard = types.InlineKeyboardMarkup()

        # Buttons set
        external_button = types.InlineKeyboardButton(text="External wall",
                                                     callback_data="external")
        partitions_button = types.InlineKeyboardButton(
            text="Wall partitions", callback_data="partitions")
        floor_button = types.InlineKeyboardButton(text="Floor",
                                                  callback_data="floor")
        ceiling_button = types.InlineKeyboardButton(text="Сeiling",
                                                    callback_data="ceiling")
        windows_button = types.InlineKeyboardButton(text="Windows",
                                                    callback_data="windows")
        doors_button = types.InlineKeyboardButton(text="Doors",
                                                  callback_data="doors")
        main_button = types.InlineKeyboardButton(
            text="\U0001F3E0 To main menu", callback_data="mainmenu")
        keyboard.add(external_button, partitions_button, floor_button,
                     ceiling_button, windows_button, doors_button, main_button)

        bot.edit_message_text(chat_id=call.message.chat.id,
                              message_id=call.message.message_id,
                              text="There are such tables:",
                              reply_markup=keyboard)

        call_log(call, "Tables")

    elif call.data == "calculations":
        Calculations.call_handler(call, bot)
        call_log(call, "Calculations")

    ##################################### ADDITIONAL LEVEL: Tables ################################################
    elif call.data == "external" or call.data == "partitions" or call.data == "floor" or call.data == "ceiling" or call.data == "windows" or call.data == "doors":
        Tables.parse(call, bot)
        call_log(call, "Tables:{0}".format(call.data))
예제 #6
0
    def show(self):
        print
        print "Pausing Job..."
        print "================================================"
        print

        Tables.showJobTable(self.pySchedUI, stateList=["RUNNING"])
        jobId = CommonUI.getTextInput("Please enter the job id")
        self.pySchedUI.pauseJobs([jobId])
예제 #7
0
파일: SQLSim.py 프로젝트: Zer0xPoint/LiteDB
def insert_into_table(command):
    # if not Database.use_new_database_name.has_been_called:
    #     print("No database selected")
    #     get_command("")
    # else:
    #     Tables.insert_table_info(command)
    if is_use_database():
        Tables.insert_table_info(command)
    else:
        get_command("")
예제 #8
0
    def show(self):
        print
        print "Getting job informations..."
        print "================================================"
        archived = CommonUI.showYesNo("Show all jobs (including Archived) (y/n)? ")
        adminMode = False
        if self.pySchedUI.isAdmin:
            adminMode = CommonUI.showYesNo("(Administrator) Show Jobs of all Users (y/n)? ")

        Tables.showJobTable(self.pySchedUI, showArchived=archived, showAllUser=adminMode)
예제 #9
0
 def show(self):
     print
     print "Aborting Job..."
     print "================================================"
     print
     Tables.showJobTable(self.pySchedUI)
     print
     jobId = CommonUI.getTextInput("Please enter the job id")
     if self.pySchedUI.abortJobs([jobId]):
         print "Job {} aborted.".format(jobId)
     else:
         print "Could not abort the job."
예제 #10
0
    def show(self):
        print
        print "Getting job log file..."
        print "================================================"

        showAll = False
        if self.pySchedUI.isAdmin:
            showAll = CommonUI.showYesNo(
                "(Administrator) Show Jobs of all Users (y/n)? ")

        Tables.showJobTable(self.pySchedUI, showAllUser=showAll)
        jobId = CommonUI.getTextInput("Please enter the job id")
        print self.pySchedUI.getJobLog(jobId)
def build_template_data(template_table: tb.Table):
    '''Create a dictionary of template data from template_table and the default template_attributes.
    '''
    template_attributes = define_template_attributes()
    template_data = template_table.read_table()
    # Transpose table so that each attribute becomes a column
    template_data = template_data.T.reset_index(drop=True)
    #TODO Select and validate attributes in this table
    template_data = tb.insert_defaults(template_data, template_attributes)
    template_data = tb.insert_missing_variables(template_data,
                                                template_attributes)
    #Only one template definition per table, so select the first row from the DataFrame
    return dict(template_data.iloc[0, :])
예제 #12
0
 def show(self):
     '''
     @summary: Sends a update command to the server.
     @result: 
     '''
     print
     print "Restart Workstation..."
     print "================================================"
     Tables.showWSTable(self.pySchedUI)
     print "Which workstation (name or 'server') should be restarted?"
     workstation = CommonUI.getTextInput("", "", "Please type the name of the workstation or 'server' to restart the server")
     if not workstation == "":        	
     	self.pySchedUI.restart([workstation])
예제 #13
0
 def predict_length(self,vector,course_list):
     tb = Tables()
     tb.read_data("grade2.csv", "student.csv")
     vector=self.courses_to_numeric(vector,True)
     lst = np.empty(tb.studyTable.shape[1])
     lst[:] = np.nan
     for i in range(len(course_list)):
         if course_list[i] in tb.courseList:
             lst[tb.courseList.index(course_list[i])] = vector[i]
     lst = lst.reshape(1,-1)
     lst = tb.study_imp.transform(lst)
     result = self.study_length.predict(lst)
     return np.round(result[0])
예제 #14
0
 def show(self):
     print
     print "Deleting Job..."
     print "================================================"
     print
     Tables.showJobTable(self.pySchedUI)
     print "Please enter the jobId"
     jobId = CommonUI.getTextInput("")
     if CommonUI.showYesNo("Are you sure that you want to delete job {}?".format(jobId)):
         if self.pySchedUI.deleteJobs([jobId]):
             print "Job deleted."
         else:
             print "Could not delete Job!"
예제 #15
0
def build_structures_lookup(structures_file_path: Path):
    structure_attributes = define_structure_attributes()
    structures_table_list = define_structure_tables(structures_file_path, structure_attributes)
    structures_lookup = tb.merge_tables(structures_file_path, \
                                        structures_table_list, \
                                        structure_attributes)
    structure_attributes = tb.process_defaults(structures_lookup, \
                                               structure_attributes)
    structures_lookup = tb.insert_defaults(structures_lookup, \
                                           structure_attributes)
    structures_lookup = tb.insert_missing_variables(structures_lookup, \
                                                    structure_attributes)
    return structures_lookup
예제 #16
0
    def show(self):
        print
        print "Getting job informations..."
        print "================================================"
        archived = CommonUI.showYesNo(
            "Show all jobs (including Archived) (y/n)? ")
        adminMode = False
        if self.pySchedUI.isAdmin:
            adminMode = CommonUI.showYesNo(
                "(Administrator) Show Jobs of all Users (y/n)? ")

        Tables.showJobTable(self.pySchedUI,
                            showArchived=archived,
                            showAllUser=adminMode)
예제 #17
0
 def predict_dropout(self,vector,course_list):
     tb = Tables()
     tb.read_data("grade2.csv", "student.csv")
     vector=self.courses_to_numeric(vector,True)
     lst = np.empty(tb.dropoutTable.shape[1])
     lst[:] = np.nan
     for i in range(len(course_list)):
         if course_list[i] in tb.courseList:
             lst[tb.courseList.index(course_list[i])] = vector[i]
     lst = lst.reshape(1,-1)
     lst = tb.dropout_imp.transform(lst)
     result = self.dropout.predict(lst)
     if result[0] == 1: return True
     else:   return False
예제 #18
0
 def show(self):
     print
     print "Deleting Job..."
     print "================================================"
     print
     Tables.showJobTable(self.pySchedUI)
     print "Please enter the jobId"
     jobId = CommonUI.getTextInput("")
     if CommonUI.showYesNo(
             "Are you sure that you want to delete job {}?".format(jobId)):
         if self.pySchedUI.deleteJobs([jobId]):
             print "Job deleted."
         else:
             print "Could not delete Job!"
예제 #19
0
    def predict_gpa(self,vector,course_list):
        tb = Tables()
        tb.read_data("grade2.csv", "student.csv")
        vector=self.courses_to_numeric(vector,True)
        lst = np.empty(tb.graduationTable.shape[1])
        lst[:] = np.nan
        for i in range(len(course_list)):
            if course_list[i] in tb.courseList:
                lst[tb.courseList.index(course_list[i])] = vector[i]
        lst = lst.reshape(1,-1)
        lst = tb.graduation_imp.transform(lst)

        result = self.gpa.predict(lst)
        if result<0: result=result*-1
        return "%.2f"%result
예제 #20
0
def refreshBars():
    setMainTable(Tables.Tables(getMainWindow()).Table)
    getMainWindow().SpecialTools = SpecialTools.SpecialTools(getMainWindow())
    if uni.tableType in ["2", "6", "8", "9"]:
        from Bars import PlayerBar

        getMainWindow().PlayerBar = PlayerBar.PlayerBar(getMainWindow())
        getMainWindow().addToolBar(Mt.TopToolBarArea,
                                   getMainWindow().PlayerBar)
    getMainWindow().Menu.refreshForTableType()
예제 #21
0
    def show(self):
        '''
        @summary: Shows the add Job dialog with template supoort
        @result:
        '''
        inp = UIDict()
        print
        print "Adding a new job..."
        print "================================================"
        print
        print "Please enter the path to the PySched-Config file or nothing if you want to create a new template:"
        temp = CommonUI.getPathInput("")
        if temp != "":
            inp.addInfo("Template-File", "template", os.path.normpath(temp))
        else: 
            inp = self.createTemplate(inp)

        if CommonUI.showValidatingInput(inp):
            if self.pySchedUI.addJob(inp.getInfos()):
                Tables.showJobTable(self.pySchedUI)
예제 #22
0
    def create_new_model(self, grade_file, student_file, predict_function, algorithm_name, parameters, course_name, semester):

        tb = Tables()
        tb.read_data(grade_file, student_file)
        
        if predict_function=='gpa':
             if algorithm_name=='linear':
                 return ML.linear_regression(tb.graduationTable, tb.graduationLabel, parameters)
            
        elif predict_function=='dropout':            
            if algorithm_name=='logistic':
                return ML.logistic_regression(tb.dropoutTable, tb.dropoutLabel, parameters)
            elif algorithm_name=='svm':
                return ML.svm(tb.dropoutTable, tb.dropoutLabel, parameters)
            elif algorithm_name=='mlp':
                return ML.mlp(tb.dropoutTable, tb.dropoutLabel, parameters)

        elif predict_function=='course_grade':
            ##get required table without target label
            c = [0,0.5,1,1.5,2,2.5,3,3.5,4]
            x = tb.courseTable.copy()
            class_index = tb.courseList.index(course_name.lower())
            y = x[:,class_index] ## class label
            x = np.delete(x,class_index,1) ## remove class column from input data
            ## change y label with class value (eg. if y[0] = 3.5 then it become 7th class)
            for i in range(y.size):
                    index = c.index(y[i])
                    y[i] = index
            
            if algorithm_name=='logistic':
                return ML.logistic_regression(x,y,parameters)
            elif algorithm_name=='svm':
                return ML.svm(x,y,parameters)
            elif algorithm_name=='mlp':
                return ML.mlp(x,y,parameters)

        elif predict_function=='study_length':
            if algorithm_name=='linear':
                return ML.linear_regression(tb.studyTable, tb.studyLabel, parameters)
            elif algorithm_name=='mlp_regressor':
                return ML.mlp_regressor(tb.studyTable, tb.studyLabel, parameters)
예제 #23
0
    def show(self):
        newInp = UIDict()
        updateableStates = ["RUNNING", "PAUSED"]
        print
        print "Updating Job data..."
        print "================================================"
        print
        Tables.showJobTable(self.pySchedUI, stateList=updateableStates)
        jobId = CommonUI.getTextInput("Please enter the job id")

        print
        print "Please specify which files should be transferred to the server."
        print "Enter nothing to to move on, '?' for help"
        paths = []
        tmp = CommonUI.getPathInput("", "", help=PATH_HELP)
        while tmp != "":
            paths.append(tmp)
            newInp.addInfo("Copy Paths", "paths", paths)
            tmp = CommonUI.getTextInput("", "", help=PATH_HELP)

        self.pySchedUI.updateJobData(jobId, paths)
예제 #24
0
 def loadSinks(self):
     self.sink_list.add(Info.init())
     self.sink_list.add(Buttons.init())
     self.sink_list.add(Menus.init())
     self.sink_list.add(Images.init())
     self.sink_list.add(Layouts.init())
     self.sink_list.add(Lists.init())
     self.sink_list.add(Popups.init())
     self.sink_list.add(Tables.init())
     self.sink_list.add(Text.init())
     self.sink_list.add(Trees.init())
     self.sink_list.add(Frames.init())
     self.sink_list.add(Tabs.init())
예제 #25
0
    def predict_course_grade(self,vector,course_list,pcourse_name):
        tb = Tables()
        tb.read_data("grade2.csv", "student.csv")
        if (pcourse_name not in tb.courseList):
            return (pcourse_name+" is not available anymore")

        model=None
        q_course = "SELECT path \
                    FROM models \
                    WHERE gradeFile='%s' AND studentFile='%s' AND function='%s' AND course='%s' AND isDefault='%d'" % ("grade2.csv","student.csv","course_grade",pcourse_name,1)
        
        db = MySQLdb.connect("localhost",mysql_user,password,"gpa_db_4" )
        cursor = db.cursor()
        try:
            cursor.execute(q_course)
            path = cursor.fetchone()
            model = joblib.load(path[0])
        except IOError as e:
            print("Model file doesn't exist.")
 
        db.close()

        if model==None:
            return ("There is no available model file for" + pcourse_name)
        
        vector=self.courses_to_numeric(vector,True) ##convert course grades to numeric ones(eg. AA=4, CB = 2.5)
        lst = np.empty(tb.courseTable.shape[1])
        lst[:] = np.nan
        for i in range(len(course_list)):
            if course_list[i] in tb.courseList:
                lst[tb.courseList.index(course_list[i])] = vector[i]
        lst = lst.reshape(1,-1)
        lst = tb.course_imp.transform(lst)

        class_index = tb.courseList.index(pcourse_name)
        lst = np.delete(lst,class_index,1) ## remove class column from input data
        result = model.predict(lst)
        result = self.courses_to_numeric(result,False)
        return result[0]
예제 #26
0
 def loadSinks(self):
     self.sink_list.addSink(Info.init())
     self.sink_list.addSink(Buttons.init())
     self.sink_list.addSink(Menus.init())
     self.sink_list.addSink(Images.init())
     self.sink_list.addSink(Layouts.init())
     self.sink_list.addSink(Lists.init())
     self.sink_list.addSink(Popups.init())
     self.sink_list.addSink(Tables.init())
     self.sink_list.addSink(Text.init())
     self.sink_list.addSink(Trees.init())
     self.sink_list.addSink(Frames.init())
     self.sink_list.addSink(Tabs.init())
예제 #27
0
def import_template_list(base_path: Path):
    '''Import the list of active templates.
    '''
    template_list_path = base_path / TEMPLATE_LIST_FILE
    variables = define_template_list()
    template_list_table = tb.Table(template_list_path,
                                   'templates',
                                   variables=variables)
    template_list = template_list_table.read_table()
    active_templates = template_list[template_list.in_use == 'True']
    active_templates['name'] = active_templates['title']
    active_templates.set_index('name', inplace=True)
    active_templates['columns'] = active_templates['columns'].astype('int64')
    return active_templates
예제 #28
0
    def show(self):
        newInp = UIDict()
        updateableStates = [
            "RUNNING",
            "PAUSED"
        ]
        print
        print "Updating Job data..."
        print "================================================"
        print        
        Tables.showJobTable(self.pySchedUI, stateList=updateableStates)
        jobId = CommonUI.getTextInput("Please enter the job id")

        print
        print "Please specify which files should be transferred to the server."
        print "Enter nothing to to move on, '?' for help"
        paths = []
        tmp = CommonUI.getPathInput("", "", help=PATH_HELP)
        while tmp != "":
            paths.append(tmp)
            newInp.addInfo("Copy Paths", "paths", paths)
            tmp = CommonUI.getTextInput("", "", help=PATH_HELP)

        self.pySchedUI.updateJobData(jobId, paths)
예제 #29
0
def Output():
    db.create_all()
    if request.method == 'POST':
        userdata = Tables(request.form["Username"], request.form["psw"])
        users = Tables.query.filter_by(
            Username=request.form["Username"]).first()
        if users is not None:
            message = "User name is already existing.Register with new user name"
            return render_template("Registration.html", message1=message)
        db.session.add(userdata)
        db.session.commit()
        message = "Registartion is successful"
        return render_template("Registration.html", message=message)
    #     result = request.form
    #     print(result['Username'])
    else:
        return render_template("Registration.html")
예제 #30
0
def define_structure_tables(file_path: Path, structures: list):
    '''Create a list of Type Table values that define all of the structure tables required to build a complete structures data lookup.
    '''
    # Define the tables
    tables_def = [
         ['Structure Dictionary Assignment', 'Structure Dictionary', 6],
         ['Volume Types', 'Volume Type', 3],
         ['Structure colors', 'Structure Colors', 6],
         ['CT Search', 'HU Values', 3],
         ['DVH Lines', 'DVH',4]]
    # values for all tables
    offset = 'A1'
    index = 'Structure'
    # Rows is not yet implemented not using
    table_list = [tb.Table(file_path, sheet_name=sheet_name, title=title, \
                        index=index, offset=offset, columns=columns, \
                        variables=structures)
                  for (sheet_name, title, columns) in tables_def]
    return  table_list
예제 #31
0
def define_structure_attributes():
    '''Create a dictionary with Type Variable values that define all of the structure attributes.
    The attributes:
        EUDAlpha
        TCPAlpha
        TCPBeta and
        TCPGamma
        Are supplied but not used,
        the add_structure method forces them to be: 'xsi:nil="true"'
    '''
    var_type = 'Structure'
    is_string = lambda x: isinstance(x, str)
    id_check = lambda x: is_string(x) and len(x) < 13
    # TODO Merge with define_structure_table from update_template_list
    # TODO more attribute checks should be added to the attribute definitions

    structure_def = [('StructureID', id_check, None), \
                     ('Name', is_string, ''), \
                     ('StructureCategory', is_string, ''), \
                     ('VolumeID', None, ''), \
                     ('VolumeType', is_string, ''), \
                     ('VolumeCode', is_string, ''), \
                     ('VolumeCodeTable', is_string, ''), \
                     ('Label', is_string, None), \
                     ('StructureCode', None, None), \
                     ('CodeScheme', is_string, None), \
                     ('CodeSchemeVersion', None, None), \
                     ('TypeIndex', None, 2), \
                     ('ColorAndStyle', is_string, 'Blue'), \
                     ('SearchCTLow', None, 'Missing'), \
                     ('SearchCTHigh', None, 'Missing'), \
                     ('DVHLineColor', None, -16777216), \
                     ('DVHLineWidth', None, 1), \
                     ('DVHLineStyle', None, 0), \
                     ('EUDAlpha', None, 'xsi:nil="true"'), \
                     ('TCPAlpha', None, 'xsi:nil="true"'), \
                     ('TCPBeta', None, 'xsi:nil="true"'), \
                     ('TCPGamma', None, 'xsi:nil="true"')]
    return {
        ID: tb.Variable(ID, var_type, validate=val, default=dflt)
        for (ID, val, dflt) in structure_def
    }
예제 #32
0
 def loadSinks(self):
     #self.sink_list.addSink(DataTree.init())
     #self.sink_list.addSink(RecipeSystemIFACE.init())
     self.sink_list.addSink(ADViewerIFACE.init())
     self.sink_list.addSink(RecipeViewer.init())
     self.sink_list.addSink(FITSStoreFACE.init())
     self.sink_list.addSink(DisplayIFACE.init())
     self.sink_list.addSink(Info.init())
     if False:
         self.sink_list.addSink(Buttons.init())
         self.sink_list.addSink(Menus.init())
         self.sink_list.addSink(Images.init())
         self.sink_list.addSink(Layouts.init())
         self.sink_list.addSink(Lists.init())
         self.sink_list.addSink(Popups.init())
         self.sink_list.addSink(Tables.init())
         self.sink_list.addSink(Text.init())
     if False: #preserving originaly order
         self.sink_list.addSink(Frames.init())
         self.sink_list.addSink(Tabs.init())
def define_template_attributes():
    '''Create a dictionary with Type Variable values that define all of the template attributes.
    '''
    var_type = 'Template'
    is_string = lambda x: isinstance(x, str)
    id_check = lambda x: is_string(x) and len(x) < 13
    #TODO more attribute checks should be added to the attribute definitions

    template_def = [('Version', None, 1.0), \
                     ('Type', is_string, 'Structure'), \
                     ('ID', id_check, None), \
                     ('Diagnosis', is_string, ''), \
                     ('TreatmentSite', is_string, '.All'), \
                     ('AssignedUsersID', is_string, 'gsal;'), \
                     ('Description', is_string, ''), \
                     ('ApprovalStatus', is_string, 'Unapproved'), \
                     ('ApprovalHistory', is_string, ''), \
                     ('LastModified', is_string, '')]
    return {
        ID: tb.Variable(ID, var_type, validate=val, default=dflt)
        for (ID, val, dflt) in template_def
    }
def add_preview(template, template_data):
    '''Add a the preview element to the template tree using the data in template_data.
    '''
    type = tb.get_value(template_data, 'Type')
    site = tb.get_value(template_data, 'TreatmentSite')
    diagnosis = tb.get_value(template_data, 'Diagnosis')
    description = tb.get_value(template_data, 'Description')
    users = tb.get_value(template_data, 'Author')
    status = tb.get_value(template_data, 'ApprovalStatus')
    history = tb.get_value(template_data, 'ApprovalHistory')
    modified = tb.get_value(template_data, 'LastModified')

    preview = ET.SubElement(template, 'Preview ', \
        attrib={'ID':template_data['TemplateID'], \
                'Type':type, \
                'TreatmentSite':site, \
                'Diagnosis':diagnosis, \
                'Description':description, \
                'AssignedUsers':users, \
                'ApprovalStatus':status, \
                'ApprovalHistory':history, \
                'LastModified':modified})

    return preview
예제 #35
0
def define_template_list():
    '''Create a dictionary with Type Variable values that define the template list columns.
    '''
    var_type = 'Template_List'

    def is_int(x):
        return isinstance(x, int)

    def is_string(x):
        return isinstance(x, str)

    # TODO more attribute checks should be added to the attribute definitions
    # TODO make attribute checks more tolerant ie. if type conversion works

    template_def = [('workbook_name', is_string, 'Structure Templates.xlsx'), \
                     ('sheet_name', is_string, None), \
                     ('title', is_string, None), \
                     ('columns', is_int, 3), \
                     ('output_file_name', is_string, 'template.xml'), \
                     ('in_use', None, True)]
    return {
        ID: tb.Variable(ID, var_type, validate=val, default=dflt)
        for (ID, val, dflt) in template_def
    }
예제 #36
0
 def __init__(self, value):
     self.value  = value
     self.tables= Tables(value)
     self.left   = None
     self.right  = None
     self.height = 0   #altura 
예제 #37
0
def add_structure(template, structure_data, version):
    '''Add a new structure to the template tree using the data in structure_data.
    The order of the elements is important
    The attributes:
        EUDAlpha
        TCPAlpha
        TCPBeta and
        TCPGamma
    Are forced to be: 'xsi:nil="true"'
    '''
    name = tb.get_value(structure_data, 'Name')
    new_structure = ET.SubElement(template, 'Structure', \
        attrib={'ID':structure_data['ID'], 'Name':name})
    structure_id = ET.SubElement(new_structure, 'Identification')

    volume_id = ET.SubElement(structure_id, 'VolumeID')
    volume_id.text = tb.get_value(structure_data, 'VolumeID')
    volume_code = ET.SubElement(structure_id, 'VolumeCode')
    volume_code.text = tb.get_value(structure_data, 'VolumeCode')
    volume_type = ET.SubElement(structure_id, 'VolumeType')
    volume_type.text = tb.get_value(structure_data, 'VolumeType')
    volume_code_table = ET.SubElement(structure_id, 'VolumeCodeTable')
    volume_code_table.text = tb.get_value(structure_data, 'VolumeCodeTable')

    if version == 13.6:
        code = tb.get_value(structure_data, 'StructureCode')
        scheme = tb.get_value(structure_data, 'CodeScheme')
        version = tb.get_value(structure_data, 'CodeSchemeVersion')
        structure_code = ET.SubElement(structure_id, 'StructureCode', \
            attrib={'Code':code, 'CodeScheme':scheme, 'CodeSchemeVersion':version})

    type_index = ET.SubElement(new_structure, 'TypeIndex')
    type_index.text = tb.get_value(structure_data, 'TypeIndex')

    color_and_style = ET.SubElement(new_structure, 'ColorAndStyle', )
    color_and_style.text = tb.get_value(structure_data, 'ColorAndStyle')

    # if SearchCT values are not given set a nil attribute
    SearchCTLow_value = tb.get_value(structure_data, 'SearchCTLow')
    if SearchCTLow_value == 'Missing':
        SearchCTLow = ET.SubElement(new_structure, 'SearchCTLow', attrib={'xsi:nil':"true"})
    else:
        SearchCTLow = ET.SubElement(new_structure, 'SearchCTLow')
        SearchCTLow.text = SearchCTLow_value

    SearchCTHigh_value = tb.get_value(structure_data, 'SearchCTHigh')
    if SearchCTHigh_value == 'Missing':
        SearchCTHigh = ET.SubElement(new_structure, 'SearchCTHigh', attrib={'xsi:nil':"true"})
    else:
        SearchCTHigh = ET.SubElement(new_structure, 'SearchCTHigh')
        SearchCTHigh.text = SearchCTHigh_value

    DVHLineStyle = ET.SubElement(new_structure, 'DVHLineStyle', )
    DVHLineStyle.text = tb.get_value(structure_data, 'DVHLineStyle')
    DVHLineColor = ET.SubElement(new_structure, 'DVHLineColor', )
    DVHLineColor.text = tb.get_value(structure_data, 'DVHLineColor')
    DVHLineWidth = ET.SubElement(new_structure, 'DVHLineWidth', )
    DVHLineWidth.text = tb.get_value(structure_data, 'DVHLineWidth')

    #Currently not used so always set as Nil
    EUDAlpha = ET.SubElement(new_structure, 'EUDAlpha', attrib={'xsi:nil':"true"})
    TCPAlpha = ET.SubElement(new_structure, 'TCPAlpha', attrib={'xsi:nil':"true"})
    TCPBeta = ET.SubElement(new_structure, 'TCPBeta', attrib={'xsi:nil':"true"})
    TCPGamma = ET.SubElement(new_structure, 'TCPGamma', attrib={'xsi:nil':"true"})

    return new_structure
예제 #38
0
 def __init__(self, data):
     self.magic = Tables.magic_item_table()
     die_table = data.split(";")
     self.die = die_table[0]
     self.table = die_table[1]
예제 #39
0
__author__ = 'Kris'
import Tables
from resources.data import *

TT = Tables.individual_treasure_table()
MiT = Tables.magic_item_table()
HT1 = Tables.hoard_treasures(Hoard_Teir_1)
HT2 = Tables.hoard_treasures(Hoard_Teir_2)
HT3 = Tables.hoard_treasures(Hoard_Teir_3)
HT4 = Tables.hoard_treasures(Hoard_Teir_4)
#for i in range(10):
#    print HT1.generate_treasure()
#    print
#for i in range(10):
#    print HT2.generate_treasure()
#    print
#for i in range(10):
#    print HT3.generate_treasure()
#    print
for i in range(10):
    print HT4.generate_treasure()
    print
#for i in range(1, 100):
#    print TT.generate_treasure(2)
#for i in range(1,10):
#    print MiT.generate_treasure("A")
#    print MiT.generate_treasure("B")
#    print MiT.generate_treasure("C")
#    print MiT.generate_treasure("D")
#    print MiT.generate_treasure("E")
#    print MiT.generate_treasure("F")
예제 #40
0
 def show(self):
     print
     print "Getting Workstation informations..."
     print "================================================"
     Tables.showWSTable(self.pySchedUI)