def getPasswords(): return NSMutableArray.arrayWithArray_([ dict(zip(FIELDS, line.rstrip().split(':'))) for line in os.popen('/usr/bin/nidump passwd .') if not line.startswith('#') ])
def testSortValues(self): array = NSMutableArray.arrayWithArray_([4,2,1,3,0,5]) self.assertArgIsFunction(CFArraySortValues, 2, b'l@@@', False) self.assertArgHasType(CFArraySortValues, 3, b'@') def compare(l, r, context): return cmp(l, r) CFArraySortValues(array, (0, 6), compare, None) self.assertEqual(array, [0, 1, 2, 3, 4, 5])
def testSortValues(self): array = NSMutableArray.arrayWithArray_([4, 2, 1, 3, 0, 5]) self.assertArgIsFunction(CFArraySortValues, 2, b'l@@@', False) self.assertArgHasType(CFArraySortValues, 3, b'@') def compare(l, r, context): return cmp(l, r) CFArraySortValues(array, (0, 6), compare, None) self.assertEqual(array, [0, 1, 2, 3, 4, 5])
# # newParam = GSCustomParameter.alloc().init() # # font.addCustomParameter_(newParam) # # font.addCustomParameter_("Axes") # # add them to the font # font.setCustomParameter_forKey_(fontAxes, "Axes") # print(font.customParameterForKey_("Axes")) from Foundation import NSMutableDictionary, NSMutableArray fontAxes = NSMutableArray.arrayWithArray_([ NSMutableDictionary.dictionaryWithDictionary_({ "Name": "Weight", "Tag": "wght" }), NSMutableDictionary.dictionaryWithDictionary_({ "Name": "Negative", "Tag": "NEGA" }) ]) font.setCustomParameter_forKey_(fontAxes, "Axes") # ============================================================================ # remove old masters ========================================================= # just do it twice for now to delete original two – would need more flexibility to be abstracted to other fonts font.removeFontMasterAtIndex_(0) font.removeFontMasterAtIndex_(0) # ============================================================================ # set axis values of new masters =============================================
def __setattr__(self, attr, value): # check to see if the attribute has been # deprecated. if so, warn the caller and # update the attribute and value. if attr in self._deprecatedAttributes: newAttr, newValue = ufoLib.convertFontInfoValueForAttributeFromVersion1ToVersion2( attr, value) note = "The %s attribute has been deprecated. Use the new %s attribute." % ( attr, newAttr) warn(note, DeprecationWarning) attr = newAttr value = newValue _baseAttributes = ["_object", "changed", "selected", "getParent"] _renameAttributes = { "openTypeNameManufacturer": "manufacturer", "openTypeNameManufacturerURL": "manufacturerURL", "openTypeNameDesigner": "designer", "openTypeNameDesignerURL": "designerURL", # "openTypeNameLicense": "license", # "openTypeNameLicenseURL": "licenseURL", "fontName": "postscriptFontName", "vendorURL": "manufacturerURL", "uniqueID": "postscriptUniqueID", "otMacName": "openTypeNameCompatibleFullName" } _masterAttributes = [ "postscriptUnderlinePosition", "postscriptUnderlineThickness", "openTypeOS2StrikeoutSize", "openTypeOS2StrikeoutPosition" ] # setting a known attribute if attr in _masterAttributes: if type(value) == type([]): value = NSMutableArray.arrayWithArray_(value) elif type(value) == type(1): value = NSNumber.numberWithInt_(value) elif type(value) == type(1.2): value = NSNumber.numberWithFloat_(value) if attr in _renameAttributes: attr = _renameAttributes[attr] self._object._font.fontMasterAtIndex_( self._object._masterIndex).setValue_forKey_(value, attr) return if attr not in _baseAttributes: try: if type(value) == type([]): value = NSMutableArray.arrayWithArray_(value) elif type(value) == type(1): value = NSNumber.numberWithInt_(value) elif type(value) == type(1.2): value = NSNumber.numberWithFloat_(value) if attr in _renameAttributes: attr = _renameAttributes[attr] self._object._font.setValue_forKey_(value, attr) except: raise AttributeError("Unknown attribute %s." % attr) return elif attr in self.__dict__ or attr in self._baseAttributes: super(BaseInfo, self).__setattr__(attr, value) else: raise AttributeError("Unknown attribute %s." % attr)
def getPasswords(): return NSMutableArray.arrayWithArray_([ dict(zip(FIELDS, line.rstrip().split(':'))) for line in os.popen('/usr/bin/nidump passwd .') if not line.startswith('#') ])
def __setattr__(self, attr, value): # check to see if the attribute has been # deprecated. if so, warn the caller and # update the attribute and value. if attr in self._deprecatedAttributes: newAttr, newValue = ufoLib.convertFontInfoValueForAttributeFromVersion1ToVersion2(attr, value) note = "The %s attribute has been deprecated. Use the new %s attribute." % (attr, newAttr) warn(note, DeprecationWarning) attr = newAttr value = newValue _baseAttributes = ["_object", "changed", "selected", "getParent"] _renameAttributes = {"openTypeNameManufacturer": "manufacturer", "openTypeNameManufacturerURL": "manufacturerURL", "openTypeNameDesigner": "designer", "openTypeNameDesignerURL": "designerURL", # "openTypeNameLicense": "license", # "openTypeNameLicenseURL": "licenseURL", "fontName": "postscriptFontName", "vendorURL": "manufacturerURL", "uniqueID": "postscriptUniqueID", "otMacName": "openTypeNameCompatibleFullName" }; _masterAttributes = ["postscriptUnderlinePosition", "postscriptUnderlineThickness", "openTypeOS2StrikeoutSize", "openTypeOS2StrikeoutPosition"] # setting a known attribute if attr in _masterAttributes: if type(value) == type([]): value = NSMutableArray.arrayWithArray_(value) elif type(value) == type(1): value = NSNumber.numberWithInt_(value) elif type(value) == type(1.2): value = NSNumber.numberWithFloat_(value) if attr in _renameAttributes: attr = _renameAttributes[attr] self._object._font.fontMasterAtIndex_(self._object._masterIndex).setValue_forKey_(value, attr) return if attr not in _baseAttributes: try: if type(value) == type([]): value = NSMutableArray.arrayWithArray_(value) elif type(value) == type(1): value = NSNumber.numberWithInt_(value) elif type(value) == type(1.2): value = NSNumber.numberWithFloat_(value) if attr in _renameAttributes: attr = _renameAttributes[attr] self._object._font.setValue_forKey_(value, attr) except: raise AttributeError("Unknown attribute %s." % attr) return elif attr in self.__dict__ or attr in self._baseAttributes: super(BaseInfo, self).__setattr__(attr, value) else: raise AttributeError("Unknown attribute %s." % attr)