Beispiel #1
0
class IDateClass(Interface):
    """This is the date class interface."""

    min = Attribute("The earliest representable date")

    max = Attribute("The latest representable date")

    resolution = Attribute(
        "The smallest difference between non-equal date objects")

    def today():
        """Return the current local time.

        This is equivalent to date.fromtimestamp(time.time())"""

    def fromtimestamp(timestamp):
        """Return the local date from a POSIX timestamp (like time.time())

        This may raise ValueError, if the timestamp is out of the range of
        values supported by the platform C localtime() function. It's common
        for this to be restricted to years from 1970 through 2038. Note that
        on non-POSIX systems that include leap seconds in their notion of a
        timestamp, leap seconds are ignored by fromtimestamp().
        """

    def fromordinal(ordinal):
        """Return the date corresponding to the proleptic Gregorian ordinal.
Beispiel #2
0
class IXMPPHandler(Interface):
    """
    Interface for XMPP protocol handlers.

    Objects that provide this interface can be added to a stream manager to
    handle of (part of) an XMPP extension protocol.
    """

    parent = Attribute("""XML stream manager for this handler""")
    xmlstream = Attribute("""The managed XML stream""")

    def setHandlerParent(parent):
        """
        Set the parent of the handler.

        @type parent: L{IXMPPHandlerCollection}
        """

    def disownHandlerParent(parent):
        """
        Remove the parent of the handler.

        @type parent: L{IXMPPHandlerCollection}
        """

    def makeConnection(xs):
        """
        A connection over the underlying transport of the XML stream has been
        established.

        At this point, no traffic has been exchanged over the XML stream
        given in C{xs}.

        This should setup L{xmlstream} and call L{connectionMade}.

        @type xs: L{XmlStream<twisted.words.protocols.jabber.XmlStream>}
        """

    def connectionMade():
        """
        Called after a connection has been established.

        This method can be used to change properties of the XML Stream, its
        authenticator or the stream manager prior to stream initialization
        (including authentication).
        """

    def connectionInitialized():
        """
        The XML stream has been initialized.

        At this point, authentication was successful, and XML stanzas can be
        exchanged over the XML stream L{xmlstream}. This method can be
        used to setup observers for incoming stanzas.
        """

    def connectionLost(reason):
        """
Beispiel #3
0
class ITimeDeltaClass(Interface):
    """This is the timedelta class interface."""

    min = Attribute("The most negative timedelta object")

    max = Attribute("The most positive timedelta object")

    resolution = Attribute(
        "The smallest difference between non-equal timedelta objects")
Beispiel #4
0
class ITimeClass(Interface):
    """This is the time class interface."""

    min = Attribute("The earliest representable time")

    max = Attribute("The latest representable time")

    resolution = Attribute(
        "The smallest possible difference between non-equal time objects")
Beispiel #5
0
class I2(_I1):
    "I2 doc"

    a1 = Attribute('a1')
    a2 = Attribute('a2', 'a2 doc')

    def f21():
        "f21 doc"

    def f22():
        pass

    def f23():
        "f23 doc"
