Beispiel #1
0
 def save_prefs(prefs):
     """
     Save the preferences to disk.
     """
     with codecs.open(PrefHelper.get_preference_path(),
                      "w",
                      encoding="utf8") as f:
         json.dump(prefs, f, indent=4, sort_keys=True)
Beispiel #2
0
    def dump(self) :
        fp = Storage(self.word).getPath() + self.word + '.ydp'
        arr_data = []
        for e in self.data :
            st = e.dumps()
            arr_data.append(st)

        with open(fp, 'w') as f:
              json.dump(arr_data, f)
def load_prefs(self):
    # load local preferences
    self.prefs = None
    try:
        with open(prefs_path, "r") as f:
            self.prefs = json.load(f)
    except:
        # file does not exist or is corrupted: fall back to default
        with open(prefs_path, "w") as f:
            self.prefs = default_prefs
            json.dump(self.prefs, f)
Beispiel #4
0
def load_prefs(self):
    # load local preferences
    self.prefs = None
    try:
        with open(prefs_path, "r") as f:
            self.prefs = json.load(f)
    except:
        # file does not exist or is corrupted: fall back to default
        with open(prefs_path, "w") as f:
            self.prefs = default_prefs
            json.dump(self.prefs, f)
Beispiel #5
0
    def dump(self) :
        fp = Storage(self.word).getPath() + self.word + '.mtp'
        arr_data = []
        for e in self.data :
            st = e.dumps()
            arr_data.append(st)

        arr_data_all = [json.dumps(self.stars), json.dumps(arr_data)]

        with open(fp, 'w') as f:
              json.dump(arr_data_all, f)
    def get_current_preferences():
        prefs = None
        try:
            with codecs.open(PrefHelper.get_preference_path(), encoding="utf8") as f:
                encoded_prefs = f.read(const.MAX_BYTES_PREFS)
                decoded_prefs = base64.b64decode(encoded_prefs)
                prefs = json.loads(decoded_prefs)
        except:
            # file does not exist or is corrupted: fall back to default
            with codecs.open(PrefHelper.get_preference_path(), "w", encoding="utf8") as f:
                prefs = PrefHelper.get_default_preferences()
                json.dump(prefs, f)
        else:
            prefs = PrefHelper.normalize_user_prefs(
                    PrefHelper.get_default_preferences(), prefs)
            PrefHelper.save_prefs(prefs)

        return prefs
    def get_current_preferences():
        prefs = None
        try:
            with codecs.open(PrefHelper.get_preference_path(),
                             encoding="utf8") as f:
                encoded_prefs = f.read(const.MAX_BYTES_PREFS)
                decoded_prefs = base64.b64decode(encoded_prefs)
                prefs = json.loads(decoded_prefs)
        except:
            # file does not exist or is corrupted: fall back to default
            with codecs.open(PrefHelper.get_preference_path(),
                             "w",
                             encoding="utf8") as f:
                prefs = PrefHelper.get_default_preferences()
                json.dump(prefs, f)
        else:
            prefs = PrefHelper.normalize_user_prefs(
                PrefHelper.get_default_preferences(), prefs)
            PrefHelper.save_prefs(prefs)

        return prefs
def save_prefs(self):
    # save local preferences to disk
    with open(prefs_path, "w") as f:
        json.dump(self.prefs, f)
Beispiel #9
0
 def writeAddonMetaID(self, dir, meta):
     path = os.path.join(self.addonsFolder(dir), "meta_id.json")
     with open(path, "w", encoding="utf8") as f:
         json.dump(meta, f)
Beispiel #10
0
 def writeAddonMeta(self, dir, meta):
     path = self._addonMetaPath(dir)
     with open(path, "w", encoding="utf8") as f:
         json.dump(meta, f)
Beispiel #11
0
def save_prefs(self):
    # save local preferences to disk
    with open(prefs_path, "w") as f:
        json.dump(self.prefs, f)
Beispiel #12
0
    def dump(self) :
        fp = Storage(self.word).getPath() + self.word + '.cdt'

        with open(fp, 'w') as f:
              json.dump(self.data, f)