11import os
22import sys
33import locale
4- from itertools import chain
54from configparser import ConfigParser
5+ from itertools import chain
6+ from pathlib import Path
67from xdg import BaseDirectory
78
89from .autocomplete import AutocompleteModes
@@ -35,12 +36,12 @@ def supports_box_chars():
3536
3637def get_config_home ():
3738 """Returns the base directory for bpython's configuration files."""
38- return os . path . join (BaseDirectory .xdg_config_home , "bpython" )
39+ return Path (BaseDirectory .xdg_config_home ) / "bpython"
3940
4041
4142def default_config_path ():
4243 """Returns bpython's default configuration file path."""
43- return os . path . join ( get_config_home (), "config" )
44+ return get_config_home () / "config"
4445
4546
4647def fill_config_with_default_values (config , default_values ):
@@ -53,11 +54,9 @@ def fill_config_with_default_values(config, default_values):
5354 config .set (section , opt , f"{ val } " )
5455
5556
56- def loadini (struct , configfile ):
57+ def loadini (struct , config_path ):
5758 """Loads .ini configuration file and stores its values in struct"""
5859
59- config_path = os .path .expanduser (configfile )
60-
6160 config = ConfigParser ()
6261 defaults = {
6362 "general" : {
@@ -287,18 +286,15 @@ def get_key_no_doublebind(command):
287286 else :
288287 struct .color_scheme = dict ()
289288
290- theme_filename = color_scheme_name + ".theme"
291- path = os .path .expanduser (
292- os .path .join (get_config_home (), theme_filename )
293- )
289+ path = get_config_home () / f"{ color_scheme_name } .theme"
294290 try :
295291 load_theme (struct , path , struct .color_scheme , default_colors )
296292 except OSError :
297- sys .stderr .write (f"Could not load theme '{ color_scheme_name } '.\n " )
293+ sys .stderr .write (f"Could not load theme '{ color_scheme_name } ' from { path } .\n " )
298294 sys .exit (1 )
299295
300296 # expand path of history file
301- struct .hist_file = os . path . expanduser (struct .hist_file )
297+ struct .hist_file = Path (struct .hist_file ). expanduser ( )
302298
303299 # verify completion mode
304300 if struct .autocomplete_mode is None :
0 commit comments