def save_configuration_object(self, plugin_name, filename, item): dirname = plugin_configuration_dir(plugin_name) if not os.path.isdir(dirname): os.makedirs(dirname) path = os.path.join(dirname, filename) with open(path, 'wb') as file: pickle.dump(item, file)
def load_configuration_object(self, plugin_name, filename, default_values=None): if default_values is not None: config = dict(default_values) else: config = dict() dirname = plugin_configuration_dir(plugin_name) path = os.path.join(dirname, filename) try: with open(path, "rb") as file: item = pickle.load(file) config.update(item) except: pass return config
def load_configuration_object(self, plugin_name, filename, default_values=None): if default_values is not None: config = dict(default_values) else: config = dict() dirname = plugin_configuration_dir(plugin_name) path = os.path.join(dirname, filename) try: with open(path, 'rb') as file: item = pickle.load(file) config.update(item) except: pass return config
""" Module for discovering templates and work with templates """ from glob import glob import os.path import subprocess import sys import tempfile import threading from GTG.core.dirs import plugin_configuration_dir from Cheetah.Template import Template as CheetahTemplate from gi.repository import GObject TEMPLATE_PATHS = [ os.path.join(plugin_configuration_dir('export'), "export_templates"), os.path.join(os.path.dirname(os.path.abspath(__file__)), "export_templates"), ] def get_templates_paths(): """ Returns a list containing the full path for all the available templates. """ template_list = [] for a_dir in TEMPLATE_PATHS: template_list += glob(os.path.join(a_dir, "template_*")) return template_list class Template():
""" Module for discovering templates and work with templates """ from glob import glob import os.path import subprocess import sys import tempfile import threading from GTG.core.dirs import plugin_configuration_dir from Cheetah.Template import Template as CheetahTemplate from gi.repository import GObject TEMPLATE_PATHS = [ os.path.join(plugin_configuration_dir('export'), "export_templates"), os.path.join( os.path.dirname(os.path.abspath(__file__)), "export_templates"), ] def get_templates_paths(): """ Returns a list containing the full path for all the available templates. """ template_list = [] for a_dir in TEMPLATE_PATHS: template_list += glob(os.path.join(a_dir, "template_*")) return template_list class Template: