1+ from typing import Optional , Callable , TypeVar
2+
13from osmium ._osmium import SimpleHandler
4+ from osmium .osm import Node , Way , Relation , Area , Changeset
5+
6+ T = TypeVar ('T' )
7+ HandlerFunc = Optional [Callable [[T ], None ]]
8+
29
3- def make_simple_handler (node = None , way = None , relation = None , area = None , changeset = None ):
10+ def make_simple_handler (node : HandlerFunc [Node ] = None ,
11+ way : HandlerFunc [Way ] = None ,
12+ relation : HandlerFunc [Relation ] = None ,
13+ area : HandlerFunc [Area ] = None ,
14+ changeset : HandlerFunc [Changeset ] = None ) -> SimpleHandler :
415 """ Convenience function that creates a `SimpleHandler` from a set of
516 callback functions. Each of the parameters takes an optional callable
617 that must expect a single positional parameter with the object being
@@ -10,14 +21,14 @@ class __HandlerWithCallbacks(SimpleHandler):
1021 pass
1122
1223 if node is not None :
13- __HandlerWithCallbacks . node = staticmethod (node )
24+ setattr ( __HandlerWithCallbacks , " node" , staticmethod (node ) )
1425 if way is not None :
15- __HandlerWithCallbacks . way = staticmethod (way )
26+ setattr ( __HandlerWithCallbacks , " way" , staticmethod (way ) )
1627 if relation is not None :
17- __HandlerWithCallbacks . relation = staticmethod (relation )
28+ setattr ( __HandlerWithCallbacks , " relation" , staticmethod (relation ) )
1829 if area is not None :
19- __HandlerWithCallbacks . area = staticmethod (area )
30+ setattr ( __HandlerWithCallbacks , " area" , staticmethod (area ) )
2031 if changeset is not None :
21- __HandlerWithCallbacks . changeset = staticmethod (changeset )
32+ setattr ( __HandlerWithCallbacks , " changeset" , staticmethod (changeset ) )
2233
2334 return __HandlerWithCallbacks ()
0 commit comments