
import re

LABEL_LENGTH = 255


def is_managed(db_table):
    return False


def model_name_to_snake(value):
    original_model_string = re.findall('[A-Z][^A-Z]*', value)
    holder = ""
    for word in original_model_string:
        holder += word.lower() + "_"
    new_model_string = holder[:-1]
    return new_model_string


def snake_to_model_name(value):
    old_value = value.split('_')
    new_value = ""
    for word in old_value:
        new_value += (word[0].upper() + word[1:])
    return new_value


import re
from django.utils.text import camel_case_to_spaces

LABEL_LENGTH = 255


def is_managed(db_table):
    return False


def model_name_to_snake(value):
    original_model_string = camel_case_to_spaces(value)
    new_model_string = original_model_string.replace(" ", "_")
    return new_model_string


def snake_to_model_name(value):
    old_value = value.split('_')
    new_value = ""
    for word in old_value:
        new_value += (word[0].upper() + word[1:])
    return new_value

Remove Custom Reegex And Use Django Util For Case Conversion
[AC-5010] Remove Custom Reegex And Use Django Util For Case Conversion

This commit uses the django built in to switch from camel case to lower case. Then the loop was removed in favor of replace().

  
  import re
+ from django.utils.text import camel_case_to_spaces
  
  LABEL_LENGTH = 255
  
  
  def is_managed(db_table):
      return False
  
  
  def model_name_to_snake(value):
+     original_model_string = camel_case_to_spaces(value)
+     new_model_string = original_model_string.replace(" ", "_")
-     original_model_string = re.findall('[A-Z][^A-Z]*', value)
-     holder = ""
-     for word in original_model_string:
-         holder += word.lower() + "_"
-     new_model_string = holder[:-1]
      return new_model_string
  
  
  def snake_to_model_name(value):
      old_value = value.split('_')
      new_value = ""
      for word in old_value:
          new_value += (word[0].upper() + word[1:])
      return new_value
  
Remove Custom Reegex And Use Django Util For Case Conversion
## Code Before:

import re

LABEL_LENGTH = 255


def is_managed(db_table):
    return False


def model_name_to_snake(value):
    original_model_string = re.findall('[A-Z][^A-Z]*', value)
    holder = ""
    for word in original_model_string:
        holder += word.lower() + "_"
    new_model_string = holder[:-1]
    return new_model_string


def snake_to_model_name(value):
    old_value = value.split('_')
    new_value = ""
    for word in old_value:
        new_value += (word[0].upper() + word[1:])
    return new_value

## Instruction:
Remove Custom Reegex And Use Django Util For Case Conversion
## Code After:

import re
from django.utils.text import camel_case_to_spaces

LABEL_LENGTH = 255


def is_managed(db_table):
    return False


def model_name_to_snake(value):
    original_model_string = camel_case_to_spaces(value)
    new_model_string = original_model_string.replace(" ", "_")
    return new_model_string


def snake_to_model_name(value):
    old_value = value.split('_')
    new_value = ""
    for word in old_value:
        new_value += (word[0].upper() + word[1:])
    return new_value
