mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 09:57:37 +03:00 
			
		
		
		
	Return env interpolation on Python 2 to support pypy 2
This commit is contained in:
		
							parent
							
								
									ecc2b585a0
								
							
						
					
					
						commit
						881764dc56
					
				| 
						 | 
					@ -52,17 +52,31 @@ if yaml:
 | 
				
			||||||
    yaml.add_constructor('!path', yaml_env_marker_constructor)
 | 
					    yaml.add_constructor('!path', yaml_env_marker_constructor)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class EnvInterpolation(iniconfigparser.BasicInterpolation):
 | 
					if sys.version_info[0] == 3:
 | 
				
			||||||
    """Interpolation which expands environment variables in values."""
 | 
					    class EnvInterpolation(iniconfigparser.BasicInterpolation):
 | 
				
			||||||
 | 
					        """Interpolation which expands environment variables in values."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def before_get(self, parser, section, option, value, defaults):
 | 
					        def before_get(self, parser, section, option, value, defaults):
 | 
				
			||||||
        value = super().before_get(parser, section, option, value, defaults)
 | 
					            value = super().before_get(parser, section, option, value, defaults)
 | 
				
			||||||
        return os.path.expandvars(value)
 | 
					            return os.path.expandvars(value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _parse_ini_file(filepath):
 | 
					    def _parse_ini_file(filepath):
 | 
				
			||||||
    parser = iniconfigparser.ConfigParser(interpolation=EnvInterpolation())
 | 
					        parser = iniconfigparser.ConfigParser(interpolation=EnvInterpolation())
 | 
				
			||||||
    parser.read(filepath)
 | 
					        parser.read(filepath)
 | 
				
			||||||
    return parser
 | 
					        return parser
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    import StringIO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _parse_ini_file(filepath):
 | 
				
			||||||
 | 
					        parser = iniconfigparser.ConfigParser()
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            with open(filepath) as config_file:
 | 
				
			||||||
 | 
					                config_string = os.path.expandvars(config_file.read())
 | 
				
			||||||
 | 
					        except IOError:
 | 
				
			||||||
 | 
					            return parser
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            parser.readfp(StringIO.StringIO(config_string))
 | 
				
			||||||
 | 
					            return parser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cdef class Provider:
 | 
					cdef class Provider:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user