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


Python DataManager.getByID方法代码示例

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


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

示例1: export

# 需要导入模块: from DataManager import DataManager [as 别名]
# 或者: from DataManager.DataManager import getByID [as 别名]
    def export(export_name, export_user, export_type, repo_id=None, schema_id=None, record_ids=None):
        export_name = export_name + '_' + export_type + '_export'
        export = {
            "name": export_name,
            "time": str(datetime.datetime.now()),
            "exporter": export_user,
            "uuid": uuid4().hex,
            "repos": []
        }
        if export_type == 'Repository':
            try:
                # Get core info about repository
                repo_info = RepoManager.getInfo(repo_id)

                # Get all field information for all schemas for this repo
                schema_info = SchemaManager.getTypes(repo_id)

                # Get all data for each schema in this repo
                for i in range(len(schema_info)):

                    data_count = DataManager.getCountForType(repo_id, schema_info[i]['id'])
                    data_total = data_count['data_count']

                    schema_data = DataManager.getDataForType(repo_id, schema_info[i]['id'], 0, data_total)
                    #print schema_data
                    schema_info[i]['data'] = schema_data

                repo_info['schemas'] = schema_info

                export['repos'].append(repo_info)

            except Exception as e:
                print e.message
                pass
        elif export_type == 'Schema':
            try:
                # Get core info about repository
                repo_info = RepoManager.getInfo(repo_id)

                # Get all field information for all schemas for this repo
                schema_info = SchemaManager.getType(repo_id, schema_id)

                # Get the total count of records for this type

                data_count = DataManager.getCountForType(repo_id, schema_id)
                data_total = data_count['data_count']
                print repo_id, schema_id, data_total
                # Get data for this schema
                schema_data = DataManager.getDataForType(repo_id, schema_id, 0, data_total)
                schema_info['data'] = schema_data
                repo_info['schemas'] = schema_info

                export['repos'].append(repo_info)
            except Exception as e:
                print e.message
                pass
        else:
            try:
                raw_results = {}
                for node_id in record_ids:
                    print node_id
                    node_data = DataManager.getByID(node_id)

                    if node_data:
                        if node_data['repo_id'] not in raw_results:
                            raw_results[node_data['repo_id']] = {}
                        if node_data['schema_id'] not in raw_results[node_data['repo_id']]:
                            raw_results[node_data['repo_id']][node_data['schema_id']] = []
                        raw_results[node_data['repo_id']][node_data['schema_id']].append(node_data['data'])
                print raw_results
                for repo_id in raw_results:
                    repo_info = RepoManager.getInfo(repo_id)
                    repo_info['schemas'] = []
                    for schema_id in raw_results[repo_id]:
                        schema_info = SchemaManager.getType(repo_id, schema_id)
                        schema_info['data'] = raw_results[repo_id][schema_id]
                        repo_info['schemas'].append(schema_info)

                    export['repos'].append(repo_info)

            except Exception as e:
                print e.message
                pass




        return export
开发者ID:inquisite,项目名称:Inquisite-Core,代码行数:90,代码来源:ExportManager.py


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