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

Improved routine for terminal dimensions. Works on windows too. #127

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

harro
Copy link
Contributor

@harro harro commented Oct 2, 2024

No description provided.

Copy link

google-cla bot commented Oct 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -32,8 +33,6 @@
except (ImportError, ModuleNotFoundError):
pass

__version__ = '0.1.1'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as this was a legacy of terminal.py being its own package.

textfsm/terminal.py Outdated Show resolved Hide resolved
@@ -472,7 +461,7 @@ def main(argv=None):
# Prints the size of the terminal and returns.
# Mutually exclusive to the paging of text and overrides that behaviour.
if opt in ('-s', '--size'):
print('Length: %d, Width: %d' % TerminalSize())
print('Width: %d, Length: %d' % TerminalSize())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only user facing change.

@harro
Copy link
Contributor Author

harro commented Oct 3, 2024

Slight change in behaviour, unlikely to be observed by users except for a corner case where environment vars are different (for some reason?) from the terminal size itself.

From https://github.com/python/cpython/blob/main/Lib/shutil.py#L1438 we see that the standard function uses the environment vars in preference to interrogating the terminal itself. The code being replaced here would only fell back to using the environment vars if the call to the terminal failed.

The new behaviour is probably preferable.

@buxtronix buxtronix merged commit c31b600 into google:master Oct 30, 2024
1 check passed
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