Exemplo n.º 1
0
 def __get_args_and_kwargs(self, func_args=None, func_kwargs=None, name=None, allow_cls_override=True):
     if not func_args and not func_kwargs:
         return self.args or [], self.kwargs or DictCaseInsensitive()
     func_args = func_args or allow_cls_override and self.args or []
     func_kwargs = func_kwargs or allow_cls_override and self.kwargs or DictCaseInsensitive()
     if is_seq_type(func_kwargs) and is_dict_type(func_args):
         func_args, func_kwargs = func_kwargs, func_args
     func_args = self.__args_to_list(func_args)
     if isinstance(func_kwargs, dict):
         func_kwargs = DictCaseInsensitive(func_kwargs, key=name, parent_key='kwargs')
     if not isinstance(func_args, list):
         func_args = []
     if not isinstance(func_kwargs, DictCaseInsensitive):
         func_kwargs = DictCaseInsensitive(key=name)
     return func_args, func_kwargs
Exemplo n.º 2
0
def log_banner(title,
               filename=None,
               length=ANKNOTES.FORMATTING.BANNER_MINIMUM,
               append_newline=True,
               timestamp=False,
               chr='-',
               center=True,
               clear=True,
               crosspost=None,
               prepend_newline=False,
               *args,
               **kwargs):
    if crosspost is not None:
        for cp in item_to_list(crosspost, False):
            log_banner(
                title, cp,
                **DictCaseInsensitive(
                    kwargs,
                    locals(),
                    delete='title crosspost kwargs args filename'))
    if length is 0:
        length = ANKNOTES.FORMATTING.LINE_LENGTH + 1
    if center:
        title = title.center(length - (
            ANKNOTES.FORMATTING.TIMESTAMP_PAD_LENGTH if timestamp else 0))
    if prepend_newline:
        log_blank(filename, **kwargs)
    log(chr * length, filename, clear=clear, timestamp=False, **kwargs)
    log(title, filename, timestamp=timestamp, **kwargs)
    log(chr * length, filename, timestamp=False, **kwargs)
    if append_newline:
        log_blank(filename, **kwargs)
Exemplo n.º 3
0
 def process_kwargs(self, get_args=None, set_dict=None, func_kwargs=None, delete_from_kwargs=True, update_cls_args=True, **kwargs):
     method_name='process_kwargs'
     kwargs['return_value_only'] = False
     cls_kwargs = func_kwargs is None
     func_kwargs = self.kwargs if cls_kwargs else DictCaseInsensitive(func_kwargs)
     keys = func_kwargs.keys()
     for key, value in set_dict.items() if set_dict else []:
         key = self.key_transform(key, keys)
         if key not in func_kwargs:
             func_kwargs[key] = value
     if not get_args:
         if cls_kwargs and update_cls_args:
             self.__func_kwargs = func_kwargs
         return func_kwargs
     gets = []
     for arg in get_args:
         # for arg in args:
         if len(arg) is 1 and isinstance(arg[0], list):
             arg = arg[0]
         result = self.process_kwarg(arg[0], arg[1], func_kwargs=func_kwargs, delete_from_kwargs=delete_from_kwargs, **kwargs)
         if delete_from_kwargs:
             func_kwargs = result[0]
             result = result[1]
         gets.append(result)
     if cls_kwargs and update_cls_args:
         self.__func_kwargs = func_kwargs
     if delete_from_kwargs:
         return [func_kwargs] + gets
     return gets
Exemplo n.º 4
0
 def aggregateSummary(self, includeHeader=True):
     aggs = '!max|!+max_allowed|total|+handled|++success|+++completed|+++queued|++delayed'
     counts = self._get_summary_(header_only=True) if includeHeader else []
     parents, last_level = [], 1
     for key_code in aggs.split('|'):
         override_default = key_code[0] is not '!'
         counts += [
             DictCaseInsensitive(marker='*' if override_default else ' ',
                                 child_values={},
                                 children=['<aggregate>'])
         ]
         if not override_default:
             key_code = key_code[1:]
         key = key_code.lstrip('+')
         counts.level, counts.value = len(key_code) - len(key) + 1, getattr(
             self, key)
         counts.class_name = type(counts.value)
         if counts.class_name is not int:
             counts.value = counts.value.getDefault()
         parent_lbl = '.'.join(parents)
         counts.key, counts.label = DictKey(key, parent_lbl), DictKey(
             key, parent_lbl, 'label')
         if counts.level < last_level:
             del parents[-1]
         elif counts.level > last_level:
             parents.append(key)
         last_level = counts.level
     return self._summarize_lines_(counts, includeHeader)
