コード例 #1
0
    def __str__(self):
        """
        Pack parts into a single string
        """
        TRANSFORM = {
            '&[Tab]': '&A',
            '&[Pages]': '&N',
            '&[Date]': '&D',
            '&[Path]': '&Z',
            '&[Page]': '&P',
            '&[Time]': '&T',
            '&[File]': '&F',
            '&[Picture]': '&G'
        }

        # escape keys and create regex
        SUBS_REGEX = re.compile("|".join(
            ["({0})".format(re.escape(k)) for k in TRANSFORM]))

        def replace(match):
            """
            Callback for re.sub
            Replace expanded control with mini-format equivalent
            """
            sub = match.group(0)
            return TRANSFORM[sub]

        txt = []
        for key, part in zip(self.__keys,
                             [self.left, self.center, self.right]):
            if part.text is not None:
                txt.append(u"&{0}{1}".format(key, unicode(part)))
        txt = "".join(txt)
        txt = SUBS_REGEX.sub(replace, txt)
        return escape(txt)
コード例 #2
0
    def __str__(self):
        """
        Pack parts into a single string
        """
        TRANSFORM = {'&[Tab]': '&A', '&[Pages]': '&N', '&[Date]': '&D',
                     '&[Path]': '&Z', '&[Page]': '&P', '&[Time]': '&T', '&[File]': '&F',
                     '&[Picture]': '&G'}

        # escape keys and create regex
        SUBS_REGEX = re.compile("|".join(["({0})".format(re.escape(k))
                                          for k in TRANSFORM]))

        def replace(match):
            """
            Callback for re.sub
            Replace expanded control with mini-format equivalent
            """
            sub = match.group(0)
            return TRANSFORM[sub]

        txt = []
        for key, part in zip(
            self.__keys, [self.left, self.center, self.right]):
            if part.text is not None:
                txt.append(u"&{0}{1}".format(key, unicode(part)))
        txt = "".join(txt)
        txt = SUBS_REGEX.sub(replace, txt)
        return escape(txt)
コード例 #3
0
ファイル: table.py プロジェクト: JLL-Benson/CHN_DQ
 def __iter__(self):
     for k, v in super(TableColumn, self).__iter__():
         if k == 'name':
             v = escape(v)
         yield k, v
コード例 #4
0
 def __iter__(self):
     for k, v in super(TableColumn, self).__iter__():
         if k == 'name':
             v = escape(v)
         yield k, v