Skip to content

Commit

Permalink
Implement version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leynier committed Dec 21, 2020
1 parent c300e3f commit dbe8f99
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Test](https://github.com/educup/uvm/workflows/CI/badge.svg)](https://github.com/educup/uvm/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/educup/uvm/branch/main/graph/badge.svg?token=Z1MEEL3EAB)](https://codecov.io/gh/educup/uvm)
[![DeepSource](https://deepsource.io/gh/educup/uvm.svg/?label=active+issues)](https://deepsource.io/gh/educup/uvm/?ref=repository-badge)
[![Version](https://img.shields.io/pypi/v/uvm?color=%2334D058&label=Version)](https://pypi.org/project/uvm)
[![Last commit](https://img.shields.io/github/last-commit/educup/uvm.svg?style=flat)](https://github.com/educup/uvm/commits)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/educup/uvm)](https://github.com/educup/uvm/commits)
Expand Down
30 changes: 23 additions & 7 deletions uvm/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import List, Optional


class Version:
Expand Down Expand Up @@ -63,7 +63,7 @@ def get(filename: str):
mark = False
for line in file.readlines():
if "bundleVersion: " in line:
content = line.split(": ")[1].strip()
content = line.split(": ")[1]
content_splited = content.split(".")
if len(content_splited) != 3:
raise Exception(
Expand All @@ -81,13 +81,13 @@ def get(filename: str):
+ "x, y and z should be an integers"
)
elif "iPhone: " in line and mark:
content = line.split(": ")[1].strip()
content = line.split(": ")[1]
try:
build = int(content)
except ValueError:
raise Exception("Build should be an integer")
elif "AndroidBundleVersionCode: " in line:
content = line.split(": ")[1].strip()
content = line.split(": ")[1]
try:
code = int(content)
except ValueError:
Expand All @@ -106,9 +106,25 @@ def get(filename: str):
raise Exception(f"Error parsing file: {version}")
return version

@staticmethod
def set(filename: str):
pass
def set(self, filename: str):
lines: List[str] = []
with open(filename, mode="r") as file:
mark = False
for line in file.readlines():
if "bundleVersion: " in line:
content = line.split(":")[0]
lines.append(f"{content}: {self.major}.{self.minor}.{self.patch}\n")
elif "iPhone: " in line and mark:
content = line.split(":")[0]
lines.append(f"{content}: {self.build}\n")
elif "AndroidBundleVersionCode: " in line:
content = line.split(":")[0]
lines.append(f"{content}: {self.code}\n")
else:
lines.append(line)
mark = "buildNumber:" in line
with open(filename, mode="w") as file:
file.writelines(lines)

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

0 comments on commit dbe8f99

Please sign in to comment.