Exemplo n.º 5
0
 def banner(self, title, filename=None, *args, **kwargs):
     filename, kwargs = self.wrap_filename(
         filename,
         **DictCaseInsensitive(self.defaults,
                               kwargs,
                               wrap_fn_auto_header=False))
     self.default_banner = title
     log_banner(title, filename, *args, **kwargs)
Exemplo n.º 6
0
 def go(self,
        content=None,
        filename=None,
        wrap_filename=True,
        *args,
        **kwargs):
     if wrap_filename:
         filename, kwargs = self.wrap_filename(
             filename, **DictCaseInsensitive(self.defaults, kwargs))
     log(content, filename, *args, **kwargs)
Exemplo n.º 7
0
 def process_kwarg(self, key, default=None, func_kwargs=None, replace_none_type=True, delete_from_kwargs=None, return_value_only=True, update_cls_args=True):
     delete_from_kwargs = delete_from_kwargs is not False
     cls_kwargs = func_kwargs is None
     func_kwargs = self.kwargs if cls_kwargs else DictCaseInsensitive(func_kwargs)
     key = self.key_transform(key, func_kwargs.keys())
     if key not in func_kwargs:
         return (func_kwargs, default) if delete_from_kwargs and not return_value_only else default
     val = func_kwargs[key]
     if val is None and replace_none_type:
         val = default
     if delete_from_kwargs:
         del func_kwargs[key]
         if cls_kwargs and update_cls_args:
             del self.__func_kwargs[key]
     if not delete_from_kwargs or return_value_only:
         return val
     return func_kwargs, val
Exemplo n.º 8
0
 def BannerHeader(self,
                  append_newline=False,
                  filename=None,
                  crosspost=None,
                  bh_wrap_filename=True,
                  **kw):
     if filename is None:
         filename = ''
     if bh_wrap_filename:
         filename = self.Label + filename
         if crosspost is not None:
             crosspost = [
                 self.Label + cp for cp in item_to_list(crosspost, False)
             ]
     log_banner(self.ActionNumeric.upper(),
                do_print=self.__do_print,
                **DictCaseInsensitive(kw,
                                      locals(),
                                      delete='self kw bh_wrap_filename cp'))
Exemplo n.º 9
0
                def process_list_item(contents):
                    def check_subnote(li, sublist):
                        def check_heading_flags():
                            if not isinstance(sublist.heading_flags, list):
                                sublist.heading_flags = []
                            for str_ in "`':":
                                if sublist.heading.endswith(str_):
                                    sublist.heading_flags.append(str_)
                                    sublist.heading = sublist.heading[:-1*len(str_)]
                                    check_heading_flags()
                                    return

                        #Begin check_subnote()
                        if not (isinstance(li, Tag) and (li.name in list_tag_names) and li.contents and li.contents[0]):
                            sublist.list_items.append(decode_html(li))
                            return sublist
                        sublist.heading = strip_tags(decode_html(''.join(sublist.list_items)), True).strip()
                        sublist.base_title = u': '.join(names).replace(title + ': ', '')
                        sublist.is_reversible = not matches_list(sublist.heading, HEADINGS.NOT_REVERSIBLE)
                        check_heading_flags()
                        if "`" in sublist.heading_flags:
                            sublist.is_reversible = not sublist.is_reversible
                        sublist.use_descriptor = "'" in sublist.heading_flags or "`" in sublist.heading_flags
                        sublist.is_subnote = ':' in sublist.heading_flags or matches_list(sublist.heading, HEADINGS.TOP + '|' + HEADINGS.BOTTOM)
                        if not sublist.is_subnote:
                            return sublist
                        sublist.subnote = li
                        return sublist

                    # Begin process_list_item()
                    sublist = DictCaseInsensitive(is_subnote=False, list_items=[])
                    for li in contents:
                        sublist = check_subnote(li, sublist)
                        if sublist.is_subnote:
                            break
                    return sublist
