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


Python Packet.load_packet_from_file方法代码示例

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


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

示例1: create_tournament_from_directory

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import load_packet_from_file [as 别名]
    def create_tournament_from_directory(self, dir, reuse_html=False):

        conf_file = os.path.join(dir, 'config.json')

        if not os.path.exists(conf_file):
            conf_file = conf_gen(dir, '*.docx')

        conf_dict = json.load(open(conf_file, 'r'))

        self.tour_name = conf_dict['tournament']
        self.year = conf_dict['year']

        packets = conf_dict['packets']

        for file_entry in packets:
            packet_file = os.path.join(dir, file_entry['filename'])
            packet_author = file_entry['author']

            packet = Packet(packet_author, tournament=self.tour_name)
            try:
                packet.load_packet_from_file(packet_file, reuse_html=reuse_html)
            except PacketParserError as ex:
                self.errors.append(ex)

            self.add_packet(packet)
开发者ID:grapesmoker,项目名称:packet_parser,代码行数:27,代码来源:Tournament.py

示例2: create_tournament_from_directory

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import load_packet_from_file [as 别名]
    def create_tournament_from_directory(self, dir):

        conf_file = os.path.join(dir, 'config.json')

        if not os.path.exists(conf_file):
            conf_file = conf_gen(dir, '*.docx')

        conf_dict = json.load(open(conf_file, 'r'))

        self.tour_name = conf_dict['tournament']
        self.year = conf_dict['year']

        packets = conf_dict['packets']

        for file_entry in packets:
            packet_file = os.path.join(dir, file_entry['filename'])
            packet_author = file_entry['author']

            packet = Packet(packet_author, tournament=self.tour_name)
            packet.load_packet_from_file(packet_file)

            self.add_packet(packet)
开发者ID:alopezlago,项目名称:packet_parser,代码行数:24,代码来源:Tournament.py

示例3: parser_driver

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import load_packet_from_file [as 别名]
def parser_driver(doc_file, mode='json'):

    p = Packet('test')
    p.load_packet_from_file(doc_file)
    p.is_valid()
开发者ID:grapesmoker,项目名称:packet_parser,代码行数:7,代码来源:packet_parser.py

示例4: parse_directory

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import load_packet_from_file [as 别名]
    parser.add_argument('-o', '--operation', dest='operation')
    parser.add_argument('-s', '--spec', dest='spec')
    parser.add_argument('-m', '--mode', dest='mode', default='json')
    parser.add_argument('-u', '--url', dest='url')
    parser.add_argument('-y', '--year', dest='year', type=int)
    parser.add_argument('--reuse-html', type=bool, default=False)
    parser.add_argument('-op', '--output-file', dest='output_file')
    
    args = parser.parse_args()

    if args.dir is not None and args.operation == 'process':
        parse_directory(args.dir, args.mode, args.reuse_html)

    if args.file is not None and args.operation == 'test':
        packet = Packet('test')
        packet.load_packet_from_file(args.file, test=True)

    if args.file is not None and args.operation is not None:
        if args.operation == 'process':
            parser_driver(args.file)

        if args.operation == 'validate':
            validate_json(args.file)

        if args.operation == 'import':
            import_json_into_mongo(args.file)

    if args.operation == 'conf' and args.dir is not None and args.spec is not None:
        conf_gen(args.dir, args.spec)

    if args.operation == 'send' and args.url is not None and args.file is not None:
开发者ID:grapesmoker,项目名称:packet_parser,代码行数:33,代码来源:packet_parser.py


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