From 3ed20c17438fc2145726d2e3b9707c922a6444b6 Mon Sep 17 00:00:00 2001 From: Mengjuei Date: Wed, 21 Mar 2012 00:01:17 -0700 Subject: [PATCH] Python style update --- Source/Tools/genRTF.py | 68 +++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Source/Tools/genRTF.py b/Source/Tools/genRTF.py index 10ce9bea..ab73c8d2 100755 --- a/Source/Tools/genRTF.py +++ b/Source/Tools/genRTF.py @@ -9,42 +9,42 @@ from Foundation import * from AppKit import * def generateRTF(inString="", inFile=""): - if len(inString) == 0: return - if len(inFile) == 0: return - paragraphStyle = NSMutableParagraphStyle.alloc().init() - paragraphStyle.setAlignment_(NSCenterTextAlignment) - attributedString = NSAttributedString.alloc().initWithString_attributes_(inString, { - NSParagraphStyleAttributeName: paragraphStyle, - NSFontAttributeName: NSFont.systemFontOfSize_(11) - }) - data = attributedString.RTFFromRange_documentAttributes_(NSMakeRange(0, len(inString)), None) - try: os.remove(inFile) - except: pass - data.writeToFile_atomically_(inFile, True) - os.utime(inFile, None) # Touch the file + if len(inString) == 0: return + if len(inFile) == 0: return + paragraphStyle = NSMutableParagraphStyle.alloc().init() + paragraphStyle.setAlignment_(NSCenterTextAlignment) + attributedString = NSAttributedString.alloc().initWithString_attributes_(inString, { + NSParagraphStyleAttributeName: paragraphStyle, + NSFontAttributeName: NSFont.systemFontOfSize_(11) + }) + data = attributedString.RTFFromRange_documentAttributes_(NSMakeRange(0, len(inString)), None) + try: os.remove(inFile) + except: pass + data.writeToFile_atomically_(inFile, True) + os.utime(inFile, None) # Touch the file def main(argv=None): - if argv is None: - argv = sys.argv - try: - path = argv[1] - except: - return + if argv is None: + argv = sys.argv + try: + path = argv[1] + except: + return - path = os.path.abspath(path) - cmd = "/usr/bin/git log --format='%h' -1" - try: - p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - lines = "" - while True: - line = p.stdout.readline() - if not line: break - line = line.strip() - if len(line): lines += line + "\n" - lines = lines.strip() - generateRTF("Build: " + lines, os.path.join(path, "Credits.rtf")) - except Exception, e: - pass + path = os.path.abspath(path) + cmd = "/usr/bin/git log --format='%h' -1" + try: + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + lines = "" + while True: + line = p.stdout.readline() + if not line: break + line = line.strip() + if len(line): lines += line + "\n" + lines = lines.strip() + generateRTF("Build: " + lines, os.path.join(path, "Credits.rtf")) + except Exception, e: + pass if __name__ == "__main__": - sys.exit(main()) + sys.exit(main())