• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.m18n函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.m18n函数的典型用法代码示例。如果您正苦于以下问题:Python m18n函数的具体用法?Python m18n怎么用?Python m18n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了m18n函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: refresh

 def refresh(self, game):
     """refresh for new values"""
     self.game = game
     lines = []
     if self.game is None:
         lines.append(m18n('There is no active game'))
     else:
         i18nName = m18n(self.game.ruleset.name)
         lines.append(m18n('Ruleset: %1', i18nName))
         lines.append('')
         for player in self.game.players:
             pLines = []
             if player.hand and player.hand.tileNames:
                 total = player.hand.total()
                 if total:
                     pLines = ['%s: %s' % (player.localName, total)]
                     for line in player.hand.explain():
                         pLines.append('- ' + line)
             elif player.handTotal:
                 pLines.append(m18n('Manual score for %1: %2 points', player.localName, player.handTotal))
             if pLines:
                 pLines.append('')
             lines.extend(pLines)
     if 'xxx'.join(lines) != 'xxx'.join(unicode(x) for x in self.model.stringList()):
         # QStringListModel does not optimize identical lists away, so we do
         self.model.setStringList(lines)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:26,代码来源:scoring.py


示例2: showMoveHelper

 def showMoveHelper(self, visible=True):
     """show help text In empty HandBoards"""
     if visible:
         if not self.__moveHelper:
             splitter = QGraphicsRectItem(self)
             hbCenter = self.rect().center()
             splitter.setRect(hbCenter.x() * 0.5, hbCenter.y(), hbCenter.x() * 1, 1)
             helpItems = [splitter]
             for name, yFactor in [(m18n('Move Exposed Tiles Here'), 0.5),
                                     (m18n('Move Concealed Tiles Here'), 1.5)]:
                 helper = QGraphicsSimpleTextItem(name, self)
                 helper.setScale(3)
                 nameRect = QRectF()
                 nameRect.setSize(helper.mapToParent(helper.boundingRect()).boundingRect().size())
                 center = QPointF(hbCenter)
                 center.setY(center.y() * yFactor)
                 helper.setPos(center - nameRect.center())
                 if self.sceneRotation() == 180:
                     rotateCenter(helper, 180)
                 helpItems.append(helper)
             self.__moveHelper = self.scene().createItemGroup(helpItems)
         self.__moveHelper.setVisible(True)
     else:
         if self.__moveHelper:
             self.__moveHelper.setVisible(False)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:25,代码来源:handboard.py


示例3: loadRules

    def loadRules(self):
        ClassicalChinese.loadRules(self)
        # the squirming snake is only covered by standard mahjongg rule if tiles are ordered
        self.mjRules.add(Rule('Squirming Snake', 'FSquirmingSnake', limits=1,
                description=m18n('All tiles of same color. Pung or Kong of 1 and 9, pair of 2, 5 or 8 and two '
                'Chows of the remaining values')))
        self.handRules.add(Rule('Little Three Dragons', 'FLittleThreeDragons', doubles=1,
                description=m18n('2 Pungs or Kongs of dragons and 1 pair of dragons')))
        self.handRules.add(Rule('Big Three Dragons', 'FBigThreeDragons', doubles=2,
                description=m18n('3 Pungs or Kongs of dragons')))
        self.handRules.add(Rule('Little Four Joys', 'FLittleFourJoys', doubles=1,
                description=m18n('3 Pungs or Kongs of winds and 1 pair of winds')))
        self.handRules.add(Rule('Big Four Joys', 'FBigFourJoys', doubles=2,
                description=m18n('4 Pungs or Kongs of winds')))

        self.winnerRules['Only Honors'].doubles = 2

        self.penaltyRules.add(Rule('False Naming of Discard, Claimed for Chow', points = -50))
        self.penaltyRules.add(Rule('False Naming of Discard, Claimed for Pung/Kong', points = -100))
        self.penaltyRules.add(Rule('False Declaration of Mah Jongg by One Player',
                'Oabsolute payees=3', points = -300))
        self.penaltyRules.add(Rule('False Declaration of Mah Jongg by Two Players',
                'Oabsolute payers=2 payees=2', points = -300))
        self.penaltyRules.add(Rule('False Declaration of Mah Jongg by Three Players',
                'Oabsolute payers=3', points = -300))
        self.penaltyRules.add(Rule('False Naming of Discard, Claimed for Mah Jongg',
                'Oabsolute payees=3', points = -300))
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:27,代码来源:predefined.py


