當前位置: 首頁>>代碼示例>>Python>>正文


Python roman.toRoman方法代碼示例

本文整理匯總了Python中roman.toRoman方法的典型用法代碼示例。如果您正苦於以下問題:Python roman.toRoman方法的具體用法?Python roman.toRoman怎麽用?Python roman.toRoman使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在roman的用法示例。


在下文中一共展示了roman.toRoman方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setPageCounter

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def setPageCounter(counter=None, style=None):

    global _counter, _counterStyle

    if counter is not None:
        _counter = counter
    if style is not None:
        _counterStyle = style

    if _counterStyle == 'lowerroman':
        ptext = toRoman(_counter).lower()
    elif _counterStyle == 'roman':
        ptext = toRoman(_counter).upper()
    elif _counterStyle == 'alpha':
        ptext = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[_counter % 26]
    elif _counterStyle == 'loweralpha':
        ptext = 'abcdefghijklmnopqrstuvwxyz'[_counter % 26]
    else:
        ptext = str(_counter)
    return ptext 
開發者ID:rst2pdf,項目名稱:rst2pdf,代碼行數:22,代碼來源:createpdf.py

示例2: format_row

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def format_row(self, row):
        for item in row:
            if 'Dt' in str(item):
                if (row[item] is not None) & (row[item] != '') & (row[item] != 'Present'):
                    try:
                        row[item] = str(arrow.get(str(row[item]), 'YYYY-MM-DD').format('DD MMMM YYYY'))
                    except Exception as e:
                        self.logger.debug('Cannot convert contents of date field ' + str(item) + ' to a formatted date. ' + str(e))
            if item in ('Number'):
                row[item] = str(roman.toRoman(int(row[item])))
        return row 
開發者ID:nmstoker,項目名稱:lockebot,代碼行數:13,代碼來源:roybot.py

示例3: section

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def section(self, level):
        """Return the LaTeX section name for section `level`.

        The name depends on the specific document class.
        Level is 1,2,3..., as level 0 is the title.
        """
        if level <= len(self.sections):
            return self.sections[level-1]
        else:  # unsupported levels
            return 'DUtitle[section%s]' % roman.toRoman(level) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:12,代碼來源:__init__.py

示例4: digits2roman

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def digits2roman(phrase, lang='en'):
  wordified = ''
  for word in phrase.split():
    if word.isnumeric():
      word = roman.toRoman(int(word))
    wordified = wordified + word + " "
  return wordified[:-1]


# Replace word-form numbers with roman numerals. 
開發者ID:m0ngr31,項目名稱:kodi-voice,代碼行數:12,代碼來源:kodi.py

示例5: pages_to_logical_pages

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def pages_to_logical_pages(self):
        labels = self.parse_pagelabels()
        self.logical_pages = list(range(0,self.pages + 1))

        def divmod_alphabetic(n):
            a, b = divmod(n, 26)
            if b == 0:
                return a - 1, b + 26
            return a, b

        def to_alphabetic(n):
            chars = []
            while n > 0:
                n, d = divmod_alphabetic(n)
                chars.append(string.ascii_uppercase[d - 1])
            return ''.join(reversed(chars))

        if labels == []:
            for p in range(0,self.pages + 1):
                self.logical_pages[p] = str(p + self.first_page_offset)
        else:
            for p in range(0,self.pages + 1):
                for label in labels:
                    if p >= label.startpage:
                        lp = (p - label.startpage) + label.firstpagenum
                        style = label.style
                        prefix = label.prefix
                if style == 'roman uppercase':
                    lp = prefix + roman.toRoman(lp)
                    lp = lp.upper()
                elif style == 'roman lowercase':
                    lp = prefix + roman.toRoman(lp)
                    lp = lp.lower()
                elif style == 'alphabetic uppercase':
                    lp = prefix + to_alphabetic(lp) 
                elif style == 'alphabetic lowercase':
                    lp = prefix + to_alphabetic(lp)
                    lp = lp.lower()
                else:
                    lp = prefix + str(lp)
                self.logical_pages[p] = lp 
開發者ID:dsanson,項目名稱:termpdf.py,代碼行數:43,代碼來源:termpdf.py

