60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
import imp
|
|
from ng_openstack.openstackRequest import Openstack_Request
|
|
from ng_openstack.keystone import Openstack_Keystone
|
|
from ng_openstack.logger import log
|
|
|
|
|
|
|
|
class OpenstackConnection():
|
|
requestor=Openstack_Request()
|
|
keystone=Openstack_Keystone(requestor)
|
|
|
|
|
|
def __init__(self, name, age):
|
|
self.name = name
|
|
self.age = age
|
|
self.speed = 0
|
|
self.moving = False
|
|
|
|
@property
|
|
def human_age(self):
|
|
return self.age * 7
|
|
|
|
@human_age.setter
|
|
def human_age(self, value):
|
|
self.age = value / 7
|
|
|
|
def __str__(self):
|
|
return '{} is {} years old'.format(
|
|
self.name, self.age
|
|
)
|
|
|
|
def __eq__(self, other):
|
|
return self.name == other.name and self.age == other.age
|
|
|
|
def make_sound(self):
|
|
print(self.SOUND)
|
|
|
|
def bark(self):
|
|
self.make_sound()
|
|
|
|
def walk(self, speed, distance):
|
|
self._set_speed(speed)
|
|
self._move(distance)
|
|
|
|
@classmethod
|
|
def can_woof(cls, animal):
|
|
return animal.SOUND == cls.SOUND
|
|
|
|
@staticmethod
|
|
def is_dog(animal):
|
|
return animal.can_woof()
|
|
|
|
def _set_speed(self, speed):
|
|
self.speed = speed
|
|
|
|
def _move(self, distance):
|
|
self.moving = True
|
|
for _ in range(distance):
|
|
print('.', end='')
|
|
print('') |