# Path: gitmostwanted/app.py

# 
# Path: gitmostwanted/lib/regex.py
# class SearchTerm:
#     pattern = r'^[\w.-]{3,}$'
# 
#     def __init__(self, term: str):
#         if re.match(self.pattern, term) is None:
#             raise ValueError('The "{}" term is not suitable'.format(term))
#         self.__term = term
# 
#     def __str__(self):
#         return '%{}%'.format(self.__term)
# 
# Path: gitmostwanted/lib/status.py
# class Status:
#     def __init__(self, status: str):
#         if status not in ('promising', 'new', 'unknown', 'deleted', 'hopeless'):
#             raise ValueError('Unknown status')
#         self.__status = status
# 
#     def __str__(self):
#         return self.__status
# 
# Path: gitmostwanted/lib/text.py
# class TextWithoutSmilies:
#     pattern = r'\s*:[a-z0-9_-]+:\s*'
# 
#     def __init__(self, text: str):
#         self.__text = text
# 
#     def __str__(self):
#         return re.sub(self.pattern, ' ', self.__text).strip()
# 
# class TextNormalized:
#     def __init__(self, text: str):
#         self.__text = unicodedata.normalize('NFC', text)
# 
#     def __str__(self):
#         return self.__text.encode(errors='ignore').decode()
# 
# Path: gitmostwanted/lib/url.py
# class Url:
#     def __init__(self, url: str):
#         url = url.strip()
#         if url.find('://') == -1:
#             url = '//' + url
#         self.__url = urlparse(url, 'http')
# 
#     def __str__(self):
#         return self.__url.geturl()


from datetime import datetime
from sqlalchemy.dialects.mysql import INTEGER, SMALLINT
from sqlalchemy.sql import expression
from werkzeug.datastructures import ImmutableMultiDict
from gitmostwanted.app import app, db
from gitmostwanted.lib.regex import SearchTerm
from gitmostwanted.lib.status import Status
from gitmostwanted.lib.text import TextWithoutSmilies, TextNormalized
from gitmostwanted.lib.url import Url
    license = db.Column(db.String(20), index=True)
    last_reset_at = db.Column(db.DateTime, index=True)
    mature = db.Column(db.Boolean, nullable=False, server_default=expression.false(), index=True)
    name = db.Column(db.String(80), nullable=False)
    open_issues_count = db.Column(INTEGER(unsigned=True), nullable=False, server_default='0')
    size = db.Column(INTEGER(unsigned=True), nullable=False, server_default='0')
    stargazers_count = db.Column(
        INTEGER(unsigned=True), nullable=False, server_default='0', index=True
    )
    status = db.Column(
        db.Enum('promising', 'new', 'unknown', 'deleted', 'hopeless'),
        server_default='new', nullable=False, index=True
    )
    status_updated_at = db.Column(db.DateTime)
    subscribers_count = db.Column(
        INTEGER(unsigned=True), nullable=False, server_default='0', index=True
    )
    topics = db.relationship(RepoTopics, cascade='all, delete-orphan')
    worth = db.Column(
        SMALLINT(display_width=2), index=True, nullable=False,
        server_default=str(app.config['REPOSITORY_WORTH_DEFAULT'])
    )
    worth_max = db.Column(SMALLINT(display_width=2), nullable=False, server_default='0')

    def __setattr__(self, key, value):
        if key == 'status' and self.status != value:
            value = str(Status(value))
            self.status_updated_at = datetime.now()

        if key == 'homepage':

# Path: gitmostwanted/app.py

# 
# Path: gitmostwanted/lib/regex.py
# class SearchTerm:
#     pattern = r'^[\w.-]{3,}$'
# 
#     def __init__(self, term: str):
#         if re.match(self.pattern, term) is None:
#             raise ValueError('The "{}" term is not suitable'.format(term))
#         self.__term = term
# 
#     def __str__(self):
#         return '%{}%'.format(self.__term)
# 
# Path: gitmostwanted/lib/status.py
# class Status:
#     def __init__(self, status: str):
#         if status not in ('promising', 'new', 'unknown', 'deleted', 'hopeless'):
#             raise ValueError('Unknown status')
#         self.__status = status
# 
#     def __str__(self):
#         return self.__status
# 
# Path: gitmostwanted/lib/text.py
# class TextWithoutSmilies:
#     pattern = r'\s*:[a-z0-9_-]+:\s*'
# 
#     def __init__(self, text: str):
#         self.__text = text
# 
#     def __str__(self):
#         return re.sub(self.pattern, ' ', self.__text).strip()
# 
# class TextNormalized:
#     def __init__(self, text: str):
#         self.__text = unicodedata.normalize('NFC', text)
# 
#     def __str__(self):
#         return self.__text.encode(errors='ignore').decode()
# 
# Path: gitmostwanted/lib/url.py
# class Url:
#     def __init__(self, url: str):
#         url = url.strip()
#         if url.find('://') == -1:
#             url = '//' + url
#         self.__url = urlparse(url, 'http')
# 
#     def __str__(self):
#         return self.__url.geturl()


# Path: gitmostwanted/models/repo.py
from datetime import datetime
from sqlalchemy.dialects.mysql import INTEGER, SMALLINT
from sqlalchemy.sql import expression
from werkzeug.datastructures import ImmutableMultiDict
from gitmostwanted.app import app, db
from gitmostwanted.lib.regex import SearchTerm
from gitmostwanted.lib.status import Status
from gitmostwanted.lib.text import TextWithoutSmilies, TextNormalized
from gitmostwanted.lib.url import Url

    license = db.Column(db.String(20), index=True)
    last_reset_at = db.Column(db.DateTime, index=True)
    mature = db.Column(db.Boolean, nullable=False, server_default=expression.false(), index=True)
    name = db.Column(db.String(80), nullable=False)
    open_issues_count = db.Column(INTEGER(unsigned=True), nullable=False, server_default='0')
    size = db.Column(INTEGER(unsigned=True), nullable=False, server_default='0')
    stargazers_count = db.Column(
        INTEGER(unsigned=True), nullable=False, server_default='0', index=True
    )
    status = db.Column(
        db.Enum('promising', 'new', 'unknown', 'deleted', 'hopeless'),
        server_default='new', nullable=False, index=True
    )
    status_updated_at = db.Column(db.DateTime)
    subscribers_count = db.Column(
        INTEGER(unsigned=True), nullable=False, server_default='0', index=True
    )
    topics = db.relationship(RepoTopics, cascade='all, delete-orphan')
    worth = db.Column(
        SMALLINT(display_width=2), index=True, nullable=False,
        server_default=str(app.config['REPOSITORY_WORTH_DEFAULT'])
    )
    worth_max = db.Column(SMALLINT(display_width=2), nullable=False, server_default='0')

    def __setattr__(self, key, value):
        if key == 'status' and self.status != value:
            value = str(Status(value))
            self.status_updated_at = datetime.now()

        if key == 'homepage':

            value = str(Url(value[:150])) if value else None