-
Notifications
You must be signed in to change notification settings - Fork 516
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
chore: add indy deprecation warnings #2332
Merged
swcurran
merged 8 commits into
openwallet-foundation:main
from
dbluhm:chore/indy-deprecation-warning
Jul 21, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
06263f8
chore: add indy deprecation warnings
dbluhm 80954c9
Update aries_cloudagent/config/logging.py
dbluhm ec06325
Merge branch 'main' into chore/indy-deprecation-warning
dbluhm 50de457
feat: more noticeable deprecation notice
dbluhm ff11945
chore: point to migration doc in deprecation warnings
dbluhm 0649f58
fix: flake8 errors
dbluhm 6cd1d5d
docs: add placeholder migration doc
dbluhm 7486ffa
Merge branch 'main' into chore/indy-deprecation-warning
dbluhm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Migrating from Indy SDK to Askar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,128 @@ | ||
"""Module to contain logic to generate the banner for ACA-py.""" | ||
|
||
|
||
class Banner: | ||
from contextlib import contextmanager | ||
from enum import Enum, auto | ||
import sys | ||
import textwrap | ||
from typing import Optional, TextIO | ||
|
||
|
||
@contextmanager | ||
def Banner(border: str, length: int, file: Optional[TextIO] = None): | ||
"""Context manager to generate a banner for ACA-py.""" | ||
banner = _Banner(border, length, file) | ||
banner.print_border() | ||
yield banner | ||
banner.print_border() | ||
|
||
|
||
class _Banner: | ||
"""Management class to generate a banner for ACA-py.""" | ||
|
||
def __init__(self, border: str, length: int): | ||
class align(Enum): | ||
"""Alignment options for banner elements.""" | ||
|
||
LEFT = auto() | ||
CENTER = auto() | ||
RIGHT = auto() | ||
|
||
def __init__(self, border: str, length: int, file: Optional[TextIO] = None): | ||
"""Initialize the banner object. | ||
|
||
The ``border`` is a single character to be used, and ``length`` | ||
is the desired length of the whole banner, inclusive. | ||
""" | ||
self.border = border | ||
self.length = length | ||
self.file = file or sys.stdout | ||
|
||
def _print(self, text: str): | ||
"""Print value.""" | ||
print(text, file=self.file) | ||
|
||
def _lr_pad(self, content: str): | ||
"""Pad string content with defined border character. | ||
|
||
Args: | ||
content: String content to pad | ||
""" | ||
return f"{self.border}{self.border} {content} {self.border}{self.border}" | ||
|
||
def _print_line(self, text: str, alignment: align = align.LEFT): | ||
"""Print line.""" | ||
lines = textwrap.wrap(text, width=self.length) | ||
for line in lines: | ||
if len(line) < self.length: | ||
if alignment == self.align.LEFT: | ||
left = "" | ||
right = " " * (self.length - len(line)) | ||
elif alignment == self.align.CENTER: | ||
left = " " * ((self.length - len(line)) // 2) | ||
right = " " * ((self.length - len(line)) // 2) | ||
if len(line) % 2 != 0: | ||
right += " " | ||
elif alignment == self.align.RIGHT: | ||
left = " " * (self.length - len(line)) | ||
right = "" | ||
else: | ||
raise ValueError(f"Invalid alignment: {alignment}") | ||
line = f"{left}{line}{right}" | ||
self._print(self._lr_pad(line)) | ||
|
||
def print_border(self): | ||
"""Print a full line using the border character.""" | ||
print(self.border * (self.length + 6)) | ||
self._print(self.border * (self.length + 6)) | ||
|
||
def print_title(self, title): | ||
def title(self, title, spacing_after: int = 2): | ||
"""Print the main title element.""" | ||
spacer = " " * (self.length - len(title)) | ||
print(self.lr_pad(f"{title}{spacer}")) | ||
self._print_line(title, self.align.CENTER) | ||
for _ in range(spacing_after): | ||
self.spacer() | ||
|
||
def print_spacer(self): | ||
def spacer(self): | ||
"""Print an empty line with the border character only.""" | ||
print(self.lr_pad(" " * self.length)) | ||
self._print(self._lr_pad(" " * self.length)) | ||
|
||
def print_subtitle(self, title): | ||
def hr(self, char: str = "-"): | ||
"""Print a line with a horizontal rule.""" | ||
self._print(self._lr_pad(char * self.length)) | ||
|
||
def subtitle(self, title: str, spacing_after: int = 1): | ||
"""Print a subtitle for a section.""" | ||
title += ":" | ||
spacer = " " * (self.length - len(title)) | ||
print(self.lr_pad(f"{title}{spacer}")) | ||
self._print_line(title, self.align.LEFT) | ||
for _ in range(spacing_after): | ||
self.spacer() | ||
|
||
def print_list(self, items): | ||
def list(self, items, spacing_after: int = 1): | ||
"""Print a list of items, prepending a dash to each item.""" | ||
for item in items: | ||
left_part = f" - {item}" | ||
spacer = " " * (self.length - len(left_part)) | ||
print(self.lr_pad(f"{left_part}{spacer}")) | ||
self._print_line(f" - {item}", self.align.LEFT) | ||
|
||
for _ in range(spacing_after): | ||
self.spacer() | ||
|
||
def print_version(self, version): | ||
def version(self, version): | ||
"""Print the current ``version``.""" | ||
version = f"ver: {version}" | ||
spacer = " " * (self.length - len(version)) | ||
print(self.lr_pad(f"{spacer}{version}")) | ||
self._print_line(version, self.align.RIGHT) | ||
|
||
def lr_pad(self, content: str): | ||
"""Pad string content with defined border character. | ||
def print(self, text: str): | ||
"""Print a line of text.""" | ||
self._print_line(text, self.align.LEFT) | ||
|
||
Args: | ||
content: String content to pad | ||
def left(self, text: str): | ||
"""Print a line of text left aligned. | ||
|
||
Same as `print` method. | ||
""" | ||
return f"{self.border}{self.border} {content} {self.border}{self.border}" | ||
self._print_line(text, self.align.LEFT) | ||
|
||
def centered(self, text: str): | ||
"""Print a line of text centered.""" | ||
self._print_line(text, self.align.CENTER) | ||
|
||
def right(self, text: str): | ||
"""Print a line of text right aligned.""" | ||
self._print_line(text, self.align.RIGHT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports ought to be grouped to avoid re-ordering...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've considered adding
isort
or similar to pre-commit hooks and our format checks lol so it's handled automatically like black for formatting.