Ignore:
Timestamp:
27 Jun 2009, 15:50:43 (15 years ago)
Author:
uli
Message:

Make helper docs more Sphinx-aware.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/utils/helpers.txt

    r4376 r4377  
    1 Helpers for the WAeUP SRP
    2 *************************
     1:mod:`waeup.utils.helpers` -- Helpers for the WAeUP SRP
     2*******************************************************
     3
     4.. module:: waeup.utils.helpers
     5
     6Helper functions for the WAeUP SRP.
    37
    48:Test-Layer: unit
    59
    6 `removeFileOrDirectory`
    7 =======================
    8 
    9 Removes a file or directory given by a path. We can remove files:
    10 
    11     >>> import os
    12     >>> from waeup.utils.helpers import removeFileOrDirectory
    13     >>> open('blah', 'wb').write('nonsense')
    14     >>> 'blah' in os.listdir('.')
    15     True
    16 
    17     >>> removeFileOrDirectory('blah')
    18     >>> 'blah' in os.listdir('.')
    19     False
    20 
    21 We can remove directories:
    22 
    23     >>> os.mkdir('blah')
    24     >>> 'blah' in os.listdir('.')
    25     True
    26 
    27     >>> removeFileOrDirectory('blah')
    28     >>> 'blah' in os.listdir('.')
    29     False
    30 
    31 
    32 `copyFileSystemTree`
    33 ====================
    34 
    35 Copies the contents of an (existing) directory to another (existing)
    36 directory:
    37 
    38     >>> os.mkdir('src')
    39     >>> os.mkdir('dst')
    40     >>> open(os.path.join('src', 'blah'), 'wb').write('nonsense')
    41 
    42     >>> from waeup.utils.helpers import copyFileSystemTree
    43     >>> result = copyFileSystemTree('src', 'dst')
    44 
    45 As a result we get a list of non-copied files:
    46 
    47     >>> result
    48     []
    49 
    50 The created file was indeed copied:
    51 
    52     >>> 'blah' in os.listdir('dst')
    53     True
    54 
    55 Hidden files (i.e. such starting with a dot) are not copied:
    56 
    57     >>> open(os.path.join('src', '.blah'), 'wb').write('nonsense')
    58     >>> result = copyFileSystemTree('src', 'dst')
    59     >>> '.blah' in os.listdir('dst')
    60     False
    61 
    62 This function supports some keyword parameters as explained below.
    63 
    64 `overwrite`
    65 -----------
     10:func:`removeFileOrDirectory`
     11=============================
     12
     13.. function:: removeFileOrDirectory(path)
     14
     15   Removes a file or directory given by a path. We can remove files:
     16
     17     >>> import os
     18     >>> from waeup.utils.helpers import removeFileOrDirectory
     19     >>> open('blah', 'wb').write('nonsense')
     20     >>> 'blah' in os.listdir('.')
     21     True
     22
     23     >>> removeFileOrDirectory('blah')
     24     >>> 'blah' in os.listdir('.')
     25     False
     26
     27   We can remove directories:
     28
     29     >>> os.mkdir('blah')
     30     >>> 'blah' in os.listdir('.')
     31     True
     32
     33     >>> removeFileOrDirectory('blah')
     34     >>> 'blah' in os.listdir('.')
     35     False
     36
     37
     38:func:`copyFileSystemTree`
     39==========================
     40
     41.. function:: copyFileSystemTree(src_path, dst_path[, overwrite=False[, del_old=False]])
     42
     43   Copies the contents of an (existing) directory to another
     44   (existing) directory.
     45
     46   :param src_path: filesystem path to copy from
     47   :type  src_path: string
     48   :param dst_path: filesystem path to copy to
     49   :type  dst_path: string
     50   :keyword overwrite: Whether exiting files with same names should be
     51                     overwritten.
     52   :type  overwrite: bool
     53   :keyword del_old: Whether old contents in destination path should be
     54                   removed.
     55   :type  del_old: bool
     56   :return: List of non-copied files
     57 
     58   Both directories must exist.
     59
     60   Unix hidden files and directories (starting with '.') are not
     61   processed by this function.
     62
     63   Without any further parameters, we can copy complete file trees:
     64
     65     >>> os.mkdir('src')
     66     >>> os.mkdir('dst')
     67     >>> open(os.path.join('src', 'blah'), 'wb').write('nonsense')
     68
     69     >>> from waeup.utils.helpers import copyFileSystemTree
     70     >>> result = copyFileSystemTree('src', 'dst')
     71
     72   As a result we get a list of non-copied files:
     73
     74     >>> result
     75     []
     76
     77   The created file was indeed copied:
     78
     79     >>> 'blah' in os.listdir('dst')
     80     True
     81
     82   Hidden files (i.e. such starting with a dot) are not copied:
     83
     84     >>> open(os.path.join('src', '.blah'), 'wb').write('nonsense')
     85     >>> result = copyFileSystemTree('src', 'dst')
     86     >>> '.blah' in os.listdir('dst')
     87     False
     88
     89   This function supports some keyword parameters as explained below.
     90
     91Using ``overwrite``
     92-------------------
    6693
    6794Boolean. If set to ``True``, any existing and same named files and
     
    107134
    108135
    109 `del_old`
    110 ---------
     136Using ``del_old``
     137-----------------
    111138
    112139Boolean. If set to ``True``, any copied files and directories will be
     
    126153    >>> removeFileOrDirectory('src')
    127154    >>> removeFileOrDirectory('dst')
     155
    128156
    129157:func:`getInnerHTMLPart()`
Note: See TracChangeset for help on using the changeset viewer.