def __init__(self): """ Create a new, empty file. Some more or less sensible defaults are set up so that if you do try to synthesise a cpio archive from a default-constructed File you don't get utter rubbish. No guarantees you get a valid archive either though .. * key_name is the name of the key under which this file is stored in the parent hierarchy. It's a complete hack, but essential for finding a file in the key map quickly without which deletion becomes an O(n^2) operation (and N = number of files in the root fs, so it's quite high). * self.name - is the name of the file in the target archive. * self.fs_name - is the name of the file in the underlying filesystem. * self.orig_file - is the name of the file from which the data in this file object comes. """ self.dev = 0 self.ino = 0 self.mode = 0644 self.uid = 0 self.gid = 0 self.nlink = 1 self.rdev = 0 self.mtime = utils.unix_time() self.name = None self.data = None self.orig_file = None # Children of this directory, if it is one. self.children = [] self.fs_name = None
def __init__(self): """ Create a new, empty file. Some more or less sensible defaults are set up so that if you do try to synthesise a cpio archive from a default-constructed File you don't get utter rubbish. No guarantees you get a valid archive either though .. * key_name is the name of the key under which this file is stored in the parent hierarchy. It's a complete hack, but essential for finding a file in the key map quickly without which deletion becomes an O(n^2) operation (and N = number of files in the root fs, so it's quite high). * self.name - is the name of the file in the target archive. * self.fs_name - is the name of the file in the underlying filesystem. * self.orig_file - is the name of the file from which the data in this file object comes. """ self.dev = 0 self.ino = 0 self.mode = 0644 self.uid = 0 self.gid = 0 self.nlink = 1 self.rdev = 0 self.mtime = utils.unix_time() self.name = None self.data = None self.orig_file = None # Children of this directory, if it is one. self.children = [ ] self.fs_name = None
def file_from_data(name, data): """ Creates a File object from some explicit data you give it. """ outfile = File() outfile.name = name outfile.data = data # Last modified just now .. outfile.mtime = utils.unix_time() outfile.orig_file = None return outfile
def write_version_file(self, builder): """ Write the version file """ utils.ensure_dir(self.dir_name(builder)) print "dir %s ensured." % (self.dir_name(builder)) f = open(self.file_name(builder), 'w') f.write("<?xml version=\"1.0\" ?>\n") f.write("\n") f.write("<version>\n") self.write_elem(f, "name", self.swname) self.write_elem(f, "version", self.version) self.write_elem(f, "build", self.build) if (self.withDate): self.write_elem(f, "built-at", utils.iso_time()) self.write_elem(f, "built-time", utils.unix_time()) if (self.withUser): self.write_elem(f, "built-by", utils.current_user()) if (self.withMachine): self.write_elem(f, "built-on", utils.current_machine_name()) f.write("</version>\n") f.close()
def write_version_file(self, builder): """ Write the version file """ utils.ensure_dir(self.dir_name(builder)) print "dir %s ensured."%(self.dir_name(builder)) f = open(self.file_name(builder), 'w') f.write("<?xml version=\"1.0\" ?>\n") f.write("\n") f.write("<version>\n") self.write_elem(f, "name", self.swname) self.write_elem(f, "version", self.version) self.write_elem(f, "build", self.build) if (self.withDate): self.write_elem(f, "built-at", utils.iso_time()) self.write_elem(f, "built-time", utils.unix_time()) if (self.withUser): self.write_elem(f, "built-by", utils.current_user()) if (self.withMachine): self.write_elem(f, "built-on", utils.current_machine_name()) f.write("</version>\n") f.close()