示例4: __init__

    def __init__(self, parent):
        QDialog.__init__(self)
        self.parent = parent
        self.model = QSqlTableModel(self, DBHandle.default)
        self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
        self.model.setTable("player")
        self.model.setSort(1, 0)
        self.model.setHeaderData(1, Qt.Horizontal, QVariant(m18nc("Player", "Name")))
        self.model.setFilter('name not like "ROBOT %" and name not like "Robot %"')
        self.view = MJTableView(self)
        self.view.verticalHeader().show()
        self.view.setModel(self.model)
        self.view.hideColumn(0)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.newButton = self.buttonBox.addButton(m18nc('define a new player', "&New"), QDialogButtonBox.ActionRole)
        self.newButton.setIcon(KIcon("document-new"))
        self.newButton.clicked.connect(self.slotInsert)
        self.deleteButton = self.buttonBox.addButton(m18n("&Delete"), QDialogButtonBox.ActionRole)
        self.deleteButton.setIcon(KIcon("edit-delete"))
        self.deleteButton.clicked.connect(self.delete)

        cmdLayout = QHBoxLayout()
        cmdLayout.addWidget(self.buttonBox)
        layout = QVBoxLayout()
        layout.addWidget(self.view)
        layout.addLayout(cmdLayout)
        self.setLayout(layout)

        self.setWindowTitle(m18n("Players") + ' - Kajongg')
        self.setObjectName('Players')
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:33,代码来源:playerlist.py


示例5: __init__

    def __init__(self, url, username, password):
        MustChooseDialog.__init__(self, None)
        self.setWindowTitle(m18n('Create User Account') + ' - Kajongg')
        self.buttonBox = KDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        vbox = QVBoxLayout(self)
        grid = QFormLayout()
        self.lbServer = QLabel()
        self.lbServer.setText(url)
        grid.addRow(m18n('Game server:'), self.lbServer)
        self.lbUser = QLabel()
        grid.addRow(m18n('Username:'), self.lbUser)
        self.edPassword = QLineEdit()
        self.edPassword.setEchoMode(QLineEdit.PasswordEchoOnEdit)
        grid.addRow(m18n('Password:'), self.edPassword)
        self.edPassword2 = QLineEdit()
        self.edPassword2.setEchoMode(QLineEdit.PasswordEchoOnEdit)
        grid.addRow(m18n('Repeat password:'), self.edPassword2)
        vbox.addLayout(grid)
        vbox.addWidget(self.buttonBox)
        pol = QSizePolicy()
        pol.setHorizontalPolicy(QSizePolicy.Expanding)
        self.lbUser.setSizePolicy(pol)

        self.edPassword.textChanged.connect(self.passwordChanged)
        self.edPassword2.textChanged.connect(self.passwordChanged)
        StateSaver(self)
        self.username = username
        self.password = password
        self.passwordChanged()
        self.edPassword2.setFocus()
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:33,代码来源:login.py


示例6: requestAvatarId

 def requestAvatarId(self, cred): # pylint: disable=R0201
     """get user id from database"""
     args = cred.username.split(SERVERMARK)
     if len(args) > 1:
         if args[0] == 'adduser':
             cred.username = args[1]
             password = args[2]
             with Transaction():
                 query = Query('insert into player(name,password) values(?,?)',
                     list([cred.username.decode('utf-8'), password.decode('utf-8')]))
                 if not query.success:
                     if query.msg.startswith('ERROR: constraint failed') \
                     or 'not unique' in query.msg:
                         template = m18nE('User %1 already exists')
                         logInfo(m18n(template, cred.username))
                         query.msg = srvMessage(template, cred.username)
                     else:
                         logInfo(query.msg)
                     return fail(credError.UnauthorizedLogin(query.msg))
         elif args[1] == 'deluser':
             pass
     query = Query('select id, password from player where name=?',
         list([cred.username.decode('utf-8')]))
     if not len(query.records):
         template = 'Wrong username: %1'
         logInfo(m18n(template, cred.username))
         return fail(credError.UnauthorizedLogin(srvMessage(template, cred.username)))
     userid, password = query.records[0]
     # checkPassword uses md5 which cannot handle unicode strings (python 2.7)
     defer1 = maybeDeferred(cred.checkPassword, password.encode('utf-8'))
     defer1.addCallback(DBPasswordChecker._checkedPassword, userid)
     return defer1
开发者ID:jsj2008,项目名称:kdegames,代码行数:32,代码来源:server.py