Exemplo n.º 10
0
 def plain(self, content=None, filename=None, *args, **kwargs):
     filename, kwargs = self.wrap_filename(
         filename, **DictCaseInsensitive(self.defaults, kwargs))
     log_plain(content, filename, *args, **kwargs)
Exemplo n.º 11
0
 def error(self, content, crosspost=None, *a, **kw):
     if crosspost is None:
         crosspost = []
     crosspost.append(self.wrap_filename('error'),
                      **DictCaseInsensitive(self.defaults, kw))
     log_error(content, crosspost=crosspost, *a, **kw)
Exemplo n.º 12
0
 def dump(self, obj, title='', filename=None, *args, **kwargs):
     filename, kwargs = self.wrap_filename(
         filename, **DictCaseInsensitive(self.defaults, kwargs))
     # noinspection PyArgumentList
     log_dump(obj, title, filename, *args, **kwargs)
Exemplo n.º 13
0
def log_plain(*args, **kwargs):
    log(*args, **DictCaseInsensitive(kwargs, timestamp=False))
Exemplo n.º 14
0
def log_blank(*args, **kwargs):
    log(None, *args,
        **DictCaseInsensitive(kwargs, timestamp=False, delete='content'))
Exemplo n.º 15
0
 def default(self, *args, **kwargs):
     self.log(wrap_filename=False,
              *args,
              **DictCaseInsensitive(self.defaults, kwargs))
