summaryrefslogtreecommitdiff
path: root/grc/core/Config.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-03-16 16:25:09 +0100
committerSebastian Koslowski <koslowski@kit.edu>2016-04-05 10:10:36 +0200
commitc285036f5674ee54c16b46c3088ed86503d63d83 (patch)
tree40888ab30b540c86037a8af117a258d56dce10eb /grc/core/Config.py
parent3201557bfbed7ad81e0e5a34ece48bbd93ad709b (diff)
grc-refactor: remove (hopefully) all deps to GR in core/ and gui/
Diffstat (limited to 'grc/core/Config.py')
-rw-r--r--grc/core/Config.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/grc/core/Config.py b/grc/core/Config.py
new file mode 100644
index 0000000000..ac38d9978c
--- /dev/null
+++ b/grc/core/Config.py
@@ -0,0 +1,55 @@
+"""
+Copyright 2016 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+
+import os
+from os.path import expanduser, normpath, expandvars, exists
+
+
+class Config(object):
+
+ key = 'grc'
+ name = 'GNU Radio Companion (no gui)'
+ license = __doc__.strip()
+ website = 'http://gnuradio.org'
+
+ hier_block_lib_dir = os.environ.get('GRC_HIER_PATH', expanduser('~/.grc_gnuradio'))
+
+ def __init__(self, prefs_file, version, version_parts=None):
+ self.prefs = prefs_file
+ self.version = version
+ self.version_parts = version_parts or version[1:].split('-', 1)[0].split('.')[:3]
+
+ @property
+ def block_paths(self):
+ path_list_sep = {'/': ':', '\\': ';'}[os.path.sep]
+
+ paths_sources = (
+ self.hier_block_lib_dir,
+ os.environ.get('GRC_BLOCKS_PATH', ''),
+ self.prefs.get_string('grc', 'local_blocks_path', ''),
+ self.prefs.get_string('grc', 'global_blocks_path', ''),
+ )
+
+ collected_paths = sum((paths.split(path_list_sep)
+ for paths in paths_sources), [])
+
+ valid_paths = [normpath(expanduser(expandvars(path)))
+ for path in collected_paths if exists(path)]
+
+ return valid_paths