apply diff from previous commits
[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 gnuradio import gr
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', Constants.WILDCARD_COLOR_SPEC),
46         ('Message', Constants.MSG_COLOR_SPEC),
47 )
48
49 class Platform(_Platform):
50
51         def __init__(self):
52                 """
53                 Make a platform for gnuradio.
54                 """
55                 #ensure hier dir
56                 if not os.path.exists(HIER_BLOCKS_LIB_DIR): os.mkdir(HIER_BLOCKS_LIB_DIR)
57                 #convert block paths to absolute paths
58                 block_paths = set(map(os.path.abspath, BLOCKS_DIRS))
59                 #init
60                 _Platform.__init__(
61                         self,
62                         name='GNU Radio Companion',
63                         version=gr.version(),
64                         key='grc',
65                         license=__doc__.strip(),
66                         website='http://gnuradio.org/trac/wiki/GNURadioCompanion',
67                         block_paths=block_paths,
68                         block_dtd=BLOCK_DTD,
69                         default_flow_graph=DEFAULT_FLOW_GRAPH,
70                         generator=Generator,
71                         colors=COLORS,
72                 )
73
74         ##############################################
75         # Constructors
76         ##############################################
77         FlowGraph = _FlowGraph
78         Connection = _Connection
79         Block = _Block
80         Source = Source
81         Sink = Sink
82         Param = _Param