@@ -61,7 +61,7 @@ class Config:
6161 runtime). The key is the property that will be read. The value is the environment variables, minus prefix,
6262 that contains the value to look up.
6363 """
64- directVariables = {
64+ _directVariables = {
6565 "project" : "PROJECT" ,
6666 "appDir" : "APP_DIR" ,
6767 "applicationName" : 'APPLICATION_NAME' ,
@@ -74,50 +74,50 @@ class Config:
7474 (runtime only). The key is the property that will be read. The value is the environment variables, minus
7575 prefix, that contains the value to look up.
7676 """
77- directVariablesRuntime = {
77+ _directVariablesRuntime = {
7878 "branch" : "BRANCH" ,
7979 "environment" : "ENVIRONMENT" ,
8080 "documentRoot" : "DOCUMENT_ROOT" ,
8181 "smtpHost" : "SMTP_HOST"
8282 }
8383
84- unPrefixedVariablesRuntime = {
84+ _unPrefixedVariablesRuntime = {
8585 "port" : "PORT" ,
8686 "socket" : "SOCKET"
8787 }
8888
8989 """
9090 A local copy of all environment variables as of when the object was initialized.
9191 """
92- environmentVariables = []
92+ _environmentVariables = []
9393
9494 """
9595 The vendor prefix for all environment variables we care about.
9696 """
97- envPrefix = ''
97+ _envPrefix = ''
9898
9999 """
100100 The routes definition array. Only available at runtime.
101101 """
102- routesDef = []
102+ _routesDef = []
103103
104104 """
105105 The relationships definition array. Only available at runtime.
106106 """
107- relationshipsDef = []
107+ _relationshipsDef = []
108108
109109 """
110110 The variables definition array. Available in both build and runtime, although possibly with different
111111 values.
112112 """
113- variablesDef = []
113+ _variablesDef = []
114114
115115 """
116116 The application definition array. This is, approximately, the .platform.app.yaml file in nested dictionary form.
117117 """
118- applicationDef = []
118+ _applicationDef = []
119119
120- credentialFormatters = {}
120+ _credentialFormatters = {}
121121
122122 def __init__ (self , environment_variables = None , env_prefix = 'PLATFORM_' ):
123123 """Constructs a ConfigReader object.
@@ -130,27 +130,27 @@ def __init__(self, environment_variables=None, env_prefix='PLATFORM_'):
130130
131131 """
132132
133- self .environmentVariables = os .environ if environment_variables is None else environment_variables
134- self .envPrefix = env_prefix
133+ self ._environmentVariables = os .environ if environment_variables is None else environment_variables
134+ self ._envPrefix = env_prefix
135135
136136 if self .is_valid_platform ():
137137 if self .in_runtime ():
138138 if self ['ROUTES' ]:
139139 routes = self ['ROUTES' ]
140- self .routesDef = self .decode (routes )
140+ self ._routesDef = self .decode (routes )
141141 if self ['RELATIONSHIPS' ]:
142142 relationships = self ['RELATIONSHIPS' ]
143- self .relationshipsDef = self .decode (relationships )
143+ self ._relationshipsDef = self .decode (relationships )
144144
145145 self .register_formatter ('pymongo' , pymongo_formatter )
146146 self .register_formatter ('pysolr' , pysolr_formatter )
147147
148148 if self ['VARIABLES' ]:
149149 variables = self ['VARIABLES' ]
150- self .variablesDef = self .decode (variables )
150+ self ._variablesDef = self .decode (variables )
151151 if self ['APPLICATION' ]:
152152 application = self ['APPLICATION' ]
153- self .applicationDef = self .decode (application )
153+ self ._applicationDef = self .decode (application )
154154
155155 def is_valid_platform (self ):
156156 """Checks whether the code is running on a platform with valid environment variables.
@@ -210,15 +210,15 @@ def credentials(self, relationship, index=0):
210210 raise BuildTimeVariableAccessException (
211211 'Relationships are not available during the build phase.'
212212 )
213- if relationship not in self .relationshipsDef :
213+ if relationship not in self ._relationshipsDef :
214214 raise KeyError (
215215 'No relationship defined: {}. Check your .platform.app.yaml file.'
216216 .format (relationship ))
217- if index >= len (self .relationshipsDef ):
217+ if index >= len (self ._relationshipsDef ):
218218 raise KeyError ('No index {} defined for relationship: {}. '
219219 'Check your .platform.app.yaml file.' .format (
220220 index , relationship ))
221- return self .relationshipsDef [relationship ][index ]
221+ return self ._relationshipsDef [relationship ][index ]
222222
223223 def variable (self , name , default = None ):
224224 """Returns a variable from the VARIABLES array.
@@ -241,7 +241,7 @@ def variable(self, name, default=None):
241241
242242 if not self .is_valid_platform ():
243243 return default
244- return self .variablesDef .get (name , default )
244+ return self ._variablesDef .get (name , default )
245245
246246 def variables (self ):
247247 """Returns the full variables array.
@@ -258,7 +258,7 @@ def variables(self):
258258 raise NotValidPlatformException (
259259 'You are not running on Platform.sh, so the variables array is not available.'
260260 )
261- return self .variablesDef
261+ return self ._variablesDef
262262
263263 @property
264264 def routes (self ):
@@ -280,7 +280,7 @@ def routes(self):
280280 raise BuildTimeVariableAccessException (
281281 'Routes are not available during the build phase.'
282282 )
283- return self .routesDef
283+ return self ._routesDef
284284
285285 def get_route (self , route_id ):
286286 """Get route definition by route ID.
@@ -319,7 +319,7 @@ def application(self):
319319 raise NotValidPlatformException (
320320 'You are not running on Platform.sh, so the application definitions are not available.'
321321 )
322- return self .applicationDef
322+ return self ._applicationDef
323323
324324 def on_enterprise (self ):
325325 """Determines if the current environment is a Platform.sh Enterprise environment.
@@ -370,7 +370,7 @@ def register_formatter(self, name, formatter):
370370
371371 """
372372
373- self .credentialFormatters [name ] = formatter
373+ self ._credentialFormatters [name ] = formatter
374374 return self
375375
376376 def formatted_credentials (self , relationship , formatter ):
@@ -387,12 +387,12 @@ def formatted_credentials(self, relationship, formatter):
387387 NoCredentialFormatterFoundException
388388
389389 """
390- if formatter not in self .credentialFormatters :
390+ if formatter not in self ._credentialFormatters :
391391 raise NoCredentialFormatterFoundException (
392392 'There is no credential formatter named {0} registered. Did you remember to call register_formatter()?'
393393 .format (formatter )
394394 )
395- return self .credentialFormatters [formatter ](self .credentials (relationship ))
395+ return self ._credentialFormatters [formatter ](self .credentials (relationship ))
396396
397397 def __getitem__ (self , item ):
398398 """Reads an environment variable, taking the prefix into account.
@@ -403,9 +403,9 @@ def __getitem__(self, item):
403403
404404 """
405405
406- check_name = self .envPrefix + item .upper ()
406+ check_name = self ._envPrefix + item .upper ()
407407
408- return self .environmentVariables .get (check_name )
408+ return self ._environmentVariables .get (check_name )
409409
410410 @staticmethod
411411 def decode (variable ):
@@ -470,23 +470,23 @@ def __getattr__(self, config_property):
470470 raise NotValidPlatformException (
471471 'You are not running on Platform.sh, so the {0} variable is not available.' .format (config_property )
472472 )
473- is_build_var = config_property in self .directVariables .keys ()
474- is_runtime_var = config_property in self .directVariablesRuntime .keys ()
473+ is_build_var = config_property in self ._directVariables .keys ()
474+ is_runtime_var = config_property in self ._directVariablesRuntime .keys ()
475475
476476 # For now, all unprefixed variables are also runtime variables. If that ever changes this logic will change
477477 # with it.
478- is_unprefixed_var = config_property in self .unPrefixedVariablesRuntime .keys ()
478+ is_unprefixed_var = config_property in self ._unPrefixedVariablesRuntime .keys ()
479479
480480 if self .in_build () and is_runtime_var :
481481 raise BuildTimeVariableAccessException (
482482 'The {0} variable is not available during build time.' .format (config_property )
483483 )
484484 if is_build_var :
485- return self [self .directVariables [config_property ]]
485+ return self [self ._directVariables [config_property ]]
486486 if is_runtime_var :
487- return self [self .directVariablesRuntime [config_property ]]
487+ return self [self ._directVariablesRuntime [config_property ]]
488488 if is_unprefixed_var :
489- return self .environmentVariables .get (self .unPrefixedVariablesRuntime [config_property ])
489+ return self ._environmentVariables .get (self ._unPrefixedVariablesRuntime [config_property ])
490490 raise AttributeError ('No such variable defined: ' .format (config_property ))
491491
492492 def isset (self , config_property ):
@@ -505,12 +505,12 @@ def isset(self, config_property):
505505 if not self .is_valid_platform ():
506506 return False
507507
508- is_build_var = config_property in self .directVariables .keys ()
509- is_runtime_var = config_property in self .directVariablesRuntime .keys ()
508+ is_build_var = config_property in self ._directVariables .keys ()
509+ is_runtime_var = config_property in self ._directVariablesRuntime .keys ()
510510
511511 # For now, all unprefixed variables are also runtime variables. If that ever changes this logic will change
512512 # with it.
513- is_unprefixed_var = config_property in self .unPrefixedVariablesRuntime .keys ()
513+ is_unprefixed_var = config_property in self ._unPrefixedVariablesRuntime .keys ()
514514
515515 if self .in_build ():
516516 return is_build_var and config_property is not None
0 commit comments