#  Copyright (C) 2023
#  ABM, Moscow
#
#  UNPUBLISHED PROPRIETARY MATERIAL.
#  ALL RIGHTS RESERVED.
#
#  Authors: Vasya Svintsov <v.svintsov@techokert.ru>

import re


def camel_case_to_underscore(raw_string: str) -> str:
    string = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', raw_string)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', string).lower()

