Python style update
This commit is contained in:
parent
b3803637ba
commit
3ed20c1743
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue