!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.16 (Debian). PHP/5.3.3-7+squeeze19 

uname -a: Linux mail.tri-specialutilitydistrict.com 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC
2014 x86_64
 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/share/pyshared/axiom/   drwxr-xr-x
Free 130.05 GB of 142.11 GB (91.51%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     queryutil.py (4.91 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# -*- test-case-name: axiom.test.test_queryutil -*-

import operator

from axiom.attributes import AND, OR

def contains(startAttribute,
             endAttribute,
             value):
    """
    Return an L{axiom.iaxiom.IComparison} (an object that can be
    passed as the 'comparison' argument to Store.query/.sum/.count)
    which will constrain a query against 2 attributes for ranges which
    contain the given argument.  The range is half-open.
    """
    return AND(
        startAttribute <= value,
        value < endAttribute)


def overlapping(startAttribute, # X
                endAttribute,   # Y
                startValue,     # A
                endValue,       # B
                ):
    """
    Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the
    'comparison' argument to Store.query/.sum/.count) which will constrain a
    query against 2 attributes for ranges which overlap with the given
    arguments.

    For a database with Items of class O which represent values in this
    configuration::

              X                   Y
             (a)                 (b)
              |-------------------|
        (c)      (d)
         |--------|          (e)      (f)
                              |--------|

     (g) (h)
      |---|                            (i)    (j)
                                        |------|

     (k)                                   (l)
      |-------------------------------------|

             (a)                           (l)
              |-----------------------------|
        (c)                      (b)
         |------------------------|

        (c)  (a)
         |----|
                                 (b)       (l)
                                  |---------|

    The query::

        myStore.query(
            O,
            findOverlapping(O.X, O.Y,
                            a, b))

    Will return a generator of Items of class O which represent segments a-b,
    c-d, e-f, k-l, a-l, c-b, c-a and b-l, but NOT segments g-h or i-j.

    (NOTE: If you want to pass attributes of different classes for
    startAttribute and endAttribute, read the implementation of this method to
    discover the additional join clauses required.  This may be eliminated some
    day so for now, consider this method undefined over multiple classes.)

    In the database where this query is run, for an item N, all values of
    N.startAttribute must be less than N.endAttribute.

    startValue must be less than endValue.
    """
    assert startValue <= endValue

    return OR(
        AND(startAttribute >= startValue,
            startAttribute <= endValue),
        AND(endAttribute >= startValue,
            endAttribute <= endValue),
        AND(startAttribute <= startValue,
            endAttribute >= endValue)
        )

def _tupleCompare(tuple1, ineq, tuple2,
                 eq=lambda a,b: (a==b),
                 ander=AND,
                 orer=OR):
    """
    Compare two 'in-database tuples'.  Useful when sorting by a compound key
    and slicing into the middle of that query.
    """

    orholder = []
    for limit in range(len(tuple1)):
        eqconstraint = [
            eq(elem1, elem2) for elem1, elem2 in zip(tuple1, tuple2)[:limit]]
        ineqconstraint = ineq(tuple1[limit], tuple2[limit])
        orholder.append(ander(*(eqconstraint + [ineqconstraint])))
    return orer(*orholder)

def _tupleLessThan(tuple1, tuple2):
    return _tupleCompare(tuple1, operator.lt, tuple2)

def _tupleGreaterThan(tuple1, tuple2):
    return _tupleCompare(tuple1, operator.gt, tuple2)

class AttributeTuple(object):
    def __init__(self, *attributes):
        self.attributes = attributes

    def __iter__(self):
        return iter(self.attributes)

    def __eq__(self, other):
        if not isinstance(other, (AttributeTuple, tuple, list)):
            return NotImplemented
        return AND(*[
                myAttr == otherAttr
                for (myAttr, otherAttr)
                in zip(self, other)])

    def __ne__(self, other):
        if not isinstance(other, (AttributeTuple, tuple, list)):
            return NotImplemented
        return OR(*[
                myAttr != otherAttr
                for (myAttr, otherAttr)
                in zip(self, other)])

    def __gt__(self, other):
        if not isinstance(other, (AttributeTuple, tuple, list)):
            return NotImplemented
        return _tupleGreaterThan(tuple(iter(self)), other)

    def __lt__(self, other):
        if not isinstance(other, (AttributeTuple, tuple, list)):
            return NotImplemented
        return _tupleLessThan(tuple(iter(self)), other)

    def __ge__(self, other):
        if not isinstance(other, (AttributeTuple, tuple, list)):
            return NotImplemented
        return OR(self > other, self == other)

    def __le__(self, other):
        if not isinstance(other, (AttributeTuple, tuple, list)):
            return NotImplemented
        return OR(self < other, self == other)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0121 ]--