Skip to content

Commit 6a70aec

Browse files
authored
Test format of json files (#2651)
1 parent f1be36b commit 6a70aec

File tree

146 files changed

+34086
-33762
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+34086
-33762
lines changed

scripts/fix_data_files.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
import fnmatch
6+
import json
7+
import os
8+
from unittest import TestCase
9+
10+
import jsonpatch
11+
12+
import cfnlint
13+
import cfnlint.core
14+
from cfnlint.helpers import format_json_string
15+
16+
modules = [
17+
"ExtendedSpecs",
18+
"AdditionalSpecs",
19+
"CfnLintCli",
20+
"Serverless",
21+
]
22+
23+
for module in modules:
24+
append_dir = os.path.join(
25+
os.path.dirname(cfnlint.__file__),
26+
"data",
27+
module,
28+
)
29+
for dirpath, _, filenames in os.walk(append_dir):
30+
for filename in fnmatch.filter(filenames, "*.json"):
31+
string_content = ""
32+
with open(os.path.join(dirpath, filename), encoding="utf8") as input_file:
33+
string_content = "".join(input_file.readlines())
34+
35+
pretty_content = format_json_string(json.loads(string_content))
36+
with open(
37+
os.path.join(dirpath, filename), encoding="utf8", mode="w"
38+
) as output_file:
39+
output_file.write(pretty_content)

scripts/install

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import subprocess
1111
import sys
1212
import tarfile
1313
import tempfile
14-
1514
from contextlib import contextmanager
1615

1716
PACKAGES_DIR = os.path.join(

scripts/make-bundle

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ ecosystem.
1313
1414
"""
1515
import os
16-
import sys
17-
import subprocess
1816
import shutil
17+
import subprocess
18+
import sys
1919
import tempfile
2020
import zipfile
2121
from contextlib import contextmanager
2222

23-
2423
EXTRA_RUNTIME_DEPS = [
2524
# Use an up to date virtualenv/pip/setuptools on > 2.6.
2625
('virtualenv', '16.7.8'),

scripts/update_serverless_aws_policies.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@
44
SPDX-License-Identifier: MIT-0
55
"""
66

7+
import json
78
import logging
9+
810
import boto3
9-
import json
1011
from samtranslator.translator.managed_policy_translator import ManagedPolicyLoader
11-
LOGGER = logging.getLogger('cfnlint')
12+
13+
LOGGER = logging.getLogger("cfnlint")
1214

1315

1416
def main():
1517
session = boto3.session.Session()
16-
client = session.client('iam', region_name='us-east-1')
18+
client = session.client("iam", region_name="us-east-1")
1719

1820
policyLoader = ManagedPolicyLoader(client)
1921
policyLoader.load()
2022

21-
filename = 'src/cfnlint/data/Serverless/ManagedPolicies.json'
22-
with open(filename, 'w+', encoding='utf-8') as f:
23-
json.dump(policyLoader._policy_map, f, indent=1, sort_keys=True, separators=(',', ': '))
23+
filename = "src/cfnlint/data/Serverless/ManagedPolicies.json"
24+
with open(filename, "w+", encoding="utf-8") as f:
25+
json.dump(
26+
policyLoader._policy_map,
27+
f,
28+
indent=1,
29+
sort_keys=True,
30+
separators=(",", ": "),
31+
)
2432

2533

26-
if __name__ == '__main__':
34+
if __name__ == "__main__":
2735
try:
2836
main()
2937
except (ValueError, TypeError):

0 commit comments

Comments
 (0)