Exemplo n.º 16
0
    def create_subnote(guid):
        def process_lists(note, lst, levels=None, names=None):
            def add_log_entry(title, content, filename=None, prefix_content=True, title_pad=16, **kw):
                names_padded = u''.join(map(lambda x: (x+':').ljust(33) + ' ', names[1:-1])) + names[-1]
                fmts = dict(levels_pad=u'\t' * level, levels=u'.'.join(map(str, levels)),
                            num_levels=len(levels), names=u': '.join(names[1:]).ljust(20),
                            names_padded=names_padded)
                fmts['levels_str'] = (fmts['levels'] + ':').ljust(6)
                if prefix_content:
                    fmts['content'] = content
                    content = u'{levels_pad}{levels_str} {content}'
                if isinstance(lst_items, Tag) and lst_items.name in list_tag_names:
                    fmts['list_name'] = list_tag_names[lst_items.name]
                content = fmt(content, 0, fmts)
                if title:
                    title = (fmt(title, 0, fmts) + u': ').ljust(title_pad)
                l.go(title + content, filename, **kw)

            def process_tag():
                def get_log_fn():
                    return u'.'.join(map(str, levels)) + u' - ' + u'-'.join(names[1:])
                def log_tag():
                    if not lst_items.contents:
                        add_log_entry('NO TOP TEXT', decode_html(lst_items.contents), crosspost='no_top_text')
                    if lst_items.name in list_tag_names:
                        add_log_entry('{list_name}', '{levels_pad}[{num_levels}] {levels}', prefix_content=False)
                    elif lst_items.name != 'li':
                        add_log_entry('OTHER TAG', decode(lst_items.contents[0]) if lst_items.contents else u'N/A')
                    elif not sublist.is_subnote:
                        add_log_entry('LIST ITEM', strip_tags(u''.join(sublist.list_items), True).strip())
                    else:
                        subnote_fn = u'..\\subnotes\\process_tag*\\' + get_log_fn()
                        subnote_shared = '*\\..\\..\\subnotes\\process_tag-all'
                        l.banner(u': '.join(names), subnote_fn)
                        if not create_subnote.logged_subnote:
                            l.blank(subnote_shared)
                            l.banner(title, subnote_shared, clear=False, append_newline=False)
                            l.banner(title, '..\\subnotes\\process_tag')
                            create_subnote.logged_subnote = True
                        add_log_entry('SUBNOTE', sublist.heading)
                        add_log_entry('', sublist.heading, '..\\subnotes\\process_tag', crosspost=subnote_fn)
                        add_log_entry('{levels}', '{names_padded}', subnote_shared, prefix_content=False, title_pad=13)
                        l.go(decode_html(sublist.subnote), subnote_fn)

                def add_note(sublist, new_levels, new_names):
                    subnote_html = decode_html(sublist.subnote)
                    log_fn = u'..\\subnotes\\add_note*\\' + get_log_fn()
                    add_log_entry('SUBNOTE', '{levels_str} {names}: \n%s\n' % subnote_html, '..\\subnotes\\add_note', crosspost=log_fn, prefix_content=False)
                    myNotes.append([new_levels, new_names, subnote_html])

                def process_list_item(contents):
                    def check_subnote(li, sublist):
                        def check_heading_flags():
                            if not isinstance(sublist.heading_flags, list):
                                sublist.heading_flags = []
                            for str_ in "`':":
                                if sublist.heading.endswith(str_):
                                    sublist.heading_flags.append(str_)
                                    sublist.heading = sublist.heading[:-1*len(str_)]
                                    check_heading_flags()
                                    return

                        #Begin check_subnote()
                        if not (isinstance(li, Tag) and (li.name in list_tag_names) and li.contents and li.contents[0]):
                            sublist.list_items.append(decode_html(li))
                            return sublist
                        sublist.heading = strip_tags(decode_html(''.join(sublist.list_items)), True).strip()
                        sublist.base_title = u': '.join(names).replace(title + ': ', '')
                        sublist.is_reversible = not matches_list(sublist.heading, HEADINGS.NOT_REVERSIBLE)
                        check_heading_flags()
                        if "`" in sublist.heading_flags:
                            sublist.is_reversible = not sublist.is_reversible
                        sublist.use_descriptor = "'" in sublist.heading_flags or "`" in sublist.heading_flags
                        sublist.is_subnote = ':' in sublist.heading_flags or matches_list(sublist.heading, HEADINGS.TOP + '|' + HEADINGS.BOTTOM)
                        if not sublist.is_subnote:
                            return sublist
                        sublist.subnote = li
                        return sublist

                    # Begin process_list_item()
                    sublist = DictCaseInsensitive(is_subnote=False, list_items=[])
                    for li in contents:
                        sublist = check_subnote(li, sublist)
                        if sublist.is_subnote:
                            break
                    return sublist

                # Begin process_tag()
                new_levels = levels[:]
                new_names = names[:]
                if lst_items.name in list_tag_names:
                    new_levels.append(0)
                    new_names.append('CHILD ' + lst_items.name.upper())
                elif lst_items.name == 'li':
                    levels[-1] = new_levels[-1] = levels[-1] + 1
                    sublist = process_list_item(lst_items.contents)
                    if sublist.is_subnote:
                        names[-1] = new_names[-1] = sublist.heading
                        add_note(sublist, new_levels, new_names)
                    else:
                        names[-1] = new_names[-1] = sublist.heading if sublist.heading else 'Xx' + strip_tags(unicode(''.join(sublist.list_items)), True).strip()
                log_tag()
                if lst_items.name in list_tag_names or lst_items.name == 'li':
                    process_lists(note, lst_items.contents, new_levels, new_names)

            # Begin process_lists()
            if levels is None or names is None:
                levels = []
                names = [title]
            level = len(levels)
            for lst_items in lst:
                if isinstance(lst_items, Tag):
                    process_tag()
                elif isinstance(lst_items, NavigableString):
                    add_log_entry('NAV STRING', decode_html(lst_items).strip(), crosspost=['nav_strings', '*\\..\\..\\nav_strings'])
                else:
                    add_log_entry('LST ITEMS', lst_items.__class__.__name__, crosspost=['unexpected-type', '*\\..\\..\\unexpected-type'])

        #Begin create_subnote()
        content = db.scalar("guid = ?", guid, columns='content')
        title = note_title = get_evernote_title_from_guid(guid)
        l.path_suffix = '\\' + title
        soup = BeautifulSoup(content)
        en_note = soup.find('en-note')
        note = DictCaseInsensitive(descriptor=None)
        first_div = en_note.find('div')
        if first_div:
            descriptor_text = first_div.text
            if descriptor_text.startswith('`'):
                note.descriptor = descriptor_text[1:]
        lists = en_note.find(['ol', 'ul'])
        lists_all = soup.findAll(['ol', 'ul'])
        l.banner(title, crosspost='strings')
        create_subnote.logged_subnote = False
        process_lists(note, [lists])
        l.go(decode_html(lists), 'lists', clear=True)
        l.go(soup.prettify(), 'full', clear=True)
Exemplo n.º 17
0
 def blank(self, filename=None, *args, **kwargs):
     filename, kwargs = self.wrap_filename(
         filename, **DictCaseInsensitive(self.defaults, kwargs))
     log_blank(filename, *args, **kwargs)
