aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/iniconfig/patches/01-arcadia.patch
blob: b62a7c2f8e7273e66640a4d5c48b374c27b59fb4 (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
--- 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,14 @@ 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 
+ 
+                _, package, resource = self.path.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: