summaryrefslogtreecommitdiffstats
path: root/lib/tqwtplot3d/scripts/makedistro.py
blob: 4af5ce5a8c2bca0d33ecf334d71439e9b2719b2a (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os.path
import shutil
import tarfile
import zlib
import zipfile
from time import gmtime, strftime

refuseddirs = ['CVS','Debug','Release','moc','obj','tmp','data','hannes','doc','lib','bin']
refusedfiles = ['Makefile','.cvsignore','gl2psTest.c','gl2ps.bat','gl2ps.pro']
requiredfiles = ['qwtplot3d.dsw','examples.dsw','qwtplot3d.sln','examples.sln','thesis.tex','valgr.sh','qwtplot3d.supp','install.nsi']
requiredfiletypes = ['pro','bat','cpp','c','h','ui','ts','png','rc','ico','py','qrc']
srcfiletypes = ['cpp','c','h']

source = 'V:\\\\cvs\\porting24\\qwtplot3d\\'

#tstr = strftime("%y%m%d", gmtime())
#tarname = 'V:\\\\cvs\\uploads\\' + tstr + 'plot3d.tgz'
#zipname = 'V:\\\\cvs\\uploads\\' + tstr + 'plot3d.zip'

refuseddirs.append('scripts')
tarname = 'V:\\\\cvs\\uploads\\qwtplot3d-0.2.6.tgz'
zipname = 'V:\\\\cvs\\uploads\\qwtplot3d-0.2.6.zip'



def dos2unix(filename):
    if os.path.isdir(filename):
        print filename, "Directory!"
        return
    data = open(filename, "rb").read()
    if '\0' in data:
        print filename, "Binary!"
        return
    newdata = data.replace("\r\n", "\n")
    if newdata != data:
        print filename
        f = open(filename, "wb")
        f.write(newdata)
        f.close()
    

def compresstree(src, tar, zip):
    names = os.listdir(src)
   
    for name in names:
        srcname = os.path.join(src, name)
        if os.path.isdir(srcname):
            if name not in refuseddirs:
                compresstree(srcname,tar, zip)
        else:
            (base,ext) = os.path.splitext(name)
            ext2 = ext[1:]
            if ((ext2 in requiredfiletypes) and (name not in refusedfiles)) or (name in requiredfiles):
                zip.write(srcname, 'qwtplot3d/' + srcname[len(source):])
                if (ext2 in srcfiletypes):
                    dos2unix(srcname)
                tar.add(srcname, 'qwtplot3d/' + srcname[len(source):])
                

if os.path.exists(tarname):
   os.remove(tarname)

tar = tarfile.open(tarname, "w:gz")
zip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
compresstree(source,tar, zip)
tar.close()
zip.close()