示例7: setupUi

 def setupUi(self):
     """create all Ui elements but do not fill them"""
     buttonBox = KDialogButtonBox(self)
     buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
     # Ubuntu 11.10 unity is a bit strange - without this, it sets focus on
     # the cancel button (which it shows on the left). I found no obvious
     # way to use setDefault and setAutoDefault for fixing this.
     buttonBox.button(QDialogButtonBox.Ok).setFocus(True)
     buttonBox.accepted.connect(self.accept)
     buttonBox.rejected.connect(self.reject)
     vbox = QVBoxLayout(self)
     self.grid = QFormLayout()
     self.cbServer = QComboBox()
     self.cbServer.setEditable(True)
     self.grid.addRow(m18n('Game server:'), self.cbServer)
     self.cbUser = QComboBox()
     self.cbUser.setEditable(True)
     self.grid.addRow(m18n('Username:'), self.cbUser)
     self.edPassword = QLineEdit()
     self.edPassword.setEchoMode(QLineEdit.PasswordEchoOnEdit)
     self.grid.addRow(m18n('Password:'), self.edPassword)
     self.cbRuleset = ListComboBox()
     self.grid.addRow(m18nc('kajongg', 'Ruleset:'), self.cbRuleset)
     vbox.addLayout(self.grid)
     vbox.addWidget(buttonBox)
     pol = QSizePolicy()
     pol.setHorizontalPolicy(QSizePolicy.Expanding)
     self.cbUser.setSizePolicy(pol)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:28,代码来源:login.py


示例8: toolTip

 def toolTip(self, button, dummyTile):
     """decorate the action button which will send this message"""
     maySay = button.client.sayable[self]
     if not maySay:
         return '', False, ''
     myself = button.client.game.myself
     txt = []
     warn = False
     if myself.originalCall and myself.mayWin:
         warn = True
         txt.append(m18n('saying %1 violates Original Call',
             self.i18nName))
     dangerousMelds = button.client.maybeDangerous(self)
     if dangerousMelds:
         lastDiscardName = Meld.tileName(button.client.game.lastDiscard.element)
         warn = True
         if Debug.dangerousGame and len(dangerousMelds) != len(maySay):
             button.client.game.debug('only some claimable melds are dangerous: %s' % dangerousMelds)
         if len(dangerousMelds) == 1:
             txt.append(m18n(
                'claiming %1 is dangerous because you will have to discard a dangerous tile',
                lastDiscardName))
         else:
             for meld in dangerousMelds:
                 txt.append(m18n(
                'claiming %1 for %2 is dangerous because you will have to discard a dangerous tile',
                lastDiscardName, str(meld)))
     if not txt:
         txt = [m18n('You may say %1', self.i18nName)]
     return '<br><br>'.join(txt), warn, ''
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:30,代码来源:message.py


示例9: tooltip

 def tooltip(self):
     """tooltip for rule: just the name of the ruleset"""
     ruleset = self.ruleset()
     if self.rawContent.description:
         return '<b>' + m18n(ruleset.name) + '</b><br><br>' + \
             m18n(self.rawContent.description)
     else:
         return m18n(ruleset.name)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:8,代码来源:rulesetselector.py


示例10: __init__

 def __init__(self, swappers):
     QMessageBox.__init__(self)
     self.setWindowTitle(m18n("Swap Seats") + ' - Kajongg')
     self.setText(m18n("By the rules, %1 and %2 should now exchange their seats. ",
         swappers[0].name, swappers[1].name))
     self.yesAnswer = QPushButton(m18n("&Exchange"))
     self.addButton(self.yesAnswer, QMessageBox.YesRole)
     self.noAnswer = QPushButton(m18n("&Keep seat"))
     self.addButton(self.noAnswer, QMessageBox.NoRole)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:9,代码来源:playfield.py


