Back to index

python3.2  3.2.2
Functions | Variables
mkreal Namespace Reference

Functions

def mkrealfile
def mkrealdir
def main

Variables

 join = os.path.join
string error = 'mkreal error'
int BUFSIZE = 32

Function Documentation

def mkreal.main ( void  )

Definition at line 45 of file mkreal.py.

00045 
00046 def main():
00047     sys.stdout = sys.stderr
00048     progname = os.path.basename(sys.argv[0])
00049     if progname == '-c': progname = 'mkreal'
00050     args = sys.argv[1:]
00051     if not args:
00052         print('usage:', progname, 'path ...')
00053         sys.exit(2)
00054     status = 0
00055     for name in args:
00056         if not os.path.islink(name):
00057             print(progname+':', name+':', 'not a symlink')
00058             status = 1
00059         else:
00060             if os.path.isdir(name):
00061                 mkrealdir(name)
00062             else:
00063                 mkrealfile(name)
00064     sys.exit(status)

Here is the call graph for this function:

def mkreal.mkrealdir (   name)

Definition at line 31 of file mkreal.py.

00031 
00032 def mkrealdir(name):
00033     st = os.stat(name) # Get the mode
00034     mode = S_IMODE(st[ST_MODE])
00035     linkto = os.readlink(name)
00036     files = os.listdir(name)
00037     os.unlink(name)
00038     os.mkdir(name, mode)
00039     os.chmod(name, mode)
00040     linkto = join(os.pardir, linkto)
00041     #
00042     for filename in files:
00043         if filename not in (os.curdir, os.pardir):
00044             os.symlink(join(linkto, filename), join(name, filename))

Here is the call graph for this function:

Here is the caller graph for this function:

def mkreal.mkrealfile (   name)

Definition at line 17 of file mkreal.py.

00017 
00018 def mkrealfile(name):
00019     st = os.stat(name) # Get the mode
00020     mode = S_IMODE(st[ST_MODE])
00021     linkto = os.readlink(name) # Make sure again it's a symlink
00022     f_in = open(name, 'r') # This ensures it's a file
00023     os.unlink(name)
00024     f_out = open(name, 'w')
00025     while 1:
00026         buf = f_in.read(BUFSIZE)
00027         if not buf: break
00028         f_out.write(buf)
00029     del f_out # Flush data to disk before changing mode
00030     os.chmod(name, mode)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 15 of file mkreal.py.

Definition at line 13 of file mkreal.py.

Definition at line 11 of file mkreal.py.