Imported Upstream version 3.2.2
[debian/gnuradio] / grc / python / Platform.py
1 """
2 Copyright 2008, 2009 Free Software Foundation, Inc.
3 This file is part of GNU Radio
4
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 GNU Radio Companion is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18 """
19
20 import os
21 from .. import VERSION #TEMP: until gnuradio has __version__
22 from .. base.Platform import Platform as _Platform
23 from FlowGraph import FlowGraph as _FlowGraph
24 from Connection import Connection as _Connection
25 from Block import Block as _Block
26 from Port import Source,Sink
27 from Param import Param as _Param
28 from Generator import Generator
29 from Constants import \
30         HIER_BLOCKS_LIB_DIR, BLOCK_DTD, \
31         DEFAULT_FLOW_GRAPH, BLOCKS_DIRS
32 import Constants
33
34 COLORS = (#title, #color spec
35         ('Complex', Constants.COMPLEX_COLOR_SPEC),
36         ('Float', Constants.FLOAT_COLOR_SPEC),
37         ('Integer', Constants.INT_COLOR_SPEC),
38         ('Short', Constants.SHORT_COLOR_SPEC),
39         ('Byte', Constants.BYTE_COLOR_SPEC),
40         ('Complex Vector', Constants.COMPLEX_VECTOR_COLOR_SPEC),
41         ('Float Vector', Constants.FLOAT_VECTOR_COLOR_SPEC),
42         ('Integer Vector', Constants.INT_VECTOR_COLOR_SPEC),
43         ('Short Vector', Constants.SHORT_VECTOR_COLOR_SPEC),
44         ('Byte Vector', Constants.BYTE_VECTOR_COLOR_SPEC),
45         ('Wildcard Type', Constants.WILDCARD_COLOR_SPEC),
46 )
47
48 class Platform(_Platform):
49
50         def __init__(self):
51                 """
52                 Make a platform for gnuradio.
53                 """
54                 #ensure hier dir
55                 if not os.path.exists(HIER_BLOCKS_LIB_DIR): os.mkdir(HIER_BLOCKS_LIB_DIR)
56                 #convert block paths to absolute paths
57                 block_paths = set(map(os.path.abspath, BLOCKS_DIRS))
58                 #init
59                 _Platform.__init__(
60                         self,
61                         name='GNU Radio Companion',
62                         version=VERSION,
63                         key='grc',
64                         license=__doc__.strip(),
65                         website='http://gnuradio.org/trac/wiki/GNURadioCompanion',
66                         block_paths=block_paths,
67                         block_dtd=BLOCK_DTD,
68                         default_flow_graph=DEFAULT_FLOW_GRAPH,
69                         generator=Generator,
70                         colors=COLORS,
71                 )
72
73         ##############################################
74         # Constructors
75         ##############################################
76         FlowGraph = _FlowGraph
77         Connection = _Connection
78         Block = _Block
79         Source = Source
80         Sink = Sink
81         Param = _Param