Hello community, here is the log from the commit of package setconf for openSUSE:Factory checked in at 2014-10-22 16:23:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/setconf (Old) and /work/SRC/openSUSE:Factory/.setconf.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "setconf" Changes: -------- --- /work/SRC/openSUSE:Factory/setconf/setconf.changes 2014-07-20 10:49:58.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.setconf.new/setconf.changes 2014-10-22 16:23:22.000000000 +0200 @@ -1,0 +2,7 @@ +Mon Oct 20 12:17:15 UTC 2014 - sor.ale...@meowr.ru + +- Update to 0.6.3: + * Fixed a problem with -a that occurred when a key existed but was commented out + * Added regression test + +------------------------------------------------------------------- Old: ---- setconf-0.6.2.tar.xz New: ---- setconf-0.6.3.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ setconf.spec ++++++ --- /var/tmp/diff_new_pack.xWDoho/_old 2014-10-22 16:23:23.000000000 +0200 +++ /var/tmp/diff_new_pack.xWDoho/_new 2014-10-22 16:23:23.000000000 +0200 @@ -15,15 +15,15 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + Name: setconf -Version: 0.6.2 +Version: 0.6.3 Release: 0 Summary: Utility to easily change settings in configuration files License: GPL-2.0+ Group: Development/Tools/Building Url: http://setconf.roboticoverlords.org/ -Source: %{name}-%{version}.tar.xz - +Source: http://setconf.roboticoverlords.org/%{name}-%{version}.tar.xz Requires: python BuildArch: noarch @@ -38,8 +38,8 @@ # Nothing to build. %install -install -Dm 0755 -p %{name}.py %{buildroot}%{_bindir}/%{name} -install -Dm 0644 -p %{name}.1.gz %{buildroot}%{_mandir}/man1/%{name}.1.gz +install -Dm 0755 %{name}.py %{buildroot}%{_bindir}/%{name} +install -Dm 0644 %{name}.1.gz %{buildroot}%{_mandir}/man1/%{name}.1.gz %files %defattr(-,root,root) ++++++ setconf-0.6.2.tar.xz -> setconf-0.6.3.tar.xz ++++++ Files old/setconf-0.6.2/setconf.1.gz and new/setconf-0.6.3/setconf.1.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/setconf-0.6.2/setconf.py new/setconf-0.6.3/setconf.py --- old/setconf-0.6.2/setconf.py 2013-11-22 12:55:35.000000000 +0100 +++ new/setconf-0.6.3/setconf.py 2014-10-13 16:23:10.000000000 +0200 @@ -1,10 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/python2 # -*- coding: utf-8 -*- # # setconf # Utility for setting options in configuration files. # -# Alexander Rødseth <rods...@gmail.com> +# Alexander F Rødseth <rods...@gmail.com> # # GPL2 # @@ -17,6 +17,8 @@ # Mar 2013 # Jul 2013 # Nov 2013 +# Aug 2014 +# Oct 2014 # from sys import argv @@ -24,12 +26,21 @@ from os import linesep from os.path import exists from tempfile import mkstemp +from subprocess import check_output # TODO: Use optparse or argparse if shedskin is no longer a target. -VERSION = "0.6.2" +VERSION = "0.6.3" ASSIGNMENTS = ['==', '=>', '=', ':=', '::', ':'] +def get_encoding(filename): + """Use the output from the file command to guess the encoding. + Returns (True, encoding) or (False, None)""" + s = check_output(["/usr/bin/file", filename]).strip().decode('utf-8') + if s.endswith("text"): + return (True, s.split(" ")[1]) + else: + return (False, None) def firstpart(line, including_assignment=True): stripline = line.strip() @@ -413,11 +424,11 @@ def test_addline(): # --- TEST 1 --- - testcontent = "MOO=yes" + linesep - testcontent_changed = "MOO=no" + linesep + "X=123" + linesep + \ - "Y=345" + linesep + "Z:=567" + linesep + \ - "FJORD => 999" + linesep + 'vm.swappiness=1' \ - + linesep + testcontent = "# cache-ttl=65000" + linesep + "MOO=yes" + linesep + testcontent_changed = "# cache-ttl=65000" + linesep + "MOO=no" + linesep + \ + "X=123" + linesep + "Y=345" + linesep + "Z:=567" + linesep + \ + "FJORD => 999" + linesep + 'vm.swappiness=1' + \ + linesep + "cache-ttl=6" + linesep filename = mkstemp()[1] # Write the testfile file = open(filename, "w") @@ -431,6 +442,7 @@ main(["--add", filename, "MOO", "no"]) main(["-a", filename, "vm.swappiness=1"]) main(["-a", filename, "vm.swappiness=1"]) + main(["-a", filename, "cache-ttl=6"]) # Read the file file = open(filename, "r") newcontent = file.read() @@ -453,6 +465,7 @@ passes = True passes = passes and (newcontent == testcontent_changed) passes = passes and (newcontent2 == testcontent_changed2) + print("Addline passes: %s" % (passes)) return passes @@ -478,6 +491,19 @@ f.close() +def has_key(data, key): + """Check if the given key exists in the given data.""" + lines = data.split(linesep)[:-1] + for line in lines: + if not line.strip(): + # Skip blank lines + continue + first = firstpart(line, False) + if key == first: + return True + return False + + def main(args=argv[1:], exitok=True): if len(args) == 1: if args[0] in ["-t", "--test"]: @@ -543,7 +569,7 @@ f = open(filename) data = f.read() f.close() - if keyvalue not in data: + if not has_key(data, key): addtofile(filename, keyvalue) else: # Single line replace ("x 123") @@ -567,7 +593,7 @@ f = open(filename) data = f.read() f.close() - if keyvalue not in data: + if not has_key(data, key): addtofile(filename, keyvalue) else: # Multiline replace -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org