示例#1
0
def basic_cmd(cb, from_cmd):
    '''
    Basic Cmd.

    todo-2021-04.30-0723 - removal to be verified.
    of bramch to basc_cmd_grid()

    if sigs.is_grid == True self.is_Load  is also True
    main.gui needs to insure if self.is_grid == True
      that the basic_cmd_grid(from_cmd) is called directly

    '''
    try:
        c.set(from_cmd)
        operation = c.operation
        c.do_lists()
        cmd_list = c.cmds_list

        for cmd in cmd_list:
            retVal = can_do_cmd(cmd)
            '''
            retVal can be True | False | None.

            retVal can only be None for operation == g.CLR (removal)
            if retVal is False for operation = g.SET
               it can't assert the value in all grids
            elif retVal is False for operation = g.CLR
                 means trying to remove lass value in a cell   
            '''
            if retVal is False:
                sigs.fail_msg = f'basic_cmd = {cmd} failed'
                return False  # -------------------------------> early fail!
            sigs.fail_msg = ''

        for cmd in cmd_list:
            retVal = can_do_cmd(cmd)
            '''
            retVal can be True | False | None.

            retVal is True for operation == g.SET
            retVal is conditionally True for operation = g.CLR (removal(
            '''
            if retVal is True:
                cc.base_cmd(cb, cmd)

        if operation == SET:
            if not basic_cmd_removals(cb, cmd_list):
                return False  # --------------------------------> early fail!

        return True

    except Exception as e:
        logger_except.exception(e)
        sys.exit()
示例#2
0
def block_only_removals(cb):
    '''
    Block only peer removals in rcn-grid generate removals in rnc & ncr grids.

    subs: set-up in c.block_subs      e.g.  'b2n6-s4578'
    B = base of block removals           e.g   'b2n6-s'
    blk_subs:                            e.g.  ['b2n6-s4', 'b2n6-s5', 'b2n6-s7', 'b2n6-s8']

    in this example
    for b2n6-s4:       sub_list = ['r2c4-n6', 'r2n6-c4', 'n6c4-r2', 'b2n6-s4']
    will pop off last entry to:   ['r2c4-n6', 'r2n6-c4', 'n6c4-r2']
    will iterate through this list of length three doing removals if able

    :param x:  Call back to GUI in main.py
    :return:  True/False   False:  could not remove last digit in cell: Fail!
    '''
    try:
        subs = c.block_subs
        B = subs[:-4]
        blk_subs = [B + subs[-4], B + subs[-3], B + subs[-2], B + subs[-1]]
        colors.remove_small_square = colors.remove_block_only

        for blk_sub in blk_subs:
            c.set(blk_sub)
            c.do_lists()
            sub_list = c.cmds_list
            sub_list.pop()

            for sub in sub_list:
                retVal = can_do_cmd(sub)
                if retVal is False:
                    return False  # --------------------------->  Fail!
                if retVal is True:
                    cc.base_cmd(cb, sub)

        return True

    except Exception as e:
        logger_except.exception(e)
        sys.exit()
示例#3
0
def basic_cmd_grid(from_cmd):
    try:
        # todo - Add Traces.py hooks
        if sigs.is_grid:  # Only True if "self.is_Load_"  is also True
            if c.multiple_cmds_from_last_digits(from_cmd):
                multiple_cmd_list = c.multiple_cmds_list
                for rcn_cmd in multiple_cmd_list:
                    rcn_cmd = rcn_cmd.replace(SET, ADD)
                    c.set(rcn_cmd)
                    c.do_lists()
                    add_list = c.cmds_list
                    for cmd in add_list:
                        cc.base_cmd(cmd)
            else:
                c.set(from_cmd)
                c.do_lists()
                set_list = c.cmds_list
                for cmd in set_list:
                    cc.base_cmd(cmd)
            return

    except Exception as e:
        logger_except.exception(e)
        sys.exit()