summaryrefslogtreecommitdiff
path: root/poezio/config.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-07-05 12:24:36 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-07-05 12:24:36 +0200
commit5c1dc0006fdde769aa068142b5f2f81dbae85f18 (patch)
treef1665b06cf51f28994b7dcb4be2b6ac45ff26a44 /poezio/config.py
parent60f21c0df4adaf3573e5e2f708a2237af83b458e (diff)
downloadpoezio-5c1dc0006fdde769aa068142b5f2f81dbae85f18.tar.gz
poezio-5c1dc0006fdde769aa068142b5f2f81dbae85f18.tar.bz2
poezio-5c1dc0006fdde769aa068142b5f2f81dbae85f18.tar.xz
poezio-5c1dc0006fdde769aa068142b5f2f81dbae85f18.zip
config: Stop using os.path to split pathlib.Path objects.
Diffstat (limited to 'poezio/config.py')
-rw-r--r--poezio/config.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/poezio/config.py b/poezio/config.py
index 0c7eaf96..f7d73164 100644
--- a/poezio/config.py
+++ b/poezio/config.py
@@ -19,7 +19,7 @@ import sys
import pkg_resources
from configparser import RawConfigParser, NoOptionError, NoSectionError
-from os import path, remove
+from os import remove
from shutil import copy2
from pathlib import Path
from poezio.args import parse_args
@@ -338,19 +338,17 @@ class Config(RawConfigParser):
before copying it to the final destination
"""
try:
- prefix, file = path.split(self.file_name)
- filename = path.join(prefix, '.%s.tmp' % file)
- fd = os.fdopen(
- os.open(
- filename,
- os.O_WRONLY | os.O_CREAT,
- 0o600,
- ),
- 'w',
- encoding='utf-8')
- for line in lines:
- fd.write('%s\n' % line)
- fd.close()
+ filename = self.file_name.parent / ('.%s.tmp' % self.file_name.name)
+ with os.fdopen(
+ os.open(
+ filename,
+ os.O_WRONLY | os.O_CREAT,
+ 0o600,
+ ),
+ 'w',
+ encoding='utf-8') as fd:
+ for line in lines:
+ fd.write('%s\n' % line)
copy2(filename, self.file_name)
remove(filename)
except:
@@ -501,7 +499,7 @@ def file_ok(filepath):
Returns True if the file exists and is readable and writeable,
False otherwise.
"""
- val = path.exists(filepath)
+ val = filepath.exists()
val &= os.access(filepath, os.R_OK | os.W_OK)
return bool(val)