Exemplo n.º 18
0
 def __init__(self,
              max=None,
              interval=100,
              info=None,
              infoStr=None,
              automated=None,
              begin=True,
              label=None,
              display_initial_info=None,
              max_allowed=None,
              do_print=False,
              **kw):
     """
     :type info : ActionInfo
     """
     args = DictCaseInsensitive(kw,
                                locals(),
                                delete='kw infoStr info max self')
     simple_label = False
     self.counts = EvernoteCounter()
     self.__interval = interval
     self.__reported_progress = False
     if not isinstance(max, int):
         if hasattr(max, '__len__'):
             max = len(max)
         else:
             max = None
     self.counts.max = -1
     if max is not None:
         self.counts.max = max
         args.max = self.counts.max
     if is_str(info):
         # noinspection PyTypeChecker
         info = ActionInfo(info, **args)
     elif infoStr and not info:
         info = ActionInfo(infoStr, **args)
     elif label and not info:
         simple_label = True
         if display_initial_info is None:
             display_initial_info = False
         info = ActionInfo(label, **args)
     elif label:
         info.Label = label
     if self.counts.max > 0 and info and (info.Max is None or info.Max < 1):
         info.Max = max
     self.counts.max_allowed = self.counts.max if max_allowed is None else max_allowed
     self.__did_break = True
     self.__do_print = do_print
     self.__info = info
     self.__action_initialized = False
     self.__action_attempted = self.hasActionInfo and (display_initial_info
                                                       is not False)
     if self.__action_attempted:
         if self.info is None:
             log("Unexpected; Timer '%s' has no ActionInfo instance" %
                 label,
                 do_print=True)
         else:
             self.__action_initialized = self.info.displayInitialInfo(
                 **args) is EvernoteAPIStatus.Initialized
     if begin:
         self.reset(False)
     log_blank(filename='counters')
     log(self.counts.fullSummary(self.name + ': Start'), 'counters')
