forked from pool/python-dparse
43 lines
1.4 KiB
Diff
43 lines
1.4 KiB
Diff
|
|
From a3d83e8bdfd694e873b5775881ab5aa62fdbb674 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Mathieu Dupuy <deronnax@gmail.com>
|
||
|
|
Date: Fri, 8 Sep 2023 11:49:00 +0200
|
||
|
|
Subject: [PATCH] replace ConfigParser's 'readfp' by 'read_string'
|
||
|
|
|
||
|
|
fixes "DeprecationWarning: This method will be removed in Python 3.12. Use
|
||
|
|
parser.read_file instead", and will marginally improve performance
|
||
|
|
---
|
||
|
|
dparse/parser.py | 6 ++----
|
||
|
|
1 file changed, 2 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/dparse/parser.py b/dparse/parser.py
|
||
|
|
index f200607..923b362 100644
|
||
|
|
--- a/dparse/parser.py
|
||
|
|
+++ b/dparse/parser.py
|
||
|
|
@@ -3,8 +3,6 @@
|
||
|
|
import re
|
||
|
|
import sys
|
||
|
|
|
||
|
|
-from io import StringIO
|
||
|
|
-
|
||
|
|
from configparser import ConfigParser, NoOptionError
|
||
|
|
from pathlib import PurePath
|
||
|
|
|
||
|
|
@@ -305,7 +303,7 @@ def parse(self):
|
||
|
|
:return:
|
||
|
|
"""
|
||
|
|
parser = ConfigParser()
|
||
|
|
- parser.readfp(StringIO(self.obj.content))
|
||
|
|
+ parser.read_string(self.obj.content)
|
||
|
|
for section in parser.sections():
|
||
|
|
try:
|
||
|
|
content = parser.get(section=section, option="deps")
|
||
|
|
@@ -413,7 +411,7 @@ def parse(self):
|
||
|
|
class SetupCfgParser(Parser):
|
||
|
|
def parse(self):
|
||
|
|
parser = ConfigParser()
|
||
|
|
- parser.readfp(StringIO(self.obj.content))
|
||
|
|
+ parser.read_string(self.obj.content)
|
||
|
|
for section in parser.values():
|
||
|
|
if section.name == 'options':
|
||
|
|
options = 'install_requires', 'setup_requires', 'test_require'
|