<commit_before>import re
from collections import namedtuple

from django.utils.translation import ugettext_lazy as _


# Add-on and File statuses.
STATUS_NULL = 0  # No review type chosen yet, add-on is incomplete.
STATUS_AWAITING_REVIEW = 1  # File waiting for review.
_STATUS_PENDING = 2  # Deprecated. Was Personas waiting for review.
STATUS_NOMINATED = 3  # Waiting for review.
STATUS_APPROVED = 4  # Approved.
STATUS_DISABLED = 5  # Rejected (single files) or disabled by Mozilla (addons).
_STATUS_LISTED = 6  # Deprecated. See bug 616242
_STATUS_BETA = 7  # Deprecated, see addons-server/issues/7163
_STATUS_LITE = 8  # Deprecated, preliminary reviewed.
_STATUS_LITE_AND_NOMINATED = 9  # Deprecated, prelim & waiting for full review.
STATUS_DELETED = 11  # Add-on has been deleted.
_STATUS_REJECTED = 12  # Deprecated. Applied only to rejected personas.
_STATUS_REVIEW_PENDING = 14  # Deprecated. Was personas, needing further action

STATUS_CHOICES_ADDON = {
    STATUS_NULL: _(u'Incomplete'),
    STATUS_NOMINATED: _(u'Awaiting Review'),
    STATUS_APPROVED: _(u'Approved'),
    STATUS_DISABLED: _(u'Disabled by Mozilla'),
    STATUS_DELETED: _(u'Deleted'),
}

STATUS_CHOICES_FILE = {
    STATUS_AWAITING_REVIEW: _(u'Awaiting Review'),
    STATUS_APPROVED: _(u'Approved'),
    STATUS_DISABLED: _(u'Disabled by Mozilla'),
}

# We need to expose nice values that aren't localisable.
STATUS_CHOICES_API = {
    STATUS_NULL: 'incomplete',
    STATUS_AWAITING_REVIEW: 'unreviewed',
    STATUS_NOMINATED: 'nominated',
    STATUS_APPROVED: 'public',
    STATUS_DISABLED: 'disabled',
    STATUS_DELETED: 'deleted',
}

STATUS_CHOICES_API_LOOKUP = {
    'incomplete': STATUS_NULL,
    'unreviewed': STATUS_AWAITING_REVIEW,
    'nominated': STATUS_NOMINATED,
    'public': STATUS_APPROVED,
    'disabled': STATUS_DISABLED,
    'deleted': STATUS_DELETED,
}

REVIEWED_STATUSES = (STATUS_APPROVED,)
UNREVIEWED_ADDON_STATUSES = (STATUS_NOMINATED,)
UNREVIEWED_FILE_STATUSES = (STATUS_AWAITING_REVIEW,)
VALID_ADDON_STATUSES = (STATUS_NOMINATED, STATUS_APPROVED)
VALID_FILE_STATUSES = (STATUS_AWAITING_REVIEW, STATUS_APPROVED)

# Version channels
RELEASE_CHANNEL_UNLISTED = 1
RELEASE_CHANNEL_LISTED = 2

RELEASE_CHANNEL_CHOICES = (
    (RELEASE_CHANNEL_UNLISTED, _(u'Unlisted')),
    (RELEASE_CHANNEL_LISTED, _(u'Listed')),
)

CHANNEL_CHOICES_API = {
    RELEASE_CHANNEL_UNLISTED: 'unlisted',
    RELEASE_CHANNEL_LISTED: 'listed',
}

CHANNEL_CHOICES_LOOKUP = {
    'unlisted': RELEASE_CHANNEL_UNLISTED,
    'listed': RELEASE_CHANNEL_LISTED,
}

# Add-on author roles.
AUTHOR_ROLE_DEV = 4
AUTHOR_ROLE_OWNER = 5

AUTHOR_CHOICES = (
    (AUTHOR_ROLE_OWNER, _(u'Owner')),
    (AUTHOR_ROLE_DEV, _(u'Developer')),
)

# Addon types
ADDON_ANY = 0
ADDON_EXTENSION = 1
_ADDON_THEME = 2
ADDON_DICT = 3
ADDON_SEARCH = 4
ADDON_LPAPP = 5
ADDON_LPADDON = 6
ADDON_PLUGIN = 7
ADDON_API = 8  # not actually a type but used to identify extensions + themes
_ADDON_PERSONA = 9  # Deprecated.  Aka Lightweight Themes.
ADDON_STATICTHEME = 10
_ADDON_WEBAPP = 11  # Deprecated.  Marketplace cruft.

