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

Add header/footer #8

Merged
merged 2 commits into from
Dec 23, 2024
Merged

Add header/footer #8

merged 2 commits into from
Dec 23, 2024

Conversation

kaliv0
Copy link
Owner

@kaliv0 kaliv0 commented Dec 23, 2024

Summary by Sourcery

Add support for specifying header and footer when saving plain text files.

New Features:

  • Added header and footer options to the f_write_options parameter of the save() method to support prepending and appending text to plain text files.

Tests:

  • Added tests to verify the functionality of the header and footer options.

Copy link
Contributor

sourcery-ai bot commented Dec 23, 2024

Reviewer's Guide by Sourcery

This pull request adds the ability to specify a header and footer when saving a FileStream to a plain text file. It also modifies the default delimiter for plain text files to be a newline character. Finally, it includes a test case to verify the new functionality.

Sequence diagram for FileStream plain text saving with header/footer

sequenceDiagram
    participant Client
    participant FileStream
    participant File

    Client->>FileStream: save(f_write_options={header, footer})
    activate FileStream
    FileStream->>FileStream: _write_plain()
    FileStream->>FileStream: to_string(delimiter)
    FileStream->>FileStream: Combine header + content + footer
    FileStream->>File: writelines(output)
    File-->>FileStream: Success
    FileStream-->>Client: Success
    deactivate FileStream
Loading

Class diagram showing FileStream changes

classDiagram
    class FileStream {
        +save(f_open_options: dict, f_write_options: dict)
        -_write_plain(path: str, tmp_path: str, f_open_options: dict, f_write_options: dict)
        +to_string(delimiter: str) str
    }
    note for FileStream "Modified _write_plain to support header/footer"
Loading

File-Level Changes

Change Details Files
Added support for header and footer in plain text files.
  • Added header and footer parameters to the save method for plain text files.
  • Updated documentation to reflect the new parameters.
  • Added a test case to verify the functionality of the new parameters.
  • Updated the example code to use the new parameters.
  • Added a new file to store the expected output of the test case.
  • Modified the _write_plain method to handle the new parameters.
  • Updated the __init__.py file to include the new functionality in the public API.
  • Updated the default delimiter for plain text files to be a newline character.
  • Updated the documentation to reflect the change in the default delimiter.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
  • Updated the example code to use the new default delimiter.
  • Updated the test case to use the new default delimiter.
  • Updated the _write_plain method to handle the new default delimiter.
  • Updated the __init__.py file to include the change in the default delimiter in the public API.
pyrio/streams/file_stream.py
docs/quickstart.md
README.md
tests/test_file_stream.py
tests/resources/save_output/foo.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Flag Coverage Δ
unittests 98.40% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pyrio/__init__.py 100.00% <100.00%> (ø)
pyrio/streams/file_stream.py 97.14% <100.00%> (+0.10%) ⬆️

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @kaliv0 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kaliv0 kaliv0 merged commit 0ebfbc5 into main Dec 23, 2024
2 checks passed
@kaliv0 kaliv0 deleted the add-result-pattern branch December 23, 2024 20:21
kaliv0 added a commit that referenced this pull request Dec 23, 2024
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