66 * For a full list of authors see the git log.
77 */
88#include < pybind11/pybind11.h>
9+ #include < pybind11/stl/filesystem.h>
910
1011#include < osmium/osm.hpp>
11- #include < osmium/io/any_input.hpp>
1212#include < osmium/handler.hpp>
1313#include < osmium/visitor.hpp>
14+
15+ #include < filesystem>
16+
1417#include " cast.h"
18+ #include " io.h"
1519
1620namespace py = pybind11;
1721
@@ -29,6 +33,12 @@ struct LastChangeHandler : public osmium::handler::Handler
2933 }
3034};
3135
36+ osmium::Timestamp newest_change_from_file (pyosmium::PyReader &reader) {
37+ LastChangeHandler handler;
38+ osmium::apply (*reader.get (), handler);
39+ return handler.last_change ;
40+ }
41+
3242} // namespace
3343
3444#ifdef Py_GIL_DISABLED
@@ -37,14 +47,18 @@ PYBIND11_MODULE(_replication, m, py::mod_gil_not_used())
3747PYBIND11_MODULE (_replication, m)
3848#endif
3949{
40- m.def (" newest_change_from_file" , [](char const *filename)
41- {
42- osmium::io::Reader reader (filename, osmium::osm_entity_bits::nwr);
43-
44- LastChangeHandler handler;
45- osmium::apply (reader, handler);
46- reader.close ();
47-
48- return handler.last_change ;
49- });
50+ m.def (" newest_change_from_file" , &newest_change_from_file,
51+ py::arg (" reader" ));
52+ m.def (" newest_change_from_file" , [](std::string file) {
53+ pyosmium::PyReader reader (osmium::io::File (std::move (file)));
54+ return newest_change_from_file (reader);
55+ });
56+ m.def (" newest_change_from_file" , [](std::filesystem::path const &file) {
57+ pyosmium::PyReader reader (osmium::io::File (file.string ()));
58+ return newest_change_from_file (reader);
59+ });
60+ m.def (" newest_change_from_file" , [](osmium::io::File file) {
61+ pyosmium::PyReader reader (std::move (file));
62+ return newest_change_from_file (reader);
63+ });
5064}
0 commit comments