# Path: django_sonic_screwdriver/utils/shell.py
# ANSCI_ESCAPE = re.compile(r"\x1b[^m]*m")
# STDERR_WRITER = getwriter("utf-8")(stderr.buffer)
# STDOUT_WRITER = getwriter("utf-8")(stdout.buffer)
#     __HEADER = "\033[95m"
#     __OK_BLUE = "\033[94m"
#     __OK_GREEN = "\033[92m"
#     __WARNING = "\033[93m"
#     __FAIL = "\033[91m"
#     __ENDC = "\033[0m"
#     __BOLD = "\033[1m"
#     __UNDERLINE = "\033[4m"
# def ansi_clean(string):
# def write_to_stream(stream, msg):
#     def msg(self, msg, append_new_line=True):
#     def success(self, msg, append_new_line=True):
#     def warn(self, msg, append_new_line=True):
#     def fail(self, msg, append_new_line=True):
#     def debug(self, msg, append_new_line=True):
#     def __text(self, msg, color):
#     def __out(self, msg, color=None, append_new_line=False):
# class Shell:
# 
# Path: django_sonic_screwdriver/settings.py
# USER_SETTINGS = getattr(settings, "SONIC_SCREWDRIVER", None)
# DEFAULTS = {
#     "DEBUG": False,
#     # Returns file where the version number is located
#     "VERSION_FILE": "setup.py",
#     "RELEASE_SEPARATOR": "",
#     "PATCH_AUTO_TAG": False,
#     # Git
#     "GIT_DIR": settings.BASE_DIR,
#     # Git Tagging
#     "GIT_TAG_AUTO_TAG_PUSH": False,
#     "GIT_STAGING_PRE_TAG": "staging",
#     "GIT_ACTIVATE_PRE_TAG": "activate",
#     "SECURE_TAGGING": True,
#     # App Ban
#     "BAN_REMOTE_ADDR_HEADER": "REMOTE_ADDR",
#     "BAN_DEFAULT_END_TIME": 60 * 60,
# }
# class APISettings(object):
#     def __init__(self, user_settings=None, defaults=None):
#     def __getattr__(self, attr):


import os
import re
import fileinput
from django_sonic_screwdriver.utils import shell
from django_sonic_screwdriver.settings import api_settings
        Return version from setup.py
        """
        with open(
            os.path.join(os.path.abspath(api_settings.VERSION_FILE))
        ) as version_desc:
            version_file = version_desc.read()

            try:
                return re.search(r"version=['\"]([^'\"]+)['\"]", version_file).group(1)
            except FileNotFoundError:  # pragma: no cover
                shell.fail("File not found!")
                raise FileNotFoundError
            except ValueError:  # pragma: no cover
                shell.fail("Version not found in file " + version_file + "!")
                raise ValueError

    @staticmethod
    def set_version(old_version, new_version):
        """
        Write new version into VERSION_FILE
        """
        try:
            if api_settings.DEBUG:
                shell.debug("* " + old_version + " --> " + new_version)
                return True

            for line in fileinput.input(
                os.path.abspath(api_settings.VERSION_FILE), inplace=True
            ):
                print(line.replace(old_version, new_version), end="")

# Path: django_sonic_screwdriver/utils/shell.py
# ANSCI_ESCAPE = re.compile(r"\x1b[^m]*m")
# STDERR_WRITER = getwriter("utf-8")(stderr.buffer)
# STDOUT_WRITER = getwriter("utf-8")(stdout.buffer)
#     __HEADER = "\033[95m"
#     __OK_BLUE = "\033[94m"
#     __OK_GREEN = "\033[92m"
#     __WARNING = "\033[93m"
#     __FAIL = "\033[91m"
#     __ENDC = "\033[0m"
#     __BOLD = "\033[1m"
#     __UNDERLINE = "\033[4m"
# def ansi_clean(string):
# def write_to_stream(stream, msg):
#     def msg(self, msg, append_new_line=True):
#     def success(self, msg, append_new_line=True):
#     def warn(self, msg, append_new_line=True):
#     def fail(self, msg, append_new_line=True):
#     def debug(self, msg, append_new_line=True):
#     def __text(self, msg, color):
#     def __out(self, msg, color=None, append_new_line=False):
# class Shell:
# 
# Path: django_sonic_screwdriver/settings.py
# USER_SETTINGS = getattr(settings, "SONIC_SCREWDRIVER", None)
# DEFAULTS = {
#     "DEBUG": False,
#     # Returns file where the version number is located
#     "VERSION_FILE": "setup.py",
#     "RELEASE_SEPARATOR": "",
#     "PATCH_AUTO_TAG": False,
#     # Git
#     "GIT_DIR": settings.BASE_DIR,
#     # Git Tagging
#     "GIT_TAG_AUTO_TAG_PUSH": False,
#     "GIT_STAGING_PRE_TAG": "staging",
#     "GIT_ACTIVATE_PRE_TAG": "activate",
#     "SECURE_TAGGING": True,
#     # App Ban
#     "BAN_REMOTE_ADDR_HEADER": "REMOTE_ADDR",
#     "BAN_DEFAULT_END_TIME": 60 * 60,
# }
# class APISettings(object):
#     def __init__(self, user_settings=None, defaults=None):
#     def __getattr__(self, attr):


# Path: django_sonic_screwdriver/version.py
import os
import re
import fileinput
from django_sonic_screwdriver.utils import shell
from django_sonic_screwdriver.settings import api_settings

        Return version from setup.py
        """
        with open(
            os.path.join(os.path.abspath(api_settings.VERSION_FILE))
        ) as version_desc:
            version_file = version_desc.read()

            try:
                return re.search(r"version=['\"]([^'\"]+)['\"]", version_file).group(1)
            except FileNotFoundError:  # pragma: no cover
                shell.fail("File not found!")
                raise FileNotFoundError
            except ValueError:  # pragma: no cover
                shell.fail("Version not found in file " + version_file + "!")
                raise ValueError

    @staticmethod
    def set_version(old_version, new_version):
        """
        Write new version into VERSION_FILE
        """
        try:
            if api_settings.DEBUG:
                shell.debug("* " + old_version + " --> " + new_version)
                return True

            for line in fileinput.input(
                os.path.abspath(api_settings.VERSION_FILE), inplace=True
            ):
                print(line.replace(old_version, new_version), end="")

            shell.success("* " + old_version + " --> " + new_version)