<commit_before>from accerciser.i18n import _
from pyatspi import *
from pyatspi.constants import *
from validate import Validator
import random

__metadata__ = {
  'name': _('Basic'),
  'description': _('Tests fundamental GUI application accessibility')}

URL_BASE = 'http://live.gnome.org/Accerciser/Validate#'


class ActionIsInteractive(Validator):
  '''
  Any item that supports the action interface should also be focusable or 
  selectable so the user may interact with it via the keyboard.
  '''
  URL = URL_BASE + 'Actionable_ITEM_ROLE_is_not_focusable_or_selectable'

  def condition(self, acc):
    return acc.queryAction()

  def before(self, acc, state, view):
    s = acc.getState()
    if (not (s.contains(STATE_FOCUSABLE) or
             s.contains(STATE_SELECTABLE))):
      view.error(_('actionable %s is not focusable or selectable') %
                 acc.getLocalizedRoleName(), acc, self.URL)

class WidgetHasAction(Validator):
  '''
  Any widget with a role listed in condition should support the action 
  interface.
  '''
  URL = URL_BASE + 'Interactive_ITEM_ROLE_is_not_actionable'
  def condition(self, acc):
    return acc.getRole() in [ROLE_PUSH_BUTTON, ROLE_MENU, ROLE_MENU_ITEM,
                             ROLE_CHECK_MENU_ITEM, ROLE_RADIO_MENU_ITEM,
                             ROLE_TOGGLE_BUTTON, ROLE_RADIO_BUTTON]<commit_msg>Validate: fix the wiki URL to Accerciser pages<commit_after>from accerciser.i18n import _
from pyatspi import *
from pyatspi.constants import *
from validate import Validator
import random

__metadata__ = {
  'name': _('Basic'),
  'description': _('Tests fundamental GUI application accessibility')}

URL_BASE = 'https://wiki.gnome.org/Apps/Accerciser/Validate#'


class ActionIsInteractive(Validator):
  '''
  Any item that supports the action interface should also be focusable or 
  selectable so the user may interact with it via the keyboard.
  '''
  URL = URL_BASE + 'Actionable_ITEM_ROLE_is_not_focusable_or_selectable'

  def condition(self, acc):
    return acc.queryAction()

  def before(self, acc, state, view):
    s = acc.getState()
    if (not (s.contains(STATE_FOCUSABLE) or
             s.contains(STATE_SELECTABLE))):
      view.error(_('actionable %s is not focusable or selectable') %
                 acc.getLocalizedRoleName(), acc, self.URL)

class WidgetHasAction(Validator):
  '''
  Any widget with a role listed in condition should support the action 
  interface.
  '''
  URL = URL_BASE + 'Interactive_ITEM_ROLE_is_not_actionable'
  def condition(self, acc):
    return acc.getRole() in [ROLE_PUSH_BUTTON, ROLE_MENU, ROLE_MENU_ITEM,
                             ROLE_CHECK_MENU_ITEM, ROLE_RADIO_MENU_ITEM,
                             ROLE_TOGGLE_BUTTON, ROLE_RADIO_BUTTON]
{'fraction_non_alphanumeric': 0.08909815284317277, 'fraction_numerical': 0.0014487504527345165, 'mean_word_length': 3.626465661641541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6691540', 'n_tokens_mistral': 878, 'n_tokens_neox': 859, 'n_words': 230}