Boost logo

Boost-Commit :

From: srajko_at_[hidden]
Date: 2007-05-26 13:18:49


Author: srajko
Date: 2007-05-26 13:18:48 EDT (Sat, 26 May 2007)
New Revision: 4281
URL: http://svn.boost.org/trac/boost/changeset/4281

Log:
template works with template source in its own directory

Removed:
   sandbox/template_under_construction/$template_library$/
Text files modified:
   sandbox/template_under_construction/make_template.py | 54 ++++++++++++++++++++++++++++-----------
   sandbox/template_under_construction/sandbox.py | 9 ++++--
   2 files changed, 44 insertions(+), 19 deletions(-)

Modified: sandbox/template_under_construction/make_template.py
==============================================================================
--- sandbox/template_under_construction/make_template.py (original)
+++ sandbox/template_under_construction/make_template.py 2007-05-26 13:18:48 EDT (Sat, 26 May 2007)
@@ -176,13 +176,19 @@
     def replace_name(self, name):
         return self.name_replacements.replace(name)
 
+ def destination_name(self, name):
+ if name.startswith(self.template_root):
+ return self.name_replacements.replace(name[len(self.template_root):])
+ else:
+ return self.name_replacements.replace(name)
+
     def replace_content(self, name, content):
         return self.content_replacements.replace(name, content)
 
     def examine(self, directory):
- file_list = list()
- directory_list = list()
- python_list = list()
+ self.__file_list__ = list()
+ self.__directory_list__ = list()
+ self.__python_list__ = list()
 
         for root, dirs, files in os.walk(directory):
             print root
@@ -203,14 +209,14 @@
                         sys.path.remove(os.path.abspath(root))
                         mod.do_smt()
                     elif content.startswith('# template file'):
- python_list.append(pathname[0:len(pathname)-3])
+ self.__python_list__.append(pathname[0:len(pathname)-3])
                     else:
- file_list.append(pathname)
+ self.__file_list__.append(pathname)
                 else:
- file_list.append(pathname)
+ self.__file_list__.append(pathname)
 
             for name in self.__files_clear__:
- file_list.remove(os.path.join(root, name))
+ self.__file_list__.remove(os.path.join(root, name))
 
             for name in dirs:
                 if name.startswith('.'):
@@ -218,17 +224,33 @@
             for name in self.__dirs_clear__:
                 dirs.remove(name)
             for name in dirs:
- directory_list.append( (os.path.join(root, name)) )
+ self.__directory_list__.append( (os.path.join(root, name)) )
             
-
- return directory_list, file_list, python_list
+ return self.__directory_list__, self.__file_list__, self.__python_list__
 
     def ignore_subdirectory(self, name):
         self.__dirs_clear__.append(name)
 
     def ignore_subfile(self, name):
         self.__files_clear__.append(name)
-
+
+ def __append_resulting__(self, resulting_list, item_list, prefix):
+ for name in item_list:
+ if name.startswith(prefix):
+ resulting_list.append(item)
+ return resulting_list
+
+ def resulting_directory_list(prefix):
+ new_prefix = self.replace_name(prefix)
+ result = list()
+ return self.__append_resulting__(result, self.__directory_list__, new_prefix)
+
+ def resulting_file_list(prefix):
+ new_prefix = self.replace_name(prefix)
+ result = list()
+ self.__append_resulting__(result, self.__file_list__, new_prefix)
+ return self.__append_resulting(result, self.__python_list__, new_prefix)
+
 def set_content(name, content):
     fout = open(name, "w")
     fout.write(content)
@@ -249,9 +271,9 @@
 # scripts.
 template.log_message('Examining the template project tree...')
 
-directory_list, file_list, python_list = template.examine(template_dir)
+directory_list, file_list, python_list = template.examine(template.template_root + template.template_dir)
 
-project_dir = template.replace_name(template_dir)
+project_dir = template.replace_name(template.template_dir)
 
 if os.path.exists(project_dir):
     print 'Directory ' + project_dir + ' already exists.'
@@ -271,17 +293,17 @@
 os.mkdir(project_dir)
 
 for name in directory_list:
- new_name = template.replace_name(name)
+ new_name = template.destination_name(name)
     print new_name
     os.mkdir(new_name)
 
 for name in python_list:
- new_name = template.replace_name(name)
+ new_name = template.destination_name(name)
     content = template.process_content(name, True)
     set_content(new_name, content)
 
 for name in file_list:
- new_name = template.replace_name(name)
+ new_name = template.destination_name(name)
     content = template.process_content(name)
     if content:
         set_content(new_name, content)

Modified: sandbox/template_under_construction/sandbox.py
==============================================================================
--- sandbox/template_under_construction/sandbox.py (original)
+++ sandbox/template_under_construction/sandbox.py 2007-05-26 13:18:48 EDT (Sat, 26 May 2007)
@@ -2,9 +2,11 @@
 
 template.log_message('Processing Boost Sandbox template.')
 
-template_dir = '$template_library$'
+template.template_root = 'sandbox/'
+template.template_dir = '$template_library$'
 
-library_name = template.options.get('library', template.options.alnum)
+library_name = template.options.get('library', template.options.alnum, None,
+ 'library name (all lowercase, use underscores to separate words, e.g. "my_library"): ')
 # Copyright 2007 Stjepan Rajko.
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or copy at
@@ -23,7 +25,8 @@
 _COMMENT_http://www.boost.org/LICENSE_1_0.txt)
 """
 
-author_list = template.options.get('author', template.options.any)
+author_list = template.options.get('author', template.options.any, None,
+ 'list of authors (comma separated, no spaces outside names, e.g., "My Name,Notmy R. Name": ')
 author_reversed = list()
 for name in author_list.rsplit(','):
     first_space_last = name.rpartition(" ")


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk