summary refs log tree commit diff stats
path: root/rust/semi-structured-logs/src
stat options
Period:
Authors:

Commits per author per week (path 'rust/semi-structured-logs/src')

AuthorW27 2025W28 2025W29 2025W30 2025Total
Total00000
id=489a1616407a3d6c588b1890c9ddbf795ae5724f'>^
d1fc8866 ^
da077109 ^
b4f58d46 ^
1c1b6c31 ^
























d1fc8866 ^
1c1b6c31 ^




da077109 ^










1c1b6c31 ^







d1fc8866 ^
1c1b6c31 ^

d1fc8866 ^



1c1b6c31 ^











d1fc8866 ^

1c1b6c31 ^
d1fc8866 ^
da077109 ^



d1fc8866 ^
da077109 ^
d1fc8866 ^
da077109 ^
d1fc8866 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103














                                                                       
              
                            
 
























                                                                         
                                                                               




                                                                  










                                                                                                







                                                                                   
                       

                            



                                                               











                                                                    

                                               
                                          
                                    



                                                                                   
                                                               
                                                           
                                             
                                                     



                                                                
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import weakref
from types import MethodType

class Signal(dict):
	stopped = False
	def __init__(self, **keywords):
		dict.__init__(self, keywords)
		self.__dict__ = self

	def stop(self):
		self.stopped = True


class SignalHandler(object):
	active = True
	def __init__(self, signal_name, function, priority, pass_signal):
		self.priority = max(0, min(1, priority))
		self.signal_name = signal_name
		self.function = function
		self.pass_signal = pass_signal


class SignalDispatcher(object):
	def __init__(self):
		self._signals = dict()

	signal_clear = __init__

	def signal_bind(self, signal_name, function, priority=0.5, weak=False):
		assert isinstance(signal_name, str)
		try:
			handlers = self._signals[signal_name]
		except:
			handlers = self._signals[signal_name] = []
		nargs = function.__code__.co_argcount

		try:
			instance = function.__self__
		except:
			if weak:
				function = weakref.proxy(function)
		else:
			nargs -= 1
			if weak:
				function = (function.__func__, weakref.proxy(function.__self__))
		handler = SignalHandler(signal_name, function, priority, nargs > 0)
		handlers.append(handler)
		handlers.sort(key=lambda handler: -handler.priority)
		return handler

	def signal_unbind(self, signal_handler):
		try:
			handlers = self._signals[signal_handler.signal_name]
		except:
			pass
		else:
			try:
				handlers.remove(signal_handler)
			except:
				pass

	def signal_emit(self, signal_name, **kw):
		assert isinstance(signal_name, str)
		try:
			handlers = self._signals[signal_name]
		except:
			return
		if not handlers:
			return

		signal = Signal(origin=self, name=signal_name, **kw)

		# propagate
		for handler in tuple(handlers):
			if handler.active:
				try:
					if isinstance(handler.function, tuple):
						fnc = MethodType(*handler.function)
					else:
						fnc = handler.function
					if handler.pass_signal:
						fnc(signal)
					else:
						fnc()
					if signal.stopped:
						return
				except ReferenceError:
					handlers.remove(handler)