@@ -34,6 +34,11 @@ def _env_config() -> List[str]:
3434 os .path .expanduser ("~/.python-gitlab.cfg" ),
3535]
3636
37+ HELPER_PREFIX = "helper:"
38+
39+ HELPER_ATTRIBUTES = [
40+ "job_token" , "http_password" , "private_token" , "oauth_token"
41+ ]
3742
3843class ConfigError (Exception ):
3944 pass
@@ -151,15 +156,7 @@ def __init__(
151156 except Exception :
152157 pass
153158
154- for attr in ("job_token" , "http_password" , "private_token" , "oauth_token" ):
155- value = getattr (self , attr )
156- prefix = "lookup:"
157- if isinstance (value , str ) and value .lower ().strip ().startswith (prefix ):
158- helper = value [len (prefix ) :].strip ()
159- value = (
160- subprocess .check_output (helper , shell = True ).decode ("utf-8" ).strip ()
161- )
162- setattr (self , attr , value )
159+ self ._get_values_from_helper ()
163160
164161 self .api_version = "4"
165162 try :
@@ -203,3 +200,13 @@ def __init__(
203200 self .user_agent = self ._config .get (self .gitlab_id , "user_agent" )
204201 except Exception :
205202 pass
203+
204+ def _get_values_from_helper (self ):
205+ """Update attributes, which may get values from an external helper program
206+ """
207+ for attr in HELPER_ATTRIBUTES :
208+ value = getattr (self , attr )
209+ if isinstance (value , str ) and value .lower ().strip ().startswith (HELPER_PREFIX ):
210+ helper = value [len (HELPER_PREFIX ) :].strip ()
211+ value = subprocess .check_output ([helper ]).decode ("utf-8" ).strip ()
212+ setattr (self , attr , value )
0 commit comments