Example #1
0

def initgroups(username, gid):
    """
    Implement initgroups(3)

    :Parameters:
     - `username`: The user name
     - `gid`: The group id

    :Types:
     - `username`: ``str``
     - `gid`: ``int``

    :Exceptions:
     - `OSError`: initgroups() didn't succeed
     - `NotImplementedError`: initgroups is not implemented
       (needs c-extension)
    """
    # pylint: disable = W0613

    raise NotImplementedError()


from wtf import c_override
cimpl = c_override('_wtf_cutil')
if cimpl is not None:
    # pylint: disable = E1103
    initgroups = cimpl.initgroups
del c_override, cimpl
Example #2
0
    """
    if size < 0:
        return read(size)
    vlen, buf = 0, []
    push = buf.append
    while vlen < size:
        val = read(size - vlen)
        if not val:
            break
        vlen += len(val)
        push(val)
    return "".join(buf)


from wtf import c_override
cimpl = c_override('_wtf_cstream')
if cimpl is not None:
    # pylint: disable = E1103
    GenericStream = cimpl.GenericStream
    MinimalSocketStream = cimpl.MinimalSocketStream
    read_exact = cimpl.read_exact
del c_override, cimpl


class dev_null(object): # pylint: disable = C0103
    """
    /dev/null like stream

    Returns EOF on read requests and throws away any written stuff.
    """
    def read(self, size=-1):
Example #3
0
        """
        remove = list(remove or [])
        add = list(add or [])
        replace = list(replace or [])

        # append replace list to remove and add
        remove.extend([tup[0] for tup in replace])
        add.extend(replace)

        self.remove(remove)
        self.add(add)


from wtf import c_override

cimpl = c_override("_wtf_cutil")
if cimpl is not None:
    # pylint: disable = E1103
    quote = cimpl.quote
    quote_plus = cimpl.quote_plus
    unquote = cimpl.unquote
    unquote_plus = cimpl.unquote_plus
else:
    import urllib as _urllib

    def quote(s, safe="/", encoding="utf-8", errors="strict", _orig=_urllib.quote):
        """
        Replacement for ``urllib.quote``, which also handles unicode.

        :Parameters:
         - `s`: The string to quote