示例11: __init__

    def __init__(self, desktopFileName=None):
        if desktopFileName is None:
            desktopFileName = 'default'
        self.tileSize = None
        self.faceSize = None
        self.__renderer = None
        self.__shadowOffsets = None
        self.defineCatalog()
        self.path = locateTileset(desktopFileName + '.desktop')
        if self.path.isEmpty():
            self.path = locateTileset('default.desktop')
            if self.path.isEmpty():
                directories = '\n\n' +'\n'.join(str(x) for x in KGlobal.dirs().resourceDirs("kmahjonggtileset"))
                logException(TileException(m18n( \
                'cannot find any tileset in the following directories, is libkmahjongg installed?') + directories))
            else:
                logWarning(m18n('cannot find tileset %1, using default', desktopFileName))
                self.desktopFileName = 'default'
        else:
            self.desktopFileName = desktopFileName
        self.darkenerAlpha = 120 if self.desktopFileName == 'jade' else 50
        tileconfig = KConfig(self.path, KConfig.SimpleConfig)
        group = KConfigGroup(tileconfig.group("KMahjonggTileset"))

        self.name = group.readEntry("Name", "unknown tileset").toString() # Returns translated data
        self.author = group.readEntry("Author", "unknown author").toString()
        self.description = group.readEntry("Description", "no description available").toString()
        self.authorEmail = group.readEntry("AuthorEmail", "no E-Mail address available").toString()

        #Version control
        tileversion, entryOK = group.readEntry("VersionFormat", QVariant(0)).toInt()
        #Format is increased when we have incompatible changes, meaning that
        # older clients are not able to use the remaining information safely
        if not entryOK or tileversion > TILESETVERSIONFORMAT:
            logException(TileException('tileversion file / program: %d/%d' % \
                (tileversion, TILESETVERSIONFORMAT)))

        graphName = QString(group.readEntry("FileName"))
        self.__graphicspath = locateTileset(graphName)
        if self.__graphicspath.isEmpty():
            logException(TileException('cannot find kmahjongglib/tilesets/%s for %s' % \
                        (graphName, self.desktopFileName )))
        self.renderer() # now that we get the sizes from the svg, we need the renderer right away

        self.svgName = { 'wn': 'WIND_1', 'ws': 'WIND_2', 'we': 'WIND_3', 'ww': 'WIND_4',
            'db': 'DRAGON_1', 'dg': 'DRAGON_2', 'dr': 'DRAGON_3'}
        for value in '123456789':
            self.svgName['s%s' % value] = 'ROD_%s' % value
            self.svgName['b%s' % value] = 'BAMBOO_%s' % value
            self.svgName['c%s' % value] = 'CHARACTER_%s' % value
        for idx, wind in enumerate('eswn'):
            self.svgName['f%s' % wind] = 'FLOWER_%d' % (idx + 1)
            self.svgName['y%s' % wind] = 'SEASON_%d' % (idx + 1)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:53,代码来源:tileset.py


示例12: _loginReallyFailed

 def _loginReallyFailed(self, failure):
     """login failed, not fixable by adding missing user"""
     msg = self._prettifyErrorMessage(failure)
     if failure.check(CancelledError):
         # show no warning, just leave
         return failure
     if 'Errno 5' in msg:
         # The server is running but something is wrong with it
         if self.useSocket and os.name != 'nt':
             if removeIfExists(socketName()):
                 logInfo(m18n('removed stale socket <filename>%1</filename>', socketName()))
             msg += '\n\n\n' + m18n('Please try again')
     logWarning(msg)
     return failure
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:14,代码来源:login.py


示例13: headerData

 def headerData(self, section, orientation, role):
     """tell the view about the wanted headers"""
     if role == Qt.TextAlignmentRole:
         if orientation == Qt.Horizontal:
             return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
     if role != Qt.DisplayRole:
         return QVariant()
     if orientation == Qt.Horizontal:
         if section == 0:
             return QVariant(m18nc("Kajongg", "Rule"))
         if section == 1:
             return QVariant(m18n(self.view.cbRuleset1.current.name))
         if section == 2:
             return QVariant(m18n(self.view.cbRuleset2.current.name))
         return QVariant()
开发者ID:jsj2008,项目名称:kdegames,代码行数:15,代码来源:differ.py


