def test_save(self): preferences = Preferences() self.assertTrue(self.preferencespersistence.save(preferences)) preferences.type = "teste_preferencespersistence" self.assertTrue(self.preferencespersistence.save(preferences))
def test_add_recent_file(self): #prefs = ? from mosaicode.model.preferences import Preferences prefs = Preferences() file_name = "../files_for_test/output/Untitled.mscd" self.assertIsNone(self.main_control.add_recent_file(prefs, file_name))
def __init__(self): self.Log = None self.properties = Preferences() self.code_templates = {} self.plugins = {} self.list_of_examples = [] self.ports = {} self.__load()
def load(cls): """ This method loads the diagram. Returns: * **Types** (:class:`boolean<boolean>`) """ prefs = Preferences() from mosaicode.system import System file_name = System.get_user_dir() + "/" + prefs.conf_file_path file_name = os.path.expanduser(file_name) if os.path.exists(file_name) is False: return prefs parser = XMLParser(file_name) if parser.getTag("MosaicodeProperties") is None: return prefs try: prefs.default_directory = parser.getTagAttr("MosaicodeProperties", "default_directory") prefs.default_filename = parser.getTagAttr("MosaicodeProperties", "default_filename") prefs.grid = int(parser.getTagAttr("MosaicodeProperties","grid")) prefs.width = int(parser.getTagAttr("MosaicodeProperties","width")) prefs.height = int(parser.getTagAttr("MosaicodeProperties", "height")) prefs.hpaned_work_area = int(parser.getTagAttr("MosaicodeProperties", "hpaned_work_area")) prefs.vpaned_bottom = int(parser.getTagAttr("MosaicodeProperties", "vpaned_bottom")) prefs.vpaned_left = int(parser.getTagAttr("MosaicodeProperties", "vpaned_left")) files = parser.getTag("MosaicodeProperties").getTag( "recent_files").getChildTags("name") for file_name in files: prefs.recent_files.append(file_name.getAttr("value")) except: pass return prefs
def test_init(self): model = Preferences()
def load(cls, path): """ This method loads the preference from JSON file. Returns: * **Types** (:class:`boolean<boolean>`) """ prefs = Preferences() file_name = path + "/" + prefs.conf_file_path + ".json" file_name = os.path.expanduser(file_name) if os.path.exists(file_name) is False: return prefs # load the port if os.path.exists(file_name) is False: return None data = "" try: data_file = open(file_name, 'r') data = json.load(data_file) data_file.close() if data["data"] != "PREFERENCES": return None prefs.author = data["author"] prefs.license = data["license"] prefs.version = data["version"] prefs.default_directory = data["default_directory"] prefs.default_filename = data["default_filename"] prefs.grid = int(data["grid"]) prefs.width = int(data["width"]) prefs.height = int(data["height"]) prefs.hpaned_work_area = int(data["hpaned_work_area"]) prefs.vpaned_bottom = int(data["vpaned_bottom"]) prefs.vpaned_left = int(data["vpaned_left"]) files = data["recent_files"] for file_name in files: prefs.recent_files.append(file_name) except: from mosaicode.system import System as System System.log("Problem loading preferences") return prefs
def load(cls, path): """ This method loads the diagram. Returns: * **Types** (:class:`boolean<boolean>`) """ prefs = Preferences() file_name = path + "/" + prefs.conf_file_path file_name = os.path.expanduser(file_name) if os.path.exists(file_name) is False: return prefs parser = XMLParser(file_name) if parser.getTag(tag_name) is None: return prefs prefs.author = parser.getTagAttr(tag_name, "author") prefs.license = parser.getTagAttr(tag_name, "license") prefs.default_directory = parser.getTagAttr(tag_name, "default_directory") prefs.default_filename = parser.getTagAttr(tag_name, "default_filename") prefs.grid = int(parser.getTagAttr(tag_name,"grid")) prefs.port = int(parser.getTagAttr(tag_name, "network_port")) prefs.width = int(parser.getTagAttr(tag_name,"width")) prefs.height = int(parser.getTagAttr(tag_name, "height")) prefs.hpaned_work_area = int(parser.getTagAttr(tag_name, "hpaned_work_area")) prefs.vpaned_bottom = int(parser.getTagAttr(tag_name, "vpaned_bottom")) prefs.vpaned_left = int(parser.getTagAttr(tag_name, "vpaned_left")) files = parser.getTag(tag_name).getTag( "recent_files").getChildTags("name") for file_name in files: prefs.recent_files.append(file_name.getAttr("value")) return prefs