Exemplo n.º 19
0
def setup_evernote(self):
    global icoEvernoteWeb
    global imgEvernoteWeb
    global elements
    global evernote_query_last_updated
    global evernote_pagination_current_page_spinner

    def update_checkbox(setting):
        if setting is DECKS.EVERNOTE_NOTEBOOK_INTEGRATION and not elements[DECKS.BASE].text():
            return
        if setting.get.startswith(QUERY.get):
            update_evernote_query_visibilities()
        setting.save(elements[setting].isChecked())
        # mw.col.conf[setting] =
        if setting is QUERY.USE_TAGS:
            update_evernote_query_visibilities()
        if setting is QUERY.LAST_UPDATED.USE:
            evernote_query_last_updated_value_set_visibilities()

    def create_checkbox(setting, label=" ", default_value=False, is_fixed_size=False, fixed_width=None):
        if isinstance(label, bool):
            default_value = label
            label = " "
        checkbox = QCheckBox(label, self)
        sval = setting.fetch()
        if not isinstance(sval, bool):
            sval = default_value
        checkbox.setChecked(sval)
        # noinspection PyUnresolvedReferences
        checkbox.stateChanged.connect(lambda: update_checkbox(setting))
        if is_fixed_size or fixed_width:
            checkbox.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            if fixed_width:
                checkbox.setFixedWidth(fixed_width)
        elements[setting] = checkbox
        return checkbox

    def create_checked_checkbox(*a, **kw):
        kw['default_value'] = True
        return create_checkbox(*a, **kw)

    def update_text(setting, text):
        text = text.strip()
        setting.save(text)
        if setting is DECKS.BASE:
            update_anki_deck_visibilities()
        if setting.get.startswith(QUERY.get):
            if text:
                use_key = getattr(QUERY, 'USE_' + setting.label.name)
                elements[use_key].setChecked(True)
            evernote_query_text_changed()
            if setting is QUERY.SEARCH_TERMS:
                update_evernote_query_visibilities()

    def create_textbox(setting, default_value=""):
        textbox = QLineEdit()
        textbox.setText(setting.fetch(default_value))
        textbox.connect(textbox,
                        SIGNAL("textEdited(QString)"),
                        lambda text: update_text(setting, text))
        elements[setting] = textbox
        return textbox

    def add_query_row(setting, is_checked=False, **kw):
        try:
            default_value = setting.val
        except:
            default_value = ''
        row_label = ' '.join(x.capitalize() for x in setting.replace('_', ' ').split())
        hbox = QHBoxLayout()
        hbox.addWidget(create_checkbox(getattr(QUERY, 'USE_' + setting),
                       default_value=is_checked, **kw))
        hbox.addWidget(create_textbox(getattr(QUERY, setting), default_value))
        form.addRow(row_label, hbox)

    def gen_qt_hr():
        vbox = QVBoxLayout()
        hr = QFrame()
        hr.setAutoFillBackground(True)
        hr.setFrameShape(QFrame.HLine)
        hr.setStyleSheet("QFrame { background-color: #0060bf; color: #0060bf; }")
        hr.setFixedHeight(2)
        vbox.addWidget(hr)
        vbox.addSpacing(4)
        return vbox

    # Begin setup_evernote()
    widget = QWidget()
    layout = QVBoxLayout()
    elements = {}
    rm_log_path('Dicts\\')
    evernote_query_last_updated = DictCaseInsensitive()


    ########################## QUERY ##########################
    ##################### QUERY: TEXTBOXES ####################
    group = QGroupBox("EVERNOTE SEARCH OPTIONS:")
    group.setStyleSheet('QGroupBox{    font-size: 10px;    font-weight: bold;  color: rgb(105, 170, 53);}')
    form = QFormLayout()

    form.addRow(gen_qt_hr())

    # Show Generated Evernote Query Button
    button_show_generated_evernote_query = QPushButton(icoEvernoteWeb, "Show Full Query", self)
    button_show_generated_evernote_query.setAutoDefault(False)
    button_show_generated_evernote_query.connect(button_show_generated_evernote_query,
                                                 SIGNAL("clicked()"),
                                                 handle_show_generated_evernote_query)


    # Add Form Row for Match Any Terms
    hbox = QHBoxLayout()
    hbox.addWidget(create_checked_checkbox(QUERY.ANY, "     Match Any Terms", is_fixed_size=True))
    hbox.addWidget(button_show_generated_evernote_query)
    form.addRow("<b>Search Parameters:</b>", hbox)

    # Add Form Rows for Evernote Query Textboxes
    for el in QUERY_TEXTBOXES:
        add_query_row(el, 'TAGS' in el)

    ################### QUERY: LAST UPDATED ###################
    # Evernote Query: Last Updated Type
    evernote_query_last_updated.type = QComboBox()
    evernote_query_last_updated.type.setStyleSheet(' QComboBox { color: rgb(45, 79, 201); font-weight: bold; } ')
    evernote_query_last_updated.type.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
    evernote_query_last_updated.type.addItems([u"Δ Day", u"Δ Week", u"Δ Month", u"Δ Year", "Date", "+ Time"])
    evernote_query_last_updated.type.setCurrentIndex(QUERY.LAST_UPDATED.TYPE.fetch(EvernoteQueryLocationType.RelativeDay))
    evernote_query_last_updated.type.activated.connect(update_evernote_query_last_updated_type)


    # Evernote Query: Last Updated Type: Relative Date
    evernote_query_last_updated.value.relative.spinner = EvernoteQueryLocationValueQSpinBox()
    evernote_query_last_updated.value.relative.spinner.setVisible(False)
    evernote_query_last_updated.value.relative.spinner.setStyleSheet(
        " QSpinBox, EvernoteQueryLocationValueQSpinBox { font-weight: bold;  color: rgb(173, 0, 0); } ")
    evernote_query_last_updated.value.relative.spinner.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
    evernote_query_last_updated.value.relative.spinner.connect(evernote_query_last_updated.value.relative.spinner,
                                                               SIGNAL("valueChanged(int)"),
                                                               update_evernote_query_last_updated_value_relative_spinner)

    # Evernote Query: Last Updated Type: Absolute Date
    evernote_query_last_updated.value.absolute.date = QDateEdit()
    evernote_query_last_updated.value.absolute.date.setDisplayFormat('M/d/yy')
    evernote_query_last_updated.value.absolute.date.setCalendarPopup(True)
    evernote_query_last_updated.value.absolute.date.setVisible(False)
    evernote_query_last_updated.value.absolute.date.setStyleSheet(
        "QDateEdit { font-weight: bold;  color: rgb(173, 0, 0); } ")
    evernote_query_last_updated.value.absolute.date.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
    evernote_query_last_updated.value.absolute.date.connect(evernote_query_last_updated.value.absolute.date,
                                                            SIGNAL("dateChanged(QDate)"),
                                                            update_evernote_query_last_updated_value_absolute_date)

    # Evernote Query: Last Updated Type: Absolute DateTime
    evernote_query_last_updated.value.absolute.datetime = QDateTimeEdit()
    evernote_query_last_updated.value.absolute.datetime.setDisplayFormat('M/d/yy h:mm AP')
    evernote_query_last_updated.value.absolute.datetime.setCalendarPopup(True)
    evernote_query_last_updated.value.absolute.datetime.setVisible(False)
    evernote_query_last_updated.value.absolute.datetime.setStyleSheet(
        "QDateTimeEdit { font-weight: bold;  color: rgb(173, 0, 0); } ")
    evernote_query_last_updated.value.absolute.datetime.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
    evernote_query_last_updated.value.absolute.datetime.connect(evernote_query_last_updated.value.absolute.datetime,
                                                                SIGNAL("dateTimeChanged(QDateTime)"),
                                                                update_evernote_query_last_updated_value_absolute_datetime)



    # Evernote Query: Last Updated Type: Absolute Time
    evernote_query_last_updated.value.absolute.time = QTimeEdit()
    evernote_query_last_updated.value.absolute.time.setDisplayFormat('h:mm AP')
    evernote_query_last_updated.value.absolute.time.setVisible(False)
    evernote_query_last_updated.value.absolute.time.setStyleSheet(
        "QTimeEdit { font-weight: bold;  color: rgb(143, 0, 30); } ")
    evernote_query_last_updated.value.absolute.time.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
    evernote_query_last_updated.value.absolute.time.connect(evernote_query_last_updated.value.absolute.time,
                                                            SIGNAL("timeChanged(QTime)"),
                                                            update_evernote_query_last_updated_value_absolute_time)

    # Create HBox for Separated Date & Time
    hbox_datetime = QHBoxLayout()
    hbox_datetime.addWidget(evernote_query_last_updated.value.absolute.date)
    hbox_datetime.addWidget(evernote_query_last_updated.value.absolute.time)

    # Evernote Query: Last Updated Type
    evernote_query_last_updated.value.stacked_layout = QStackedLayout()
    evernote_query_last_updated.value.stacked_layout.addWidget(evernote_query_last_updated.value.relative.spinner)
    evernote_query_last_updated.value.stacked_layout.addItem(hbox_datetime)

    # Add Form Row for Evernote Query: Last Updated
    hbox = QHBoxLayout()
    label = QLabel("Last Updated: ")
    label.setMinimumWidth(SETTINGS.FORM.LABEL_MINIMUM_WIDTH.val)
    hbox.addWidget(create_checkbox(QUERY.LAST_UPDATED.USE, is_fixed_size=True))
    hbox.addWidget(evernote_query_last_updated.type)
    hbox.addWidget(evernote_query_last_updated.value.relative.spinner)
    hbox.addWidget(evernote_query_last_updated.value.absolute.date)
    hbox.addWidget(evernote_query_last_updated.value.absolute.time)
    form.addRow(label, hbox)

    # Add Horizontal Row Separator
    form.addRow(gen_qt_hr())

    ############################ PAGINATION ##########################
    # Evernote Pagination: Current Page
    evernote_pagination_current_page_spinner = QSpinBox()
    evernote_pagination_current_page_spinner.setStyleSheet("QSpinBox { font-weight: bold;  color: rgb(173, 0, 0);  } ")
    evernote_pagination_current_page_spinner.setPrefix("PAGE: ")
    evernote_pagination_current_page_spinner.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
    evernote_pagination_current_page_spinner.setValue(EVERNOTE.PAGINATION_CURRENT_PAGE.fetch(1))
    evernote_pagination_current_page_spinner.connect(evernote_pagination_current_page_spinner,
                                                     SIGNAL("valueChanged(int)"),
                                                     update_evernote_pagination_current_page_spinner)

    # Evernote Pagination: Automation
    hbox = QHBoxLayout()
    hbox.addWidget(create_checked_checkbox(EVERNOTE.AUTO_PAGING, "     Automate", fixed_width=105))
    hbox.addWidget(evernote_pagination_current_page_spinner)

    # Add Form Row for Evernote Pagination
    form.addRow("<b>Pagination:</b>", hbox)

    # Add Query Form to Group Box
    group.setLayout(form)

    # Add Query Group Box to Main Layout
    layout.addWidget(group)

    ########################## DECK ##########################
    # Setup Group Box and Form
    group = QGroupBox("ANKI NOTE OPTIONS:")
    group.setStyleSheet('QGroupBox{    font-size: 10px;    font-weight: bold;  color: rgb(105, 170, 53);}')
    form = QFormLayout()

    # Add Horizontal Row Separator
    form.addRow(gen_qt_hr())

    # Add Form Row for Default Anki Deck
    hbox = QHBoxLayout()
    hbox.insertSpacing(0, 33)
    hbox.addWidget(create_textbox(DECKS.BASE, DECKS.BASE_DEFAULT_VALUE))
    label_deck = QLabel("<b>Anki Deck:</b>")
    label_deck.setMinimumWidth(SETTINGS.FORM.LABEL_MINIMUM_WIDTH.val)
    form.addRow(label_deck, hbox)

    # Add Form Row for Evernote Notebook Integration
    label_deck = QLabel("Evernote Notebook:")
    label_deck.setMinimumWidth(SETTINGS.FORM.LABEL_MINIMUM_WIDTH.val)
    form.addRow("", create_checked_checkbox(DECKS.EVERNOTE_NOTEBOOK_INTEGRATION, "      Append Evernote Notebook"))

    # Add Horizontal Row Separator
    form.addRow(gen_qt_hr())

    ############################ TAGS ##########################
    # Add Form Row for Evernote Tag Options
    label = QLabel("<b>Evernote Tags:</b>")
    label.setMinimumWidth(SETTINGS.FORM.LABEL_MINIMUM_WIDTH.val)

    # Tags: Save To Anki Note
    form.addRow(label, create_checkbox(TAGS.KEEP_TAGS, "     Save To Anki Note", TAGS.KEEP_TAGS_DEFAULT_VALUE))
    hbox = QHBoxLayout()
    hbox.insertSpacing(0, 33)
    hbox.addWidget(create_textbox(TAGS.TO_DELETE))

    # Tags: Tags To Delete
    form.addRow("Tags to Delete:", hbox)
    form.addRow(" ", create_checkbox(TAGS.DELETE_EVERNOTE_QUERY_TAGS, "     Also Delete Search Tags"))

    # Add Horizontal Row Separator
    form.addRow(gen_qt_hr())

    ############################ NOTE UPDATING ##########################
    # Note Update Method
    update_existing_notes = QComboBox()
    update_existing_notes.setStyleSheet(
        ' QComboBox { color: #3b679e; font-weight: bold; } QComboBoxItem { color: #A40F2D; font-weight: bold; } ')
    update_existing_notes.addItems(["Ignore Existing Notes", "Update In-Place",
                                    "Delete and Re-Add"])
    sval = ANKI.UPDATE_EXISTING_NOTES.fetch()
    if not isinstance(sval, int):
        sval = ANKI.UPDATE_EXISTING_NOTES.val
    update_existing_notes.setCurrentIndex(sval)
    update_existing_notes.activated.connect(update_update_existing_notes)

    # Add Form Row for Note Update Method
    hbox = QHBoxLayout()
    hbox.insertSpacing(0, 33)
    hbox.addWidget(update_existing_notes)
    form.addRow("<b>Note Updating:</b>", hbox)

    # Add Note Update Method Form to Group Box
    group.setLayout(form)

    # Add Note Update Method Group Box to Main Layout
    layout.addWidget(group)

    ######################### UPDATE VISIBILITIES #######################
    # Update Visibilities of Anki Deck Options
    update_anki_deck_visibilities()

    # Update Visibilities of Query Options
    evernote_query_text_changed()
    update_evernote_query_visibilities()

    ######################## ADD TO SETTINGS PANEL ######################
    # Vertical Spacer
    vertical_spacer = QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
    layout.addItem(vertical_spacer)

    # Parent Widget
    widget.setLayout(layout)

    # New Tab
    self.form.tabWidget.addTab(widget, "Anknotes")