示例14: __init__

    def __init__(self, client):
        super(TableList, self).__init__(None)
        self.autoStarted = False
        self.client = client
        self.setObjectName('TableList')
        self.resize(700, 400)
        self.view = MJTableView(self)
        self.differ = None
        self.debugModelTest = None
        self.__requestedNewTable = False
        self.view.setItemDelegateForColumn(2, RichTextColumnDelegate(self.view))

        buttonBox = QDialogButtonBox(self)
        self.newButton = buttonBox.addButton(m18n("&New"), QDialogButtonBox.ActionRole)
        self.newButton.setIcon(KIcon("document-new"))
        self.newButton.setToolTip(m18n("Allocate a new table"))
        self.newButton.clicked.connect(self.newTable)
        self.joinButton = buttonBox.addButton(m18n("&Join"), QDialogButtonBox.AcceptRole)
        self.joinButton.clicked.connect(self.joinTable)
        self.joinButton.setIcon(KIcon("list-add-user"))
        self.joinButton.setToolTip(m18n("Join a table"))
        self.leaveButton = buttonBox.addButton(m18n("&Leave"), QDialogButtonBox.AcceptRole)
        self.leaveButton.clicked.connect(self.leaveTable)
        self.leaveButton.setIcon(KIcon("list-remove-user"))
        self.leaveButton.setToolTip(m18n("Leave a table"))
        self.compareButton = buttonBox.addButton(m18nc('Kajongg-Ruleset','Compare'), QDialogButtonBox.AcceptRole)
        self.compareButton.clicked.connect(self.compareRuleset)
        self.compareButton.setIcon(KIcon("preferences-plugin-script"))
        self.compareButton.setToolTip(m18n('Compare the rules of this table with my own rulesets'))
        self.chatButton = buttonBox.addButton(m18n('&Chat'), QDialogButtonBox.AcceptRole)
        self.chatButton.setIcon(KIcon("call-start"))
        self.chatButton.clicked.connect(self.chat)
        self.startButton = buttonBox.addButton(m18n('&Start'), QDialogButtonBox.AcceptRole)
        self.startButton.clicked.connect(self.startGame)
        self.startButton.setIcon(KIcon("arrow-right"))
        self.startButton.setToolTip(m18n("Start playing on a table. Empty seats will be taken by robot players."))

        cmdLayout = QHBoxLayout()
        cmdLayout.addWidget(buttonBox)

        layout = QVBoxLayout()
        layout.addWidget(self.view)
        layout.addLayout(cmdLayout)
        self.setLayout(layout)

        self.view.doubleClicked.connect(self.joinTable)
        StateSaver(self, self.view.horizontalHeader())
        self.updateButtonsForTable(None)
开发者ID:jsj2008,项目名称:kdegames,代码行数:48,代码来源:tables.py


示例15: __init__

 def __init__(self, game):
     """selection for this player, tiles are the still available tiles"""
     QDialog.__init__(self, None)
     self.setWindowTitle(m18n("Penalty") + ' - Kajongg')
     self.game = game
     grid = QGridLayout(self)
     lblOffense = QLabel(m18n('Offense:'))
     crimes = list([x for x in game.ruleset.penaltyRules if not ('absolute' in x.options and game.winner)])
     self.cbCrime = ListComboBox(crimes)
     lblOffense.setBuddy(self.cbCrime)
     grid.addWidget(lblOffense, 0, 0)
     grid.addWidget(self.cbCrime, 0, 1, 1, 4)
     lblPenalty = QLabel(m18n('Total Penalty'))
     self.spPenalty = PenaltyBox(2)
     self.spPenalty.setRange(0, 9999)
     lblPenalty.setBuddy(self.spPenalty)
     self.lblUnits = QLabel(m18n('points'))
     grid.addWidget(lblPenalty, 1, 0)
     grid.addWidget(self.spPenalty, 1, 1)
     grid.addWidget(self.lblUnits, 1, 2)
     self.payers = []
     self.payees = []
     # a penalty can never involve the winner, neither as payer nor as payee
     for idx in range(3):
         self.payers.append(ListComboBox(game.losers()))
         self.payees.append(ListComboBox(game.losers()))
     for idx, payer in enumerate(self.payers):
         grid.addWidget(payer, 3+idx, 0)
         payer.lblPayment = QLabel()
         grid.addWidget(payer.lblPayment, 3+idx, 1)
     for idx, payee in enumerate(self.payees):
         grid.addWidget(payee, 3+idx, 3)
         payee.lblPayment = QLabel()
         grid.addWidget(payee.lblPayment, 3+idx, 4)
     grid.addWidget(QLabel(''), 6, 0)
     grid.setRowStretch(6, 10)
     for player in self.payers + self.payees:
         player.currentIndexChanged.connect(self.playerChanged)
     self.spPenalty.valueChanged.connect(self.penaltyChanged)
     self.cbCrime.currentIndexChanged.connect(self.crimeChanged)
     buttonBox = KDialogButtonBox(self)
     grid.addWidget(buttonBox, 7, 0, 1, 5)
     buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
     buttonBox.rejected.connect(self.reject)
     self.btnExecute = buttonBox.addButton(m18n("&Execute"), QDialogButtonBox.AcceptRole,
         self, SLOT("accept()"))
     self.crimeChanged()
     StateSaver(self)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:48,代码来源:scoring.py


