(root, comment_bool, currently_deleting_text, deletion_progress_bar, num_deleted_items_text, reddit_state, scheduled_bool)
Deletes the items according to user configurations.
    :param root: the reference to the actual tkinter GUI window
    :param comment_bool: true if deleting comments, false if deleting submissions
    :param currently_deleting_text: Describes the item that is currently being deleted.
    :param deletion_progress_bar: updates as the items are looped through
    :param num_deleted_items_text: updates as X out of Y comments are looped through
    :param reddit_state: dictionary holding reddit settings
    :param scheduled_bool: True if a scheduled run, False if triggered manually
    :return: none
Deletes the items according to user configurations.
    :param root: the reference to the actual tkinter GUI window
    :param comment_bool: true if deleting comments, false if deleting submissions
    :param currently_deleting_text: Describes the item that is currently being deleted.
    :param deletion_progress_bar: updates as the items are looped through
    :param num_deleted_items_text: updates as X out of Y comments are looped through
    :param reddit_state: dictionary holding reddit settings
    :param scheduled_bool: True if a scheduled run, False if triggered manually
    :return: none
Deletes the items according to user configurations . : param root : the reference to the actual tkinter GUI window : param comment_bool : true if deleting comments false if deleting submissions : param currently_deleting_text : Describes the item that is currently being deleted . : param deletion_progress_bar : updates as the items are looped through : param num_deleted_items_text : updates as X out of Y comments are looped through : param reddit_state : dictionary holding reddit settings : param scheduled_bool : True if a scheduled run False if triggered manually : return : none
def delete_reddit_items(root, comment_bool, currently_deleting_text, deletion_progress_bar, num_deleted_items_text, reddit_state, scheduled_bool):
    """
    Deletes the items according to user configurations.
    :param root: the reference to the actual tkinter GUI window
    :param comment_bool: true if deleting comments, false if deleting submissions
    :param currently_deleting_text: Describes the item that is currently being deleted.
    :param deletion_progress_bar: updates as the items are looped through
    :param num_deleted_items_text: updates as X out of Y comments are looped through
    :param reddit_state: dictionary holding reddit settings
    :param scheduled_bool: True if a scheduled run, False if triggered manually
    :return: none
    """
    if reddit_state['confirmation_window_open'] == 1 and not scheduled_bool:
        return

    confirmation_window = tk.Toplevel(root)
    reddit_state['confirmation_window_open'] = 1
    reddit_state.sync

    confirmation_window.protocol(
        'WM_DELETE_WINDOW', lambda: close_window(confirmation_window, reddit_state, 'confirmation_window_open'))

    frame = build_window(root, confirmation_window,
                         f"The following {'comments' if comment_bool else 'posts'} will be deleted/edited")

    if comment_bool:
        total_items = sum(
            1 for _ in reddit_state['user'].comments.new(limit=None))
        item_array = reddit_state['user'].comments.new(limit=None)
        identifying_text = 'comments'
    else:
        total_items = sum(
            1 for _ in reddit_state['user'].submissions.new(limit=None))
        item_array = reddit_state['user'].submissions.new(limit=None)
        identifying_text = 'posts'

    num_deleted_items_text.set(f'0/{str(total_items)} items processed so far')

    button_frame = tk.Frame(frame)
    button_frame.grid(row=1, column=0, sticky='w')

    def delete_items():
        close_window(confirmation_window, reddit_state,
                     'confirmation_window_open')

        count = 1

        # refetch item_array since we sent the generator all the way to the
        # end of the items when we showed which would be deleted
        if comment_bool:
            item_array = reddit_state['user'].comments.new(limit=None)
        else:
            item_array = reddit_state['user'].submissions.new(limit=None)

        for item in item_array:
            if comment_bool:
                item_string = 'Comment'
                item_snippet = helpers.format_snippet(item.body, 50)
            else:
                item_string = 'Submission'
                item_snippet = helpers.format_snippet(item.title, 50)

            time_created = arrow.get(item.created_utc)

            if time_created > reddit_state['time_to_save']:
                currently_deleting_text.set(
                    f'{item_string} `{item_snippet}` more recent than cutoff, skipping.')
            elif item.score > reddit_state['max_score']:
                currently_deleting_text.set(
                    f'{item_string} `{item_snippet}` is higher than max score, skipping.')
            elif item.gilded and reddit_state['gilded_skip']:
                currently_deleting_text.set(
                    f'{item_string} `{item_snippet}` is gilded, skipping.')
            elif reddit_state[f'whitelisted_{identifying_text}'][item.id]:
                currently_deleting_text.set(
                    f'{item_string} `{item_snippet}` is whitelisted, skipping.`'
                )
            else:
                # Need the try/except here as it will crash on
                #  link submissions otherwise
                try:
                    if reddit_state['multi_edit']:
                        times = random.randint(5, 10)

                        for i in range(0, times):
                            allchar = string.ascii_letters + string.punctuation + string.digits
                            gibberish = "".join(random.choice(allchar)
                                                for x in range(random.randint(50, 200)))

                            item.edit(gibberish)
                    else:
                        item.edit(EDIT_OVERWRITE)
                except:
                    pass

                if not reddit_state['only_edit']:
                    item.delete()

                currently_deleting_text.set(
                    f'Editing/Deleting {item_string} `{item_snippet}`')

            num_deleted_items_text.set(
                f'{str(count)}/{str(total_items)} items processed.')
            deletion_progress_bar['value'] = round(
                (count / total_items) * 100, 1)

            root.update()
            count += 1

    proceed_button = tk.Button(
        button_frame, text='Proceed', command=lambda: delete_items())
    cancel_button = tk.Button(button_frame, text='Cancel',
                              command=lambda: close_window(confirmation_window, reddit_state, 'confirmation_window_open'))

    proceed_button.grid(row=1, column=0, sticky='nsew')
    cancel_button.grid(row=1, column=1, sticky='nsew')

    counter = 3

    for item in item_array:
        time_created = arrow.get(item.created_utc)
        if time_created > reddit_state['time_to_save']:
            pass
        elif item.score > reddit_state['max_score']:
            pass
        elif item.gilded and reddit_state['gilded_skip']:
            pass
        elif reddit_state[f'whitelisted_{identifying_text}'][item.id]:
            pass
        else:
            tk.Label(frame,
                     text=helpers.format_snippet(item.body if comment_bool else item.title, 100)).grid(row=counter, column=0)
            ttk.Separator(frame, orient=tk.HORIZONTAL).grid(
                row=counter+1, columnspan=2, sticky='ew', pady=5)
        counter = counter + 2