示例6: _peptide_header_display_data

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def _peptide_header_display_data(self, vaccine_peptide, rank):
        """
        Returns a dictionary with info used to populate the header section of a peptide table.

        Parameters
        ----------
        vaccine_peptide : VaccinePeptide
          The given peptide to convert to display form

        rank : int
          Rank of vaccine peptide in list
        """
        mutant_protein_fragment = vaccine_peptide.mutant_protein_fragment
        amino_acids = mutant_protein_fragment.amino_acids
        mutation_start = mutant_protein_fragment.mutant_amino_acid_start_offset
        mutation_end = mutant_protein_fragment.mutant_amino_acid_end_offset
        aa_before_mutation = amino_acids[:mutation_start]
        aa_mutant = amino_acids[mutation_start:mutation_end]
        aa_after_mutation = amino_acids[mutation_end:]

        header_display_data = {
            'num': roman.toRoman(rank + 1).lower(),
            'aa_before_mutation': aa_before_mutation,
            'aa_mutant': aa_mutant,
            'aa_after_mutation': aa_after_mutation,
        }
        return header_display_data 
開發者ID:openvax,項目名稱:vaxrank,代碼行數:29,代碼來源:report.py

示例7: list_start

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def list_start(self, node):
        class enum_char(object):
            enum_style = {
                    'bullet'     : '\\(bu',
                    'emdash'     : '\\(em',
                     }

            def __init__(self, style):
                self._style = style
                if 'start' in node:
                    self._cnt = node['start'] - 1
                else:
                    self._cnt = 0
                self._indent = 2
                if style == 'arabic':
                    # indentation depends on number of childrens
                    # and start value.
                    self._indent = len(str(len(node.children)))
                    self._indent += len(str(self._cnt)) + 1
                elif style == 'loweralpha':
                    self._cnt += ord('a') - 1
                    self._indent = 3
                elif style == 'upperalpha':
                    self._cnt += ord('A') - 1
                    self._indent = 3
                elif style.endswith('roman'):
                    self._indent = 5

            def __next__(self):
                if self._style == 'bullet':
                    return self.enum_style[self._style]
                elif self._style == 'emdash':
                    return self.enum_style[self._style]
                self._cnt += 1
                # TODO add prefix postfix
                if self._style == 'arabic':
                    return "%d." % self._cnt
                elif self._style in ('loweralpha', 'upperalpha'):
                    return "%c." % self._cnt
                elif self._style.endswith('roman'):
                    res = roman.toRoman(self._cnt) + '.'
                    if self._style.startswith('upper'):
                        return res.upper()
                    return res.lower()
                else:
                    return "%d." % self._cnt
            def get_width(self):
                return self._indent
            def __repr__(self):
                return 'enum_style-%s' % list(self._style)

        if 'enumtype' in node:
            self._list_char.append(enum_char(node['enumtype']))
        else:
            self._list_char.append(enum_char('bullet'))
        if len(self._list_char) > 1:
            # indent nested lists
            self.indent(self._list_char[-2].get_width())
        else:
            self.indent(self._list_char[-1].get_width()) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:62,代碼來源:manpage.py

示例8: visit_enumerated_list

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def visit_enumerated_list(self, node):
        # enumeration styles:
        types = {'': '',
                  'arabic':'arabic',
                  'loweralpha':'alph',
                  'upperalpha':'Alph',
                  'lowerroman':'roman',
                  'upperroman':'Roman'}
        # the 4 default LaTeX enumeration labels: präfix, enumtype, suffix,
        labels = [('',  'arabic', '.'), #  1.
                  ('(', 'alph',   ')'), # (a)
                  ('',  'roman',  '.'), #  i.
                  ('',  'Alph',   '.')] #  A.

        prefix = ''
        if self.compound_enumerators:
            if (self.section_prefix_for_enumerators and self.section_level
                and not self._enumeration_counters):
                prefix = '.'.join([str(n) for n in
                                   self._section_number[:self.section_level]]
                                 ) + self.section_enumerator_separator
            if self._enumeration_counters:
                prefix += self._enumeration_counters[-1]
        # TODO: use LaTeX default for unspecified label-type?
              # (needs change of parser)
        prefix += node.get('prefix', '')
        enumtype = types[node.get('enumtype' '')]
        suffix = node.get('suffix', '')

        enumeration_level = len(self._enumeration_counters)+1
        counter_name = 'enum' + roman.toRoman(enumeration_level).lower()
        label = r'%s\%s{%s}%s' % (prefix, enumtype, counter_name, suffix)
        self._enumeration_counters.append(label)

        if enumeration_level <= 4:
            self.out.append('\\begin{enumerate}\n')
            if (prefix, enumtype, suffix
               ) != labels[enumeration_level-1]:
                self.out.append('\\renewcommand{\\label%s}{%s}\n' %
                                (counter_name, label))
        else:
            self.fallbacks[counter_name] = '\\newcounter{%s}' % counter_name
            self.out.append('\\begin{list}')
            self.out.append('{%s}' % label)
            self.out.append('{\\usecounter{%s}}\n' % counter_name)
        if 'start' in node:
            self.out.append('\\setcounter{%s}{%d}\n' %
                            (counter_name,node['start']-1))
        #     ## set rightmargin equal to leftmargin
        #     self.out.append('\\setlength{\\rightmargin}{\\leftmargin}\n') 
