1
- from typing import Optional
1
+ from typing import List , Optional
2
2
3
3
4
4
class Version :
@@ -63,7 +63,7 @@ def get(filename: str):
63
63
mark = False
64
64
for line in file .readlines ():
65
65
if "bundleVersion: " in line :
66
- content = line .split (": " )[1 ]. strip ()
66
+ content = line .split (": " )[1 ]
67
67
content_splited = content .split ("." )
68
68
if len (content_splited ) != 3 :
69
69
raise Exception (
@@ -81,13 +81,13 @@ def get(filename: str):
81
81
+ "x, y and z should be an integers"
82
82
)
83
83
elif "iPhone: " in line and mark :
84
- content = line .split (": " )[1 ]. strip ()
84
+ content = line .split (": " )[1 ]
85
85
try :
86
86
build = int (content )
87
87
except ValueError :
88
88
raise Exception ("Build should be an integer" )
89
89
elif "AndroidBundleVersionCode: " in line :
90
- content = line .split (": " )[1 ]. strip ()
90
+ content = line .split (": " )[1 ]
91
91
try :
92
92
code = int (content )
93
93
except ValueError :
@@ -106,9 +106,25 @@ def get(filename: str):
106
106
raise Exception (f"Error parsing file: { version } " )
107
107
return version
108
108
109
- @staticmethod
110
- def set (filename : str ):
111
- pass
109
+ def set (self , filename : str ):
110
+ lines : List [str ] = []
111
+ with open (filename , mode = "r" ) as file :
112
+ mark = False
113
+ for line in file .readlines ():
114
+ if "bundleVersion: " in line :
115
+ content = line .split (":" )[0 ]
116
+ lines .append (f"{ content } : { self .major } .{ self .minor } .{ self .patch } \n " )
117
+ elif "iPhone: " in line and mark :
118
+ content = line .split (":" )[0 ]
119
+ lines .append (f"{ content } : { self .build } \n " )
120
+ elif "AndroidBundleVersionCode: " in line :
121
+ content = line .split (":" )[0 ]
122
+ lines .append (f"{ content } : { self .code } \n " )
123
+ else :
124
+ lines .append (line )
125
+ mark = "buildNumber:" in line
126
+ with open (filename , mode = "w" ) as file :
127
+ file .writelines (lines )
112
128
113
129
@staticmethod
114
130
def parse (version : str ) -> Optional ["Version" ]:
0 commit comments