Main Page
Namespaces
Classes
Files
File List
rtsprofile
direction.py
Go to the documentation of this file.
1
# -*- Python -*-
2
# -*- coding: utf-8 -*-
3
4
'''rtsprofile
5
6
Copyright (C) 2009-2010
7
Geoffrey Biggs
8
RT-Synthesis Research Group
9
Intelligent Systems Research Institute,
10
National Institute of Advanced Industrial Science and Technology (AIST),
11
Japan
12
All rights reserved.
13
Licensed under the Eclipse Public License -v 1.0 (EPL)
14
http://www.opensource.org/licenses/eclipse-1.0.txt
15
16
File: direction.py
17
18
Enumeration for directions.
19
20
This module stores the possible types of component direction.
21
22
Valid types are UP, DOWN, LEFT, RIGHT.
23
24
'''
25
26
__version__ =
'$Revision: $'
27
# $Source$
28
29
30
from
rtsprofile.exceptions
import
InvalidDirectionError
31
32
33
UP =
'UP'
34
DOWN =
'DOWN'
35
LEFT =
'LEFT'
36
RIGHT =
'RIGHT'
37
38
39
# Use this to match the correct type when specifying data correctness
40
const_type = str
41
42
43
def
from_string
(dir_string):
44
'''Returns the correct constant for a given string.
45
46
@raises InvalidDirectionError
47
48
'''
49
dir_string = dir_string.upper()
50
if
dir_string == UP:
51
return
UP
52
elif
dir_string == DOWN:
53
return
DOWN
54
elif
dir_string == LEFT:
55
return
LEFT
56
elif
dir_string == RIGHT:
57
return
RIGHT
58
else
:
59
raise
InvalidDirectionError
(dir_string)
60
61
62
def
to_string
(direction):
63
'''Returns the correct string for a given direction.
64
65
@raises InvalidDirectionError
66
67
'''
68
if
direction == UP:
69
return
UP
70
elif
direction == DOWN:
71
return
DOWN
72
elif
direction == LEFT:
73
return
LEFT
74
elif
direction == RIGHT:
75
return
RIGHT
76
else
:
77
raise
InvalidDirectionError
(type_string)
78
79
80
# vim: tw=79
81
rtsprofile.direction.to_string
def to_string(direction)
Definition:
direction.py:62
rtsprofile.direction.from_string
def from_string(dir_string)
Definition:
direction.py:43
rtsprofile.exceptions
Definition:
exceptions.py:1
rtsprofile.exceptions.InvalidDirectionError
Definition:
exceptions.py:54
rtsprofile
Author(s): Geoffrey Biggs
autogenerated on Fri Jun 7 2019 21:52:35