Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6fb906e

Browse files
authored
Merge pull request #14010 from anntzer/home
Deprecate get_home()
2 parents 3ba7b19 + c5b896a commit 6fb906e

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``matplotlib.get_home`` is deprecated (use e.g. ``os.path.expanduser("~")``)
5+
instead.

lib/matplotlib/__init__.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ def checkdep_usetex(s):
497497
return True
498498

499499

500+
@cbook.deprecated("3.2", alternative="os.path.expanduser('~')")
500501
@_logged_cached('$HOME=%s')
501502
def get_home():
502503
"""
@@ -526,10 +527,7 @@ def _get_xdg_config_dir():
526527
base directory spec
527528
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
528529
"""
529-
return (os.environ.get('XDG_CONFIG_HOME')
530-
or (str(Path(get_home(), ".config"))
531-
if get_home()
532-
else None))
530+
return os.environ.get('XDG_CONFIG_HOME') or str(Path.home() / ".config")
533531

534532

535533
def _get_xdg_cache_dir():
@@ -538,10 +536,7 @@ def _get_xdg_cache_dir():
538536
base directory spec
539537
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
540538
"""
541-
return (os.environ.get('XDG_CACHE_HOME')
542-
or (str(Path(get_home(), ".cache"))
543-
if get_home()
544-
else None))
539+
return os.environ.get('XDG_CACHE_HOME') or str(Path.home() / ".cache")
545540

546541

547542
def _get_config_or_cache_dir(xdg_base):
@@ -550,20 +545,15 @@ def _get_config_or_cache_dir(xdg_base):
550545
configdir = Path(configdir).resolve()
551546
elif sys.platform.startswith(('linux', 'freebsd')) and xdg_base:
552547
configdir = Path(xdg_base, "matplotlib")
553-
elif get_home():
554-
configdir = Path(get_home(), ".matplotlib")
555548
else:
556-
configdir = None
557-
558-
if configdir:
559-
try:
560-
configdir.mkdir(parents=True, exist_ok=True)
561-
except OSError:
562-
pass
563-
else:
564-
if os.access(str(configdir), os.W_OK) and configdir.is_dir():
565-
return str(configdir)
566-
549+
configdir = Path.home() / ".matplotlib"
550+
try:
551+
configdir.mkdir(parents=True, exist_ok=True)
552+
except OSError:
553+
pass
554+
else:
555+
if os.access(str(configdir), os.W_OK) and configdir.is_dir():
556+
return str(configdir)
567557
return _create_tmp_config_or_cache_dir()
568558

569559

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@
9494
# OS Font paths
9595
MSFolders = \
9696
r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
97-
9897
MSFontDirectories = [
9998
r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts',
10099
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts']
101-
102100
MSUserFontDirectories = [
103-
os.path.join(str(Path.home()), r'AppData\Local\Microsoft\Windows\Fonts'),
104-
os.path.join(str(Path.home()), r'AppData\Roaming\Microsoft\Windows\Fonts')]
105-
101+
str(Path.home() / 'AppData/Local/Microsoft/Windows/Fonts'),
102+
str(Path.home() / 'AppData/Roaming/Microsoft/Windows/Fonts'),
103+
]
106104
X11FontDirectories = [
107105
# an old standard installation point
108106
"/usr/X11R6/lib/X11/fonts/TTF/",
@@ -118,7 +116,6 @@
118116
Path.home() / ".local/share")) / "fonts"),
119117
str(Path.home() / ".fonts"),
120118
]
121-
122119
OSXFontDirectories = [
123120
"/Library/Fonts/",
124121
"/Network/Library/Fonts/",

0 commit comments

Comments
 (0)