Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove es-en and en-ie from test files #2571

Merged
merged 5 commits into from
Aug 25, 2021
Merged

Conversation

iCollin
Copy link
Collaborator

@iCollin iCollin commented Aug 19, 2021

ATF Test Scripts to check smartdevicelink/sdl_core#1942

This PR is ready for review.

Summary

Remove invalid languages EN-IE and ES-EN from the policy tables

Script

Since this affected so many files and so many lines I did not want to make the changes by hand, but this became more difficult when I realized the files may use either newline character, and python's open function changes the newline character unless you pass param newline=''

The script is messy but it removed the lines from all files ending in .json and then I manually edited the to_clarify/ files, hence the fixup commit.

import os

all_pts = []

def collect_pts(dir):
    for filename in os.listdir(dir):
        path = os.path.join(dir, filename)
        if filename.endswith(".json"):
            all_pts.append(path)
        elif os.path.isdir(path):
            collect_pts(path)

collect_pts('./')

for pt in all_pts:
    file_lines = []
    with open(pt, "r", newline='') as in_f:
        file_lines = in_f.readlines()
        _lb = file_lines[0][1:]
        if _lb[0] == ' ':
            _lb = _lb[1:]
        print(pt, repr(_lb), len(file_lines))

    writing = True
    with open(pt, "wb") as out_f:
        for i in range(0, len(file_lines)):
            line = file_lines[i]
            if "en-ie" in line or "es-en" in line:
                writing = False
            elif not writing and "}," in line:
                writing = True
                continue

            if writing:
                if line == '}':
                    out_f.write(bytes(line.rstrip("\r\n"), 'utf-8'))
                else:
                    out_f.write(bytes(line.rstrip("\r\n"), 'utf-8') + bytes(_lb, 'utf-8'))

CLA

@iCollin iCollin merged commit 5e5d463 into develop Aug 25, 2021
@iCollin iCollin deleted the fix/remove_languages branch August 25, 2021 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants