[TxMt] some Python thoughts

Hans-Jörg Bibiko bibiko at eva.mpg.de
Thu Jun 5 17:29:12 UTC 2008


Hi,

I'm just beginning to like Python ;)

Caused by that issue here are some tiny suggestions:

Walter Dörwald had the idea to provide exit codes similar to Ruby's  
exit_codes.rb.

This could be integrate in tm_helpers.py à la:

def exit_discard():
     sys.exit(200)

def exit_replace_text(out = ''):
     if out: print out
     sys.exit(201)

def exit_replace_document(out = ''):
     if out: print out
     sys.exit(202)

def exit_insert_text(out = ''):
     if out: print out
     sys.exit(203)

def exit_insert_snippet(out = ''):
     if out: print out
     sys.exit(204)

def exit_show_html(out = ''):
     if out: print out
     sys.exit(205)

def exit_show_tool_tip(out = ''):
     if out: print out
     sys.exit(206)

def exit_create_new_document(out = ''):
     if out: print out
     sys.exit(207)


Furthermore tm_helpers' sh(cmd) is not UTF-8 safe.
If I'm using e.g. popen("grep 'ä' 'test.txt'") or tm_helpers.sh("grep  
'ä' 'test.txt'") I have problems with the codec.
I tried several things to encode/decode unicode but no success. Maybe  
some of you can fix this.
I went the way to use popen2. Then I didn't have such problems (?)


The next issue is regarding dialog.py. Maybe one could the function  
'menu' looking for DIALOG2. If there's DIALOG2 it uses that syntax,  
if not fall back to DIALOG1.
This could also be done for Ruby's ui.rb.

Cheers,

--Hans





More information about the textmate mailing list