commit setconf for openSUSE:Factory
Hello community, here is the log from the commit of package setconf for openSUSE:Factory checked in at 2017-05-10 20:53:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/setconf (Old) and /work/SRC/openSUSE:Factory/.setconf.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "setconf" Wed May 10 20:53:28 2017 rev:8 rq:494040 version:0.7.4 Changes: -------- --- /work/SRC/openSUSE:Factory/setconf/setconf.changes 2016-05-10 09:27:34.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.setconf.new/setconf.changes 2017-05-10 20:53:31.537378852 +0200 @@ -1,0 +2,8 @@ +Tue May 9 16:45:47 UTC 2017 - sor.alexei@meowr.ru + +- Update to version 0.7.4 (changes since 0.7.2): + * Add Python 3.5 when testing. + * Can change single-line #define values by using the -d flag. + * Correctly formatted help text. + +------------------------------------------------------------------- Old: ---- setconf-0.7.2.tar.xz New: ---- setconf-0.7.4.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ setconf.spec ++++++ --- /var/tmp/diff_new_pack.WptNm4/_old 2017-05-10 20:53:32.385259205 +0200 +++ /var/tmp/diff_new_pack.WptNm4/_new 2017-05-10 20:53:32.393258077 +0200 @@ -1,7 +1,7 @@ # # spec file for package setconf # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: setconf -Version: 0.7.2 +Version: 0.7.4 Release: 0 Summary: Utility to easily change settings in configuration files License: GPL-2.0+ @@ -38,8 +38,8 @@ # Nothing to build. %install -install -Dm 0755 %{name}.py %{buildroot}%{_bindir}/%{name} -install -Dm 0644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1 +install -Dpm 0755 %{name}.py %{buildroot}%{_bindir}/%{name} +install -Dpm 0644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1 %files %defattr(-,root,root) ++++++ setconf-0.7.2.tar.xz -> setconf-0.7.4.tar.xz ++++++ Binary files old/setconf-0.7.2/setconf.1.gz and new/setconf-0.7.4/setconf.1.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/setconf-0.7.2/setconf.py new/setconf-0.7.4/setconf.py --- old/setconf-0.7.2/setconf.py 2016-03-28 15:07:26.000000000 +0200 +++ new/setconf-0.7.4/setconf.py 2016-10-30 15:46:34.000000000 +0100 @@ -33,7 +33,7 @@ from decimal import Decimal from base64 import b64decode -VERSION = "0.7.2" +VERSION = "0.7.4" # TODO: Use optparse or argparse if shedskin is no longer a target. @@ -145,7 +145,7 @@ return passes -def change(lines, key, value): +def change(lines, key, value, define=False): key = bs(key) value = bs(value) @@ -154,7 +154,17 @@ if not line.strip(): newlines.append(line) continue - firstp = firstpart(line, False) + if define: + if line.strip().startswith(b"#define") and line.count(b" ") >= 2: + firstp = line.split()[1].strip() + oldvalue = line.split()[2].strip() + if firstp == key: + newlines.append(line.replace(oldvalue, value)) + continue + newlines.append(line) + continue + else: + firstp = firstpart(line, False) if not firstp: newlines.append(line) continue @@ -187,8 +197,23 @@ print("Change passes: %s" % (passes)) return passes +def test_change_define(): + passes = True + + testcontent = b"#define X 12" + testcontent_changed = b"#define X 42" + output = change([testcontent], "X", "42", define=True)[0] + passes = passes and output == testcontent_changed + + testcontent = b" #define X 12" + testcontent_changed = b" #define X 42" + output = change([testcontent], "X", "42", define=True)[0] + passes = passes and output == testcontent_changed + + print("Change define passes: %s" % (passes)) + return passes -def changefile(filename, key, value, dummyrun=False): +def changefile(filename, key, value, dummyrun=False, define=False): """if dummyrun==True, don't write but return True if changes would have been made""" key = bs(key) @@ -209,7 +234,7 @@ elif not data.endswith(NL): final_nl = False # Change and write the file - changed_contents = NL.join(change(lines, key, value)) + changed_contents = NL.join(change(lines, key, value, define=define)) # Only add a final newline if the original contents had one at the end if final_nl: changed_contents += NL @@ -273,7 +298,7 @@ return passes -def change_multiline(data, key, value, endstring=NL, verbose=True, searchfrom=0): +def change_multiline(data, key, value, endstring=NL, verbose=True, searchfrom=0, define=False): data = bs(data) key = bs(key) @@ -299,7 +324,7 @@ # If the first part of the line is not a key (could be because it's commented out)... if not firstpart(line): # Search again, from endpos this time - return change_multiline(data, key, value, endstring, verbose, endpos) + return change_multiline(data, key, value, endstring, verbose, endpos, define=define) after = data[endpos + len(endstring):] newbetween = changeline(between, value) @@ -553,6 +578,7 @@ passes = True passes = passes and test_changeline() passes = passes and test_change() + passes = passes and test_change_define() passes = passes and test_changefile() passes = passes and test_change_multiline() passes = passes and test_changefile_multiline() @@ -651,6 +677,7 @@ print("\t-v or --version\t\tversion number") print("\t-a or --add\t\tadd the option if it doesn't exist") print("\t\t\t\tcreates the file if needed") + print("\t-d or --define\t\tset a #define") #print("\t-r or --remove\t\tremove the option if it exist") print("") print("Examples:") @@ -660,6 +687,7 @@ print("\tsetconf PKGBUILD sha256sums \"('123abc' 'abc123')\" ')'") print("\tsetconf app.py NUMS \"[1, 2, 3]\" ']'") print("\tsetconf -a server.conf ABC 123") + print("\tsetconf -d linux/printk.h CONSOLE_LOGLEVEL_DEFAULT=4") #print("\tsetconf -r server.conf ABC") print("") elif args[0] in ["-v", "--version"]: @@ -701,7 +729,6 @@ create_if_missing(filename) - # Change the file if possible, if not, add the key value assignment = None special = None for ass in ASSIGNMENTS: @@ -713,6 +740,7 @@ _, value = keyvalue.split(assignment, 1) key = firstpart(keyvalue, False) + # Change the file if possible, if not, add the key value if changefile(filename, key, value, dummyrun=True): changefile(filename, key, value) else: @@ -720,6 +748,23 @@ data = f.read() if not has_key(data, key): addtofile(filename, keyvalue) + elif args[0] in ["-d", "--define"]: + filename = args[1] + keyvalue = bs(args[2]) + + assignment = None + special = None + for ass in ASSIGNMENTS: + if ass in keyvalue: + assignment = ass + break + if not assignment: + sysexit(2) + _, value = keyvalue.split(assignment, 1) + key = firstpart(keyvalue, False) + + # Change the #define value in the file + changefile(filename, key, value, define=True) else: # Single line replace ("x 123") filename = args[0]
participants (1)
-
root@hilbert.suse.de