jrabbit / Xz.py secret
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View Xz.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# xz support module
# copyright 2010 Jack Laxson (Jrabbit)
from subprocess import Popen
import os
 
def is_xzfile(path):
extension = path.split("/")[-1].split(".")[-1]
if extension is "xz":
return True
 
def expand(xz):
Popen(['xz', '-d', xz])
 
# move all the files into the workingdir
def move(path, workDir):
pwd = path.split("/")[:-1]
for f in os.listdir(pwd)
os.rename(f, os.path.join(workDir, f))
View Xz.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Index: haikuporter
===================================================================
--- haikuporter (revision 1221)
+++ haikuporter (working copy)
@@ -24,7 +24,7 @@
import hashlib
import shutil
import commands
-from subprocess import check_call
+from subprocess import check_call, Popen
from optparse import OptionParser
# -- HaikuPorts options -------------------------------------------------------
@@ -684,6 +684,13 @@
zf = zipfile.ZipFile(self.downloadDir + "/" + self.src_local, 'r')
zf.extractall(self.workDir)
zf.close()
+ elif archiveFullPath.split("/")[-1].split(".")[-1] == "xz":
+ Popen(['xz', '-d', archiveFullPath])
+ tar = archiveFullPath[:-3]
+ if tarfile.is_tarfile(tar):
+ tf = tarfile.open(tar, 'r')
+ tf.extractall(self.workDir)
+ tf.close()
else:
sys.exit("Error: Unrecognized archive type.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.