Skip to content

Commit 34045f8

Browse files
committed
First commit.
0 parents  commit 34045f8

File tree

11 files changed

+395
-0
lines changed

11 files changed

+395
-0
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Verace Changelog
2+
================
3+
## verace-0.1.0 (TODO)
4+
### Release highlights
5+
- First release.
6+
7+
### All additions and changes
8+
Not applicable.
9+
10+
### Bug fixes
11+
Not applicable.

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Jeff Rimko
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Verace
2+
3+
## Introduction
4+
This project provides a Python 2.x library for creating scripts that check version strings. The main features are the following:
5+
6+
- Custom parse any project files for version string.
7+
- Easily determine if all version strings in a project are consistent.
8+
- Should work on any platform without additional dependencies.
9+
10+
## Status
11+
Currently, this project is **under active development**. The contents of the repository should be considered unstable during active development.

_Check_Dependencies.bat

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
::=============================================================::
2+
:: DEVELOPED 2013, REVISED 2013, Jeff Rimko. ::
3+
::=============================================================::
4+
5+
::=============================================================::
6+
:: SECTION: Environment Setup ::
7+
::=============================================================::
8+
9+
@set TITLE=%~n0 "%~dp0"
10+
@cd /d %~dp0 && echo off && title %TITLE%
11+
12+
::=============================================================::
13+
:: SECTION: Main Body ::
14+
::=============================================================::
15+
16+
:: Check for Python.
17+
call:ChkDepVer^
18+
"Python"^
19+
"Python language interpreter."^
20+
"www.python.org"^
21+
"2.7"^
22+
python -V
23+
24+
pause
25+
exit /b 0
26+
27+
::=============================================================::
28+
:: SECTION: Function Definitions ::
29+
::=============================================================::
30+
31+
::-------------------------------------------------------------::
32+
:: Checks if a dependency is available.
33+
::
34+
:: **Params**:
35+
:: - 1 - Name of dependency.
36+
:: - 2 - Description of dependency.
37+
:: - 3 - Reference website or where to obtain info.
38+
:: - 4 - Recommended version.
39+
:: - 5+ - Non-blocking command to check if installed; usually version display
40+
:: or help.
41+
::
42+
:: **Attention**:
43+
:: Do not use quotes around the non-blocking command.
44+
:: Quotes may be included in the remaining params if they are needed for the
45+
:: non-blocking call.
46+
::
47+
:: **Preconditions**:
48+
:: The global variable DEP_OK should be set to 1 before the first call to this
49+
:: function.
50+
::
51+
:: **Postconditions**:
52+
:: The global variable DEP_OK will be set to 0 if a dependency check fails.
53+
:: This variable is not set back to 1 by this function, it may be explicitly
54+
:: set outside the function
55+
::
56+
:: **Example**:
57+
:: call::ChkDep^
58+
:: "Utility"^
59+
:: "Does something."^
60+
:: "www.website.com"^
61+
:: "1.2.3"^
62+
:: utility -h
63+
:: call::ChkDep^
64+
:: "Utility"^
65+
:: "Does something."^
66+
:: "www.website.com"^
67+
:: "1.2.3"^
68+
:: utility -c "non-blocking cmd"
69+
::-------------------------------------------------------------::
70+
:ChkDep
71+
echo Checking dependency for %~1...
72+
shift
73+
echo %~1
74+
shift
75+
echo Reference: %~1
76+
shift
77+
echo Recommended version: %~1
78+
shift
79+
echo --------
80+
set CMD=%1
81+
shift
82+
:chkdep_shift_next
83+
if [%1] neq [] (
84+
set CMD=%CMD% %1
85+
shift
86+
goto:chkdep_shift_next
87+
)
88+
%CMD% > NUL 2>&1
89+
if %ERRORLEVEL% neq 0 (
90+
echo NOT FOUND!
91+
set DEP_OK=0
92+
goto:eof
93+
)
94+
echo OK.
95+
goto:eof
96+
97+
::-------------------------------------------------------------::
98+
:: Checks if a dependency is available and is the required version.
99+
::
100+
:: **Params**:
101+
:: - 1 - Name of dependency.
102+
:: - 2 - Description of dependency.
103+
:: - 3 - Reference website or where to obtain info.
104+
:: - 4 - Required version.
105+
:: - 5+ - Non-blocking command to check if installed; usually version display
106+
:: or help.
107+
::
108+
:: **Attention**:
109+
:: Do not use quotes around the non-blocking command.
110+
:: Quotes may be included in the remaining params if they are needed for the
111+
:: non-blocking call.
112+
::
113+
:: **Preconditions**:
114+
:: The global variable DEP_OK should be set to 1 before the first call to this
115+
:: function.
116+
::
117+
:: **Postconditions**:
118+
:: The global variable DEP_OK will be set to 0 if a dependency check fails.
119+
:: This variable is not set back to 1 by this function, it may be explicitly
120+
:: set outside the function
121+
::
122+
:: **Example**:
123+
:: call::ChkDepVer^
124+
:: "Utility"^
125+
:: "Does something."^
126+
:: "www.website.com"^
127+
:: "1.2.3"^
128+
:: utility -h
129+
:: call::ChkDepVer^
130+
:: "Utility"^
131+
:: "Does something."^
132+
:: "www.website.com"^
133+
:: "1.2.3"^
134+
:: utility -c "non-blocking cmd"
135+
::-------------------------------------------------------------::
136+
:ChkDepVer
137+
echo Checking dependency for %~1...
138+
shift
139+
echo %~1
140+
shift
141+
echo Reference: %~1
142+
shift
143+
set DEP_VER=%~1
144+
echo Required version: %DEP_VER%
145+
shift
146+
echo --------
147+
set CMD=%1
148+
shift
149+
:chkdepver_shift_next
150+
if [%1] neq [] (
151+
set CMD=%CMD% %1
152+
shift
153+
goto:chkdepver_shift_next
154+
)
155+
%CMD% > NUL 2>&1
156+
if %ERRORLEVEL% neq 0 (
157+
echo NOT FOUND!
158+
set DEP_OK=0
159+
goto:eof
160+
)
161+
%CMD% 2>&1 | find "%DEP_VER%" >NUL
162+
if %ERRORLEVEL% neq 0 (
163+
echo NOT FOUND!
164+
set DEP_OK=0
165+
goto:eof
166+
)
167+
echo OK.
168+
goto:eof

