コード例 #1
0
def test_GetDefaultPaperType():
    assert Utils.GetDefaultPaperType('en_GB') == "A4"
    assert Utils.GetDefaultPaperType('en_US') == "Letter"
    assert Utils.GetDefaultPaperType('en_gb') == "A4"
    assert Utils.GetDefaultPaperType('en_us') == "Letter"
    assert Utils.GetDefaultPaperType('de_DE') == "A4"
    assert Utils.GetDefaultPaperType('es_MX') == "Letter"
    assert Utils.GetDefaultPaperType('') == "Letter"
コード例 #2
0
ファイル: printer.py プロジェクト: xuhui/CUPS-Cloud-Print
    def generatePPD(self):
        """Generates a PPD string for this printer."""
        defaultlocale = locale.getdefaultlocale()
        language, newlocale = Utils.GetLanguage(defaultlocale,
                                                self._cupsHelper)
        defaultpapertype = Utils.GetDefaultPaperType(newlocale)
        ppd = self._PPD_TEMPLATE_HEAD % {
            'language': language,
            'defaultpapertype': defaultpapertype,
            'ieee1284': self.getIEEE1284(),
            'ppdname': self.getPPDName()
        }
        if self['capabilities'] is not None:
            addedCapabilities = []
            for capability in self['capabilities']:
                originCapabilityName = None
                internalCapabilityName = \
                    self._getInternalName(capability, 'capability', None, addedCapabilities)
                addedCapabilities.append(internalCapabilityName)
                if 'displayName' in capability and len(
                        capability['displayName']) > 0:
                    originCapabilityName = self._sanitizeText(
                        capability['displayName'])
                elif 'psk:DisplayName' in capability and len(
                        capability['psk:DisplayName']) > 0:
                    originCapabilityName = self._sanitizeText(
                        capability['psk:DisplayName'])
                else:
                    originCapabilityName = self._sanitizeText(
                        capability['name'])
                if capability['type'] == 'Feature':
                    ppd += '*OpenUI *%s/%s: PickOne\n' % \
                        (internalCapabilityName, internalCapabilityName)
                    # translation of capability, allows use of 8
                    # bit chars
                    ppd += '*%s.Translation %s/%s: ""\n' % \
                        (language, internalCapabilityName, originCapabilityName)
                    addedOptions = []
                    for option in capability['options']:
                        originOptionName = None
                        if 'displayName' in option and len(
                                option['displayName']) > 0:
                            originOptionName = self._sanitizeText(
                                option['displayName'])
                        elif 'psk:DisplayName' in option and len(
                                option['psk:DisplayName']) > 0:
                            originOptionName = self._sanitizeText(
                                option['psk:DisplayName'])
                        else:
                            originOptionName = self._sanitizeText(
                                option['name'])
                        internalOptionName = self._getInternalName(
                            option, 'option', capability['name'], addedOptions)
                        addedOptions.append(internalOptionName)
                        if 'default' in option and option['default']:
                            ppd += '*Default%s: %s\n' % (
                                internalCapabilityName, internalOptionName)
                        ppd += '*%s %s:%s\n' % \
                            (internalCapabilityName, internalOptionName, internalOptionName)
                        # translation of option, allows use of 8
                        # bit chars
                        value = ''
                        if 'ppd:value' in option:
                            value = option['ppd:value']
                        ppd += '*%s.%s %s/%s: "%s"\n' % (
                            language, internalCapabilityName,
                            internalOptionName, originOptionName, value)

                    ppd += '*CloseUI: *%s\n' % internalCapabilityName

        ppd += self._PPD_TEMPLATE_FOOT
        return ppd
コード例 #3
0
def test_GetDefaultPaperType():
    assert Utils.GetDefaultPaperType(['en_GB',]) == "A4"
    assert Utils.GetDefaultPaperType(['en_US',]) == "Letter"
    assert Utils.GetDefaultPaperType([None,None]) == "Letter"