Files
e2b-dev--e2b/packages/python-sdk/Makefile
T
Mish Ushakov edeafb1cdd Adds files.getInfo / files.get_info methods to retrieve information about directory/files (#724)
**Changelog**

- Adds `files.getInfo`, `files.get_info` methods to the SDKs.
- Adds tests for the new methods
- Adds documentation for the above.

**Examples**

JavaScript

```js
import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()

// Create a new file
await sandbox.files.write('test_file.txt', 'Hello, world!')

// Get information about the file
const info = await sandbox.files.getInfo('test_file.txt')

console.log(info)
// {
//   name: 'test_file.txt',
//   type: 'file',
//   path: '/home/user/test_file.txt'
// }
```

Python

```py
from e2b_code_interpreter import Sandbox

sandbox = Sandbox()

# Create a new file
sandbox.files.write('test_file', 'Hello, world!')

# Get information about the file
info = sandbox.files.get_info('test_file')

print(info)
# EntryInfo(name='test_file.txt', type=<FileType.FILE: 'file'>, path='/home/user/test_file.txt')
```

---------

Co-authored-by: Jakub Novak <jakub@e2b.dev>
2025-07-29 03:39:42 -07:00

28 lines
737 B
Makefile

ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../..)
generate-api:
python $(ROOT_DIR)/spec/remove_extra_tags.py sandboxes
openapi-python-client generate --output-path $(ROOT_DIR)/packages/python-sdk/e2b/api/api --overwrite --path $(ROOT_DIR)/spec/openapi_generated.yml
rm -rf e2b/api/client
mv e2b/api/api/e2b_api_client e2b/api/client
rm -rf e2b/api/api
black .
generate-envd:
if [ ! -f "/go/bin/protoc-gen-connect-python" ]; then \
$(MAKE) -C $(ROOT_DIR)/packages/connect-python build; \
fi
cd $(ROOT_DIR)/spec/envd && pwd && buf generate --template buf-python.gen.yaml
./scripts/fix-python-pb.sh
black .
generate: generate-api generate-envd
init:
pip install openapi-python-client
lint:
ruff check .