Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Mac/PythonLauncher/FileSettings.h

    r2 r391  
    4646+ (id)newSettingsForFileType: (NSString *)filetype;
    4747
    48 //- (id)init;
    4948- (id)initForFileType: (NSString *)filetype;
    5049- (id)initForFSDefaultFileType: (NSString *)filetype;
    5150- (id)initForDefaultFileType: (NSString *)filetype;
    52 //- (id)initWithFileSettings: (FileSettings *)source;
    5351
    5452- (void)updateFromSource: (id <FileSettingsSource>)source;
    5553- (NSString *)commandLineForScript: (NSString *)script;
    5654
    57 //- (void)applyFactorySettingsForFileType: (NSString *)filetype;
    58 //- (void)saveDefaults;
    59 //- (void)applyUserDefaults: (NSString *)filetype;
    6055- (void)applyValuesFromDict: (NSDictionary *)dict;
    6156- (void)reset;
  • python/trunk/Mac/PythonLauncher/FileSettings.m

    r2 r391  
    1515    static FileSettings *fsdefault_py, *fsdefault_pyw, *fsdefault_pyc;
    1616    FileSettings **curdefault;
    17    
     17
    1818    if ([filetype isEqualToString: @"Python Script"]) {
    1919        curdefault = &fsdefault_py;
     
    3737    static FileSettings *default_py, *default_pyw, *default_pyc;
    3838    FileSettings **curdefault;
    39    
     39
    4040    if ([filetype isEqualToString: @"Python Script"]) {
    4141        curdefault = &default_py;
     
    5858{
    5959    FileSettings *cur;
    60    
     60
    6161    cur = [FileSettings new];
    6262    [cur initForFileType: filetype];
     
    6868    self = [super init];
    6969    if (!self) return self;
    70    
     70
    7171    interpreter = [source->interpreter retain];
    7272    honourhashbang = source->honourhashbang;
     
    8282    prefskey = source->prefskey;
    8383    if (prefskey) [prefskey retain];
    84    
     84
    8585    return self;
    8686}
     
    8989{
    9090    FileSettings *defaults;
    91    
     91
    9292    defaults = [FileSettings getDefaultsForFileType: filetype];
    9393    self = [self initWithFileSettings: defaults];
     
    9696}
    9797
    98 //- (id)init
    99 //{
    100 //    self = [self initForFileType: @"Python Script"];
    101 //    return self;
    102 //}
    103 
    10498- (id)initForFSDefaultFileType: (NSString *)filetype
    10599{
     
    108102    NSDictionary *dict;
    109103    static NSDictionary *factorySettings;
    110    
     104
    111105    self = [super init];
    112106    if (!self) return self;
    113    
     107
    114108    if (factorySettings == NULL) {
    115109        NSBundle *bdl = [NSBundle mainBundle];
     
    150144    NSUserDefaults *defaults;
    151145    NSDictionary *dict;
    152    
     146
    153147    defaults = [NSUserDefaults standardUserDefaults];
    154148    dict = [defaults dictionaryForKey: filetype];
     
    157151    [self applyValuesFromDict: dict];
    158152}
    159    
     153
    160154- (id)initForDefaultFileType: (NSString *)filetype
    161155{
    162156    FileSettings *fsdefaults;
    163    
     157
    164158    fsdefaults = [FileSettings getFactorySettingsForFileType: filetype];
    165159    self = [self initWithFileSettings: fsdefaults];
     
    221215{
    222216    id value;
    223    
     217
    224218    value = [dict objectForKey: @"interpreter"];
    225219    if (value) interpreter = [value retain];
     
    248242- (NSString*)_replaceSingleQuotes: (NSString*)string
    249243{
    250         /* Replace all single-quotes by '"'"', that way shellquoting will
    251         * be correct when the result value is delimited  using single quotes.
    252         */
    253         NSArray* components = [string componentsSeparatedByString:@"'"];
    254 
    255         return [components componentsJoinedByString:@"'\"'\"'"];
     244    /* Replace all single-quotes by '"'"', that way shellquoting will
     245    * be correct when the result value is delimited  using single quotes.
     246    */
     247    NSArray* components = [string componentsSeparatedByString:@"'"];
     248
     249    return [components componentsJoinedByString:@"'\"'\"'"];
    256250}
    257251
     
    266260    script_dir = [script substringToIndex:
    267261            [script length]-[[script lastPathComponent] length]];
    268    
     262
    269263    if (honourhashbang &&
    270        (fp=fopen([script cString], "r")) &&
     264       (fp=fopen([script fileSystemRepresentation], "r")) &&
    271265       fgets(hashbangbuf, sizeof(hashbangbuf), fp) &&
    272266       strncmp(hashbangbuf, "#!", 2) == 0 &&
     
    275269            p = hashbangbuf + 2;
    276270            while (*p == ' ') p++;
    277             cur_interp = [NSString stringWithCString: p];
     271            cur_interp = [NSString stringWithUTF8String: p];
    278272    }
    279273    if (!cur_interp)
    280274        cur_interp = interpreter;
    281        
     275
    282276    return [NSString stringWithFormat:
    283277        @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s",
     
    298292- (NSArray *) interpreters { return interpreters;};
    299293
    300 // FileSettingsSource protocol 
     294// FileSettingsSource protocol
    301295- (NSString *) interpreter { return interpreter;};
    302296- (BOOL) honourhashbang { return honourhashbang; };
  • python/trunk/Mac/PythonLauncher/Info.plist.in

    r2 r391  
    4141        <string>PythonLauncher</string>
    4242        <key>CFBundleGetInfoString</key>
    43         <string>%VERSION%, © 001-2006 Python Software Foundation</string>
     43        <string>%VERSION%, © 2001-2013 Python Software Foundation</string>
    4444        <key>CFBundleIconFile</key>
    4545        <string>PythonLauncher.icns</string>
  • python/trunk/Mac/PythonLauncher/Makefile.in

    r2 r391  
    33BASECFLAGS=@BASECFLAGS@
    44OPT=@OPT@
    5 CFLAGS=$(BASECFLAGS) $(OPT)
     5CFLAGS=@CFLAGS@ $(BASECFLAGS) $(OPT)
    66LDFLAGS=@LDFLAGS@
    77srcdir=         @srcdir@
     
    2222BUNDLEBULDER=$(srcdir)/../../Lib/plat-mac/bundlebuilder.py
    2323
    24 PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
     24PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
    2525OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
    2626
  • python/trunk/Mac/PythonLauncher/MyAppDelegate.m

    r2 r391  
    3434- (BOOL)shouldShowUI
    3535{
    36     // if this call comes before applicationDidFinishLaunching: we 
     36    // if this call comes before applicationDidFinishLaunching: we
    3737    // should terminate immedeately after starting the script.
    3838    if (!initial_action_done)
     
    6363    NSString **ext_p;
    6464    int i;
    65    
     65
    6666    if ([[NSUserDefaults standardUserDefaults] boolForKey: @"SkipFileBindingTest"])
    6767        return;
     
    9393    }
    9494}
    95        
     95
    9696@end
  • python/trunk/Mac/PythonLauncher/MyDocument.m

    r2 r391  
    1717    self = [super init];
    1818    if (self) {
    19    
     19
    2020        // Add your subclass-specific initialization here.
    2121        // If an error occurs here, send a [self dealloc] message and return nil.
     
    3838    NSApplication *app = [NSApplication sharedApplication];
    3939    [super close];
    40     if ([[app delegate] shouldTerminate])
     40    if ([(MyAppDelegate*)[app delegate] shouldTerminate])
    4141        [app terminate: self];
    4242}
     
    4444- (void)load_defaults
    4545{
    46 //    if (settings) [settings release];
    4746    settings = [FileSettings newSettingsForFileType: filetype];
    4847}
     
    5049- (void)update_display
    5150{
    52 //    [[self window] setTitle: script];
    53    
    5451    [interpreter setStringValue: [settings interpreter]];
    5552    [honourhashbang setState: [settings honourhashbang]];
     
    6360    [scriptargs setStringValue: [settings scriptargs]];
    6461    [with_terminal setState: [settings with_terminal]];
    65    
     62
    6663    [commandline setStringValue: [settings commandLineForScript: script]];
    6764}
     
    7673    const char *cmdline;
    7774    int sts;
    78    
    79      cmdline = [[settings commandLineForScript: script] cString];
     75
     76     cmdline = [[settings commandLineForScript: script] UTF8String];
    8077   if ([settings with_terminal]) {
    8178        sts = doscript(cmdline);
     
    108105    // Insert code here to read your document from the given data.  You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
    109106    BOOL show_ui;
    110    
    111     // ask the app delegate whether we should show the UI or not. 
    112     show_ui = [[[NSApplication sharedApplication] delegate] shouldShowUI];
     107
     108    // ask the app delegate whether we should show the UI or not.
     109    show_ui = [(MyAppDelegate*)[[NSApplication sharedApplication] delegate] shouldShowUI];
    113110    [script release];
    114111    script = [fileName retain];
    115112    [filetype release];
    116113    filetype = [type retain];
    117 //    if (settings) [settings release];
    118114    settings = [FileSettings newSettingsForFileType: filetype];
    119115    if (show_ui) {
     
    153149}
    154150
    155 // FileSettingsSource protocol 
     151// FileSettingsSource protocol
    156152- (NSString *) interpreter { return [interpreter stringValue];};
    157153- (BOOL) honourhashbang { return [honourhashbang state];};
  • python/trunk/Mac/PythonLauncher/PreferencesWindowController.m

    r2 r391  
    66{
    77    static PreferencesWindowController *_singleton;
    8    
     8
    99    if (!_singleton)
    1010        _singleton = [[PreferencesWindowController alloc] init];
     
    2222{
    2323    NSString *title = [filetype titleOfSelectedItem];
    24    
     24
    2525    settings = [FileSettings getDefaultsForFileType: title];
    2626}
     
    2828- (void)update_display
    2929{
    30 //    [[self window] setTitle: script];
    31    
    32         [interpreter reloadData];
     30    [interpreter reloadData];
    3331    [interpreter setStringValue: [settings interpreter]];
    3432    [honourhashbang setState: [settings honourhashbang]];
     
    4240    [with_terminal setState: [settings with_terminal]];
    4341    // Not scriptargs, it isn't for preferences
    44    
    4542    [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
    4643}
     
    7673}
    7774
    78 // FileSettingsSource protocol 
     75// FileSettingsSource protocol
    7976- (NSString *) interpreter { return [interpreter stringValue];};
    8077- (BOOL) honourhashbang { return [honourhashbang state]; };
     
    9996- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
    10097{
    101         NSArray *interp_list = [settings interpreters];
     98    NSArray *interp_list = [settings interpreters];
    10299    unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
    103         return rv;
     100    return rv;
    104101}
    105102
    106103- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
    107104{
    108         NSArray *interp_list = [settings interpreters];
     105    NSArray *interp_list = [settings interpreters];
    109106    id rv = [interp_list objectAtIndex: index];
    110         return rv;
     107    return rv;
    111108}
    112109
    113110- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
    114111{
    115         NSArray *interp_list = [settings interpreters];
     112    NSArray *interp_list = [settings interpreters];
    116113    int rv = [interp_list count];
    117         return rv;
     114    return rv;
    118115}
    119116
  • python/trunk/Mac/PythonLauncher/doscript.m

    r2 r391  
    1212#import "doscript.h"
    1313
    14 extern int 
     14extern int
    1515doscript(const char *command)
    1616{
    17         char *bundleID = "com.apple.Terminal";
    18         AppleEvent evt, res;
    19         AEDesc desc;
    20         OSStatus err;
     17    char *bundleID = "com.apple.Terminal";
     18    AppleEvent evt, res;
     19    AEDesc desc;
     20    OSStatus err;
    2121
    22         [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"];
     22    [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"];
    2323
    24         // Build event
    25         err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript,
    26                                  typeApplicationBundleID,
    27                                  bundleID, strlen(bundleID),
    28                                  kAutoGenerateReturnID,
    29                                  kAnyTransactionID,
    30                                  &evt, NULL,
    31                                  "'----':utf8(@)", strlen(command),
    32                                  command);
    33         if (err) {
    34                 NSLog(@"AEBuildAppleEvent failed: %d\n", err);
    35                 return err;
    36         }
     24    // Build event
     25    err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript,
     26                             typeApplicationBundleID,
     27                             bundleID, strlen(bundleID),
     28                             kAutoGenerateReturnID,
     29                             kAnyTransactionID,
     30                             &evt, NULL,
     31                             "'----':utf8(@)", strlen(command),
     32                             command);
     33    if (err) {
     34        NSLog(@"AEBuildAppleEvent failed: %ld\n", (long)err);
     35        return err;
     36    }
    3737
    38         // Send event and check for any Apple Event Manager errors
    39         err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout);
    40         AEDisposeDesc(&evt);
    41         if (err) {
    42                 NSLog(@"AESendMessage failed: %d\n", err);
    43                 return err;
    44         }
    45         // Check for any application errors
    46         err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc);
    47         AEDisposeDesc(&res);
    48         if (!err) {
    49                 AEGetDescData(&desc, &err, sizeof(err));
    50                 NSLog(@"Terminal returned an error: %d", err);
    51                 AEDisposeDesc(&desc);
    52         } else if (err == errAEDescNotFound) {
    53                 err = noErr;
    54         } else {
    55                 NSLog(@"AEGetPArmDesc returned an error: %d", err);
    56         }
     38    // Send event and check for any Apple Event Manager errors
     39    err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout);
     40    AEDisposeDesc(&evt);
     41    if (err) {
     42        NSLog(@"AESendMessage failed: %ld\n", (long)err);
     43        return err;
     44    }
     45    // Check for any application errors
     46    err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc);
     47    AEDisposeDesc(&res);
     48    if (!err) {
     49        AEGetDescData(&desc, &err, sizeof(err));
     50        NSLog(@"Terminal returned an error: %ld", (long)err);
     51        AEDisposeDesc(&desc);
     52    } else if (err == errAEDescNotFound) {
     53        err = noErr;
     54    } else {
     55        NSLog(@"AEGetPArmDesc returned an error: %ld", (long)err);
     56    }
    5757
    58         return err;
     58    return err;
    5959}
  • python/trunk/Mac/PythonLauncher/main.m

    r2 r391  
    1212int main(int argc, const char *argv[])
    1313{
    14         char *home = getenv("HOME");
    15         if (home) chdir(home);
     14    char *home = getenv("HOME");
     15    if (home) chdir(home);
    1616    return NSApplicationMain(argc, argv);
    1717}
Note: See TracChangeset for help on using the changeset viewer.