Skip to content

Commit 1e32210

Browse files
committed
Added method to update version strings. Started bumping project version.
1 parent 90f1d20 commit 1e32210

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

CHANGELOG.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
= Verace Changelog
22

3+
== verace-0.2.5 (2015-12-08)
4+
=== Release highlights
5+
- Added convenience function.
6+
7+
=== All additions and changes
8+
- Added `update()` method to allow version strings in files to be updated.
9+
10+
=== Bug fixes
11+
Not applicable.
12+
313
== verace-0.2.4 (2015-10-21)
414
=== Release highlights
515
- Fixed bug related to passing directory as `root` parameter to `VerChecker`.

lib/_Upload_PyPI.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@
1414
sys.dont_write_bytecode = True
1515

1616
from _Check_Versions import VERCHK
17+
from _Install_Package import generate_readme, cleanup_readme
1718

1819
##==============================================================#
1920
## SECTION: Main Body #
2021
##==============================================================#
2122

2223
if __name__ == '__main__':
2324
ver = VERCHK.run()
24-
if ver:
25-
if qprompt.ask_yesno("Upload version `%s`?" % (ver)):
26-
subprocess.call("asciidoc -b docbook ../README.adoc", shell=True)
27-
subprocess.call("pandoc -r docbook -w rst -o README.rst ../README.xml", shell=True)
28-
os.remove("../README.xml")
29-
if os.path.exists("README.rst"):
30-
subprocess.call("python setup.py sdist upload", shell=True)
31-
os.remove("README.rst")
32-
else:
33-
qprompt.alert("Readme not generated properly!")
34-
else:
25+
if not ver:
3526
qprompt.alert("Issue with version info!")
27+
exit()
28+
if qprompt.ask_yesno("Upload version `%s`?" % (ver)):
29+
generate_readme()
30+
subprocess.call("python setup.py sdist upload", shell=True)
31+
cleanup_readme()

lib/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
setup(
44
name = "verace",
5-
version = "0.2.4",
5+
version = "0.2.5",
66
author = "Jeff Rimko",
77
author_email = "jeffrimko@gmail.com",
88
description = "Library for checking version strings in project files.",
99
license = "MIT",
10+
keywords = "project files version check library",
1011
url = "https://github.com/jeffrimko/Verace",
1112
py_modules=["verace"],
1213
long_description=open("README.rst").read(),

lib/verace.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
##==============================================================#
1010

1111
import copy
12+
import os
1213
import os.path as op
1314
from collections import namedtuple
1415

@@ -17,7 +18,7 @@
1718
##==============================================================#
1819

1920
#: Library version string.
20-
__version__ = "0.2.4"
21+
__version__ = "0.2.5"
2122

2223
#: Contains version information for a single checked item.
2324
VerInfo = namedtuple("VerInfo", "path linenum string")
@@ -88,6 +89,22 @@ def run(self, verbose=True, debug=False):
8889
self._string = None
8990
vprint(" [!] WARNING: No version info found!")
9091
return self._string
92+
def update(self, newver):
93+
"""Updates all associated version strings to the given new string. Use
94+
caution as this will modify file content!"""
95+
self.run(verbose=False)
96+
for vi in self._vinfos:
97+
with open(vi.path) as fi:
98+
temp = op.join(
99+
op.dirname(vi.path),
100+
"__temp-verace-" + op.basename(vi.path))
101+
with open(temp, "w") as fo:
102+
for num,line in enumerate(fi.readlines(), 1):
103+
if num == vi.linenum:
104+
line = line.replace(vi.string, newver)
105+
fo.write(line)
106+
os.remove(vi.path)
107+
os.rename(temp, vi.path)
91108

92109
##==============================================================#
93110
## SECTION: Function Definitions #

0 commit comments

Comments
 (0)