cfn-check 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cfn-check might be problematic. Click here for more details.

@@ -1,6 +1,7 @@
1
1
 
2
2
  import asyncio
3
3
  import os
4
+ import pathlib
4
5
  import yaml
5
6
  from cfn_check.loader.loader import (
6
7
  Loader,
@@ -9,23 +10,62 @@ from cfn_check.loader.loader import (
9
10
  )
10
11
  from cfn_check.shared.types import YamlObject, Data
11
12
 
12
- def open_template(path: str) -> YamlObject | Exception:
13
+ def open_template(path: str) -> YamlObject | None:
14
+
15
+ if os.path.exists(path) is False:
16
+ return None
17
+
13
18
  try:
14
19
  with open(path, 'r') as f:
15
20
  return yaml.load(f, Loader=Loader)
16
- except (Exception, ) as e:
21
+ except Exception as e:
17
22
  raise e
18
23
 
19
24
  def is_file(path: str) -> bool:
20
25
  return os.path.isdir(path) is False
21
26
 
22
27
 
28
+ async def path_exists(path: str, loop: asyncio.AbstractEventLoop):
29
+ return await loop.run_in_executor(
30
+ None,
31
+ os.path.exists,
32
+ path,
33
+ )
34
+
35
+ async def convert_to_cwd(loop: asyncio.AbstractEventLoop):
36
+ return await loop.run_in_executor(
37
+ None,
38
+ os.getcwd,
39
+ )
40
+
41
+ async def localize_path(path: str, loop: asyncio.AbstractEventLoop):
42
+ localized = path.replace('~/', '')
43
+
44
+ home_directory = await loop.run_in_executor(
45
+ None,
46
+ pathlib.Path.home,
47
+ )
48
+
49
+ return await loop.run_in_executor(
50
+ None,
51
+ os.path.join,
52
+ home_directory,
53
+ localized,
54
+ )
55
+
23
56
  async def load_templates(
24
57
  path: str,
25
58
  tags: list[str],
26
59
  file_pattern: str | None = None,
27
60
  ):
61
+
28
62
  loop = asyncio.get_event_loop()
63
+
64
+ if path == '.':
65
+ path = await convert_to_cwd(loop)
66
+
67
+ elif path.startswith('~/'):
68
+ path = await localize_path(path, loop)
29
69
 
30
70
  if await loop.run_in_executor(
31
71
  None,
@@ -36,6 +76,8 @@ async def load_templates(
36
76
  path,
37
77
  ]
38
78
 
79
+ assert await path_exists(path, loop) is True, f'❌ Template at {path} does not exist'
80
+
39
81
  elif file_pattern:
40
82
 
41
83
  template_filepaths = await loop.run_in_executor(
@@ -65,4 +107,10 @@ async def load_templates(
65
107
  ) for template_path in template_filepaths
66
108
  ])
67
109
 
110
+ found_templates = [
111
+ template for template in templates if template is not None
112
+ ]
113
+
114
+ assert len(found_templates) > 0, "❌ Could not open any templates"
115
+
68
116
  return templates
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cfn-check
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Validate Cloud Formation
5
5
  Author-email: Ada Lundhe <adalundhe@lundhe.audio>
6
6
  License: MIT License
@@ -235,13 +235,13 @@ This represents a basic configuration for an AWS Lambda function.
235
235
  Finally, run:
236
236
 
237
237
  ```bash
238
- cfn-lint validate -r rules.py template.yaml
238
+ cfn-check validate -r rules.py template.yaml
239
239
  ```
240
240
 
241
241
  which outputs:
242
242
 
243
243
  ```
244
- 2025-09-17T01:46:41.542078+00:00 - INFO - 19783474 - /Users/adalundhe/Documents/Duckbill/cfn-check/cfn_check/cli/validate.py:validate.80 - ✅ 1 validations met for 1 templates
244
+ 2025-09-17T01:46:41.542078+00:00 - INFO - 19783474 - /Users/adalundhe/Documents/adalundhe/cfn-check/cfn_check/cli/validate.py:validate.80 - ✅ 1 validations met for 1 templates
245
245
  ```
246
246
 
247
247
  Congrats! You've just made the cloud a bit better place!
@@ -4,7 +4,7 @@ cfn_check/cli/root.py,sha256=dHq9zzXyj-Wrj-fzirtFjptShzWbBGsO3n9tspm-pec,1688
4
4
  cfn_check/cli/validate.py,sha256=e20Hyfs3GJSrBbMRPt8dy3L0yjVnYo36ol_zOVhZco8,2013
5
5
  cfn_check/cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  cfn_check/cli/utils/attributes.py,sha256=iIUIgl6cT5XEUOW7D54-xxmMpTis84ySQY1b9osB47E,339
7
- cfn_check/cli/utils/files.py,sha256=W2lf42qAlTOJ-YJeBWsK99FjnsxZtmit241cLyURg2A,1448
7
+ cfn_check/cli/utils/files.py,sha256=QMYYR7C7mXdDx_6jj1Ye9w7ol1twAzUEZ9hxSa-O4-k,2563
8
8
  cfn_check/collection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  cfn_check/collection/collection.py,sha256=wNxahoOqQge3C56blz5VtOq6lX5MZ9F2JjQIyZ3_SxU,27
10
10
  cfn_check/evaluation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -22,10 +22,10 @@ cfn_check/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
22
22
  cfn_check/shared/types.py,sha256=-om3DyZsjK_tJd-I8SITkoE55W0nB2WA3LOc87Cs7xI,414
23
23
  cfn_check/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  cfn_check/validation/validator.py,sha256=FGPeb8Uc8lvX3Y5rs-fxeJKIOqzUXwXh_gCFcy6d3b0,1182
25
- cfn_check-0.2.0.dist-info/licenses/LICENSE,sha256=EbCpGNzOkyQ53ig7J2Iwgmy4Og0dgHe8COo3WylhIKk,1069
25
+ cfn_check-0.2.2.dist-info/licenses/LICENSE,sha256=EbCpGNzOkyQ53ig7J2Iwgmy4Og0dgHe8COo3WylhIKk,1069
26
26
  example/rules.py,sha256=XVsOkY5gxEier6oVyMVwuJ3ftwbv987udEkg2qZe_Zs,369
27
- cfn_check-0.2.0.dist-info/METADATA,sha256=cDvMHGXpDG6Fb28nO7GCkdc_kKVo19RnuHLfoeprJ1E,8471
28
- cfn_check-0.2.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
29
- cfn_check-0.2.0.dist-info/entry_points.txt,sha256=B4lCHoDHmwisABxKgRLShwqqFv7QwwDAFXoAChOnkwg,53
30
- cfn_check-0.2.0.dist-info/top_level.txt,sha256=hUn9Ya50yY1fpgWxEhG5iMgfMDDVX7qWQnM1xrgZnhM,18
31
- cfn_check-0.2.0.dist-info/RECORD,,
27
+ cfn_check-0.2.2.dist-info/METADATA,sha256=ed2EjVEAiPHoas5_4KKQjrX7Mx0Pe4sSQPI7fM99qeo,8473
28
+ cfn_check-0.2.2.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
29
+ cfn_check-0.2.2.dist-info/entry_points.txt,sha256=B4lCHoDHmwisABxKgRLShwqqFv7QwwDAFXoAChOnkwg,53
30
+ cfn_check-0.2.2.dist-info/top_level.txt,sha256=hUn9Ya50yY1fpgWxEhG5iMgfMDDVX7qWQnM1xrgZnhM,18
31
+ cfn_check-0.2.2.dist-info/RECORD,,