aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/iniconfig/patches/01-arcadia.patch
blob: 3c618d6f09b2f339117a9428ba360bf8c45c3d10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--- contrib/python/iniconfig/iniconfig/__init__.py	(index)
+++ contrib/python/iniconfig/iniconfig/__init__.py	(working tree)
@@ -1,6 +1,7 @@
 """ brain-dead simple parser for ini-style files.
 (C) Ronny Pfannschmidt, Holger Krekel -- MIT licensed
 """
+import os
 __all__ = ['IniConfig', 'ParseError']
 
 COMMENTCHARS = "#;"
@@ -49,7 +50,15 @@ class IniConfig(object):
     def __init__(self, path, data=None):
         self.path = str(path)  # convenience
         if data is None:
-            f = open(self.path)
+            if os.path.basename(self.path).startswith('pkg:'):
+                import io, pkgutil
+
+                basename = os.path.basename(self.path)
+                _, package, resource = basename.split(':')
+                content = pkgutil.get_data(package, resource)
+                f = io.StringIO(content.decode('utf-8'))
+            else:
+                f = open(self.path)
             try:
                 tokens = self._parse(iter(f))
             finally: