Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski authored Dec 1, 2023
1 parent f56b8ed commit 079fa60
Showing 1 changed file with 52 additions and 13 deletions.
65 changes: 52 additions & 13 deletions libhockeydata/hockeyfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,37 +162,55 @@ def UncompressFile(infile, mode="rt"):
import gzip;
except ImportError:
return False;
filefp = gzip.open(infile, mode, encoding="UTF-8");
try:
filefp = gzip.open(infile, mode, encoding="UTF-8");
except TypeError:
filefp = gzip.open(infile, mode);
if(compresscheck=="bzip2"):
try:
import bz2;
except ImportError:
return False;
filefp = bz2.open(infile, mode, encoding="UTF-8");
try:
filefp = bz2.open(infile, mode, encoding="UTF-8");
except TypeError:
filefp = bz2.open(infile, mode);
if(compresscheck=="zstd"):
try:
import zstandard;
except ImportError:
return False;
filefp = zstandard.open(infile, mode, encoding="UTF-8");
try:
filefp = zstandard.open(infile, mode, encoding="UTF-8");
except TypeError:
filefp = zstandard.open(infile, mode);
if(compresscheck=="lz4"):
try:
import lz4.frame;
except ImportError:
return False;
filefp = lz4.frame.open(infile, mode, encoding="UTF-8");
try:
filefp = lz4.frame.open(infile, mode, encoding="UTF-8");
except TypeError:
filefp = lz4.frame.open(infile, mode);
if(compresscheck=="lzo"):
try:
import lzo;
except ImportError:
return False;
filefp = lzo.open(infile, mode, encoding="UTF-8");
try:
filefp = lzo.open(infile, mode, encoding="UTF-8");
except TypeError:
filefp = lzo.open(infile, mode);
if(compresscheck=="lzma"):
try:
import lzma;
except ImportError:
return False;
filefp = lzma.open(infile, mode, encoding="UTF-8");
try:
filefp = lzma.open(infile, mode, encoding="UTF-8");
except TypeError:
filefp = lzma.open(infile, mode);
if(not compresscheck):
try:
filefp = open(infile, mode, encoding="UTF-8");
Expand Down Expand Up @@ -288,43 +306,64 @@ def CompressOpenFile(outfile):
import gzip;
except ImportError:
return False;
outfp = gzip.open(outfile, "wt", 9, encoding="UTF-8");
try:
outfp = gzip.open(outfile, "wt", 9, encoding="UTF-8");
except TypeError:
outfp = gzip.open(outfile, "wt", 9);
elif(fextname==".bz2"):
try:
import bz2;
except ImportError:
return False;
outfp = bz2.open(outfile, "wt", 9, encoding="UTF-8");
try:
outfp = bz2.open(outfile, "wt", 9, encoding="UTF-8");
except TypeError:
outfp = bz2.open(outfile, "wt", 9);
elif(fextname==".zst"):
try:
import zstandard;
except ImportError:
return False;
outfp = zstandard.open(outfile, "wt", zstandard.ZstdCompressor(level=10), encoding="UTF-8");
try:
outfp = zstandard.open(outfile, "wt", zstandard.ZstdCompressor(level=10), encoding="UTF-8");
except TypeError:
outfp = zstandard.open(outfile, "wt", zstandard.ZstdCompressor(level=10));
elif(fextname==".xz"):
try:
import lzma;
except ImportError:
return False;
outfp = lzma.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9, encoding="UTF-8");
try:
: outfp = lzma.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9, encoding="UTF-8");
except TypeError:
outfp = lzma.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9);
elif(fextname==".lz4"):
try:
import lz4.frame;
except ImportError:
return False;
outfp = lz4.frame.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9, encoding="UTF-8");
try:
outfp = lz4.frame.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9, encoding="UTF-8");
except TypeError:
outfp = lz4.frame.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9);
elif(fextname==".lzo"):
try:
import lzo;
except ImportError:
return False;
outfp = lzo.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9, encoding="UTF-8");
try:
outfp = lzo.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9, encoding="UTF-8");
except TypeError:
outfp = lzo.open(outfile, "wt", format=lzma.FORMAT_XZ, preset=9);
elif(fextname==".lzma"):
try:
import lzma;
except ImportError:
return False;
outfp = lzma.open(outfile, "wt", format=lzma.FORMAT_ALONE, preset=9, encoding="UTF-8");
try:
outfp = lzma.open(outfile, "wt", format=lzma.FORMAT_ALONE, preset=9, encoding="UTF-8");
except TypeError:
outfp = lzma.open(outfile, "wt", format=lzma.FORMAT_ALONE, preset=9);
return outfp;

def MakeFileFromString(instringfile, stringisfile, outstringfile, returnstring=False):
Expand Down

0 comments on commit 079fa60

Please sign in to comment.