rpaframework icon indicating copy to clipboard operation
rpaframework copied to clipboard

RPA.FileSystem.Append To File fails if file does not exists

Open orlof opened this issue 3 years ago • 2 comments

orlof avatar Sep 24 '21 07:09 orlof

Consider whether it is more productive to fail the keyword or implicitly create the missing file. In the use cases that I have faced, it would have been easier to just automatically create the file. However, if also the parent directory is missing then I would fail this keyword. Opinions?

orlof avatar Sep 27 '21 10:09 orlof

No strong opinion here and my common use-cases would be:

A.

Append To File    ...    ensure=True

-> ensures that

  1. Parent directories are created (mkdir -p)
  2. File is created if it doesn't exist (touch)

B.

Append To File    ...

-> works as before

This will simplify usual calls like (note steps 1, 2, 3):

File work
    ${exists} =     Does File Exist    ${text_file}  # 1
    Run Keyword Unless    ${exists}    Create File    ${text_file}  # 2
    ${time} =     Get Current Date
    Append To File    ${text_file}    Ran at: ${time}${\n}  # 3

@mikahanninen Let me know if during our sync it was decided something else.

cmin764 avatar Sep 27 '21 12:09 cmin764