-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
The easiest way to do this is to convert str inputs for interface_dir to pathlib.Path. importlib.resources.abc.Traversable is a subset of pathlib.Path.
Line 75 in 70735a7
| self.interface_dir = interface_dir |
if isinstance(interface_dir, str):
interface_dir = Path(interface_dir)
self.interface_dir = interface_dirThis would narrow the type of self.interface_dir to pathlib.Path | importlib.resources.abc.Traversable, which both implement joinpath and read_text.
Lines 260 to 267 in 70735a7
| def _add_interface(self, filename, handler): | |
| if not os.path.isabs(filename): | |
| filename = os.path.join(self.interface_dir, filename + ".varlink") | |
| with open(filename) as f: | |
| interface = Interface(f.read()) | |
| self.interfaces[interface.name] = interface | |
| self.interfaces_handlers[interface.name] = handler |
def _add_interface(self, filename, handler):
filepath = Path(filename)
if not filepath.is_absolute():
filepath = self.interface_dir.joinpath(filename + ".varlink")
interface = Interface(filepath.read_text())
self.interfaces[interface.name] = interface
self.interfaces_handlers[interface.name] = handlerMetadata
Metadata
Assignees
Labels
No labels