File: EncodingGuessListMetadata.py

package info (click to toggle)
scribes 0.4~r543-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 6,836 kB
  • ctags: 6,779
  • sloc: python: 32,963; perl: 2,747; xml: 2,233; sh: 847; makefile: 597
file content (27 lines) | stat: -rw-r--r-- 625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from SCRIBES.Utils import open_database
from os.path import join
basepath = join("Preferences", "EncodingGuessList.gdb")

def get_value():
	try:
		encodings = []
		database = open_database(basepath, "r")
		encodings = database["encodings"]
	except KeyError:
		pass
	finally:
		database.close()
	return encodings

def set_value(encoding):
	try:
		database = None
		if encoding == "utf-8": return
		encodings = get_value()
		if encoding in encodings: return
		encodings.append(encoding)
		database = open_database(basepath, "w")
		database["encodings"] = encodings
	finally:
		if database is not None: database.close()
	return