示例#1
0
 def SaveList(self, exportlist, week, path, price, publisher):
     if path:
         print "Creating file"
         w = StreamWriter(path, False)
         w.WriteLine("Checklist for week of " + week)
         w.WriteLine()
         w.WriteLine()
         for item in exportlist:
             w.Write("[] ")
             if publisher:
                 w.Write(item["Publisher"] + " ")
             w.Write(item["Title"])
             if price:
                 w.Write(" " + item["Price"])
             w.WriteLine()
         w.Close()
         w.Dispose()
示例#2
0
 def save(self, filename):
    """ Implements the module-level save() method by writing the 
        debug log information to the given file. """
    
    # protect access to the logLines with a mutex (for multiple threads)
    self._mutex.WaitOne(-1)
    try:
       if self._loglines == None:
          raise Exception("you must install the __Logger before using it")
       loglines_copy = list(self._loglines)
    finally:
       self._mutex.ReleaseMutex()
       
    try:
       writer = StreamWriter(filename, False, UTF8Encoding())
       for line in loglines_copy:
          writer.Write(line)
    finally:
       if writer: writer.Dispose()
sr = StreamReader(path)
sb = StringBuilder()

line = sr.ReadLine()
while not line is None:
    
    #I'm sure this could all be done in a couple of lines with a nice multi-line Regex
    #All this does is comment out property groups that attempt to set signing 
    if line.Trim().StartsWith("<PropertyGroup") and line.Contains("PrivateKey"):
        
        sb.AppendFormat("<!--{0}\r\n", line)                 
        while line is not None and line.Trim() != "</PropertyGroup>":
            sb.AppendLine(line)
            line = sr.ReadLine()
        else:
            sb.AppendFormat("{0}-->\r\n", line)            
    else:
        sb.AppendLine(line)
    
    line = sr.ReadLine()
        
content = sb.ToString()
content = content.Replace("<DelaySign>true</DelaySign>", "<DelaySign>false</DelaySign>")
content = content.Replace("<SignAssembly>true</SignAssembly>", "<SignAssembly>false</SignAssembly>")
sr.Dispose()

sw = StreamWriter(path, False)
sw.Write(sb.ToString())
sw.Dispose()