Back to index

enigmail  1.4.3
Functions | Variables
pymake.builtins Namespace Reference

Functions

def mkdir
def rm
def sleep
def touch

Variables

list __all__ = ["mkdir", "rm", "sleep", "touch"]

Function Documentation

def pymake.builtins.mkdir (   args)
Emulate some of the behavior of mkdir(1).
Only supports the -p (--parents) argument.

Definition at line 9 of file builtins.py.

00009 
00010 def mkdir(args):
00011   """
00012   Emulate some of the behavior of mkdir(1).
00013   Only supports the -p (--parents) argument.
00014   """
00015   try:
00016     opts, args = getopt(args, "p", ["parents"])
00017   except GetoptError, e:
00018     raise PythonException, ("mkdir: %s" % e, 1)
00019   parents = False
00020   for o, a in opts:
00021     if o in ('-p', '--parents'):
00022       parents = True
00023   for f in args:
00024     try:
00025       if parents:
00026         os.makedirs(f)
00027       else:
00028         os.mkdir(f)
00029     except OSError, e:
00030       if e.errno == errno.EEXIST and parents:
00031         pass
00032       else:
00033         raise PythonException, ("mkdir: %s" % e, 1)

Here is the caller graph for this function:

def pymake.builtins.rm (   args)
Emulate most of the behavior of rm(1).
Only supports the -r (--recursive) and -f (--force) arguments.

Definition at line 34 of file builtins.py.

00034 
00035 def rm(args):
00036   """
00037   Emulate most of the behavior of rm(1).
00038   Only supports the -r (--recursive) and -f (--force) arguments.
00039   """
00040   try:
00041     opts, args = getopt(args, "rRf", ["force", "recursive"])
00042   except GetoptError, e:
00043     raise PythonException, ("rm: %s" % e, 1)
00044   force = False
00045   recursive = False
00046   for o, a in opts:
00047     if o in ('-f', '--force'):
00048       force = True
00049     elif o in ('-r', '-R', '--recursive'):
00050       recursive = True
00051   for f in args:
00052     if os.path.isdir(f):
00053       if not recursive:
00054         raise PythonException, ("rm: cannot remove '%s': Is a directory" % f, 1)
00055       else:
00056         shutil.rmtree(f, force)
00057     elif os.path.exists(f):
00058       try:
00059         os.unlink(f)
00060       except:
00061         if not force:
00062           raise PythonException, ("rm: failed to remove '%s': %s" % (f, sys.exc_info()[0]), 1)
00063     elif not force:
00064       raise PythonException, ("rm: cannot remove '%s': No such file or directory" % f, 1)

Here is the caller graph for this function:

def pymake.builtins.sleep (   args)
Emulate the behavior of sleep(1).

Definition at line 65 of file builtins.py.

00065 
00066 def sleep(args):
00067     """
00068     Emulate the behavior of sleep(1).
00069     """
00070     total = 0
00071     values = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400}
00072     for a in args:
00073         multiplier = 1
00074         for k, v in values.iteritems():
00075             if a.endswith(k):
00076                 a = a[:-1]
00077                 multiplier = v
00078                 break
00079         try:
00080             f = float(a)
00081             total += f * multiplier
00082         except ValueError:
00083             raise PythonException, ("sleep: invalid time interval '%s'" % a, 1)
00084     time.sleep(total)

def pymake.builtins.touch (   args)
Emulate the behavior of touch(1).

Definition at line 85 of file builtins.py.

00085 
00086 def touch(args):
00087     """
00088     Emulate the behavior of touch(1).
00089     """
00090     for f in args:
00091         if os.path.exists(f):
00092             os.utime(f, None)
00093         else:
00094             open(f, 'w').close()

Variable Documentation

list pymake.builtins.__all__ = ["mkdir", "rm", "sleep", "touch"]

Definition at line 7 of file builtins.py.