Formatting

This commit is contained in:
Jason Rhinelander 2021-10-22 16:08:57 -03:00
parent c4d9eb8a8f
commit a62f6c4769
1 changed files with 11 additions and 6 deletions

View File

@ -66,7 +66,7 @@ struct stderr_logger {
constexpr auto noopt = [] {}; constexpr auto noopt = [] {};
void void
OxenMQ_Init(py::module & mod) OxenMQ_Init(py::module& mod)
{ {
using namespace pybind11::literals; using namespace pybind11::literals;
constexpr py::kw_only kwonly{}; constexpr py::kw_only kwonly{};
@ -114,11 +114,11 @@ If set to None then this address is set to use an unencrypted plaintext connecti
.def_property_readonly("ipc", py::overload_cast<>(&address::ipc, py::const_), "true if this is an ipc address") .def_property_readonly("ipc", py::overload_cast<>(&address::ipc, py::const_), "true if this is an ipc address")
.def_property_readonly("zmq_address", &address::zmq_address, .def_property_readonly("zmq_address", &address::zmq_address,
"accesses the zmq address portion of the address (note that this does not contain any curve encryption information)") "accesses the zmq address portion of the address (note that this does not contain any curve encryption information)")
.def_property_readonly("full_address", [](const address &a) { return a.full_address(address::encoding::base32z); }, .def_property_readonly("full_address", [](const address& a) { return a.full_address(address::encoding::base32z); },
"returns the full address, including curve information, encoding the curve pubkey as base32z") "returns the full address, including curve information, encoding the curve pubkey as base32z")
.def_property_readonly("full_address_b64", [](const address &a) { return a.full_address(address::encoding::base64); }, .def_property_readonly("full_address_b64", [](const address& a) { return a.full_address(address::encoding::base64); },
"returns the full address, including curve information, encoding the curve pubkey as base64") "returns the full address, including curve information, encoding the curve pubkey as base64")
.def_property_readonly("full_address_hex", [](const address &a) { return a.full_address(address::encoding::hex); }, .def_property_readonly("full_address_hex", [](const address& a) { return a.full_address(address::encoding::hex); },
"returns the full address, including curve information, encoding the curve pubkey as hex") "returns the full address, including curve information, encoding the curve pubkey as hex")
.def_property_readonly("qr", &address::qr_address, .def_property_readonly("qr", &address::qr_address,
R"(Access the full address as a RQ-encoding optimized string. R"(Access the full address as a RQ-encoding optimized string.
@ -261,7 +261,7 @@ instance is still alive).)")
"Helper class to add in registering category commands, returned from OxenMQ.add_category(...)") "Helper class to add in registering category commands, returned from OxenMQ.add_category(...)")
.def("add_command", &CatHelper::add_command) .def("add_command", &CatHelper::add_command)
.def("add_request_command", .def("add_request_command",
[](CatHelper &cat, [](CatHelper& cat,
std::string name, std::string name,
std::function<py::object(Message* msg)> handler) std::function<py::object(Message* msg)> handler)
{ {
@ -312,7 +312,12 @@ callback itself.)")
// function, but that deadlocks pretty much right away because of the crappiness of the gil. // function, but that deadlocks pretty much right away because of the crappiness of the gil.
return std::make_unique<OxenMQ>(stderr_logger{}, level); return std::make_unique<OxenMQ>(stderr_logger{}, level);
})) }))
.def(py::init([](py::bytes pubkey, py::bytes privkey, bool sn, OxenMQ::SNRemoteAddress sn_lookup, std::optional<LogLevel> log_level) { .def(py::init([](
py::bytes pubkey,
py::bytes privkey,
bool sn,
OxenMQ::SNRemoteAddress sn_lookup,
std::optional<LogLevel> log_level) {
return std::make_unique<OxenMQ>(pubkey, privkey, sn, std::move(sn_lookup), return std::make_unique<OxenMQ>(pubkey, privkey, sn, std::move(sn_lookup),
log_level ? OxenMQ::Logger{stderr_logger{}} : nullptr, log_level ? OxenMQ::Logger{stderr_logger{}} : nullptr,
log_level.value_or(LogLevel::warn)); log_level.value_or(LogLevel::warn));