-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consistently allow str, Path, File and FileBuffer for file input
Uses built-in support for Path from pybind11 which has only been added in version 2.7 and needs C++17.
- Loading branch information
Showing
16 changed files
with
227 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,8 @@ | |
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others. | ||
* For a full list of authors see the git log. | ||
*/ | ||
#include <vector> | ||
|
||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl/filesystem.h> | ||
|
||
#include <osmium/osm.hpp> | ||
#include <osmium/handler.hpp> | ||
|
@@ -22,6 +21,9 @@ | |
#include "handler_chain.h" | ||
#include "buffer_iterator.h" | ||
|
||
#include <vector> | ||
#include <filesystem> | ||
|
||
namespace py = pybind11; | ||
|
||
void pyosmium::apply_item(osmium::OSMEntity &obj, pyosmium::BaseHandler &handler) | ||
|
@@ -102,6 +104,32 @@ PYBIND11_MODULE(_osmium, m) { | |
pyosmium::apply(rd, handler); | ||
}, | ||
py::arg("filename")); | ||
m.def("apply", [](std::filesystem::path const &fn, pyosmium::BaseHandler &h) | ||
{ | ||
osmium::io::Reader rd{fn}; | ||
pyosmium::apply(rd, h); | ||
}, | ||
py::arg("filename"), py::arg("handler")); | ||
m.def("apply", [](std::filesystem::path const &fn, py::args args) | ||
{ | ||
pyosmium::HandlerChain handler{args}; | ||
osmium::io::Reader rd{fn}; | ||
pyosmium::apply(rd, handler); | ||
}, | ||
py::arg("filename")); | ||
m.def("apply", [](osmium::io::File fn, pyosmium::BaseHandler &h) | ||
{ | ||
osmium::io::Reader rd{fn}; | ||
pyosmium::apply(rd, h); | ||
}, | ||
py::arg("filename"), py::arg("handler")); | ||
m.def("apply", [](osmium::io::File fn, py::args args) | ||
{ | ||
pyosmium::HandlerChain handler{args}; | ||
osmium::io::Reader rd{fn}; | ||
pyosmium::apply(rd, handler); | ||
}, | ||
py::arg("filename")); | ||
|
||
py::class_<pyosmium::BaseHandler>(m, "BaseHandler"); | ||
py::class_<pyosmium::BaseFilter, pyosmium::BaseHandler>(m, "BaseFilter") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.