_Check_Versions.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
##==============================================================#
2+
## SECTION: Imports #
3+
##==============================================================#
4+
5+
from verace import VerChecker, VerInfo
6+
7+
##==============================================================#
8+
## SECTION: Class Definitions #
9+
##==============================================================#
10+
11+
class VeraceChecker(VerChecker):
12+
"""Check versions in the Verace project (meta)."""
13+
NAME = "Verace"
14+
def check_setup(self):
15+
path = r"lib\setup.py"
16+
with open(path) as f:
17+
for num,line in enumerate(f.readlines(), 1):
18+
if line.find("version =") > -1:
19+
return [VerInfo(path, num, line.split('"')[1].strip())]
20+
def check_main(self):
21+
path = r"lib\verace.py"
22+
with open(path) as f:
23+
for num,line in enumerate(f.readlines(), 1):
24+
if line.find("__version__ =") > -1:
25+
return [VerInfo(path, num, line.split('"')[1].strip())]
26+
def check_log(self):
27+
path = r"CHANGELOG.md"
28+
with open(path) as f:
29+
for num,line in enumerate(f.readlines(), 1):
30+
if line.find("verace-") > -1:
31+
return [VerInfo(path, num, line.split('-')[1].split(" ")[0].strip())]
32+
33+
##==============================================================#
34+
## SECTION: Main Body #
35+
##==============================================================#
36+
37+
if __name__ == '__main__':
38+
VeraceChecker(debug=False).show()
39+
raw_input("Press ENTER to continue...")

examples/file.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Hello world!
2+
version = 0.1.0
3+
One more:
4+
another = 0.1.0

examples/test_1.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from verace import VerChecker, VerInfo
2+
3+
class TestChecker(VerChecker):
4+
NAME = "Test"
5+
def check_version(self):
6+
path = r"file.txt"
7+
for num,line in enumerate(open(path).readlines()):
8+
if line.find("version") > -1:
9+
return [VerInfo(path, num+1, line.split('=')[1].strip())]
10+
def check_another(self):
11+
path = r"file.txt"
12+
for num,line in enumerate(open(path).readlines()):
13+
if line.find("another") > -1:
14+
return [VerInfo(path, num+1, line.split('=')[1].strip())]
15+
16+
if __name__ == '__main__':
17+
TestChecker().show()
18+
print "The version is `%s`." % (TestChecker().string())
19+
raw_input("Press ENTER to continue...")

lib/_Cleanup.bat

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:: Removes generated files.
2+
:: **Dependencies**: None
3+
4+
::=============================================================::
5+
:: DEVELOPED 2015, REVISED 2015, Jeff Rimko. ::
6+
::=============================================================::
7+
8+
::=============================================================::
9+
:: SECTION: Environment Setup ::
10+
::=============================================================::
11+
12+
@set TITLE=%~n0 "%~dp0"
13+
@cd /d %~dp0 && echo off && title %TITLE%
14+
15+
::=============================================================::
16+
:: SECTION: Main Body ::
17+
::=============================================================::
18+
19+
del /Q /S *.pyc 2>NUL
20+
rd /Q /S build 2>NUL
21+
rd /Q /S dist 2>NUL
22+
rd /Q /S verace.egg-info 2>NUL

lib/_Install_Package.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
:: Installs the Python package.
2+
:: **Dependencies**: Python on PATH.
3+
4+
::=============================================================::
5+
:: DEVELOPED 2015, REVISED 2015, Jeff Rimko. ::
6+
::=============================================================::
7+
8+
::=============================================================::
9+
:: SECTION: Environment Setup ::
10+
::=============================================================::
11+
12+
@set TITLE=%~n0 "%~dp0"
13+
@cd /d %~dp0 && echo off && title %TITLE%
14+
15+
::=============================================================::
16+
:: SECTION: Main Body ::
17+
::=============================================================::
18+
19+
python setup.py install
20+
pause

lib/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name = "verace",
5+
version = "0.1.0",
6+
author = "Jeff Rimko",
7+
author_email = "jeffrimko@gmail.com",
8+
description = "Library for creating version string checking scripts.",
9+
license = "MIT",
10+
url = "https://github.com/jeffrimko/Verace",
11+
py_modules=["verace"],
12+
long_description=__doc__,
13+
classifiers=[
14+
"Development Status :: 3 - Alpha",
15+
"Topic :: Utilities",
16+
"Programming Language :: Python :: 2.7",
17+
],
18+
)

0 commit comments

Comments
 (0)