diff --git a/README.rst b/README.rst index 6cb340e..c5f9d7d 100644 --- a/README.rst +++ b/README.rst @@ -22,11 +22,11 @@ You normally will like to specify some "version record files"; see below. Version Record Files ==================== -Version record files record which version of the software you know or is available. They are simple key-value pairs of ``(name, version)`` seperated by ``:`` :: +Version record files record which version of the software you know or is available. They are simple key-value pairs of ``(name, version)`` seperated by a space\ [#]_:: - fcitx: 4.2.7 - google-chrome: 27.0.1453.93-200836 - vim: 7.3.1024 + fcitx 4.2.7 + google-chrome 27.0.1453.93-200836 + vim 7.3.1024 Say you've got a version record file called ``old_ver.txt`` which records all your watched software and their versions. To update it using ``nvchecker``:: @@ -36,7 +36,7 @@ Compare the two files for updates (assuming they are sorted alphabetically; file comm -13 old_ver.txt new_ver.txt # or say that in English: - comm -13 old_ver.txt new_ver.txt | sed 's/:/ has updated to version/;s/$/./' + comm -13 old_ver.txt new_ver.txt | awk '{print $1 " has updated to version " $2 "."}' # show both old and new versions join old_ver.txt new_ver.txt | awk '$2 != $3' @@ -137,4 +137,7 @@ TODO ==== * Tool to replace the ``join`` command * Support GitHub tags -* Remove troublesome colon from record files + +Footnotes +========= +.. [#] Note: with nvchecker <= 0.2, there are one more colon each line. You can use ``sed -i 's/://' FILES...`` to remove them. diff --git a/nvchecker/__init__.py b/nvchecker/__init__.py index b650ceb..cce384d 100644 --- a/nvchecker/__init__.py +++ b/nvchecker/__init__.py @@ -1 +1 @@ -__version__ = '0.2' +__version__ = '0.3' diff --git a/nvchecker/main.py b/nvchecker/main.py index 8bc2a0d..1a4f8ac 100755 --- a/nvchecker/main.py +++ b/nvchecker/main.py @@ -52,10 +52,10 @@ def print_version_update(name, version): oldver = g_oldver.get(name, None) if not oldver or parse_version(oldver) < parse_version(version): - logger.info('%s: updated version %s', name, version) + logger.info('%s updated version %s', name, version) _updated(name, version) else: - logger.info('%s: current version %s', name, version) + logger.info('%s current version %s', name, version) task_dec() def _updated(name, version): diff --git a/nvchecker/util.py b/nvchecker/util.py index d3303cd..5f3a84b 100644 --- a/nvchecker/util.py +++ b/nvchecker/util.py @@ -72,14 +72,14 @@ def read_verfile(file): v = {} with open(file) as f: for l in f: - name, ver = [x.strip() for x in l.split(':', 1)] + name, ver = l.rstrip().split(None, 1) v[name] = ver return v def write_verfile(file, versions): # sort using only alphanums, as done by the sort command, and needed by # comm command - data = ['%s: %s\n' % item + data = ['%s %s\n' % item for item in sorted(versions.items(), key=lambda i: (''.join(filter(str.isalnum, i[0])), i[1]))] safe_overwrite(file, data, method='writelines')