Beginning of the symbols from controller

Ref #496
This commit is contained in:
Julien Duponchelle committed 2016-06-27 18:37:20 +02:00
1 parent deb97f8ec0
commit b66f7daa28
51 files changed
+21580

No files matched your search

+2
View File
@@ -25,6 +25,7 @@ from ..config import Config
from .project import Project
from .compute import Compute
from .notification import Notification
from .symbols import Symbols
from ..version import __version__
from .topology import load_topology
@@ -39,6 +40,7 @@ class Controller:
self._computes = {}
self._projects = {}
self._notification = Notification(self)
self.symbols = Symbols()
if sys.platform.startswith("win"):
config_path = os.path.join(os.path.expandvars("%APPDATA%"), "GNS3")
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python
#
# Copyright (C) 2016 GNS3 Technologies Inc.
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program 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, see <http://www.gnu.org/licenses/>.
import os
from ..utils.get_resource import get_resource
class Symbols:
"""
Manage GNS3 symbols
"""
def __init__(self):
self.list()
def list(self):
self._symbols_path = {}
symbols = []
for file in os.listdir(get_resource("symbols")):
if file.startswith('.'):
continue
symbol_id = ':/symbols/' + file
symbols.append({
'symbol_id': symbol_id,
'filename': file,
'builtin': True,
'url': '/static/builtin_symbols/' + file
})
self._symbols_path[symbol_id] = os.path.join(get_resource("symbols"), file)
#TODO: support ~/GNS3/symbols directory
return symbols
def get_path(self, symbol_id):
return self._symbols_path[symbol_id]