# Addon type groupings.
GROUP_TYPE_ADDON = [ADDON_EXTENSION, ADDON_DICT, ADDON_SEARCH, ADDON_LPAPP,
                    ADDON_LPADDON, ADDON_PLUGIN, ADDON_API]
GROUP_TYPE_THEME = [ADDON_STATICTHEME]

# Singular
ADDON_TYPE = {
    ADDON_EXTENSION: _(u'Extension'),
    _ADDON_THEME: _(u'Deprecated Complete Theme'),
    ADDON_DICT: _(u'Dictionary'),
    ADDON_SEARCH: _(u'Search Engine'),
    ADDON_LPAPP: _(u'Language Pack (Application)'),
    ADDON_LPADDON: _(u'Language Pack (Add-on)'),
    ADDON_PLUGIN: _(u'Plugin'),
    _ADDON_PERSONA: _(u'Deprecated LWT'),
    ADDON_STATICTHEME: _(u'Theme (Static)'),
}

# Plural
ADDON_TYPES = {
    ADDON_EXTENSION: _(u'Extensions'),
    _ADDON_THEME: _(u'Deprecated Complete Themes'),
    ADDON_DICT: _(u'Dictionaries'),
    ADDON_SEARCH: _(u'Search Tools'),
    ADDON_LPAPP: _(u'Language Packs (Application)'),
    ADDON_LPADDON: _(u'Language Packs (Add-on)'),
    ADDON_PLUGIN: _(u'Plugins'),
    _ADDON_PERSONA: _(u'Deprecated LWTs'),
    ADDON_STATICTHEME: _(u'Themes (Static)'),
}

# Searchable Add-on Types
ADDON_SEARCH_TYPES = [
    ADDON_ANY,
    ADDON_EXTENSION,
    _ADDON_THEME,
    ADDON_DICT,
    ADDON_SEARCH,
    ADDON_LPAPP,
    _ADDON_PERSONA,
    ADDON_STATICTHEME,
]

# We use these slugs in browse page urls.
ADDON_SLUGS = {
    ADDON_EXTENSION: 'extensions',
    ADDON_DICT: 'language-tools',
    ADDON_LPAPP: 'language-tools',
    ADDON_SEARCH: 'search-tools',
    ADDON_STATICTHEME: 'themes',
}

# These are used in the update API.
ADDON_SLUGS_UPDATE = {
    ADDON_EXTENSION: 'extension',
    _ADDON_THEME: 'theme',
    ADDON_DICT: 'extension',
    ADDON_SEARCH: 'search',
    ADDON_LPAPP: 'item',
    ADDON_LPADDON: 'extension',
    _ADDON_PERSONA: 'background-theme',
    ADDON_PLUGIN: 'plugin',
    ADDON_STATICTHEME: 'static-theme',
}

# A slug to ID map for the search API. Included are all ADDON_TYPES that are
# found in ADDON_SEARCH_TYPES.
ADDON_SEARCH_SLUGS = {
    'any': ADDON_ANY,
    'extension': ADDON_EXTENSION,
    'theme': _ADDON_THEME,
    'dictionary': ADDON_DICT,
    'search': ADDON_SEARCH,
    'language': ADDON_LPAPP,
    'persona': _ADDON_PERSONA,
    'statictheme': ADDON_STATICTHEME,
}

ADDON_TYPE_CHOICES_API = {
    ADDON_EXTENSION: 'extension',
    _ADDON_THEME: 'theme',
    ADDON_DICT: 'dictionary',
    ADDON_SEARCH: 'search',
    ADDON_LPAPP: 'language',
    _ADDON_PERSONA: 'persona',
    ADDON_STATICTHEME: 'statictheme',
}

# Edit addon information
MAX_TAGS = 20
MIN_TAG_LENGTH = 2
MAX_CATEGORIES = 2
CONTRIBUTE_UTM_PARAMS = {
    'utm_content': 'product-page-contribute',
    'utm_medium': 'referral',
    'utm_source': 'addons.mozilla.org'}
