• Main Page
  • Modules
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/examples/COCO/bbob/createfolders.py

00001 #!/usr/bin/env python
00002 
00003 """
00004     This module generates the folder structure for doing a BBOB experiment.
00005     To use this module either do from the shell command line:
00006        $ python createfolders.py DATAPATH
00007 
00008     or from the python command line:
00009        >>> import createfolders
00010        >>> createfolders.main('DATAPATH')
00011 """
00012 
00013 import os
00014 import sys
00015 
00016 
00017 
00018 class Usage(Exception):
00019     def __init__(self, msg):
00020         self.msg = msg
00021 
00022 def main(argv=None):
00023     """Creates the whole folder structure for an experiment using fgeneric.
00024 
00025     This function, provided with a folder name, creates the whole folder
00026     structure needed by the fgeneric interface for the BBOB experiments.
00027     """
00028 
00029     if argv is None:
00030         argv = sys.argv[1:]
00031 
00032     try:
00033         if len(argv) < 1:
00034             raise Usage('Give as input to this script a disk location to '
00035                         'create the whole folder structure for fgeneric.')
00036 
00037         if isinstance(argv, basestring):
00038             outputdir = argv
00039         else:
00040             outputdir = argv[0] #only process the first argument.
00041 
00042         verbose = True
00043 
00044         if not os.path.exists(outputdir):
00045             os.mkdir(outputdir)
00046             if verbose:
00047                 print '%s was created.' % (outputdir)
00048 
00049         for i in range(1, 25):
00050             datapath = os.path.join(outputdir, 'data_f%d' % i)
00051             if not os.path.exists(datapath):
00052                 os.mkdir(datapath)
00053 
00054         for i in range(101, 131):
00055             datapath = os.path.join(outputdir, 'data_f%d' % i)
00056             if not os.path.exists(datapath):
00057                 os.mkdir(datapath)
00058 
00059     except Usage, err:
00060         print >>sys.stderr, err.msg
00061         #print >>sys.stderr, "for help use -h or --help"
00062         return 2
00063 
00064 if __name__ == "__main__":
00065    sys.exit(main())
00066 

Generated on Fri Jul 5 2013 09:34:24 for ECF by  doxygen 1.7.1