Skip to content

Conversation

@abaczek
Copy link
Contributor

@abaczek abaczek commented Nov 25, 2025

This pull request introduces improvements to the CustomPath class in mfd_connect/pathlib/path.py, focusing on compatibility and robustness. The main changes include adding custom division operator methods for path joining and updating the file reading method to use a more reliable process-based approach.

Compatibility enhancements:

  • Added __truediv__ and __rtruediv__ methods to CustomPath to support path joining with proper owner propagation, improving compatibility with older Python versions.

Robustness improvements:

  • Updated the read_text method to use a process iterator for reading file contents, which enhances reliability when handling large files or streaming output.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modifies the CustomPath class to improve SSH path operations and text reading capabilities. The changes enable proper handling of path division operations for Python versions prior to 3.12 and refactor the read_text method to use streaming instead of blocking command execution.

Key Changes:

  • Added __truediv__ and __rtruediv__ methods for Python <3.12 to preserve _owner attribute during path operations
  • Refactored read_text to use start_process with streaming output instead of blocking execute_command

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

else:
def __truediv__(self, key):
try:
child = super(CustomPath, self).__truediv__(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
child = super(CustomPath, self).__truediv__(key)
child = super().__truediv__(key)

python2 syntax


def __rtruediv__(self, key):
try:
child = super(CustomPath, self).__rtruediv__(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
child = super(CustomPath, self).__rtruediv__(key)
child = super().__rtruediv__(key)

as above

Copy link
Contributor

@mchromin mchromin left a comment

Choose a reason for hiding this comment

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

.

Signed-off-by: Baczek, Arkadiusz <arkadiusz.baczek@intel.com>
hanging due to large output

Signed-off-by: Baczek, Arkadiusz <arkadiusz.baczek@intel.com>
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.

3 participants