<commit_before># -*- coding: UTF-8 -*-
from .exceptions import StaleElementReferenceException, \
    NoSuchElementException


class StaleOf(object):

    def __init__(self, check_status):
        self.__check_status = check_status

    def __call__(self, element):
        try:
            # Calling any method forces a staleness check
            element.is_enabled()
            return self.__check_status
        except StaleElementReferenceException:
            return not self.__check_status


class Stale(StaleOf):

    def __init__(self):
        super().__init__(True)


class Fresh(StaleOf):

    def __init__(self):
        super().__init__(False)


class VisibleOf(object):

    def __init__(self, check_status):
        self.__check_status = check_status

    def __call__(self, element):
        try:
            return element.is_displayed() == self.__check_status
        except (NoSuchElementException, StaleElementReferenceException):
            # In the case of NoSuchElement, returns true because the element is
            # not present in DOM. The try block checks if the element is present
            # but is invisible.
            # In the case of StaleElementReference, returns true because stale
            # element reference implies that element is no longer visible.
            return not self.__check_status


class VisibleAny(VisibleOf):

    def __init__(self):
        super().__init__(None)

    def __call__(self, element):
        try:
            # Empty statement just check element is valid
            element.is_displayed()
            return True
        except (NoSuchElementException, StaleElementReferenceException):
            # In the case of NoSuchElement, returns true because the element is
            # not present in DOM. The try block checks if the element is present
            # but is invisible.
            # In the case of StaleElementReference, returns true because stale
            # element reference implies that element is no longer visible.
            return not self.__check_status


class Visible(VisibleOf):

    def __init__(self):
        super().__init__(True)


class Invisible(VisibleOf):

    def __init__(self):
        super().__init__(False)


class Existed(object):
    """
    This validator only use to check if element existed, don't care if
    it visible or not.
    """

    def __init__(self):
        pass

    def __call__(self, element):
        return element is not None
<commit_msg>Fixed VisibleAny will return True if element not existed<commit_after># -*- coding: UTF-8 -*-
from .exceptions import StaleElementReferenceException, \
    NoSuchElementException


class StaleOf(object):

    def __init__(self, check_status):
        self.__check_status = check_status

    def __call__(self, element):
        try:
            # Calling any method forces a staleness check
            element.is_enabled()
            return self.__check_status
        except StaleElementReferenceException:
            return not self.__check_status


class Stale(StaleOf):

    def __init__(self):
        super().__init__(True)


class Fresh(StaleOf):

    def __init__(self):
        super().__init__(False)


class VisibleOf(object):

    def __init__(self, check_status):
        self.__check_status = check_status

    def __call__(self, element):
        try:
            return element.is_displayed() == self.__check_status
        except (NoSuchElementException, StaleElementReferenceException):
            # In the case of NoSuchElement, returns true because the element is
            # not present in DOM. The try block checks if the element is present
            # but is invisible.
            # In the case of StaleElementReference, returns true because stale
            # element reference implies that element is no longer visible.
            return not self.__check_status


class VisibleAny(VisibleOf):

    def __init__(self):
        super().__init__(None)

    def __call__(self, element):
        try:
            # Empty statement just check element is valid
            element.is_displayed()
            return True
        except (NoSuchElementException, StaleElementReferenceException):
            # These exceptions are means element disapperred.
            # So it's not in any visible status!
            return False


class Visible(VisibleOf):

    def __init__(self):
        super().__init__(True)


class Invisible(VisibleOf):

    def __init__(self):
        super().__init__(False)


class Existed(object):
    """
    This validator only use to check if element existed, don't care if
    it visible or not.
    """

    def __init__(self):
        pass

    def __call__(self, element):
        return element is not None

{'fraction_non_alphanumeric': 0.06985062066063538, 'fraction_numerical': 0.00042078687144961075, 'mean_word_length': 2.444927536231884, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5375452', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1185, 'n_words': 411}