Ejemplo n.º 1
0
if __name__ == "__main__":
    argv = sys.argv[1:]
    length = len(argv)
    if length != 0:
        input_file = argv[0]
    else:
        print("Error: not enough argument supplied:")
        print("android-compiler.py <input file>")
        exit(0)

TEXT_PLACE_HOLDER = "[TEXT]"
ID_PLACE_HOLDER = "[ID]"

dsl_path = "assets/android-dsl-mapping.json"
compiler = Compiler(dsl_path)


def render_content_with_text(key, value):
    value = value.replace(TEXT_PLACE_HOLDER,
                          Utils.get_random_text(length_text=5, space_number=0))
    while value.find(ID_PLACE_HOLDER) != -1:
        value = value.replace(ID_PLACE_HOLDER, Utils.get_android_id(), 1)
    return value


file_uid = basename(input_file)[:basename(input_file).find(".")]
path = input_file[:input_file.find(file_uid)]

input_file_path = "{}{}.gui".format(path, file_uid)
output_file_path = "{}{}.xml".format(path, file_uid)
Ejemplo n.º 2
0
if __name__ == "__main__":
    argv = sys.argv[1:]
    length = len(argv)
    if length != 0:
        input_file = argv[0]
    else:
        print("Error: not enough argument supplied:")
        print("web-compiler.py <path> <file name>")
        exit(0)

FILL_WITH_RANDOM_TEXT = True
TEXT_PLACE_HOLDER = "[]"

dsl_path = "assets/web-dsl-mapping.json"
compiler = Compiler(dsl_path)


def render_content_with_text(key, value):
    if FILL_WITH_RANDOM_TEXT:
        if key.find("btn") != -1:
            value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text())
        elif key.find("title") != -1:
            value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text(length_text=5, space_number=0))
        elif key.find("text") != -1:
            value = value.replace(TEXT_PLACE_HOLDER,
                                  Utils.get_random_text(length_text=56, space_number=7, with_upper_case=False))
    return value

file_uid = basename(input_file)[:basename(input_file).find(".")]
path = input_file[:input_file.find(file_uid)]
Ejemplo n.º 3
0
        if (key.find("button") != -1):
            value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text())

        elif (key.find("CodeSnippet") != -1):
            value = value.replace(
                TEXT_PLACE_HOLDER,
                Utils.get_random_text(length_text=30,
                                      space_number=7,
                                      with_upper_case=False))

        elif (key.find("Search") != -1):
            value = value.replace(
                TEXT_PLACE_HOLDER,
                Utils.get_random_text(length_text=35,
                                      space_number=7,
                                      with_upper_case=False))
    return value


dsl_path = "assets/carbon-dsl-mapping.json"
compiler = Compiler(dsl_path)
FILL_WITH_RANDOM_TEXT = True
TEXT_PLACE_HOLDER = "[]"
file_uid = basename(input_file)[:basename(input_file).find(".")]
path = input_file[:input_file.find(file_uid)]
input_file_path = "{}{}.gui".format(path, file_uid)
output_file_path = "{}{}.xml".format(path, file_uid)
#compiler.compile("[ 'text-input-basic', ',', ',', 'text-input-basic', '}', 'text-input-basic', 'text-input-basic', 'text-input-basic', 'text-input-basic', ", output_file_path)
compiler.compile(
    "  text-input-basic  , text-input-basic , text-input-basic , text-input-basic   ",
    output_file_path)
Ejemplo n.º 4
0
if __name__ == "__main__":
    argv = sys.argv[1:]
    length = len(argv)
    if length != 0:
        input_file = argv[0]
    else:
        print("Error: not enough argument supplied:")
        print("android-compiler.py <input file>")
        exit(0)

TEXT_PLACE_HOLDER = "[TEXT]"
ID_PLACE_HOLDER = "[ID]"

dsl_path = "assets/android-dsl-mapping.json"
compiler = Compiler(dsl_path)


def render_content_with_text(key, value):
    value = value.replace(TEXT_PLACE_HOLDER, Utils.get_random_text(length_text=5, space_number=0))
    while value.find(ID_PLACE_HOLDER) != -1:
        value = value.replace(ID_PLACE_HOLDER, Utils.get_android_id(), 1)
    return value

file_uid = basename(input_file)[:basename(input_file).find(".")]
path = input_file[:input_file.find(file_uid)]

input_file_path = "{}{}.gui".format(path, file_uid)
output_file_path = "{}{}.xml".format(path, file_uid)

compiler.compile(input_file_path, output_file_path)