def _nestedRunLoopReaderUntilEOLchars_(self, eolchars): """ This makes the baby jesus cry. I want co-routines. """ app = NSApplication.sharedApplication() window = self.textView.window() self.setCharacterIndexForInput_(self.lengthOfTextView()) # change the color.. eh self.textView.setTypingAttributes_({ NSFontAttributeName: self.font(), NSForegroundColorAttributeName: self.codeColor(), }) while True: event = app.nextEventMatchingMask_untilDate_inMode_dequeue_( NSAnyEventMask, NSDate.distantFuture(), NSDefaultRunLoopMode, True) if (event.type() == NSKeyDown) and (event.window() == window): eol = event.characters() if eol in eolchars: break app.sendEvent_(event) cl = self.currentLine() if eol == "\r": self.writeCode_("\n") return cl + eol
def _nestedRunLoopReaderUntilEOLchars_(self, eolchars): """ This makes the baby jesus cry. I want co-routines. """ app = NSApplication.sharedApplication() window = self.textView.window() self.setCharacterIndexForInput_(self.lengthOfTextView()) # change the color.. eh self.textView.setTypingAttributes_({ NSFontAttributeName:self.font(), NSForegroundColorAttributeName:self.codeColor(), }) while True: event = app.nextEventMatchingMask_untilDate_inMode_dequeue_( NSUIntegerMax, NSDate.distantFuture(), NSDefaultRunLoopMode, True) if (event.type() == NSKeyDown) and (event.window() == window): eol = event.characters() if eol in eolchars: break app.sendEvent_(event) cl = self.currentLine() if eol == '\r': self.writeCode_('\n') return cl+eol
def events(self): store = CalCalendarStore.defaultCalendarStore() # Pull all events starting now from all calendars in the CalendarStore allEventsPredicate = ( CalCalendarStore.eventPredicateWithStartDate_endDate_calendars_( NSDate.date(), NSDate.distantFuture(), store.calendars())) return store.eventsWithPredicate_(allEventsPredicate)
## # Copyright (c) 2010-2015 Apple Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ## from __future__ import print_function import eventkitframework as EventKit from Cocoa import NSDate store = EventKit.EKEventStore.alloc().init() calendars = store.calendarsForEntityType_(0) print(calendars) raise SystemExit predicate = store.predicateForEventsWithStartDate_endDate_calendars_( NSDate.date(), NSDate.distantFuture(), [calendars[2]]) print(store.eventsMatchingPredicate_(predicate))
## # Copyright (c) 2010-2017 Apple Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ## from __future__ import print_function import eventkitframework as EventKit from Cocoa import NSDate store = EventKit.EKEventStore.alloc().init() calendars = store.calendarsForEntityType_(0) print(calendars) raise SystemExit predicate = store.predicateForEventsWithStartDate_endDate_calendars_( NSDate.date(), NSDate.distantFuture(), [calendars[2]]) print(store.eventsMatchingPredicate_(predicate))
f = open('vendor') try: url = vendors[f.readline().rstrip()] except Exception, e: url = vendors['google'] f.close() dests = filter(lambda x:x!=u"", query.split(';',1)) if len(dests)<2: clm = LocationManager.alloc().init_with_thread(NSThread.currentThread()) loop = NSRunLoop.currentRunLoop() loop.runMode_beforeDate_(NSDefaultRunLoopMode, NSDate.distantFuture()) loc = clm.goodLocation if loc != None: latitude = unicode(loc.coordinate().latitude) longitude = unicode(loc.coordinate().longitude) clm.dealloc() if query.index(';') < 2: url = url.replace(u"{source}",latitude + u"," + longitude) url = url.replace(u"{destination}", dests[0]) else: url = url.replace(u"{destination}",latitude + u"," + longitude) url = url.replace(u"{source}", dests[0]) else: url = url.replace(u"{source}", dests[0])