예제 #1
0
파일: snippet.py 프로젝트: szabo92/gistable
def get_avaliable_languages():
    single_langs = filter(lambda x: x.count() == 1, \
        map(lambda x: objc_object(carbon.TISGetInputSourceProperty(CoreFoundation.CFArrayGetValueAtIndex(objc_object(s), x).__c_void_p__(), kTISPropertyInputSourceLanguages_p)), \
            range(CoreFoundation.CFArrayGetCount(objc_object(carbon.TISCreateInputSourceList(None, 0))))))
    res = set()
    map(lambda y: res.add(y[0]), single_langs)
    return res
예제 #2
0
    def testCounts(self):
        array = CoreFoundation.CFArrayCreate(
            None, [1, 2, 3, 4, 4, 2], 6, CoreFoundation.kCFTypeArrayCallBacks
        )
        self.assertEqual(array, [1, 2, 3, 4, 4, 2])
        self.assertIsInstance(array, NSArray)

        self.assertEqual(CoreFoundation.CFArrayGetCount(array), 6)
        self.assertEqual(CoreFoundation.CFArrayGetCountOfValue(array, (0, 6), 4), 2)
        self.assertEqual(CoreFoundation.CFArrayGetCountOfValue(array, (0, 6), 2), 2)
        self.assertEqual(CoreFoundation.CFArrayGetCountOfValue(array, (0, 6), 3), 1)