Beispiel #6
0
class IUser(Interface):
    """Interface through which clients interact with IChatService.
    """

    realm = Attribute(
        "A reference to the Realm to which this user belongs.  Set if and only if the user is logged in."
    )
    mind = Attribute(
        "A reference to the mind which logged in to this user.  Set if and only if the user is logged in."
    )
    name = Attribute("A short string, unique among users.")

    lastMessage = Attribute(
        "A POSIX timestamp indicating the time of the last message received from this user."
    )
    signOn = Attribute(
        "A POSIX timestamp indicating this user's most recent sign on time.")

    def loggedIn(realm, mind):
        """Invoked by the associated L{IChatService} when login occurs.

        @param realm: The L{IChatService} through which login is occurring.
        @param mind: The mind object used for cred login.
        """

    def send(recipient, message):
        """Send the given message to the given user or group.

        @type recipient: Either L{IUser} or L{IGroup}
        @type message: C{dict}
        """

    def join(group):
        """Attempt to join the given group.

        @type group: L{IGroup}
        @rtype: L{twisted.internet.defer.Deferred}
        """

    def leave(group):
        """Discontinue participation in the given group.

        @type group: L{IGroup}
        @rtype: L{twisted.internet.defer.Deferred}
        """

    def itergroups():
        """
Beispiel #7
0
class IGroup(Interface):
    """
    A group which you may have a conversation with.

    Groups generally have a loosely-defined set of members, who may
    leave and join at any time.
    """

    name = Attribute('My C{str} name, as the server knows me.')
    account = Attribute('The L{Account<IAccount>} I am accessed through.')

    def __init__(name, account):
        """
        Initialize me.

        @param name: My name, as the server knows me.
        @type name: str
        @param account: The account I am accessed through.
        @type account: L{Account<IAccount>}
        """

    def setTopic(text):
        """
        Set this Groups topic on the server.

        @type text: string
        """

    def sendGroupMessage(text, metadata=None):
        """
        Send a message to this group.

        @type text: str

        @type metadata: dict
        @param metadata: Valid keys for this dictionary include:

            - C{'style'}: associated with one of:
                - C{'emote'}: indicates this is an action
        """

    def join():
        """
        Join this group.
        """

    def leave():
        """
Beispiel #8
0
class IClient(Interface):

    account = Attribute('The L{IAccount} I am a Client for')

    def __init__(account, chatui, logonDeferred):
        """
        @type account: L{IAccount}
        @type chatui: L{IChatUI}
        @param logonDeferred: Will be called back once I am logged on.
        @type logonDeferred: L{Deferred<twisted.internet.defer.Deferred>}
        """

    def joinGroup(groupName):
        """
        @param groupName: The name of the group to join.
        @type groupName: string
        """

    def leaveGroup(groupName):
        """
        @param groupName: The name of the group to leave.
        @type groupName: string
        """

    def getGroupConversation(name, hide=0):
        pass

    def getPerson(name):
        pass
Beispiel #9
0
class IAccount(Interface):
    """
    I represent a user's account with a chat service.
    """

    client = Attribute('The L{IClient} currently connecting to this account, if any.')
    gatewayType = Attribute('A C{str} that identifies the protocol used by this account.')

    def __init__(accountName, autoLogin, username, password, host, port):
        """
        @type accountName: string
        @param accountName: A name to refer to the account by locally.
        @type autoLogin: boolean
        @type username: string
        @type password: string
        @type host: string
        @type port: integer
        """

    def isOnline():
        """
        Am I online?

        @rtype: boolean
        """

    def logOn(chatui):
        """
        Go on-line.

        @type chatui: Implementor of C{IChatUI}

        @rtype: L{Deferred} L{Client}
        """

    def logOff():
        """
        Sign off.
        """

    def getGroup(groupName):
        """
        @rtype: L{Group<IGroup>}
        """

    def getPerson(personName):
        """
Beispiel #10
0
class IInitiatingInitializer(IInitializer):
    """
    Interface for XML stream initializers for the initiating entity.
    """

    xmlstream = Attribute("""The associated XML stream""")

    def initialize():
        """
Beispiel #11
0
class IProtocolPlugin(Interface):
    """Interface for plugins providing an interface to a Words service
    """

    name = Attribute(
        "A single word describing what kind of interface this is (eg, irc or web)"
    )

    def getFactory(realm, portal):
        """Retrieve a C{twisted.internet.interfaces.IServerFactory} provider
class IProxiedInterface(Interface):
    """
    An interface class for use by L{proxyForInterface}.
    """

    ifaceAttribute = Attribute("""
        An example declared attribute, which should be proxied.""")

    def yay(*a, **kw):
        """
Beispiel #13
0
        class _I1(Interface):

            a1 = Attribute("This is an attribute")

            def f11():
                pass

            def f12():
                pass

            f12.optional = 1