def delete_reddit_items ( root , comment_bool , currently_deleting_text , deletion_progress_bar , num_deleted_items_text , reddit_state , scheduled_bool ) : if reddit_state [ 'confirmation_window_open' ] == 1 and not scheduled_bool : return confirmation_window = tk . Toplevel ( root ) reddit_state [ 'confirmation_window_open' ] = 1 reddit_state . sync confirmation_window . protocol ( 'WM_DELETE_WINDOW' , lambda : close_window ( confirmation_window , reddit_state , 'confirmation_window_open' ) ) frame = build_window ( root , confirmation_window , f"The following {'comments' if comment_bool else 'posts'} will be deleted/edited" ) if comment_bool : total_items = sum ( 1 for _ in reddit_state [ 'user' ] . comments . new ( limit = None ) ) item_array = reddit_state [ 'user' ] . comments . new ( limit = None ) identifying_text = 'comments' else : total_items = sum ( 1 for _ in reddit_state [ 'user' ] . submissions . new ( limit = None ) ) item_array = reddit_state [ 'user' ] . submissions . new ( limit = None ) identifying_text = 'posts' num_deleted_items_text . set ( f'0/{str(total_items)} items processed so far' ) button_frame = tk . Frame ( frame ) button_frame . grid ( row = 1 , column = 0 , sticky = 'w' ) def delete_items ( ) : close_window ( confirmation_window , reddit_state , 'confirmation_window_open' ) count = 1 # refetch item_array since we sent the generator all the way to the # end of the items when we showed which would be deleted if comment_bool : item_array = reddit_state [ 'user' ] . comments . new ( limit = None ) else : item_array = reddit_state [ 'user' ] . submissions . new ( limit = None ) for item in item_array : if comment_bool : item_string = 'Comment' item_snippet = helpers . format_snippet ( item . body , 50 ) else : item_string = 'Submission' item_snippet = helpers . format_snippet ( item . title , 50 ) time_created = arrow . get ( item . created_utc ) if time_created > reddit_state [ 'time_to_save' ] : currently_deleting_text . set ( f'{item_string} `{item_snippet}` more recent than cutoff, skipping.' ) elif item . score > reddit_state [ 'max_score' ] : currently_deleting_text . set ( f'{item_string} `{item_snippet}` is higher than max score, skipping.' ) elif item . gilded and reddit_state [ 'gilded_skip' ] : currently_deleting_text . set ( f'{item_string} `{item_snippet}` is gilded, skipping.' ) elif reddit_state [ f'whitelisted_{identifying_text}' ] [ item . id ] : currently_deleting_text . set ( f'{item_string} `{item_snippet}` is whitelisted, skipping.`' ) else : # Need the try/except here as it will crash on #  link submissions otherwise try : if reddit_state [ 'multi_edit' ] : times = random . randint ( 5 , 10 ) for i in range ( 0 , times ) : allchar = string . ascii_letters + string . punctuation + string . digits gibberish = "" . join ( random . choice ( allchar ) for x in range ( random . randint ( 50 , 200 ) ) ) item . edit ( gibberish ) else : item . edit ( EDIT_OVERWRITE ) except : pass if not reddit_state [ 'only_edit' ] : item . delete ( ) currently_deleting_text . set ( f'Editing/Deleting {item_string} `{item_snippet}`' ) num_deleted_items_text . set ( f'{str(count)}/{str(total_items)} items processed.' ) deletion_progress_bar [ 'value' ] = round ( ( count / total_items ) * 100 , 1 ) root . update ( ) count += 1 proceed_button = tk . Button ( button_frame , text = 'Proceed' , command = lambda : delete_items ( ) ) cancel_button = tk . Button ( button_frame , text = 'Cancel' , command = lambda : close_window ( confirmation_window , reddit_state , 'confirmation_window_open' ) ) proceed_button . grid ( row = 1 , column = 0 , sticky = 'nsew' ) cancel_button . grid ( row = 1 , column = 1 , sticky = 'nsew' ) counter = 3 for item in item_array : time_created = arrow . get ( item . created_utc ) if time_created > reddit_state [ 'time_to_save' ] : pass elif item . score > reddit_state [ 'max_score' ] : pass elif item . gilded and reddit_state [ 'gilded_skip' ] : pass elif reddit_state [ f'whitelisted_{identifying_text}' ] [ item . id ] : pass else : tk . Label ( frame , text = helpers . format_snippet ( item . body if comment_bool else item . title , 100 ) ) . grid ( row = counter , column = 0 ) ttk . Separator ( frame , orient = tk . HORIZONTAL ) . grid ( row = counter + 1 , columnspan = 2 , sticky = 'ew' , pady = 5 ) counter = counter + 2