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

Tools - Writeme: Updates to logging #6592

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .tools/readmes/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ def __init__(self, scanner, sdk_ver, safe, svc_folder=None):
self.safe = safe

@staticmethod
def _doc_link(url):
return url if url.startswith("http") else f"{config.doc_base_url}/{url}"
def _doc_link(url_like: str) -> str:
"""Ensures `url_like` is a complete URL; either itself a http(s) URL, or prefixed with `doc_base_url`."""
if url_like.startswith("http"):
return url_like
return f"{config.doc_base_url}/{url_like}"

def _transform_sdk(self):
pre_sdk = self.scanner.sdk()["sdk"][self.sdk_ver]
Expand Down Expand Up @@ -124,9 +127,6 @@ def _transform_hello(self, pre_hello):
"file": self.scanner.snippet(
pre, self.sdk_ver, self.lang_config["service_folder"], api
),
"run_file": self.scanner.snippet(
pre, self.sdk_ver, self.lang_config["service_folder"], ''
),
"api": api,
}
post_hello.append(action)
Expand Down Expand Up @@ -291,7 +291,7 @@ def _scrape_customs(self, readme_filename, sdk_short):

def render(self):
if self.lang_config is None:
return None
return None, False # Return False to indicate no update
sdk = self._transform_sdk()
svc = self._transform_service()
hello = self._transform_hello(self.scanner.hello())
Expand Down Expand Up @@ -327,7 +327,14 @@ def render(self):
unsupported=unsupported,
)
self.readme_text = self._expand_entities(self.readme_text)
return self

# Check if the rendered text is different from the existing file
readme_updated = not self.check()
ford-at-aws marked this conversation as resolved.
Show resolved Hide resolved

# Assign the boolean value to the Renderer instance
self.readme_updated = readme_updated

return self, readme_updated

def write(self):
if self.safe and Path(self.readme_filename).exists():
Expand All @@ -339,7 +346,10 @@ def write(self):
Path(self.readme_filename).unlink(missing_ok=True)
with open(self.readme_filename, "w", encoding="utf-8") as f:
f.write(self.readme_text)
print(f"Updated {self.readme_filename}.")
if self.readme_updated:
print(f"Updated {self.readme_filename}.")
else:
print(f"No updates required for {self.readme_filename}.")

def check(self):
with open(self.readme_filename, "r", encoding="utf-8") as f:
Expand Down
2 changes: 1 addition & 1 deletion .tools/readmes/writeme.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def main():
logging.debug("Rendering %s", id)
renderer = Renderer(scanner, int(version), args.safe)

result = renderer.render()
result, _readme_updated = renderer.render()
if result is None:
logging.info("Render returned empty for %s", id)
skipped.append(id)
Expand Down
2 changes: 1 addition & 1 deletion python/example_code/auto-scaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ functions within the same service.
This example shows you how to get started using Auto Scaling.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ functions within the same service.
This example shows you how to get started using Amazon EC2.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/elastic-load-balancing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ functions within the same service.
This example shows you how to get started using Elastic Load Balancing.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/keyspaces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ functions within the same service.
This example shows you how to get started using Amazon Keyspaces.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/lookoutvision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ python export_datasets.py <project> <destination>
This example shows you how to get started using Lookout for Vision.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/medical-imaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ functions within the same service.
This example shows you how to get started using HealthImaging.

```
python imaging_set_and_frames_workflow/hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/redshift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ functions within the same service.
This example shows you how to get started using Amazon Redshift.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Sample applications that work across multiple AWS services.
This example shows you how to get started using Amazon S3.

```
python s3_basics/hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/ssm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ functions within the same service.
This example shows you how to get started using Systems Manager.

```
python hello.py
python
```


Expand Down
2 changes: 1 addition & 1 deletion python/example_code/support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ functions within the same service.
This example shows you how to get started using Support.

```
python hello.py
python
```


Expand Down
Loading