Beispiel #14
0
class IGroup(Interface):
    name = Attribute("A short string, unique among groups.")

    def add(user):
        """Include the given user in this group.

        @type user: L{IUser}
        """

    def remove(user, reason=None):
        """Remove the given user from this group.

        @type user: L{IUser}
        @type reason: C{unicode}
        """

    def size():
        """Return the number of participants in this group.

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with an C{int} representing the the
        number of participants in this group.
        """

    def receive(sender, recipient, message):
        """
        Broadcast the given message from the given sender to other
        users in group.

        The message is not re-transmitted to the sender.

        @param sender: L{IUser}

        @type recipient: L{IGroup}
        @param recipient: This is probably a wart.  Maybe it will be removed
        in the future.  For now, it should be the group object the message
        is being delivered to.

        @param message: C{dict}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with None when delivery has been
        attempted for all users.
        """

    def setMetadata(meta):
        """Change the metadata associated with this group.

        @type meta: C{dict}
        """

    def iterusers():
        """Return an iterator of all users in this group.
Beispiel #15
0
class IChatClient(Interface):
    """Interface through which IChatService interacts with clients.
    """

    name = Attribute(
        "A short string, unique among users.  This will be set by the L{IChatService} at login time."
    )

    def receive(sender, recipient, message):
        """
        Callback notifying this user of the given message sent by the
        given user.

        This will be invoked whenever another user sends a message to a
        group this user is participating in, or whenever another user sends
        a message directly to this user.  In the former case, C{recipient}
        will be the group to which the message was sent; in the latter, it
        will be the same object as the user who is receiving the message.

        @type sender: L{IUser}
        @type recipient: L{IUser} or L{IGroup}
        @type message: C{dict}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires when the message has been delivered,
        or which fails in some way.  If the Deferred fails and the message
        was directed at a group, this user will be removed from that group.
        """

    def groupMetaUpdate(group, meta):
        """
        Callback notifying this user that the metadata for the given
        group has changed.

        @type group: L{IGroup}
        @type meta: C{dict}

        @rtype: L{twisted.internet.defer.Deferred}
        """

    def userJoined(group, user):
        """
        Callback notifying this user that the given user has joined
        the given group.

        @type group: L{IGroup}
        @type user: L{IUser}

        @rtype: L{twisted.internet.defer.Deferred}
        """

    def userLeft(group, user, reason=None):
        """
