@@ -59,18 +59,14 @@ class FileOrData(object):
5959 content of obj[%file_key_name] and represent it as file or data.
6060 Note that the data is preferred. The obj[%file_key_name] will be used iff
6161 obj['%data_key_name'] is not set or empty. Assumption is file content is
62- raw data and data field is base64 string. The assumption can be changed
63- with base64_file_content flag. If set to False, the content of the file
64- will assumed to be base64 and read as is. The default True value will
65- result in base64 encode of the file content after read."""
62+ raw data and data field is base64 string."""
6663
6764 def __init__ (self , obj , file_key_name , data_key_name = None ,
68- file_base_path = "" , base64_file_content = True ):
65+ file_base_path = "" ):
6966 if not data_key_name :
7067 data_key_name = file_key_name + "-data"
7168 self ._file = None
7269 self ._data = None
73- self ._base64_file_content = base64_file_content
7470 if data_key_name in obj :
7571 self ._data = obj [data_key_name ]
7672 elif file_key_name in obj :
@@ -82,11 +78,8 @@ def as_file(self):
8278 decoded obj[%data_key_name] content otherwise obj[%file_key_name]."""
8379 use_data_if_no_file = not self ._file and self ._data
8480 if use_data_if_no_file :
85- if self ._base64_file_content :
86- self ._file = _create_temp_file_with_content (
87- base64 .decodestring (self ._data .encode ()))
88- else :
89- self ._file = _create_temp_file_with_content (self ._data )
81+ self ._file = _create_temp_file_with_content (
82+ base64 .decodestring (self ._data .encode ()))
9083 if self ._file and not os .path .isfile (self ._file ):
9184 raise ConfigException ("File does not exists: %s" % self ._file )
9285 return self ._file
@@ -97,11 +90,8 @@ def as_data(self):
9790 use_file_if_no_data = not self ._data and self ._file
9891 if use_file_if_no_data :
9992 with open (self ._file ) as f :
100- if self ._base64_file_content :
101- self ._data = bytes .decode (
102- base64 .encodestring (str .encode (f .read ())))
103- else :
104- self ._data = f .read ()
93+ self ._data = bytes .decode (
94+ base64 .encodestring (str .encode (f .read ())))
10595 return self ._data
10696
10797
@@ -174,8 +164,7 @@ def _load_gcp_token(self):
174164 def _load_user_token (self ):
175165 token = FileOrData (
176166 self ._user , 'tokenFile' , 'token' ,
177- file_base_path = self ._config_base_path ,
178- base64_file_content = False ).as_data ()
167+ file_base_path = self ._config_base_path ).as_data ()
179168 if token :
180169 self .token = "Bearer %s" % token
181170 return True
0 commit comments