Skip to content

Commit dbe8f99

Browse files
committed
Implement version 1.0.0
1 parent c300e3f commit dbe8f99

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

docs/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
44
[![Test](https://github.com/educup/uvm/workflows/CI/badge.svg)](https://github.com/educup/uvm/actions?query=workflow%3ACI)
55
[![codecov](https://codecov.io/gh/educup/uvm/branch/main/graph/badge.svg?token=Z1MEEL3EAB)](https://codecov.io/gh/educup/uvm)
6-
[![DeepSource](https://deepsource.io/gh/educup/uvm.svg/?label=active+issues)](https://deepsource.io/gh/educup/uvm/?ref=repository-badge)
76
[![Version](https://img.shields.io/pypi/v/uvm?color=%2334D058&label=Version)](https://pypi.org/project/uvm)
87
[![Last commit](https://img.shields.io/github/last-commit/educup/uvm.svg?style=flat)](https://github.com/educup/uvm/commits)
98
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/educup/uvm)](https://github.com/educup/uvm/commits)

uvm/core.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from typing import List, Optional
22

33

44
class Version:
@@ -63,7 +63,7 @@ def get(filename: str):
6363
mark = False
6464
for line in file.readlines():
6565
if "bundleVersion: " in line:
66-
content = line.split(": ")[1].strip()
66+
content = line.split(": ")[1]
6767
content_splited = content.split(".")
6868
if len(content_splited) != 3:
6969
raise Exception(
@@ -81,13 +81,13 @@ def get(filename: str):
8181
+ "x, y and z should be an integers"
8282
)
8383
elif "iPhone: " in line and mark:
84-
content = line.split(": ")[1].strip()
84+
content = line.split(": ")[1]
8585
try:
8686
build = int(content)
8787
except ValueError:
8888
raise Exception("Build should be an integer")
8989
elif "AndroidBundleVersionCode: " in line:
90-
content = line.split(": ")[1].strip()
90+
content = line.split(": ")[1]
9191
try:
9292
code = int(content)
9393
except ValueError:
@@ -106,9 +106,25 @@ def get(filename: str):
106106
raise Exception(f"Error parsing file: {version}")
107107
return version
108108

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)
112128

113129
@staticmethod
114130
def parse(version: str) -> Optional["Version"]:

0 commit comments

Comments
 (0)