class ISASLMechanism(Interface):
    name = Attribute("""Common name for the SASL Mechanism.""")

    def getInitialResponse():
        """
        Get the initial client response, if defined for this mechanism.

        @return: initial client response string.
        @rtype: L{str}.
        """

    def getResponse(challenge):
        """
Beispiel #17
0
class ITimeDelta(ITimeDeltaClass):
    """Represent the difference between two datetime objects.

    Supported operators:

    - add, subtract timedelta
    - unary plus, minus, abs
    - compare to timedelta
    - multiply, divide by int/long

    In addition, datetime supports subtraction of two datetime objects
    returning a timedelta, and addition or subtraction of a datetime
    and a timedelta giving a datetime.

    Representation: (days, seconds, microseconds).
    """

    days = Attribute("Days between -999999999 and 999999999 inclusive")

    seconds = Attribute("Seconds between 0 and 86399 inclusive")

    microseconds = Attribute("Microseconds between 0 and 999999 inclusive")
Beispiel #18
0
class IIQResponseTracker(Interface):
    """
    IQ response tracker interface.

    The XMPP stanza C{iq} has a request-response nature that fits
    naturally with deferreds. You send out a request and when the response
    comes back a deferred is fired.

    The L{IQ} class implements a C{send} method that returns a deferred. This
    deferred is put in a dictionary that is kept in an L{XmlStream} object,
    keyed by the request stanzas C{id} attribute.

    An object providing this interface (usually an instance of L{XmlStream}),
    keeps the said dictionary and sets observers on the iq stanzas of type
    C{result} and C{error} and lets the callback fire the associated deferred.
    """
    iqDeferreds = Attribute("Dictionary of deferreds waiting for an iq "
                            "response")
Beispiel #19
0
class IElement(Interface):
    """
    Interface to XML element nodes.

    See L{Element} for a detailed example of its general use.

    Warning: this Interface is not yet complete!
    """

    uri = Attribute(""" Element's namespace URI """)
    name = Attribute(""" Element's local name """)
    defaultUri = Attribute(""" Default namespace URI of child elements """)
    attributes = Attribute(""" Dictionary of element attributes """)
    children = Attribute(""" List of child nodes """)
    parent = Attribute(""" Reference to element's parent element """)
    localPrefixes = Attribute(""" Dictionary of local prefixes """)

    def toXml(prefixes=None, closeElement=1, defaultUri='',
              prefixesInScope=None):
        """ Serializes object to a (partial) XML document

        @param prefixes: dictionary that maps namespace URIs to suggested
                         prefix names.
        @type prefixes: L{dict}
        @param closeElement: flag that determines whether to include the
                             closing tag of the element in the serialized
                             string. A value of C{0} only generates the
                             element's start tag. A value of C{1} yields a
                             complete serialization.
        @type closeElement: L{int}
        @param defaultUri: Initial default namespace URI. This is most useful
                           for partial rendering, where the logical parent
                           element (of which the starttag was already
                           serialized) declares a default namespace that should
                           be inherited.
        @type defaultUri: L{str}
        @param prefixesInScope: list of prefixes that are assumed to be
                                declared by ancestors.
        @type prefixesInScope: L{list}
        @return: (partial) serialized XML
        @rtype: L{unicode}
        """

    def addElement(name, defaultUri = None, content = None):
        """ Create an element and add as child.

        The new element is added to this element as a child, and will have
        this element as its parent.

        @param name: element name. This can be either a L{unicode} object that
                     contains the local name, or a tuple of (uri, local_name)
                     for a fully qualified name. In the former case,
                     the namespace URI is inherited from this element.
        @type name: L{unicode} or L{tuple} of (L{unicode}, L{unicode})
        @param defaultUri: default namespace URI for child elements. If
                           C{None}, this is inherited from this element.
        @type defaultUri: L{unicode}
        @param content: text contained by the new element.
        @type content: L{unicode}
        @return: the created element
        @rtype: object providing L{IElement}
        """

    def addChild(node):
        """ Adds a node as child of this element.
Beispiel #20
0
class IChatService(Interface):
    name = Attribute(
        "A short string identifying this chat service (eg, a hostname)")

    createGroupOnRequest = Attribute(
        "A boolean indicating whether L{getGroup} should implicitly "
        "create groups which are requested but which do not yet exist.")

    createUserOnRequest = Attribute(
        "A boolean indicating whether L{getUser} should implicitly "
        "create users which are requested but which do not yet exist.")

    def itergroups():
        """Return all groups available on this service.

        @rtype: C{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with a list of C{IGroup} providers.
        """

    def getGroup(name):
        """Retrieve the group by the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the group with the given
        name if one exists (or if one is created due to the setting of
        L{createGroupOnRequest}, or which fails with
        L{twisted.words.ewords.NoSuchGroup} if no such group exists.
        """

    def createGroup(name):
        """Create a new group with the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the created group, or
        with fails with L{twisted.words.ewords.DuplicateGroup} if a
        group by that name exists already.
        """

    def lookupGroup(name):
        """Retrieve a group by name.

        Unlike C{getGroup}, this will never implicitly create a group.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the group by the given
        name, or which fails with L{twisted.words.ewords.NoSuchGroup}.
        """

    def getUser(name):
        """Retrieve the user by the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the user with the given
        name if one exists (or if one is created due to the setting of
        L{createUserOnRequest}, or which fails with
        L{twisted.words.ewords.NoSuchUser} if no such user exists.
        """

    def createUser(name):
        """Create a new user with the given name.
Beispiel #21
0
 class IFoo(Interface):
      foo = Attribute("The foo Attribute")
Beispiel #22
0
class IDateTimeClass(Interface):
    """This is the datetime class interface."""

    min = Attribute("The earliest representable datetime")

    max = Attribute("The latest representable datetime")

    resolution = Attribute(
        "The smallest possible difference between non-equal datetime objects")

    def today():
        """Return the current local datetime, with tzinfo None.

        This is equivalent to datetime.fromtimestamp(time.time()).
        See also now(), fromtimestamp().
        """

    def now(tz=None):
        """Return the current local date and time.

        If optional argument tz is None or not specified, this is like today(),
        but, if possible, supplies more precision than can be gotten from going
        through a time.time() timestamp (for example, this may be possible on
        platforms supplying the C gettimeofday() function).

        Else tz must be an instance of a class tzinfo subclass, and the current
        date and time are converted to tz's time zone. In this case the result
        is equivalent to tz.fromutc(datetime.utcnow().replace(tzinfo=tz)).

        See also today(), utcnow().
        """

    def utcnow():
        """Return the current UTC date and time, with tzinfo None.

        This is like now(), but returns the current UTC date and time, as a
        naive datetime object. 

        See also now().
        """

    def fromtimestamp(timestamp, tz=None):
        """Return the local date and time corresponding to the POSIX timestamp.

        Same as is returned by time.time(). If optional argument tz is None or
        not specified, the timestamp is converted to the platform's local date
        and time, and the returned datetime object is naive.

        Else tz must be an instance of a class tzinfo subclass, and the
        timestamp is converted to tz's time zone. In this case the result is
        equivalent to
        tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)).

        fromtimestamp() may raise ValueError, if the timestamp is out of the
        range of values supported by the platform C localtime() or gmtime()
        functions. It's common for this to be restricted to years in 1970
        through 2038. Note that on non-POSIX systems that include leap seconds
        in their notion of a timestamp, leap seconds are ignored by
        fromtimestamp(), and then it's possible to have two timestamps
        differing by a second that yield identical datetime objects.

        See also utcfromtimestamp().
        """

    def utcfromtimestamp(timestamp):
        """Return the UTC datetime from the POSIX timestamp with tzinfo None.

        This may raise ValueError, if the timestamp is out of the range of
        values supported by the platform C gmtime() function. It's common for
        this to be restricted to years in 1970 through 2038.

        See also fromtimestamp().
        """

    def fromordinal(ordinal):
        """Return the datetime from the proleptic Gregorian ordinal.

        January 1 of year 1 has ordinal 1. ValueError is raised unless
        1 <= ordinal <= datetime.max.toordinal().
        The hour, minute, second and microsecond of the result are all 0, and
        tzinfo is None.
        """

    def combine(date, time):
        """Return a new datetime object.
Beispiel #23
0
class IDateTime(IDate, IDateTimeClass):
    """Object contains all the information from a date object and a time object.
    """

    year = Attribute("Year between MINYEAR and MAXYEAR inclusive")

    month = Attribute("Month between 1 and 12 inclusive")

    day = Attribute(
        "Day between 1 and the number of days in the given month of the year")

    hour = Attribute("Hour in range(24)")

    minute = Attribute("Minute in range(60)")

    second = Attribute("Second in range(60)")

    microsecond = Attribute("Microsecond in range(1000000)")

    tzinfo = Attribute(
        """The object passed as the tzinfo argument to the datetime constructor
        or None if none was passed""")

    def date():
        """Return date object with same year, month and day."""

    def time():
        """Return time object with same hour, minute, second, microsecond.

        tzinfo is None. See also method timetz().
        """

    def timetz():
        """Return time object with same hour, minute, second, microsecond,
        and tzinfo.

        See also method time().
        """

    def replace(year, month, day, hour, minute, second, microsecond, tzinfo):
        """Return a datetime with the same members, except for those members
        given new values by whichever keyword arguments are specified.

        Note that tzinfo=None can be specified to create a naive datetime from
        an aware datetime with no conversion of date and time members.
        """

    def astimezone(tz):
        """Return a datetime object with new tzinfo member tz, adjusting the
        date and time members so the result is the same UTC time as self, but
        in tz's local time.

        tz must be an instance of a tzinfo subclass, and its utcoffset() and
        dst() methods must not return None. self must be aware (self.tzinfo
        must not be None, and self.utcoffset() must not return None).

        If self.tzinfo is tz, self.astimezone(tz) is equal to self: no
        adjustment of date or time members is performed. Else the result is
        local time in time zone tz, representing the same UTC time as self:
            after astz = dt.astimezone(tz), astz - astz.utcoffset()
        will usually have the same date and time members as dt - dt.utcoffset().
        The discussion of class tzinfo explains the cases at Daylight Saving
        Time transition boundaries where this cannot be achieved (an issue only
        if tz models both standard and daylight time).

        If you merely want to attach a time zone object tz to a datetime dt
        without adjustment of date and time members, use dt.replace(tzinfo=tz).
        If you merely want to remove the time zone object from an aware
        datetime dt without conversion of date and time members, use 
        dt.replace(tzinfo=None).

        Note that the default tzinfo.fromutc() method can be overridden in a
        tzinfo subclass to effect the result returned by astimezone().
        """

    def utcoffset():
        """Return the timezone offset in minutes east of UTC (negative west of
        UTC)."""

    def dst():
        """Return 0 if DST is not in effect, or the DST offset (in minutes
        eastward) if DST is in effect.
        """

    def tzname():
        """Return the timezone name."""

    def timetuple():
        """Return a 9-element tuple of the form returned by time.localtime()."""

    def utctimetuple():
        """Return UTC time tuple compatilble with time.gmtimr()."""

    def toordinal():
        """Return the proleptic Gregorian ordinal of the date.

        The same as self.date().toordinal().
        """

    def weekday():
        """Return the day of the week as an integer.

        Monday is 0 and Sunday is 6. The same as self.date().weekday().
        See also isoweekday().
        """

    def isoweekday():
        """Return the day of the week as an integer.

        Monday is 1 and Sunday is 7. The same as self.date().isoweekday.
        See also weekday(), isocalendar().
        """

    def isocalendar():
        """Return a 3-tuple, (ISO year, ISO week number, ISO weekday).

        The same as self.date().isocalendar().
        """

    def isoformat(sep='T'):
        """Return a string representing the date and time in ISO 8601 format.

        YYYY-MM-DDTHH:MM:SS.mmmmmm or YYYY-MM-DDTHH:MM:SS if microsecond is 0

        If utcoffset() does not return None, a 6-character string is appended,
        giving the UTC offset in (signed) hours and minutes:

        YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM or YYYY-MM-DDTHH:MM:SS+HH:MM
        if microsecond is 0.

        The optional argument sep (default 'T') is a one-character separator,
        placed between the date and time portions of the result.
        """

    def __str__():
        """For a datetime instance d, str(d) is equivalent to d.isoformat(' ').
        """

    def ctime():
        """Return a string representing the date and time.

        datetime(2002, 12, 4, 20, 30, 40).ctime() == 'Wed Dec 4 20:30:40 2002'.
        d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple())) on
        platforms where the native C ctime() function (which time.ctime()
        invokes, but which datetime.ctime() does not invoke) conforms to the
        C standard.
        """

    def strftime(format):
        """Return a string representing the date and time.
Beispiel #24
0
        class I(Interface):
            "xxx"

            __doc__ = Attribute('the doc')
Beispiel #25
0
class IDate(IDateClass):
    """Represents a date (year, month and day) in an idealized calendar.

    Operators:

    __repr__, __str__
    __cmp__, __hash__
    __add__, __radd__, __sub__ (add/radd only with timedelta arg)
    """

    year = Attribute("Between MINYEAR and MAXYEAR inclusive.")

    month = Attribute("Between 1 and 12 inclusive")

    day = Attribute(
        "Between 1 and the number of days in the given month of the given year."
    )

    def replace(year, month, day):
        """Return a date with the same value.

        Except for those members given new values by whichever keyword
        arguments are specified. For example, if d == date(2002, 12, 31), then
        d.replace(day=26) == date(2000, 12, 26). 
        """

    def timetuple():
        """Return a 9-element tuple of the form returned by time.localtime().

        The hours, minutes and seconds are 0, and the DST flag is -1.
        d.timetuple() is equivalent to
        (d.year, d.month, d.day, 0, 0, 0, d.weekday(), d.toordinal() -
        date(d.year, 1, 1).toordinal() + 1, -1)
        """

    def toordinal():
        """Return the proleptic Gregorian ordinal of the date

        January 1 of year 1 has ordinal 1. For any date object d,
        date.fromordinal(d.toordinal()) == d.
        """

    def weekday():
        """Return the day of the week as an integer.

        Monday is 0 and Sunday is 6. For example,
        date(2002, 12, 4).weekday() == 2, a Wednesday.

        See also isoweekday().
        """

    def isoweekday():
        """Return the day of the week as an integer.

        Monday is 1 and Sunday is 7. For example,
        date(2002, 12, 4).isoweekday() == 3, a Wednesday.

        See also weekday(), isocalendar().
        """

    def isocalendar():
        """Return a 3-tuple, (ISO year, ISO week number, ISO weekday).

        The ISO calendar is a widely used variant of the Gregorian calendar.
        See http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm for a good
        explanation.

        The ISO year consists of 52 or 53 full weeks, and where a week starts
        on a Monday and ends on a Sunday. The first week of an ISO year is the
        first (Gregorian) calendar week of a year containing a Thursday. This
        is called week number 1, and the ISO year of that Thursday is the same
        as its Gregorian year.

        For example, 2004 begins on a Thursday, so the first week of ISO year
        2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004, so
        that date(2003, 12, 29).isocalendar() == (2004, 1, 1) and
        date(2004, 1, 4).isocalendar() == (2004, 1, 7).
        """

    def isoformat():
        """Return a string representing the date in ISO 8601 format.

        This is 'YYYY-MM-DD'.
        For example, date(2002, 12, 4).isoformat() == '2002-12-04'.
        """

    def __str__():
        """For a date d, str(d) is equivalent to d.isoformat()."""

    def ctime():
        """Return a string representing the date.

        For example date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'.
        d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple()))
        on platforms where the native C ctime() function
        (which time.ctime() invokes, but which date.ctime() does not invoke)
        conforms to the C standard.
        """

    def strftime(format):
        """Return a string representing the date.
Beispiel #26
0
class ITime(ITimeClass):
    """Represent time with time zone.

    Operators:

    __repr__, __str__
    __cmp__, __hash__
    """

    hour = Attribute("Hour in range(24)")

    minute = Attribute("Minute in range(60)")

    second = Attribute("Second in range(60)")

    microsecond = Attribute("Microsecond in range(1000000)")

    tzinfo = Attribute(
        """The object passed as the tzinfo argument to the time constructor
        or None if none was passed.""")

    def replace(hour, minute, second, microsecond, tzinfo):
        """Return a time with the same value.

        Except for those members given new values by whichever keyword
        arguments are specified. Note that tzinfo=None can be specified
        to create a naive time from an aware time, without conversion of the
        time members.
        """

    def isoformat():
        """Return a string representing the time in ISO 8601 format.

        That is HH:MM:SS.mmmmmm or, if self.microsecond is 0, HH:MM:SS
        If utcoffset() does not return None, a 6-character string is appended,
        giving the UTC offset in (signed) hours and minutes:
        HH:MM:SS.mmmmmm+HH:MM or, if self.microsecond is 0, HH:MM:SS+HH:MM
        """

    def __str__():
        """For a time t, str(t) is equivalent to t.isoformat()."""

    def strftime(format):
        """Return a string representing the time.

        This is controlled by an explicit format string.
        """

    def utcoffset():
        """Return the timezone offset in minutes east of UTC (negative west of
        UTC).

        If tzinfo is None, returns None, else returns
        self.tzinfo.utcoffset(None), and raises an exception if the latter
        doesn't return None or a timedelta object representing a whole number
        of minutes with magnitude less than one day.
        """

    def dst():
        """Return 0 if DST is not in effect, or the DST offset (in minutes
        eastward) if DST is in effect.

        If tzinfo is None, returns None, else returns self.tzinfo.dst(None),
        and raises an exception if the latter doesn't return None, or a
        timedelta object representing a whole number of minutes with
        magnitude less than one day.
        """

    def tzname():
        """Return the timezone name.