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

files.block is not working as expected when path exists and line missing #1075

Open
xiaoxiaoyu93 opened this issue Mar 20, 2024 · 0 comments
Labels
Bug Label for all kind of bugs.

Comments

@xiaoxiaoyu93
Copy link

files.block is not working as expected

Describe the bug

The document (both 2x and next) says:

Content appended if line not found in the file
If content is not in the file but is required (present=True) and line is not found in the file, content (surrounded by markers) will be appended to the file. The file is created if necessary.

But in the case of the actual empty file, there is no addition.

To Reproduce

Steps to reproduce the behavior, please include where possible:

from pyinfra.operations import files

files.block(
    name="Block Test",
    path="test.txt",
    line="foo",
    content="bar",
    present=True,
    after=True,
)
$ rm test.txt
$ touch test.txt
$ pyinfra @local test.py
$ cat test.txt #just empty line

Expected behavior

$ cat test.txt
# BEGIN PYINFRA BLOCK
bar
# END PYINFRA BLOCK

Meta

  • Include output of pyinfra --support.

    If you are having issues with pyinfra or wish to make feature requests, please
    check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
    When adding an issue, be sure to include the following:

    System: Darwin
      Platform: macOS-14.0-x86_64-i386-64bit
      Release: 23.0.0
      Machine: x86_64
    pyinfra: v3.0b0
    Executable: /Users/who/OneClick/LunaticDaemon/.venv/bin/pyinfra
    Python: 3.11.7 (CPython, Clang 15.0.0 (clang-1500.1.0.2.5))
  • How was pyinfra installed (source/pip)?
    pip
  • Include pyinfra-debug.log (if one was created)
    None
  • Consider including output with -vv and --debug.
@xiaoxiaoyu93 xiaoxiaoyu93 added the Bug Label for all kind of bugs. label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Label for all kind of bugs.
Projects
None yet
Development

No branches or pull requests

1 participant