summaryrefslogtreecommitdiff
path: root/portato/backend
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-02-09 18:07:19 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-02-09 18:07:19 +0100
commit58e5f45f4c1f254e626e144c52ff527fcf8b0b59 (patch)
treec830ae9ee945035f9f1ba25224f13aacf7fc5350 /portato/backend
parentd6cbb904419bb5e5c0efcf2bf6cef40f52be94e6 (diff)
downloadportato-58e5f45f4c1f254e626e144c52ff527fcf8b0b59.tar.gz
portato-58e5f45f4c1f254e626e144c52ff527fcf8b0b59.tar.bz2
portato-58e5f45f4c1f254e626e144c52ff527fcf8b0b59.zip
Re-honor the newline add the end :). (It was removed by normal 'split()'). Other minor code enhancements too
Diffstat (limited to '')
-rw-r--r--portato/backend/flags.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/portato/backend/flags.py b/portato/backend/flags.py
index c80bf8d..baa1f37 100644
--- a/portato/backend/flags.py
+++ b/portato/backend/flags.py
@@ -343,22 +343,22 @@ def write_use_flags ():
"""This writes our changed useflags into the file."""
global newUseFlags, useFlags
+ def combine (list):
+ """Shortcut for reverting the list into a string."""
+ return " ".join(list)+"\n"
+
def insert (flag, list):
"""Shortcut for inserting a new flag right after the package-name."""
list.insert(1,flag)
def remove (flag, list):
"""Removes a flag."""
- try:
- list.remove(flag)
- except ValueError: # flag is given as flag\n
- list.remove(flag+"\n")
- list.append("\n") #re-insert the newline
+ list.remove(flag)
# no more flags there - comment it out
- if len(list) == 1 or list[1][0] in ("#","\n"):
+ if len(list) == 1 or list[1][0] == "#":
list[0] = "#"+list[0]
- insert("#removed by portato#",list)
+ list.append("#removed by portato#")
file_cache = {} # cache for having to read the file only once: name->[lines]
for cpv in newUseFlags:
@@ -388,7 +388,7 @@ def write_use_flags ():
remove(flag,l)
else:
insert(flag,l)
- lines.append(" ".join(l))
+ lines.append(combine(l))
# read the rest
lines.extend(f.readlines())
@@ -400,29 +400,30 @@ def write_use_flags ():
if delete:
remove(flag, l)
else:
- insert(flag,l)
- file_cache[file][line-1] = " ".join(l)
+ insert(flag, l)
+ file_cache[file][line-1] = combine(l)
if flagsToAdd:
# write new lines
msg = "\n#portato update#\n"
+ comb = combine(flagsToAdd)
if CONFIG["usePerVersion"]: # add on a per-version-base
- msg += "=%s %s\n" % (cpv, ' '.join(flagsToAdd))
+ msg += "=%s %s" % (cpv, comb)
else: # add on a per-package-base
list = system.split_cpv(cpv)
- msg += "%s/%s %s\n" % (list[0], list[1], ' '.join(flagsToAdd))
+ msg += "%s/%s %s" % (list[0], list[1], combine)
+
if not file in file_cache:
- f = open(file, "a")
- f.write(msg)
- f.close()
+ with open(file, "a") as f:
+ f.write(msg)
else:
file_cache[file].append(msg)
# write to disk
- for file in file_cache.keys():
- f = open(file, "w")
- f.writelines(file_cache[file])
- f.close()
+ for file in file_cache:
+ with open(file, "w") as f:
+ f.writelines(file_cache[file])
+
# reset
useFlags = {}
newUseFlags = {}
ow=1'>Make glade update the MainWindow.ui fileRené 'Necoro' Neumann1-85/+134 2009-09-06Moved the menu to an extra fileRené 'Necoro' Neumann2-210/+207 2009-09-05One database instance is enough :)René 'Necoro' Neumann1-7/+18 2009-09-05Print database type at the bottom of exceptions. NOTE: This does not handle ↵René 'Necoro' Neumann2-1/+6 multiple databases used at the same time 2009-09-05Fix an error, where a category vanishes after refreshing, using the ↵René 'Necoro' Neumann2-1/+19 EixSQLDatabase 2009-09-03And here is the debugging again :) ... using ctypesRené 'Necoro' Neumann1-1/+8 2009-09-03Screw debugging ... prefer the ctypes approach to get rid of yet another ↵René 'Necoro' Neumann3-27/+11 c-module. 2009-09-03Use this wrapper instead of ctypes to set the textdomain and stuff for the ↵René 'Necoro' Neumann1-9/+5 gtk.Builder 2009-09-03Add small wrapper to C-gettextRené 'Necoro' Neumann2-1/+22 2009-08-31Update messages.potRené 'Necoro' Neumann1-42/+94 2009-08-31Removed the gtk- strings from translationsRené 'Necoro' Neumann7-3639/+3479 2009-08-31Removed the 'translatable' attribute from 'gtk-*' stringsRené 'Necoro' Neumann5-11/+11 2009-08-31Removed TODO. Renamed ChangeLog to TODORené 'Necoro' Neumann2-40/+0 2009-08-27Only import stuff if necessaryRené 'Necoro' Neumann1-8/+8 2009-08-25Release the threadQueue-Lock in syncv0.13René 'Necoro' Neumann1-0/+1 2009-08-25Updated portugese translationAlberto Federman Neto1-650/+687 2009-08-15Update spanish translationDaniel Halens1-245/+258 2009-08-15Use boolean flags instead of obscure C flags for ipc.MessageQueueRené 'Necoro' Neumann3-13/+15 2009-08-15TypoRené 'Necoro' Neumann1-1/+1 2009-08-15Enhanced the extensions.shRené 'Necoro' Neumann1-3/+8 2009-08-15Move eix-format to correct locationRené 'Necoro' Neumann1-0/+0