Rename encoding to _encoding in Collection
This commit is contained in:
parent
33ad60503f
commit
1ce404ca35
@ -700,7 +700,9 @@ class Collection(BaseCollection):
|
|||||||
folder = self._get_collection_root_folder()
|
folder = self._get_collection_root_folder()
|
||||||
# Path should already be sanitized
|
# Path should already be sanitized
|
||||||
self.path = sanitize_path(path).strip("/")
|
self.path = sanitize_path(path).strip("/")
|
||||||
self.encoding = self.configuration.get("encoding", "stock")
|
self._encoding = self.configuration.get("encoding", "stock")
|
||||||
|
# DEPRECATED: Use ``self._encoding`` instead
|
||||||
|
self.encoding = self._encoding
|
||||||
self._filesystem_path = path_to_filesystem(folder, self.path)
|
self._filesystem_path = path_to_filesystem(folder, self.path)
|
||||||
self._props_path = os.path.join(
|
self._props_path = os.path.join(
|
||||||
self._filesystem_path, ".Radicale.props")
|
self._filesystem_path, ".Radicale.props")
|
||||||
@ -731,7 +733,7 @@ class Collection(BaseCollection):
|
|||||||
directory = os.path.dirname(path)
|
directory = os.path.dirname(path)
|
||||||
tmp = NamedTemporaryFile(
|
tmp = NamedTemporaryFile(
|
||||||
mode=mode, dir=directory, delete=False, prefix=".Radicale.tmp-",
|
mode=mode, dir=directory, delete=False, prefix=".Radicale.tmp-",
|
||||||
newline=newline, encoding=None if "b" in mode else self.encoding)
|
newline=newline, encoding=None if "b" in mode else self._encoding)
|
||||||
try:
|
try:
|
||||||
yield tmp
|
yield tmp
|
||||||
self._fsync(tmp.fileno())
|
self._fsync(tmp.fileno())
|
||||||
@ -932,7 +934,7 @@ class Collection(BaseCollection):
|
|||||||
raise UnsafePathError(href)
|
raise UnsafePathError(href)
|
||||||
path = path_to_filesystem(self._filesystem_path, href)
|
path = path_to_filesystem(self._filesystem_path, href)
|
||||||
fs.append(stack.enter_context(
|
fs.append(stack.enter_context(
|
||||||
open(path, "w", encoding=self.encoding, newline="")))
|
open(path, "w", encoding=self._encoding, newline="")))
|
||||||
fs[-1].write(item.serialize())
|
fs[-1].write(item.serialize())
|
||||||
# sync everything at once because it's slightly faster.
|
# sync everything at once because it's slightly faster.
|
||||||
for f in fs:
|
for f in fs:
|
||||||
@ -1194,7 +1196,7 @@ class Collection(BaseCollection):
|
|||||||
if input_hash != cinput_hash:
|
if input_hash != cinput_hash:
|
||||||
try:
|
try:
|
||||||
vobject_item = Item(self, href=href,
|
vobject_item = Item(self, href=href,
|
||||||
text=btext.decode(self.encoding)).item
|
text=btext.decode(self._encoding)).item
|
||||||
check_and_sanitize_item(vobject_item, uid=cuid,
|
check_and_sanitize_item(vobject_item, uid=cuid,
|
||||||
tag=self.get_meta("tag"))
|
tag=self.get_meta("tag"))
|
||||||
# Serialize the object again, to normalize the text
|
# Serialize the object again, to normalize the text
|
||||||
@ -1316,7 +1318,7 @@ class Collection(BaseCollection):
|
|||||||
if self._writer or self._meta_cache is None:
|
if self._writer or self._meta_cache is None:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
with open(self._props_path, encoding=self.encoding) as f:
|
with open(self._props_path, encoding=self._encoding) as f:
|
||||||
self._meta_cache = json.load(f)
|
self._meta_cache = json.load(f)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self._meta_cache = {}
|
self._meta_cache = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user