Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[script.module.blinker@matrix] 1.7.0 #2543

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions script.module.blinker/CHANGES

This file was deleted.

20 changes: 20 additions & 0 deletions script.module.blinker/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2010 Jason Kirtland

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
72 changes: 0 additions & 72 deletions script.module.blinker/README.md

This file was deleted.

32 changes: 16 additions & 16 deletions script.module.blinker/addon.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.blinker" name="blinker" version="1.4.0+matrix.2" provider-name="Jason Kirtand">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
</requires>
<extension point="xbmc.python.module" library="lib" />
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en_GB">Blinker provides a fast dispatching system that allows any number of interested parties to subscribe to events, or signals</summary>
<description lang="en_GB">Blinker provides a fast dispatching system that allows any number of interested parties to subscribe to events, or signals</description>
<license>MIT</license>
<website>https://pythonhosted.org/blinker/</website>
<source>https://pypi.org/project/blinker/</source>
<assets>
<icon>icon.png</icon>
</assets>
</extension>
<addon id="script.module.blinker" name="blinker" version="1.7.0" provider-name="Jason Kirtland">
<requires>
<import addon="xbmc.python" version="3.0.0" />
</requires>
<extension point="xbmc.python.module" library="lib" />
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">Fast, simple object-to-object and broadcast signaling</summary>
<description lang="en_GB">Blinker provides a fast dispatching system that allows any number of interested parties to subscribe to events, or "signals".</description>
<license>MIT</license>
<platform>all</platform>
<website>https://blinker.readthedocs.io/</website>
<source>https://github.com/pallets-eco/blinker/</source>
<assets>
<icon>resources/icon.png</icon>
</assets>
</extension>
</addon>
35 changes: 16 additions & 19 deletions script.module.blinker/lib/blinker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
from blinker.base import (
ANY,
NamedSignal,
Namespace,
Signal,
WeakNamespace,
receiver_connected,
signal,
)
from blinker.base import ANY
from blinker.base import NamedSignal
from blinker.base import Namespace
from blinker.base import receiver_connected
from blinker.base import Signal
from blinker.base import signal
from blinker.base import WeakNamespace

__all__ = [
'ANY',
'NamedSignal',
'Namespace',
'Signal',
'WeakNamespace',
'receiver_connected',
'signal',
]
"ANY",
"NamedSignal",
"Namespace",
"Signal",
"WeakNamespace",
"receiver_connected",
"signal",
]


__version__ = '1.4'
__version__ = "1.7.0"
54 changes: 25 additions & 29 deletions script.module.blinker/lib/blinker/_saferef.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,14 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
"""Refactored 'safe reference from dispatcher.py"""

import operator
import sys
import traceback
import weakref


try:
callable
except NameError:
def callable(object):
return hasattr(object, '__call__')


if sys.version_info < (3,):
get_self = operator.attrgetter('im_self')
get_func = operator.attrgetter('im_func')
else:
get_self = operator.attrgetter('__self__')
get_func = operator.attrgetter('__func__')
get_self = operator.attrgetter("__self__")
get_func = operator.attrgetter("__func__")


def safe_ref(target, on_delete=None):
Expand All @@ -78,14 +66,15 @@ def safe_ref(target, on_delete=None):
if im_self is not None:
# Turn a bound method into a BoundMethodWeakref instance.
# Keep track of these instances for lookup by disconnect().
assert hasattr(target, 'im_func') or hasattr(target, '__func__'), (
"safe_ref target %r has im_self, but no im_func, "
"don't know how to create reference" % target)
assert hasattr(target, "im_func") or hasattr(target, "__func__"), (
f"safe_ref target {target!r} has im_self, but no im_func, "
"don't know how to create reference"
)
reference = BoundMethodWeakref(target=target, on_delete=on_delete)
return reference


class BoundMethodWeakref(object):
class BoundMethodWeakref:
"""'Safe' and reusable weak references to instance methods.

BoundMethodWeakref objects provide a mechanism for referencing a
Expand Down Expand Up @@ -119,13 +108,13 @@ class BoundMethodWeakref(object):
produce the same BoundMethodWeakref instance.
"""

_all_instances = weakref.WeakValueDictionary()
_all_instances = weakref.WeakValueDictionary() # type: ignore[var-annotated]

def __new__(cls, target, on_delete=None, *arguments, **named):
"""Create new instance or return current instance.

Basically this method of construction allows us to
short-circuit creation of references to already- referenced
short-circuit creation of references to already-referenced
instance methods. The key corresponding to the target is
calculated, and if there is already an existing reference,
that is returned, with its deletion_methods attribute updated.
Expand All @@ -138,7 +127,7 @@ def __new__(cls, target, on_delete=None, *arguments, **named):
current.deletion_methods.append(on_delete)
return current
else:
base = super(BoundMethodWeakref, cls).__new__(cls)
base = super().__new__(cls)
cls._all_instances[key] = base
base.__init__(target, on_delete, *arguments, **named)
return base
Expand All @@ -159,6 +148,7 @@ def __init__(self, target, on_delete=None):
single argument, which will be passed a pointer to this
object.
"""

def remove(weak, self=self):
"""Set self.isDead to True when method or instance is destroyed."""
methods = self.deletion_methods[:]
Expand All @@ -176,8 +166,11 @@ def remove(weak, self=self):
traceback.print_exc()
except AttributeError:
e = sys.exc_info()[1]
print ('Exception during saferef %s '
'cleanup function %s: %s' % (self, function, e))
print(
f"Exception during saferef {self} "
f"cleanup function {function}: {e}"
)

self.deletion_methods = [on_delete]
self.key = self.calculate_key(target)
im_self = get_self(target)
Expand All @@ -187,34 +180,37 @@ def remove(weak, self=self):
self.self_name = str(im_self)
self.func_name = str(im_func.__name__)

@classmethod
def calculate_key(cls, target):
"""Calculate the reference key for this reference.

Currently this is a two-tuple of the id()'s of the target
object and the target function respectively.
"""
return (id(get_self(target)), id(get_func(target)))
calculate_key = classmethod(calculate_key)

def __str__(self):
"""Give a friendly representation of the object."""
return "%s(%s.%s)" % (
return "{}({}.{})".format(
self.__class__.__name__,
self.self_name,
self.func_name,
)
)

__repr__ = __str__

def __hash__(self):
return hash((self.self_name, self.key))

def __nonzero__(self):
"""Whether we are still a valid reference."""
return self() is not None

def __cmp__(self, other):
def __eq__(self, other):
"""Compare with another reference."""
if not isinstance(other, self.__class__):
return cmp(self.__class__, type(other))
return cmp(self.key, other.key)
return operator.eq(self.__class__, type(other))
return operator.eq(self.key, other.key)

def __call__(self):
"""Return a strong reference to the bound method.
Expand Down
Loading
Loading