示例16: validateParameter

 def validateParameter(self):
     """check for validity"""
     if 'min' in self.options:
         minValue = self.parType(self.options['min'])
         if self.parameter < minValue:
             return m18nc('wrong value for rule', '%1: %2 is too small, minimal value is %3',
                 m18n(self.name), self.parameter, minValue)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:7,代码来源:rule.py


示例17: __checkExistingConnections

 def __checkExistingConnections(self):
     """do we already have a connection to the wanted URL?"""
     for client in self.client.humanClients:
         if client.connection and client.connection.url == self.url:
             logWarning(m18n('You are already connected to server %1', self.url))
             client.tableList.activateWindow()
             raise CancelledError
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:7,代码来源:login.py


示例18: _prettifyErrorMessage

 def _prettifyErrorMessage(self, failure):
     """instead of just failure.getErrorMessage(), return something more user friendly.
     That will be a localized error text, the original english text will be removed"""
     url = self.url
     message = failure.getErrorMessage()
     match = re.search(r".*gaierror\(-\d, '(.*)'.*", message)
     if not match:
         match = re.search(r".*ConnectError\('(.*)',\)", message)
     if not match:
         match = re.search(r".*ConnectionRefusedError\('(.*)',\)", message)
     if not match:
         match = re.search(r".*DNS lookup.*\[Errno -5\] (.*)", message)
         if match:
             url = url.split(':')[0] # remove the port
     # current twisted (version 12.3) returns different messages:
     if not match:
         match = re.search(r".*DNS lookup failed: address u'(.*)' not found.*", message)
         if match:
             return u'%s: %s' % (match.group(1), m18n('DNS lookup failed, address not found'))
     if not match:
         match = re.search(r".*DNS lookup.*\[Errno 110\] (.*)", message)
     if not match:
         match = re.search(r".*while connecting: 113: (.*)", message)
     if match:
         message = match.group(1).decode('string-escape').decode('string-escape')
     return u'%s: %s' % (url, message.decode('utf-8'))
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:26,代码来源:login.py


示例19: serverListening

 def serverListening(self):
     """is somebody listening on that port?"""
     if self.useSocket and os.name != 'nt':
         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
         sock.settimeout(1)
         try:
             sock.connect(socketName())
         except socket.error as exception:
             if os.path.exists(socketName()):
                 # try again, avoiding a race
                 try:
                     sock.connect(socketName())
                 except socket.error as exception:
                     if removeIfExists(socketName()):
                         logInfo(m18n('removed stale socket <filename>%1</filename>', socketName()))
                     logInfo('socket error:%s' % str(exception))
                     return False
                 else:
                     return True
         else:
             return True
     else:
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sock.settimeout(1)
         try:
             sock.connect((self.dlg.host, self.dlg.port))
         except socket.error:
             return False
         else:
             return True
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:30,代码来源:login.py


示例20: __saveScores

 def __saveScores(self):
     """save computed values to database, update score table and balance in status line"""
     if not self.__needSave():
         return
     scoretime = datetime.datetime.now().replace(microsecond=0).isoformat()
     for player in self.players:
         if player.hand:
             manualrules = '||'.join(x.rule.name for x in player.hand.usedRules)
         else:
             manualrules = m18n('Score computed manually')
         Query("INSERT INTO SCORE "
             "(game,hand,data,manualrules,player,scoretime,won,prevailing,wind,"
             "points,payments, balance,rotated,notrotated) "
             "VALUES(%d,%d,?,?,%d,'%s',%d,'%s','%s',%d,%d,%d,%d,%d)" % \
             (self.gameid, self.handctr, player.nameid,
                 scoretime, int(player == self.__winner),
                 WINDS[self.roundsFinished % 4], player.wind, player.handTotal,
                 player.payment, player.balance, self.rotated, self.notRotated),
             list([player.hand.string, manualrules]))
         if Debug.scores:
             self.debug('%s: handTotal=%s balance=%s %s' % (
                 player,
                 player.handTotal, player.balance, 'won' if player == self.winner else ''))
         for usedRule in player.hand.usedRules:
             rule = usedRule.rule
             if rule.score.limits:
                 tag = rule.function.__class__.__name__
                 if hasattr(rule.function, 'limitHand'):
                     tag = rule.function.limitHand.__class__.__name__
                 self.addCsvTag(tag)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:30,代码来源:game.py



注:本文中的util.m18n函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.makedate函数代码示例发布时间:2022-05-26
下一篇:
Python util.lookup_es_key函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap