[arch-commits] Commit in python-irc/trunk (PKGBUILD jaraco.py)

Kyle Keen kkeen at archlinux.org
Sat Feb 7 11:00:21 UTC 2015


    Date: Saturday, February 7, 2015 @ 12:00:21
  Author: kkeen
Revision: 127235

upgpkg: python-irc 11.0.1-1

Modified:
  python-irc/trunk/PKGBUILD
  python-irc/trunk/jaraco.py

-----------+
 PKGBUILD  |   10 +++--
 jaraco.py |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2015-02-07 10:44:48 UTC (rev 127234)
+++ PKGBUILD	2015-02-07 11:00:21 UTC (rev 127235)
@@ -6,7 +6,7 @@
 
 pkgbase=python-irc
 pkgname=('python-irc' 'python2-irc')
-pkgver=8.9.1
+pkgver=11.0.1
 pkgrel=1
 pkgdesc="IRC (Internet Relay Chat) protocol client library for Python"
 depends=('python-six')
@@ -18,8 +18,8 @@
 install='python-irc.install'
 source=(http://pypi.python.org/packages/source/i/irc/irc-$pkgver.zip
         jaraco.py)
-md5sums=('b19439f713a33d13585302e15c45bc26'
-         '90a2ebb75d5b5263ea8f688f024a93d5')
+md5sums=('391088628b92b5a5ad48e2fefa4feab1'
+         '0577cd2b5ffe3907b9b7ce60aa422bb6')
 
 build() {
   cd "$srcdir"
@@ -27,7 +27,11 @@
   cp jaraco.py "irc-$pkgver/irc/"
   pushd "irc-$pkgver"
   sed -i 's/jaraco.util.itertools/irc.jaraco/' irc/client.py
+  sed -i 's/jaraco.util.string/irc.jaraco/'    irc/strings.py
+  sed -i 's/jaraco.util.dictlib/irc.jaraco/'   irc/dict.py
   sed -i '25i irc/jaraco.py' irc.egg-info/SOURCES.txt
+  sed -i "s/'jaraco.util',//" setup.py
+  echo "six" > irc.egg-info/requires.txt
   popd
   cp -a "irc-$pkgver" "irc2-$pkgver"
 }

Modified: jaraco.py
===================================================================
--- jaraco.py	2015-02-07 10:44:48 UTC (rev 127234)
+++ jaraco.py	2015-02-07 11:00:21 UTC (rev 127235)
@@ -4,8 +4,13 @@
 new package for these util functions, let's embed them
 instead.  Reconsider this when there is more than a dozen
 lines of code.
+
+He also says that "this grab-bag of routines is deprecated"
 """
 
+import six
+
+# from jaraco.util.itertools import always_iterable
 def always_iterable(item):
     "taken from jaraco.util-10.0.2"
     if item is None:
@@ -14,3 +19,104 @@
         item = (item,)
     return item
 
+
+# from jaraco.util.string import FoldedCase
+class FoldedCase(six.text_type):
+    """
+    A case insensitive string class; behaves just like str
+    except compares equal when the only variation is case.
+    >>> s = FoldedCase('hello world')
+
+    >>> s == 'Hello World'
+    True
+
+    >>> 'Hello World' == s
+    True
+
+    >>> s.index('O')
+    4
+
+    >>> s.split('O')
+    ['hell', ' w', 'rld']
+
+    >>> sorted(map(FoldedCase, ['GAMMA', 'alpha', 'Beta']))
+    ['alpha', 'Beta', 'GAMMA']
+    """
+    def __lt__(self, other):
+        return self.lower() < other.lower()
+
+    def __gt__(self, other):
+        return self.lower() > other.lower()
+
+    def __eq__(self, other):
+        return self.lower() == other.lower()
+
+    def __hash__(self):
+        return hash(self.lower())
+
+    # cache lower since it's likely to be called frequently.
+    def lower(self):
+        self._lower = super(FoldedCase, self).lower()
+        self.lower = lambda: self._lower
+        return self._lower
+
+    def index(self, sub):
+        return self.lower().index(sub.lower())
+
+    def split(self, splitter=' ', maxsplit=0):
+        pattern = re.compile(re.escape(splitter), re.I)
+        return pattern.split(self, maxsplit)
+
+
+# from jaraco.util.dictlib import KeyTransformingDict
+class KeyTransformingDict(dict):
+    """
+    A dict subclass that transforms the keys before they're used.
+    Subclasses may override the default transform_key to customize behavior.
+    """
+    @staticmethod
+    def transform_key(key):
+        return key
+
+    def __init__(self, *args, **kargs):
+        super(KeyTransformingDict, self).__init__()
+        # build a dictionary using the default constructs
+        d = dict(*args, **kargs)
+        # build this dictionary using transformed keys.
+        for item in d.items():
+            self.__setitem__(*item)
+
+    def __setitem__(self, key, val):
+        key = self.transform_key(key)
+        super(KeyTransformingDict, self).__setitem__(key, val)
+
+    def __getitem__(self, key):
+        key = self.transform_key(key)
+        return super(KeyTransformingDict, self).__getitem__(key)
+
+    def __contains__(self, key):
+        key = self.transform_key(key)
+        return super(KeyTransformingDict, self).__contains__(key)
+
+    def __delitem__(self, key):
+        key = self.transform_key(key)
+        return super(KeyTransformingDict, self).__delitem__(key)
+
+    def setdefault(self, key, *args, **kwargs):
+        key = self.transform_key(key)
+        return super(KeyTransformingDict, self).setdefault(key, *args, **kwargs)
+
+    def pop(self, key, *args, **kwargs):
+        key = self.transform_key(key)
+        return super(KeyTransformingDict, self).pop(key, *args, **kwargs)
+
+    def matching_key_for(self, key):
+        """
+        Given a key, return the actual key stored in self that matches.
+        Raise KeyError if the key isn't found.
+        """
+        try:
+            return next(e_key for e_key in self.keys() if e_key == key)
+        except StopIteration:
+            raise KeyError(key)
+



More information about the arch-commits mailing list