Added help() fn; use os.sep
This commit is contained in:
parent
e33cb80d5e
commit
fff3a1ee05
@ -1,12 +1,26 @@
|
|||||||
# Module 'packmail' -- create a shell script out of some files.
|
# Module 'packmail' -- create a self-unpacking shell archive.
|
||||||
|
|
||||||
|
# This module works on UNIX and on the Mac; the archives can unpack
|
||||||
|
# themselves only on UNIX.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from stat import ST_MTIME
|
from stat import ST_MTIME
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
# Print help
|
||||||
|
def help():
|
||||||
|
print 'All fns have a file open for writing as first parameter'
|
||||||
|
print 'pack(f, fullname, name): pack fullname as name'
|
||||||
|
print 'packsome(f, directory, namelist): selected files from directory'
|
||||||
|
print 'packall(f, directory): pack all files from directory'
|
||||||
|
print 'packnotolder(f, directory, name): pack all files from directory'
|
||||||
|
print ' that are not older than a file there'
|
||||||
|
print 'packtree(f, directory): pack entire directory tree'
|
||||||
|
|
||||||
# Pack one file
|
# Pack one file
|
||||||
def pack(outfp, file, name):
|
def pack(outfp, file, name):
|
||||||
fp = open(file, 'r')
|
fp = open(file, 'r')
|
||||||
|
outfp.write('echo ' + name + '\n')
|
||||||
outfp.write('sed "s/^X//" >' + name + ' <<"!"\n')
|
outfp.write('sed "s/^X//" >' + name + ' <<"!"\n')
|
||||||
while 1:
|
while 1:
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
@ -15,6 +29,7 @@ def pack(outfp, file, name):
|
|||||||
line = line + '\n'
|
line = line + '\n'
|
||||||
outfp.write('X' + line)
|
outfp.write('X' + line)
|
||||||
outfp.write('!\n')
|
outfp.write('!\n')
|
||||||
|
fp.close()
|
||||||
|
|
||||||
# Pack some files from a directory
|
# Pack some files from a directory
|
||||||
def packsome(outfp, dirname, names):
|
def packsome(outfp, dirname, names):
|
||||||
@ -64,7 +79,7 @@ def packtree(outfp, dirname):
|
|||||||
packtree(outfp, subdirname)
|
packtree(outfp, subdirname)
|
||||||
|
|
||||||
def unixfix(name):
|
def unixfix(name):
|
||||||
comps = string.splitfields(name, ':')
|
comps = string.splitfields(name, os.sep)
|
||||||
res = ''
|
res = ''
|
||||||
for comp in comps:
|
for comp in comps:
|
||||||
if comp:
|
if comp:
|
||||||
|
@ -1,12 +1,26 @@
|
|||||||
# Module 'packmail' -- create a shell script out of some files.
|
# Module 'packmail' -- create a self-unpacking shell archive.
|
||||||
|
|
||||||
|
# This module works on UNIX and on the Mac; the archives can unpack
|
||||||
|
# themselves only on UNIX.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from stat import ST_MTIME
|
from stat import ST_MTIME
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
# Print help
|
||||||
|
def help():
|
||||||
|
print 'All fns have a file open for writing as first parameter'
|
||||||
|
print 'pack(f, fullname, name): pack fullname as name'
|
||||||
|
print 'packsome(f, directory, namelist): selected files from directory'
|
||||||
|
print 'packall(f, directory): pack all files from directory'
|
||||||
|
print 'packnotolder(f, directory, name): pack all files from directory'
|
||||||
|
print ' that are not older than a file there'
|
||||||
|
print 'packtree(f, directory): pack entire directory tree'
|
||||||
|
|
||||||
# Pack one file
|
# Pack one file
|
||||||
def pack(outfp, file, name):
|
def pack(outfp, file, name):
|
||||||
fp = open(file, 'r')
|
fp = open(file, 'r')
|
||||||
|
outfp.write('echo ' + name + '\n')
|
||||||
outfp.write('sed "s/^X//" >' + name + ' <<"!"\n')
|
outfp.write('sed "s/^X//" >' + name + ' <<"!"\n')
|
||||||
while 1:
|
while 1:
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
@ -15,6 +29,7 @@ def pack(outfp, file, name):
|
|||||||
line = line + '\n'
|
line = line + '\n'
|
||||||
outfp.write('X' + line)
|
outfp.write('X' + line)
|
||||||
outfp.write('!\n')
|
outfp.write('!\n')
|
||||||
|
fp.close()
|
||||||
|
|
||||||
# Pack some files from a directory
|
# Pack some files from a directory
|
||||||
def packsome(outfp, dirname, names):
|
def packsome(outfp, dirname, names):
|
||||||
@ -64,7 +79,7 @@ def packtree(outfp, dirname):
|
|||||||
packtree(outfp, subdirname)
|
packtree(outfp, subdirname)
|
||||||
|
|
||||||
def unixfix(name):
|
def unixfix(name):
|
||||||
comps = string.splitfields(name, ':')
|
comps = string.splitfields(name, os.sep)
|
||||||
res = ''
|
res = ''
|
||||||
for comp in comps:
|
for comp in comps:
|
||||||
if comp:
|
if comp:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user