Skip to content

Commit

Permalink
use string() for filesystem::path to make Windows happy
Browse files Browse the repository at this point in the history
  • Loading branch information
lonvia committed Sep 17, 2024
1 parent 710f225 commit 138fd12
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/id_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void init_id_tracker(pybind11::module &m)
py::arg("fname"), py::arg("relation_depth") = 0)
.def("complete_backward_references",
[](IdTracker &self, std::filesystem::path const &fname, int relation_depth) {
self.complete_backward_references(osmium::io::File{fname}, relation_depth);
self.complete_backward_references(osmium::io::File{fname.string()}, relation_depth);
},
py::arg("fname"), py::arg("relation_depth") = 0)
.def("complete_forward_references", &IdTracker::complete_forward_references,
Expand All @@ -314,7 +314,7 @@ void init_id_tracker(pybind11::module &m)
py::arg("fname"), py::arg("relation_depth") = 0)
.def("complete_forward_references",
[](IdTracker &self, std::filesystem::path const &fname, int relation_depth) {
self.complete_forward_references(osmium::io::File{fname.c_str()}, relation_depth);
self.complete_forward_references(osmium::io::File{fname.string()}, relation_depth);
},
py::arg("fname"), py::arg("relation_depth") = 0)
.def("id_filter",
Expand Down
10 changes: 5 additions & 5 deletions lib/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ PYBIND11_MODULE(io, m)
.def(py::init<std::string>())
.def(py::init<std::string, std::string>())
.def(py::init<>([] (std::filesystem::path const &file) {
return new osmium::io::File(file.c_str());
return new osmium::io::File(file.string());
}))
.def(py::init<>([] (std::filesystem::path const &file, const char *format) {
return new osmium::io::File(file.c_str(), format);
return new osmium::io::File(file.string(), format);
}))
.def_property("has_multiple_object_versions",
&osmium::io::File::has_multiple_object_versions,
Expand Down Expand Up @@ -78,10 +78,10 @@ PYBIND11_MODULE(io, m)
.def(py::init<std::string>())
.def(py::init<std::string, osmium::osm_entity_bits::type>())
.def(py::init<>([] (std::filesystem::path const &file) {
return new osmium::io::Reader(file.c_str());
return new osmium::io::Reader(file.string());
}))
.def(py::init<>([] (std::filesystem::path const &file, osmium::osm_entity_bits::type etype) {
return new osmium::io::Reader(file.c_str(), etype);
return new osmium::io::Reader(file.string(), etype);
}))
.def(py::init<osmium::io::File>(),
py::keep_alive<1, 2>())
Expand All @@ -97,7 +97,7 @@ PYBIND11_MODULE(io, m)
py::class_<osmium::io::Writer>(m, "Writer")
.def(py::init<std::string>())
.def(py::init<>([] (std::filesystem::path const &file) {
return new osmium::io::Writer(file.c_str());
return new osmium::io::Writer(file.string());
}))
.def(py::init<osmium::io::File>())
.def(py::init<std::string, osmium::io::Header>())
Expand Down
4 changes: 2 additions & 2 deletions lib/osmium.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ PYBIND11_MODULE(_osmium, m) {
py::arg("filename"));
m.def("apply", [](std::filesystem::path const &fn, pyosmium::BaseHandler &h)
{
osmium::io::Reader rd{fn};
osmium::io::Reader rd{fn.string()};
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};
osmium::io::Reader rd{fn.string()};
pyosmium::apply(rd, handler);
},
py::arg("filename"));
Expand Down
2 changes: 1 addition & 1 deletion lib/simple_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void init_simple_writer(pybind11::module &m)
py::arg("filetype") = "")
.def(py::init<>([] (std::filesystem::path const &file, unsigned long bufsz,
osmium::io::Header const *header, bool overwrite) {
return new SimpleWriter(file.c_str(), bufsz, header, overwrite, "");
return new SimpleWriter(file.string().c_str(), bufsz, header, overwrite, "");
}),
py::arg("filename"), py::arg("bufsz") = 4096*1024,
py::arg("header") = nullptr,
Expand Down
2 changes: 1 addition & 1 deletion test/test_file_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_filtered_handler_basehandler(opl_buffer, tmp_path):

ids = IDCollector()

o.apply(str(testf), ids)
o.apply(testf, ids)

assert ids.nodes == [3]
assert ids.ways == [2]
Expand Down

0 comments on commit 138fd12

Please sign in to comment.