Package gofer :: Package rmi :: Module window :: Class Window
[hide private]
[frames] | no frames]

Class Window

source code

       object --+    
                |    
messaging.Options --+
                    |
                   Window

Represents a maintenance (time) window. An empty Window defines an unbounded window. A begin of 'None' = UTC now. An end of 'None' = begin plus 1 hour.

Instance Methods [hide private]
 
__init__(self, *D, **window)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
bool
match(self)
Get whether the current datetime (UTC) falls within the window.
source code
bool
future(self)
Get whether window is in the future.
source code
bool
past(self)
Get whether window is in the past.
source code
dict
__setbegin(self, window)
Set the proper window beginning.
source code
dict
__setend(self, window)
Set the proper window ending.
source code
bool
__hasduration(self, window)
Get whether one of the duration keywords are specified in the window definition.
source code
(datetime, datetime)
__dates(self, now=None)
Convert to datetime objects.
source code
 
__str__(self)
str(x)
source code

Inherited from messaging.Options: __getattr__, __getitem__, __iadd__, __iter__, __len__, __repr__, __setitem__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
str FORMAT = '%Y-%m-%dT%H:%M:%S'
The datetime format.
[str,..] DURATION = ('days', 'seconds', 'minutes', 'hours', 'weeks')
The duration keywords.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *D, **window)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • D ([dict,..]) - A (optional) dictionary.
  • window - The window specification:
    • begin

    One of:

    • end
    • days
    • seconds
    • minutes
    • hours
    • weeks
Overrides: object.__init__

Note: An empty window indicates an unbounded window.

match(self)

source code 

Get whether the current datetime (UTC) falls within the window.

Returns: bool
True when matched.

Note: Empty = match ALL.

future(self)

source code 

Get whether window is in the future.

Returns: bool
True if begin > utcnow().

Note: Empty = match ALL.

past(self)

source code 

Get whether window is in the past.

Returns: bool
True if utcnow() > end.

Note: Empty = match ALL.

__setbegin(self, window)

source code 

Set the proper window beginning. Performs:

  • Convert to string if dt object.
  • Default to UTC (now) when value is (None).
Parameters:
  • window (dict) - The window specification.
Returns: dict
The updated window.

__setend(self, window)

source code 

Set the proper window ending. Performs:

  • Convert to string if dt object.
  • Default begin plus 1 hour when value is (None).
Parameters:
  • window (dict) - The window specification.
Returns: dict
The updated window.

__hasduration(self, window)

source code 

Get whether one of the duration keywords are specified in the window definition.

Parameters:
  • window (dict) - The window specification.
Returns: bool
True if found.

__dates(self, now=None)

source code 

Convert to datetime objects.

Parameters:
  • now (datetime) - The current UTC time.
Returns: (datetime, datetime)
(begin, end)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Class Variable Details [hide private]

FORMAT

The datetime format. ISO 8601
Type:
str
Value:
'%Y-%m-%dT%H:%M:%S'