INNER CODE UNIT · Python
convert_hex_to_kotlin_color
wikimedia/apps-android-wikipedia · scripts/generate-codex-colors.py:65
def convert_hex_to_kotlin_color(hex_color):
hex_color = hex_color.lstrip("#")
# handle 3-digit CSS color
if len(hex_color) == 3:
hex_color = ''.join([char * 2 for char in hex_color])
return f"0xFF{hex_color}"
def to_camel_case(text):
# Split on both single and double dashes
parts = re.split(r'-+', text)
if not parts:
return text
# First part will be lowercase, rest are capitalized
return parts[0].lower() + ''.join(word.capitalize() for word in parts[1:] if word)
# colors_dict: the processed codex colors with { name: value } format
# file_path: path where you want to save the file