VALID_CONTRIBUTION_DOMAINS = (
    'donate.mozilla.org',
    'flattr.com',
    'liberapay.com',
    'micropayment.de',
    'opencollective.com',
    'patreon.com',<commit_msg>Added BuyMeACoffee in Contributors domain (#13231)<commit_after>import re
from collections import namedtuple

from django.utils.translation import ugettext_lazy as _


# Add-on and File statuses.
STATUS_NULL = 0  # No review type chosen yet, add-on is incomplete.
STATUS_AWAITING_REVIEW = 1  # File waiting for review.
_STATUS_PENDING = 2  # Deprecated. Was Personas waiting for review.
STATUS_NOMINATED = 3  # Waiting for review.
STATUS_APPROVED = 4  # Approved.
STATUS_DISABLED = 5  # Rejected (single files) or disabled by Mozilla (addons).
_STATUS_LISTED = 6  # Deprecated. See bug 616242
_STATUS_BETA = 7  # Deprecated, see addons-server/issues/7163
_STATUS_LITE = 8  # Deprecated, preliminary reviewed.
_STATUS_LITE_AND_NOMINATED = 9  # Deprecated, prelim & waiting for full review.
STATUS_DELETED = 11  # Add-on has been deleted.
_STATUS_REJECTED = 12  # Deprecated. Applied only to rejected personas.
_STATUS_REVIEW_PENDING = 14  # Deprecated. Was personas, needing further action

STATUS_CHOICES_ADDON = {
    STATUS_NULL: _(u'Incomplete'),
    STATUS_NOMINATED: _(u'Awaiting Review'),
    STATUS_APPROVED: _(u'Approved'),
    STATUS_DISABLED: _(u'Disabled by Mozilla'),
    STATUS_DELETED: _(u'Deleted'),
}

STATUS_CHOICES_FILE = {
    STATUS_AWAITING_REVIEW: _(u'Awaiting Review'),
    STATUS_APPROVED: _(u'Approved'),
    STATUS_DISABLED: _(u'Disabled by Mozilla'),
}

# We need to expose nice values that aren't localisable.
STATUS_CHOICES_API = {
    STATUS_NULL: 'incomplete',
    STATUS_AWAITING_REVIEW: 'unreviewed',
    STATUS_NOMINATED: 'nominated',
    STATUS_APPROVED: 'public',
    STATUS_DISABLED: 'disabled',
    STATUS_DELETED: 'deleted',
}

STATUS_CHOICES_API_LOOKUP = {
    'incomplete': STATUS_NULL,
    'unreviewed': STATUS_AWAITING_REVIEW,
    'nominated': STATUS_NOMINATED,
    'public': STATUS_APPROVED,
    'disabled': STATUS_DISABLED,
    'deleted': STATUS_DELETED,
}

REVIEWED_STATUSES = (STATUS_APPROVED,)
UNREVIEWED_ADDON_STATUSES = (STATUS_NOMINATED,)
UNREVIEWED_FILE_STATUSES = (STATUS_AWAITING_REVIEW,)
VALID_ADDON_STATUSES = (STATUS_NOMINATED, STATUS_APPROVED)
VALID_FILE_STATUSES = (STATUS_AWAITING_REVIEW, STATUS_APPROVED)

# Version channels
RELEASE_CHANNEL_UNLISTED = 1
RELEASE_CHANNEL_LISTED = 2

RELEASE_CHANNEL_CHOICES = (
    (RELEASE_CHANNEL_UNLISTED, _(u'Unlisted')),
    (RELEASE_CHANNEL_LISTED, _(u'Listed')),
)

CHANNEL_CHOICES_API = {
    RELEASE_CHANNEL_UNLISTED: 'unlisted',
    RELEASE_CHANNEL_LISTED: 'listed',
}

CHANNEL_CHOICES_LOOKUP = {
    'unlisted': RELEASE_CHANNEL_UNLISTED,
    'listed': RELEASE_CHANNEL_LISTED,
}

# Add-on author roles.
AUTHOR_ROLE_DEV = 4
AUTHOR_ROLE_OWNER = 5

AUTHOR_CHOICES = (
    (AUTHOR_ROLE_OWNER, _(u'Owner')),
    (AUTHOR_ROLE_DEV, _(u'Developer')),
)

# Addon types
ADDON_ANY = 0
ADDON_EXTENSION = 1
_ADDON_THEME = 2
ADDON_DICT = 3
ADDON_SEARCH = 4
ADDON_LPAPP = 5
ADDON_LPADDON = 6
ADDON_PLUGIN = 7
ADDON_API = 8  # not actually a type but used to identify extensions + themes
_ADDON_PERSONA = 9  # Deprecated.  Aka Lightweight Themes.
ADDON_STATICTHEME = 10
_ADDON_WEBAPP = 11  # Deprecated.  Marketplace cruft.

# Addon type groupings.
GROUP_TYPE_ADDON = [ADDON_EXTENSION, ADDON_DICT, ADDON_SEARCH, ADDON_LPAPP,
                    ADDON_LPADDON, ADDON_PLUGIN, ADDON_API]
GROUP_TYPE_THEME = [ADDON_STATICTHEME]

# Singular
ADDON_TYPE = {
    ADDON_EXTENSION: _(u'Extension'),
    _ADDON_THEME: _(u'Deprecated Complete Theme'),
    ADDON_DICT: _(u'Dictionary'),
    ADDON_SEARCH: _(u'Search Engine'),
    ADDON_LPAPP: _(u'Language Pack (Application)'),
    ADDON_LPADDON: _(u'Language Pack (Add-on)'),
    ADDON_PLUGIN: _(u'Plugin'),
    _ADDON_PERSONA: _(u'Deprecated LWT'),
    ADDON_STATICTHEME: _(u'Theme (Static)'),
}

# Plural
ADDON_TYPES = {
    ADDON_EXTENSION: _(u'Extensions'),
    _ADDON_THEME: _(u'Deprecated Complete Themes'),
    ADDON_DICT: _(u'Dictionaries'),
    ADDON_SEARCH: _(u'Search Tools'),
    ADDON_LPAPP: _(u'Language Packs (Application)'),
    ADDON_LPADDON: _(u'Language Packs (Add-on)'),
    ADDON_PLUGIN: _(u'Plugins'),
    _ADDON_PERSONA: _(u'Deprecated LWTs'),
    ADDON_STATICTHEME: _(u'Themes (Static)'),
}

# Searchable Add-on Types
ADDON_SEARCH_TYPES = [
    ADDON_ANY,
    ADDON_EXTENSION,
    _ADDON_THEME,
    ADDON_DICT,
    ADDON_SEARCH,
    ADDON_LPAPP,
    _ADDON_PERSONA,
    ADDON_STATICTHEME,
]

# We use these slugs in browse page urls.
ADDON_SLUGS = {
    ADDON_EXTENSION: 'extensions',
    ADDON_DICT: 'language-tools',
    ADDON_LPAPP: 'language-tools',
    ADDON_SEARCH: 'search-tools',
    ADDON_STATICTHEME: 'themes',
}

# These are used in the update API.
ADDON_SLUGS_UPDATE = {
    ADDON_EXTENSION: 'extension',
    _ADDON_THEME: 'theme',
    ADDON_DICT: 'extension',
    ADDON_SEARCH: 'search',
    ADDON_LPAPP: 'item',
    ADDON_LPADDON: 'extension',
    _ADDON_PERSONA: 'background-theme',
    ADDON_PLUGIN: 'plugin',
    ADDON_STATICTHEME: 'static-theme',
}

# A slug to ID map for the search API. Included are all ADDON_TYPES that are
# found in ADDON_SEARCH_TYPES.
ADDON_SEARCH_SLUGS = {
    'any': ADDON_ANY,
    'extension': ADDON_EXTENSION,
    'theme': _ADDON_THEME,
    'dictionary': ADDON_DICT,
    'search': ADDON_SEARCH,
    'language': ADDON_LPAPP,
    'persona': _ADDON_PERSONA,
    'statictheme': ADDON_STATICTHEME,
}

ADDON_TYPE_CHOICES_API = {
    ADDON_EXTENSION: 'extension',
    _ADDON_THEME: 'theme',
    ADDON_DICT: 'dictionary',
    ADDON_SEARCH: 'search',
    ADDON_LPAPP: 'language',
    _ADDON_PERSONA: 'persona',
    ADDON_STATICTHEME: 'statictheme',
}

# Edit addon information
MAX_TAGS = 20
MIN_TAG_LENGTH = 2
MAX_CATEGORIES = 2
CONTRIBUTE_UTM_PARAMS = {
    'utm_content': 'product-page-contribute',
    'utm_medium': 'referral',
    'utm_source': 'addons.mozilla.org'}
VALID_CONTRIBUTION_DOMAINS = (
    'buymeacoffee.com',
    'donate.mozilla.org',
    'flattr.com',
    'liberapay.com',
    'micropayment.de',
    'opencollective.com',
    'patreon.com',
{'fraction_non_alphanumeric': 0.10816067653276956, 'fraction_numerical': 0.00854122621564482, 'mean_word_length': 4.573044297832234, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4866569', 'n_tokens_mistral': 4711, 'n_tokens_neox': 4523, 'n_words': 907}