{"id":33937341,"url":"https://github.com/omerbenamram/pyo3-file","last_synced_at":"2026-03-27T02:43:35.379Z","repository":{"id":34892390,"uuid":"187502166","full_name":"omerbenamram/pyo3-file","owner":"omerbenamram","description":"A small helper library for working with python file-like objects with rust.","archived":false,"fork":false,"pushed_at":"2026-02-08T18:03:03.000Z","size":135,"stargazers_count":47,"open_issues_count":1,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-08T23:58:04.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omerbenamram.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-19T16:37:23.000Z","updated_at":"2026-02-08T18:02:41.000Z","dependencies_parsed_at":"2024-06-11T09:42:38.242Z","dependency_job_id":"9b67ba22-290a-4e03-a3b7-5fd4d2db8456","html_url":"https://github.com/omerbenamram/pyo3-file","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/omerbenamram/pyo3-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerbenamram%2Fpyo3-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerbenamram%2Fpyo3-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerbenamram%2Fpyo3-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerbenamram%2Fpyo3-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omerbenamram","download_url":"https://codeload.github.com/omerbenamram/pyo3-file/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omerbenamram%2Fpyo3-file/sbom","scorecard":{"id":706128,"data":{"date":"2025-08-11","repo":{"name":"github.com/omerbenamram/pyo3-file","commit":"87458f7fe6599350207f487566e27ac3a5f23bc2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"name":"Code-Review","score":5,"reason":"Found 7/13 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":4,"reason":"5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/omerbenamram/pyo3-file/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/omerbenamram/pyo3-file/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/omerbenamram/pyo3-file/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/omerbenamram/pyo3-file/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/omerbenamram/pyo3-file/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/omerbenamram/pyo3-file/release.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:20","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:21","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned","Info:   1 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T06:38:36.688Z","repository_id":34892390,"created_at":"2025-08-22T06:38:36.688Z","updated_at":"2025-08-22T06:38:36.688Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31011700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T02:33:22.146Z","status":"ssl_error","status_checked_at":"2026-03-27T02:33:21.763Z","response_time":164,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-12T14:58:30.841Z","updated_at":"2026-03-27T02:43:35.366Z","avatar_url":"https://github.com/omerbenamram.png","language":"Rust","funding_links":[],"categories":["Build Tools \u0026 Frameworks"],"sub_categories":[],"readme":"![crates.io](https://img.shields.io/crates/v/pyo3-file.svg)\n\n# PyO3-File\n\nThis is a small utility library to facilitate working with python file-like objects with rust.\n\n## Example\n\nAn example use case for this is when a file is opened in python, and needs to be passed to a rust library.\n\nWe could support both by introspecting the `PyObject`, and pick the correct behavior.\n\nWe would like this to work:\n```python\nfrom path_or_file_like import accepts_path_or_file_like\n\ndef main():\n    # should open `some_file.txt`.\n    accepts_path_or_file_like(\"./some_file.txt\")\n\n    # should read from the python handle.\n    f = open('./some_file.txt')\n    accepts_path_or_file_like(f)\n```\n\nWe could use `pyo3_file` to extend an existing a `pyo3` module.\n\n```rust\nuse pyo3_file::PyFileLikeObject;\nuse pyo3::types::PyString;\n\nuse pyo3::prelude::*;\nuse pyo3::wrap_pyfunction;\nuse std::io::Read;\nuse std::fs::File;\n\n/// Represents either a path `File` or a file-like object `FileLike`\n#[derive(Debug)]\nenum FileOrFileLike {\n    File(String),\n    FileLike(PyFileLikeObject),\n}\n\nimpl\u003c'py\u003e FromPyObject\u003c'py\u003e for FileOrFileLike {\n    fn extract_bound(ob: \u0026Bound\u003c'py, PyAny\u003e) -\u003e PyResult\u003cSelf\u003e {\n        // is a path\n        if let Ok(string) = ob.extract::\u003cString\u003e() {\n            return Ok(FileOrFileLike::File(string));\n        }\n\n        // is a file-like\n        let f = PyFileLikeObject::py_with_requirements(ob.clone(), true, false, true, false)?;\n        Ok(FileOrFileLike::FileLike(f))\n    }\n}\n\n#[pyfunction]\n/// Opens a file or file-like, and reads it to string.\nfn accepts_path_or_file_like(path_or_file_like: FileOrFileLike) -\u003e PyResult\u003cString\u003e {\n    match path_or_file_like {\n        FileOrFileLike::File(s) =\u003e {\n            println!(\"It's a file! - path {}\", s);\n            let mut f = File::open(s)?;\n            let mut string = String::new();\n\n            f.read_to_string(\u0026mut string)?;\n            Ok(string)\n        }\n        FileOrFileLike::FileLike(mut f) =\u003e {\n            println!(\"Its a file-like object\");\n            let mut string = String::new();\n\n            f.read_to_string(\u0026mut string)?;\n            Ok(string)\n        }\n    }\n}\n\n#[pymodule]\nfn path_or_file_like(_py: Python, m: \u0026PyModule) -\u003e PyResult\u003c()\u003e {\n    m.add_wrapped(wrap_pyfunction!(accepts_path_or_file_like))?;\n\n    Ok(())\n}\n\n\n# fn main() {}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomerbenamram%2Fpyo3-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomerbenamram%2Fpyo3-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomerbenamram%2Fpyo3-file/lists"}