当前位置: 首页>>代码示例>>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;未经允许,请勿转载。