Read file content and return content as string / unicode. NOTE: It's only mean to be used to read non-binary files since API right now doesn't support passing binary data.
(file_path)
| 808 | action_ref_or_id = action.ref |
| 809 | |
| 810 | def read_file(file_path): |
| 811 | """ |
| 812 | Read file content and return content as string / unicode. |
| 813 | |
| 814 | NOTE: It's only mean to be used to read non-binary files since API right now doesn't |
| 815 | support passing binary data. |
| 816 | """ |
| 817 | if not os.path.exists(file_path): |
| 818 | raise ValueError('File "%s" doesn\'t exist' % (file_path)) |
| 819 | |
| 820 | if not os.path.isfile(file_path): |
| 821 | raise ValueError('"%s" is not a file' % (file_path)) |
| 822 | |
| 823 | with open(file_path, "rb") as fp: |
| 824 | content = fp.read() |
| 825 | |
| 826 | return content.decode("utf-8") |
| 827 | |
| 828 | def transform_object(value): |
| 829 | # Also support simple key1=val1,key2=val2 syntax |