開發者ID:skarlekar,項目名稱:faces,代碼行數:52,代碼來源:__init__.py

示例9: visit_enumerated_list

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def visit_enumerated_list(self, node):
        # enumeration styles:
        types = {'': '',
                  'arabic':'arabic',
                  'loweralpha':'alph',
                  'upperalpha':'Alph',
                  'lowerroman':'roman',
                  'upperroman':'Roman'}
        # the 4 default LaTeX enumeration labels: präfix, enumtype, suffix,
        labels = [('',  'arabic', '.'), #  1.
                  ('(', 'alph',   ')'), # (a)
                  ('',  'roman',  '.'), #  i.
                  ('',  'Alph',   '.')] #  A.

        prefix = ''
        if self.compound_enumerators:
            if (self.section_prefix_for_enumerators and self.section_level
                and not self._enumeration_counters):
                prefix = '.'.join([str(n) for n in
                                   self._section_number[:self.section_level]]
                                 ) + self.section_enumerator_separator
            if self._enumeration_counters:
                prefix += self._enumeration_counters[-1]
        # TODO: use LaTeX default for unspecified label-type?
        #       (needs change of parser)
        prefix += node.get('prefix', '')
        enumtype = types[node.get('enumtype' '')]
        suffix = node.get('suffix', '')

        enumeration_level = len(self._enumeration_counters)+1
        counter_name = 'enum' + roman.toRoman(enumeration_level).lower()
        label = r'%s\%s{%s}%s' % (prefix, enumtype, counter_name, suffix)
        self._enumeration_counters.append(label)

        self.duclass_open(node)
        if enumeration_level <= 4:
            self.out.append('\\begin{enumerate}')
            if (prefix, enumtype, suffix
               ) != labels[enumeration_level-1]:
                self.out.append('\n\\renewcommand{\\label%s}{%s}' %
                                (counter_name, label))
        else:
            self.fallbacks[counter_name] = '\\newcounter{%s}' % counter_name
            self.out.append('\\begin{list}')
            self.out.append('{%s}' % label)
            self.out.append('{\\usecounter{%s}}' % counter_name)
        if 'start' in node:
            self.out.append('\n\\setcounter{%s}{%d}' %
                            (counter_name,node['start']-1)) 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:51,代碼來源:__init__.py

示例10: list_start

# 需要導入模塊: import roman [as 別名]
# 或者: from roman import toRoman [as 別名]
def list_start(self, node):
        class enum_char(object):
            enum_style = {
                    'bullet'     : '\\(bu',
                    'emdash'     : '\\(em',
                     }

            def __init__(self, style):
                self._style = style
                if node.has_key('start'):
                    self._cnt = node['start'] - 1
                else:
                    self._cnt = 0
                self._indent = 2
                if style == 'arabic':
                    # indentation depends on number of childrens
                    # and start value.
                    self._indent = len(str(len(node.children)))
                    self._indent += len(str(self._cnt)) + 1
                elif style == 'loweralpha':
                    self._cnt += ord('a') - 1
                    self._indent = 3
                elif style == 'upperalpha':
                    self._cnt += ord('A') - 1
                    self._indent = 3
                elif style.endswith('roman'):
                    self._indent = 5

            def next(self):
                if self._style == 'bullet':
                    return self.enum_style[self._style]
                elif self._style == 'emdash':
                    return self.enum_style[self._style]
                self._cnt += 1
                # TODO add prefix postfix
                if self._style == 'arabic':
                    return "%d." % self._cnt
                elif self._style in ('loweralpha', 'upperalpha'):
                    return "%c." % self._cnt
                elif self._style.endswith('roman'):
                    res = roman.toRoman(self._cnt) + '.'
                    if self._style.startswith('upper'):
                        return res.upper()
                    return res.lower()
                else:
                    return "%d." % self._cnt
            def get_width(self):
                return self._indent
            def __repr__(self):
                return 'enum_style-%s' % list(self._style)

        if node.has_key('enumtype'):
            self._list_char.append(enum_char(node['enumtype']))
        else:
            self._list_char.append(enum_char('bullet'))
        if len(self._list_char) > 1:
            # indent nested lists
            self.indent(self._list_char[-2].get_width())
        else:
            self.indent(self._list_char[-1].get_width()) 
開發者ID:jmwright,項目名稱:cadquery-freecad-module,代碼行數:62,代碼來源:manpage.py


注:本文中的roman.toRoman方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。