<commit_before>import datetime
import json
from time import mktime

import click
import parsedatetime
import urwid
from dateutil.tz import tzlocal
from tabulate import tabulate


from . import widgets

_palette = [
    ('error', 'light red', '')
]


class EditState:
    none = object()
    saved = object()


class TodoEditor:
    """
    The UI for a single todo entry.
    """

    def __init__(self, todo, lists, formatter):
        """
        :param model.Todo todo: The todo object which will be edited.
        """
        self.current_list = todo.list
        self.todo = todo
        self.lists = list(lists)
        self.formatter = formatter
        self.saved = EditState.none
        self._loop = None

        self._msg_text = urwid.Text('')
        if todo.due:
            # TODO: use proper date_format
            due = formatter.format_datetime(todo.due, humanize=False)
        else:
            due = ""

        if todo.start:
            # TODO: use proper date_format
            dtstart = formatter.format_datetime(todo.start, humanize=False)
        else:
            dtstart = ''

        if todo.priority:
            priority = formatter.parse_priority(todo.priority, humanize=False)
        else:
            priority = ''

        self._summary = widgets.ExtendedEdit(parent=self,
                                             edit_text=todo.summary)
        self._description = widgets.ExtendedEdit(
            parent=self,
            edit_text=todo.description,
            multiline=True,
        )
        self._location = widgets.ExtendedEdit(
            parent=self,
            edit_text=todo.location
        )
        self._due = widgets.ExtendedEdit(parent=self, edit_text=due)
        self._dtstart = widgets.ExtendedEdit(parent=self, edit_text=dtstart)
        self._completed = urwid.CheckBox("", state=todo.is_completed)
        self._priority = widgets.ExtendedEdit(parent=self, edit_text=priority)

        save_btn = urwid.Button('Save', on_press=self._save)
        cancel_text = urwid.Text('Hit Ctrl-C to cancel, F1 for help.')
        buttons = urwid.Columns([(8, save_btn), cancel_text], dividechars=2)<commit_msg>Remove unnecessary conditional<commit_after>import datetime
import json
from time import mktime

import click
import parsedatetime
import urwid
from dateutil.tz import tzlocal
from tabulate import tabulate


from . import widgets

_palette = [
    ('error', 'light red', '')
]


class EditState:
    none = object()
    saved = object()


class TodoEditor:
    """
    The UI for a single todo entry.
    """

    def __init__(self, todo, lists, formatter):
        """
        :param model.Todo todo: The todo object which will be edited.
        """
        self.current_list = todo.list
        self.todo = todo
        self.lists = list(lists)
        self.formatter = formatter
        self.saved = EditState.none
        self._loop = None

        self._msg_text = urwid.Text('')

        due = formatter.format_datetime(todo.due, humanize=False)
        dtstart = formatter.format_datetime(todo.start, humanize=False)

        if todo.priority:
            priority = formatter.parse_priority(todo.priority, humanize=False)
        else:
            priority = ''

        self._summary = widgets.ExtendedEdit(parent=self,
                                             edit_text=todo.summary)
        self._description = widgets.ExtendedEdit(
            parent=self,
            edit_text=todo.description,
            multiline=True,
        )
        self._location = widgets.ExtendedEdit(
            parent=self,
            edit_text=todo.location
        )
        self._due = widgets.ExtendedEdit(parent=self, edit_text=due)
        self._dtstart = widgets.ExtendedEdit(parent=self, edit_text=dtstart)
        self._completed = urwid.CheckBox("", state=todo.is_completed)
        self._priority = widgets.ExtendedEdit(parent=self, edit_text=priority)

        save_btn = urwid.Button('Save', on_press=self._save)
        cancel_text = urwid.Text('Hit Ctrl-C to cancel, F1 for help.')
        buttons = urwid.Columns([(8, save_btn), cancel_text], dividechars=2)
{'fraction_non_alphanumeric': 0.09703113685734975, 'fraction_numerical': 0.001448225923244026, 'mean_word_length': 2.2249027237354086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6908070', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1170, 'n_words': 269}