当前位置: 首页>>代码示例>>Python>>正文


Python Election.sort方法代码示例

本文整理汇总了Python中election.Election.sort方法的典型用法代码示例。如果您正苦于以下问题:Python Election.sort方法的具体用法?Python Election.sort怎么用?Python Election.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在election.Election的用法示例。


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

示例1: main_function

# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import sort [as 别名]
def main_function():

    try:
        election_ids = Election().get_questions()
        if len(election_ids) == 0:
            print "Sätteid pole laaditud"
        else:
            election_ids.sort()
            for el_i in election_ids:
                process_elid(el_i)

    except Exception as ex:
        print 'Viga valijanimekirjade uuenduste ajaloo kuvamisel: ' + str(ex)
        sys.exit(1)
开发者ID:Augustyn,项目名称:evalimine,代码行数:16,代码来源:show_config_files_history.py

示例2: main_function

# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import sort [as 别名]
def main_function():

    try:

        if Election().is_hes():
            server = 'hes'
        elif Election().is_hts():
            server = 'hts'
        else:
            raise Exception('Vigane serveri tüüp')

        election_ids = Election().get_questions()

        if len(election_ids) == 0:
            print "Valijanimekirju pole laaditud"
        else:
            election_ids.sort()
            for el_i in election_ids:
                print "%s" % el_i
                reg_i = Election().get_sub_reg(el_i, [server])
                if not reg_i.check(['voters_files']):
                    print "\tValijanimekirju pole laaditud"
                    continue

                file_list = reg_i.list_keys(['voters_files'])
                file_list.sort()
                if len(file_list) == 0:
                    print "\tValijanimekirju pole laaditud"
                else:
                    prefix_len = 8 + 1 + 14 + 1
                    j = 1
                    added_total = 0
                    for vf_i in file_list:
                        file_date = vf_i[0:4] + "." + vf_i[4:6] + \
                            "." + vf_i[6:8] + " " + vf_i[8:10] + \
                            ":" + vf_i[10:12] + ":" + vf_i[12:14]
                        file_name = vf_i[15:]
                        if len(file_name) > prefix_len:
                            file_name = file_name[prefix_len:]
                        print "\t%02d. %s - %s" % (j, file_date, file_name)
                        j += 1

                        # nimekirja kokkulugemine
                        _rf = file(reg_i.path(['voters_files', vf_i]), "r")
                        line = _rf.readline()      # päise 1. rida
                        line = _rf.readline()      # päise 2. rida
                        filetype = _rf.readline()  # päise 3. rida
                        added = 0
                        removed = 0
                        while 1:
                            line = _rf.readline()
                            if len(line) == 0:
                                break
                            fields = line.split("\t")
                            if fields[2] == "lisamine":
                                added += 1
                                added_total += 1
                            else:
                                removed += 1
                                added_total -= 1
                        print \
                            "\t    Faili tüüp: %s\n" % filetype.strip() + \
                            "\t    Lisamisi %d, " % added + \
                                  "eemaldamisi %d\n" % removed + \
                            "\t    Kokku peale laadimist: %d" % added_total

    except Exception, ex:
        print 'Viga valijanimekirjade uuenduste ajaloo kuvamisel: ' + str(ex)
        sys.exit(1)
开发者ID:Cougar,项目名称:evalimine,代码行数:71,代码来源:show_voters_files_history.py


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