Merge branch 'dfsg-orig'
[debian/gnuradio] / grc / python / Platform.py
1 """
2 Copyright 2008, 2009, 2010 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 .. gui.Platform import Platform as _GUIPlatform
24 from FlowGraph import FlowGraph as _FlowGraph
25 from Connection import Connection as _Connection
26 from Block import Block as _Block
27 from Port import Port as _Port
28 from Param import Param as _Param
29 from Generator import Generator
30 from Constants import \
31         HIER_BLOCKS_LIB_DIR, BLOCK_DTD, \
32         DEFAULT_FLOW_GRAPH, BLOCKS_DIRS
33 import Constants
34
35 COLORS = (#title, #color spec
36         ('Complex', Constants.COMPLEX_COLOR_SPEC),
37         ('Float', Constants.FLOAT_COLOR_SPEC),
38         ('Integer', Constants.INT_COLOR_SPEC),
39         ('Short', Constants.SHORT_COLOR_SPEC),
40         ('Byte', Constants.BYTE_COLOR_SPEC),
41         ('Complex Vector', Constants.COMPLEX_VECTOR_COLOR_SPEC),
42         ('Float Vector', Constants.FLOAT_VECTOR_COLOR_SPEC),
43         ('Integer Vector', Constants.INT_VECTOR_COLOR_SPEC),
44         ('Short Vector', Constants.SHORT_VECTOR_COLOR_SPEC),
45         ('Byte Vector', Constants.BYTE_VECTOR_COLOR_SPEC),
46         ('Wildcard', Constants.WILDCARD_COLOR_SPEC),
47         ('Message', Constants.MSG_COLOR_SPEC),
48 )
49
50 class Platform(_Platform, _GUIPlatform):
51
52         def __init__(self):
53                 """
54                 Make a platform for gnuradio.
55                 """
56                 #ensure hier dir
57                 if not os.path.exists(HIER_BLOCKS_LIB_DIR): os.mkdir(HIER_BLOCKS_LIB_DIR)
58                 #convert block paths to absolute paths
59                 block_paths = set(map(os.path.abspath, BLOCKS_DIRS))
60                 #init
61                 _Platform.__init__(
62                         self,
63                         name='GNU Radio Companion',
64                         version=gr.version(),
65                         key='grc',
66                         license=__doc__.strip(),
67                         website='http://gnuradio.org/redmine/wiki/gnuradio/GNURadioCompanion',
68                         block_paths=block_paths,
69                         block_dtd=BLOCK_DTD,
70                         default_flow_graph=DEFAULT_FLOW_GRAPH,
71                         generator=Generator,
72                         colors=COLORS,
73                 )
74                 _GUIPlatform.__init__(self)
75
76         ##############################################
77         # Constructors
78         ##############################################
79         FlowGraph = _FlowGraph
80         Connection = _Connection
81         Block = _Block
82         Port = _Port
83         Param = _Param