Skip to content

Commit

Permalink
puke 1.5.0
Browse files Browse the repository at this point in the history
Few fixes
More FileSystem features
  • Loading branch information
etabard committed Jan 16, 2012
1 parent 996c5aa commit b576ac6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion puke/FileList.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def check(flist, full = False):

def __explore(self, dir ):
dir = os.path.abspath(dir)
for file in [file for file in os.listdir(dir) if not file in [".",".."]]:
for file in sorted([file for file in os.listdir(dir) if not file in [".",".."]]):
nfile = os.path.join(dir,file)

if os.path.isdir(nfile):
Expand Down
19 changes: 16 additions & 3 deletions puke/FileSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@ def isdir(dirname):
return True


def writefile(dst, content, mtime = None):
def writefile(dst, content, mtime = None, binary = False):
# First test for existance of destination directory
makedir(os.path.dirname(dst))

# Open file handle and write
if binary:
mode = "wb"
else:
mode = "w"
try:
handle = open(dst, mode="wb")
handle = open(dst, mode=mode)
handle.write(content)
handle.close()
except Exception as e:
Expand All @@ -154,6 +158,15 @@ def abspath(path):
def basename(path):
return os.path.basename(path)

def dirname(path):
return os.path.dirname(path)

def normpath(path):
return os.path.normpath(path)

def sep():
return os.sep

def chown(path, uname = None, gname = None):
isfile(path)

Expand All @@ -171,7 +184,7 @@ def chown(path, uname = None, gname = None):


if uid == None or gid == None:
raise FileSystemError('Invalid uname or gname')
raise FileSystemError('CHOWN %s : Invalid uname or gname (%s->%s:%s->%s)' % (path, uname, uid, gname, gid))

return os.chown(path, uid, gid)

Expand Down
9 changes: 6 additions & 3 deletions puke/Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@ def pack (file_list, output):

console.confirm(" %s packed" % output)

def unpack (pack_file, output, extract = None):
def unpack (pack_file, output, extract = None, verbose=True):

console.header( "- Unpacking %s to %s " % (pack_file, output))

if not Compress.check(pack_file):
console.error(" %s is not a valid pack" % output)
raise PukeError('%s is not a valid pack' % output)
return

comp = Compress.open(pack_file, "r")
Expand All @@ -347,8 +348,10 @@ def unpack (pack_file, output, extract = None):

if exists(output_file) and os.path.getmtime(output_file) == infos.mtime:
continue

console.info(' + %s' % __pretty(output_file))

if verbose == True:
console.info(' + %s' % __pretty(output_file))

writefile(output_file, data, mtime=infos.mtime)

if infos.mode:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name = "puke",
version = "1.5.0b25",
version = "1.5.0",
packages = ['puke'],

scripts = [
Expand Down

0 comments on commit b576ac6

Please sign in to comment.