#!/usr/bin/env python3
import json
import string
import random
import glob, os
import sys


def move_config(path):
    # print("processing content: %s..." % path)
    with open(path, "r", encoding="utf-8") as f:
        # readlines以列表的形式将文件读出
        lines = f.readlines()
    move_finished=0
    with open(path, "w", encoding="utf-8") as f_w:
        for line in lines:
            if "product {" in line:
                move_finished += 1
            if move_finished == 1 and "{" in line:
                move_finished +=1
            if move_finished >1:
                break

            if "'color', 'main_color'" in line:
                color = line.split(",").replace("'","").replace(" ","").replace(")","").replace("'\n","")
                line = line.replace("resValue('color', 'main_color', \"${main_color}\")\n")

            f_w.write(line)
    return


move_config("../../../app/app_config.gradle")