Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /leo/plugins/

leo
Discussion topic

Back to topic list

CVS update: /leo/plugins/

Author bwmulder
Full name Bernhard Mulder
Date 2006-08-07 08:41:23 PDT
Message User: bwmulder
Date: 2006-08-07 08:41:23-0700
Modified:
   leo/plugins/mod_shadow.py
   leo/plugins/mod_shadow_core.py

Log:
 Pass in marker_from_extension function

File Changes:

Directory: /leo/plugins/
========================

File [changed]: mod_shadow.py
Url: http://leo.tigris.or​g/source/browse/leo/​plugins/mod_shadow.p​y?r1=1.14&r2=1.1​5
Delta lines: +24 -20
---------------------
--- mod_shadow.py 2006-08-01 22:59:33-0700 1.14
+++ mod_shadow.py 2006-08-07 08:41:21-0700 1.15
@@ -11,11 +11,11 @@
 Leo comments, and still have information flow in both directions:
 from the file into Leo, and from Leo into the file.
  
- The simplest way to start using this plugin is to use the 'convert_to_shadow.py'
- script in the scripts section.
-
- After (re)starting, Leo will copy the files from the LeoShadow subfolder to the old
- location after removing all sentinels.
+ To use this plugin:
+ 1. Install the shadow button
+ 2. Position the cursor somewhere in your tree.
+ 3. Upon clicking on the shadow button, all @thin files will be converted to have
+ a shadow file.
     
     After this initial setup, changes in Leo will be reflected both in the file
     in the Leo subfolder, and the file without sentinels.
@@ -31,12 +31,11 @@
     
 You can set settings for this plugin in leoSettings.leo at: @settings-->Plugi​ns-->shadow plugin.
     
- shadow_verbose >= 1: print logon message in status pane.
- shadow_verbose >= 2: print message each time the subfolder is used.
+ shadow_subdir (default: LeoFolder): name of the shadow directory.
+ shadow_prefix (default: x): prefix of shadow files.
     
-You can specify a prefix for the shadow files. This is so that the py.test script
-does not pick up test scripts twice (once the file without Leo sentinels, once the
-shadow file).
+The prefix allows the shadow file and the original file to have different names.
+This is useful for name-based tools like py.test.
 """
 #@-node:ekr.20060715​100156.53:<< docstring >>
 #@nl
@@ -99,8 +98,8 @@
 #@+node:ekr.20060715​100156.55:<< globals >>
 __version__ = "$Rev: 3076 $"
 __author__ = "Bernhard Mulder"
-__date__ = "$Date: 2006/08/02 05:59:33 $"
-__cvsid__ = "$Id: mod_shadow.py,v 1.14 2006/08/02 05:59:33 bwmulder Exp $"
+__date__ = "$Date: 2006/08/07 15:41:21 $"
+__cvsid__ = "$Id: mod_shadow.py,v 1.15 2006/08/07 15:41:21 bwmulder Exp $"
 #@-node:ekr.20060715​100156.55:<< globals >>
 #@nl
 #@<< Notes >>
@@ -178,8 +177,6 @@
 
 shadow_subdir_default = 'LeoFolder'
 shadow_prefix_default = ''
-
-#@nonl
 #@-node:ekr.20060801​095508:<< imports >>
 #@nl
    
@@ -268,6 +265,11 @@
     return verbosity
 #@nonl
 #@-node:ekr.20060801​102118:getVerbosity
+#@+node:bwmulder.20​060806152117:marker_​from_extension
+def marker_from_extensio​n(filename):
+ return g.comment_delims_fro​m_extension(filename​)[0]
+#@nonl
+#@-node:bwmulder.20​060806152117:marker_​from_extension
 #@-node:ekr.20060801​095508.1:Module level
 #@+node:ekr.20060715​100156.68:Leo overwrites
 #@+node:ekr.20060715​100156.65:openForRea​d
@@ -293,15 +295,18 @@
             if newfile:
                 if shadow_verbosity >= 2:
                     g.es("Copy %s to %s without sentinels"%(shadow_filename, filename))
- mod_shadow_core.copy​_file_removing_senti​nels(sourcefilename=​shadow_filename, targetfilename=filename)
+ mod_shadow_core.copy​_file_removing_senti​nels(sourcefilename=​shadow_filename,
+ targetfilename=filename,
+ marker_from_extensio​n=marker_from_extens​ion)
             else:
                 sq = mod_shadow_core.sent​inel_squasher(g.es, g.nullObject)
                 if shadow_verbosity >= 2:
- g.es("reading in shadow directory %s"% (
+ g.es("reading from shadow directory %s"% (
                         shadow_subdir),color="orange")
                 written = sq.propagate_changes​_from_file_without_s​entinels_to_file_wit​h_sentinels(
                                 with_sentinels=shadow_filename,
- without_sentinels=filename)
+ without_sentinels=filename,
+ marker_from_extensio​n=marker_from_extens​ion)
                 if written:
                     g.es("file %s updated from %s" % (shadow_filename, filename), color="orange")
         else:
@@ -356,7 +361,7 @@
         if os.path.exists(shado​w_filename):
             lines = file(shadow_filename​).readlines()
             self.line_mapping = mod_shadow_core.push​_filter_mapping(
- lines, mod_shadow_core.mark​er_from_extension(si​mplename))
+ lines, marker_from_extensio​n(shadow_filename))
         else:
             self.line_mapping ={}
             lines = file(filename).readlines()
@@ -417,7 +422,7 @@
             if self.writing_to_shad​ow_directory:
                 if shadow_verbosity >= 2:
                     g.es("Updating file from shadow folder %s" % shadow_subdir,color='orange')
- mod_shadow_core.copy​_file_removing_senti​nels(self.shadow_fil​ename,targetFileName​)
+ mod_shadow_core.copy​_file_removing_senti​nels(self.shadow_fil​ename,targetFileName​, marker_from_extension)
 
     finally:
         if self.writing_to_shad​ow_directory:
@@ -431,7 +436,6 @@
         # Not sure if this finally clause is needed or not
         self.targetFileName = targetFileName
         self.outputFileName = outputFileName
-#@nonl
 #@-node:ekr.20060715​100156.72:atFile.rep​laceTargetFileIfDiff​erent
 #@-node:ekr.20060715​100156.71:writing
 #@+node:ekr.20060715​100156.73:massageCom​ment

File [changed]: mod_shadow_core.py
Url: http://leo.tigris.or​g/source/browse/leo/​plugins/mod_shadow_c​ore.py?r1=1.9&r2​=1.10
Delta lines: +10 -10
---------------------
--- mod_shadow_core.py 2006-08-01 22:59:33-0700 1.9
+++ mod_shadow_core.py 2006-08-07 08:41:21-0700 1.10
@@ -22,8 +22,8 @@
 
 __version__ = "$Rev: 1765 $"
 __author__ = "Bernhard Mulder"
-__date__ = "$Date: 2006/08/02 05:59:33 $"
-__cvsid__ = "$Id: mod_shadow_core.py,v 1.9 2006/08/02 05:59:33 bwmulder Exp $"
+__date__ = "$Date: 2006/08/07 15:41:21 $"
+__cvsid__ = "$Id: mod_shadow_core.py,v 1.10 2006/08/07 15:41:21 bwmulder Exp $"
 #@-node:ekr.20060715​100156.10:<< globals >>
 #@nl
 
@@ -49,13 +49,13 @@
    else:
       assert 0, "Sync operation can't work if no modification time can be set"
 #@-node:ekr.20060715​100156.13:copy_time
-#@+node:ekr.2006071​5100156.14:marker_fr​om_extension
-def marker_from_extension (filename):
+#@+node:ekr.2006071​5100156.14:default_m​arker_from_extension​
+def default_marker_from_extension (filename):
     """
     Tries to guess the sentinel leadin
     comment from the filename extension.
    
