revert r12253 as it breaks whole external scripts which uses specFile cause api.init becomes must with that revision, we will solve these issues with the big refactor :)

This commit is contained in:
S.Çağlar Onur
2007-02-09 10:07:39 +00:00
parent 1105b99964
commit 06935526cc
3 changed files with 9 additions and 29 deletions
+4 -9
View File
@@ -90,14 +90,11 @@ class File:
return localfile return localfile
@staticmethod @staticmethod
def download(uri, transfer_dir = None, sha1sum = False, def download(uri, transfer_dir = "/tmp", sha1sum = False,
compress = None, sign = None, copylocal = False): compress = None, sign = None, copylocal = False):
assert isinstance(uri, URI) assert isinstance(uri, URI)
if not transfer_dir:
transfer_dir = ctx.config.tmp_dir()
if sha1sum: if sha1sum:
sha1filename = File.download(URI(uri.get_uri() + '.sha1sum'), transfer_dir) sha1filename = File.download(URI(uri.get_uri() + '.sha1sum'), transfer_dir)
sha1f = file(sha1filename) sha1f = file(sha1filename)
@@ -142,14 +139,12 @@ class File:
return localfile return localfile
def __init__(self, uri, mode, transfer_dir = None, def __init__(self, uri, mode, transfer_dir = "/tmp",
sha1sum = False, compress = None, sign = None): sha1sum = False, compress = None, sign = None):
"it is pointless to open a file without a URI and a mode" "it is pointless to open a file without a URI and a mode"
if transfer_dir: self.transfer_dir = transfer_dir
self.transfer_dir = transfer_dir
else:
self.trasfer_dir = ctx.config.tmp_dir()
self.sha1sum = sha1sum self.sha1sum = sha1sum
self.compress = compress self.compress = compress
self.sign = sign self.sign = sign
+3 -14
View File
@@ -310,11 +310,8 @@ class autoxml(oo.autosuper, oo.autoprop):
# generate top-level helper functions # generate top-level helper functions
cls.initializers = inits cls.initializers = inits
def initialize(self, uri = None, keepDoc = False, tmpDir = None, def initialize(self, uri = None, keepDoc = False, tmpDir = '/tmp',
**args): **args):
if not tmpDir:
tmpDir = ctx.config.tmp_dir()
if xmlfile_support: if xmlfile_support:
if args.has_key('tag'): if args.has_key('tag'):
XmlFile.__init__(self, tag = args['tag']) XmlFile.__init__(self, tag = args['tag'])
@@ -435,13 +432,9 @@ class autoxml(oo.autosuper, oo.autoprop):
if errs: if errs:
errs.append(_("autoxml.parse: String '%s' has errors") % xml) errs.append(_("autoxml.parse: String '%s' has errors") % xml)
def read(self, uri, keepDoc = False, tmpDir = None, def read(self, uri, keepDoc = False, tmpDir = '/tmp',
sha1sum = False, compress = None, sign = None, copylocal = False): sha1sum = False, compress = None, sign = None, copylocal = False):
"read XML file and decode it into a python object" "read XML file and decode it into a python object"
if not tmpDir:
tmpDir = ctx.config.tmp_dir()
self.readxml(uri, tmpDir, sha1sum=sha1sum, self.readxml(uri, tmpDir, sha1sum=sha1sum,
compress=compress, sign=sign, copylocal=copylocal) compress=compress, sign=sign, copylocal=copylocal)
errs = [] errs = []
@@ -460,7 +453,7 @@ class autoxml(oo.autosuper, oo.autoprop):
errs.append(_("autoxml.read: File '%s' has errors") % uri) errs.append(_("autoxml.read: File '%s' has errors") % uri)
raise Error(*errs) raise Error(*errs)
def write(self, uri, keepDoc = False, tmpDir = None, def write(self, uri, keepDoc = False, tmpDir = '/tmp',
sha1sum = False, compress = None, sign = None): sha1sum = False, compress = None, sign = None):
"encode the contents of the python object into an XML file" "encode the contents of the python object into an XML file"
errs = self.errors() errs = self.errors()
@@ -468,10 +461,6 @@ class autoxml(oo.autosuper, oo.autoprop):
errs.append(_("autoxml.write: object validation has failed")) errs.append(_("autoxml.write: object validation has failed"))
raise Error(*errs) raise Error(*errs)
errs = [] errs = []
if not tmpDir:
tmpDir = ctx.config.tmp_dir()
self.newDocument() self.newDocument()
self.encode(self.rootNode(), errs) self.encode(self.rootNode(), errs)
if hasattr(self, 'write_hook'): if hasattr(self, 'write_hook'):
+2 -6
View File
@@ -72,12 +72,8 @@ class XmlFile(object):
raise Error(_("File '%s' has invalid XML") % (f) ) raise Error(_("File '%s' has invalid XML") % (f) )
def readxml(self, uri, tmpDir=None, sha1sum=False, def readxml(self, uri, tmpDir='/tmp', sha1sum=False,
compress=None, sign=None, copylocal = False): compress=None, sign=None, copylocal = False):
if not tmpDir:
tmpDir = ctx.config.tmp_dir()
uri = File.make_uri(uri) uri = File.make_uri(uri)
#try: #try:
localpath = File.download(uri, tmpDir, sha1sum=sha1sum, localpath = File.download(uri, tmpDir, sha1sum=sha1sum,
@@ -90,7 +86,7 @@ class XmlFile(object):
except Exception, e: except Exception, e:
raise Error(_("File '%s' has invalid XML") % (localpath) ) raise Error(_("File '%s' has invalid XML") % (localpath) )
def writexml(self, uri, tmpDir = None, sha1sum=False, compress=None, sign=None): def writexml(self, uri, tmpDir = '/tmp', sha1sum=False, compress=None, sign=None):
f = File(uri, File.write, sha1sum=sha1sum, compress=compress, sign=sign) f = File(uri, File.write, sha1sum=sha1sum, compress=compress, sign=sign)
f.write(self.doc.toPrettyString()) f.write(self.doc.toPrettyString())
f.close() f.close()