mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- added new methods "__write_storelist()" and "store_readlist()"
this simplifies write_deletelist(), write_conflictlist(), read_tobedeleted(), read_inconflict()
This commit is contained in:
parent
25cbda4200
commit
af035f683e
53
osc/core.py
53
osc/core.py
@ -875,23 +875,10 @@ class Package:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
fname = os.path.join(self.storedir, '_size_limit')
|
store_write_string(self.absdir, '_size_limit', self.size_limit)
|
||||||
f = open(fname, 'w')
|
|
||||||
f.write(str(self.size_limit))
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def write_deletelist(self):
|
def write_deletelist(self):
|
||||||
if len(self.to_be_deleted) == 0:
|
self.__write_storelist('_to_be_deleted', self.to_be_deleted)
|
||||||
try:
|
|
||||||
os.unlink(os.path.join(self.storedir, '_to_be_deleted'))
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
fname = os.path.join(self.storedir, '_to_be_deleted')
|
|
||||||
f = open(fname, 'w')
|
|
||||||
f.write('\n'.join(self.to_be_deleted))
|
|
||||||
f.write('\n')
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def delete_source_file(self, n):
|
def delete_source_file(self, n):
|
||||||
"""delete local a source file"""
|
"""delete local a source file"""
|
||||||
@ -1036,18 +1023,17 @@ class Package:
|
|||||||
os.unlink(filename) # remove local files
|
os.unlink(filename) # remove local files
|
||||||
print_request_list(self.apiurl, self.prjname, self.name)
|
print_request_list(self.apiurl, self.prjname, self.name)
|
||||||
|
|
||||||
def write_conflictlist(self):
|
def __write_storelist(self, name, data):
|
||||||
if len(self.in_conflict) == 0:
|
if len(data) == 0:
|
||||||
try:
|
try:
|
||||||
os.unlink(os.path.join(self.storedir, '_in_conflict'))
|
os.unlink(os.path.join(self.storedir, name))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
fname = os.path.join(self.storedir, '_in_conflict')
|
store_write_string(self.absdir, name, '%s\n' % '\n'.join(data))
|
||||||
f = open(fname, 'w')
|
|
||||||
f.write('\n'.join(self.in_conflict))
|
def write_conflictlist(self):
|
||||||
f.write('\n')
|
self.__write_storelist('_in_conflict', self.in_conflict)
|
||||||
f.close()
|
|
||||||
|
|
||||||
def updatefile(self, n, revision):
|
def updatefile(self, n, revision):
|
||||||
filename = os.path.join(self.dir, n)
|
filename = os.path.join(self.dir, n)
|
||||||
@ -1976,16 +1962,14 @@ def read_filemeta(dir):
|
|||||||
'%s' % (dir, e))
|
'%s' % (dir, e))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def store_readlist(dir, name):
|
||||||
def read_tobedeleted(dir):
|
|
||||||
r = []
|
r = []
|
||||||
fname = os.path.join(dir, store, '_to_be_deleted')
|
if os.path.exists(os.path.join(dir, store, name)):
|
||||||
|
r = [line.strip() for line in open(os.path.join(dir, store, name), 'r')]
|
||||||
if os.path.exists(fname):
|
|
||||||
r = [ line.strip() for line in open(fname) ]
|
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def read_tobedeleted(dir):
|
||||||
|
return store_readlist(dir, '_to_be_deleted')
|
||||||
|
|
||||||
def read_sizelimit(dir):
|
def read_sizelimit(dir):
|
||||||
r = None
|
r = None
|
||||||
@ -1999,14 +1983,7 @@ def read_sizelimit(dir):
|
|||||||
return int(r)
|
return int(r)
|
||||||
|
|
||||||
def read_inconflict(dir):
|
def read_inconflict(dir):
|
||||||
r = []
|
return store_readlist(dir, '_in_conflict')
|
||||||
fname = os.path.join(dir, store, '_in_conflict')
|
|
||||||
|
|
||||||
if os.path.exists(fname):
|
|
||||||
r = [ line.strip() for line in open(fname) ]
|
|
||||||
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
def parseargs(list_of_args):
|
def parseargs(list_of_args):
|
||||||
"""Convenience method osc's commandline argument parsing.
|
"""Convenience method osc's commandline argument parsing.
|
||||||
|
Loading…
Reference in New Issue
Block a user