- This function belongs into the Leo core.
+ This function allows testing independent of Leo
     
     """
     root, ext = os.path.splitext(filename)
@@ -70,7 +70,7 @@
     else:
         assert 0, "extension %s not handled by this plugin" % ext
     return marker
-#@-node:ekr.2006071​5100156.14:marker_fr​om_extension
+#@-node:ekr.2006071​5100156.14:default_m​arker_from_extension​
 #@+node:ekr.20060715​100156.15:write_if_c​hanged
 def write_if_changed (lines, sourcefilename, targetfilename):
    """
@@ -232,7 +232,7 @@
     #@-others
 #@-node:ekr.20060715​100156.26:class sourcewriter
 #@+node:ekr.20060715​100156.32:copy_file_​removing_sentinels
-def copy_file_removing_sentinels (sourcefilename, targetfilename):
+def copy_file_removing_sentinels (sourcefilename, targetfilename, marker_from_extension):
     """
     Filter out Leo comments.
     
@@ -240,12 +240,12 @@
     to targetfilename, if the contents of those lines is different
     from the lines in targetfilename.
     """
- outlines, sentinel_lines = read_file_separating​_out_sentinels(sourc​efilename)
+ outlines, sentinel_lines = read_file_separating​_out_sentinels(sourc​efilename, marker_from_extension)
     write_if_changed(outlines, sourcefilename, targetfilename)
 
 #@-node:ekr.20060715​100156.32:copy_file_​removing_sentinels
 #@+node:ekr.20060715​100156.33:read_file_​separating_out_senti​nels
-def read_file_separating​_out_sentinels (sourcefilename):
+def read_file_separating​_out_sentinels (sourcefilename, marker_from_extension):
    """
    Removes sentinels from the lines of 'sourcefilename'.
    
@@ -410,7 +410,7 @@
     
     #@-node:ekr.20060715​100156.40:check_the_​final_output
     #@+node:ekr.20060715​100156.41:propagate_​changes_from_file_wi​thout_sentinels_to_f​ile_with_sentinels
- def propagate_changes_fr​om_file_without_sent​inels_to_file_with_s​entinels (self, with_sentinels, without_sentinels):
+ def propagate_changes_fr​om_file_without_sent​inels_to_file_with_s​entinels (self, with_sentinels, without_sentinels, marker_from_extension):
         """
         Propagate the changes from file 'without_sentinels' to file 'with_sentinels'.

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /leo/plugins/ bwmulder Bernhard Mulder 2006-08-07 08:41:23 PDT
Messages per page: