コード例 #1
0
def create_node_from_project_json(egap_assets_path, egap_project_dir, creator):
    with open(os.path.join(egap_assets_path, egap_project_dir, 'project.json'),
              'r') as fp:
        project_data = json.load(fp)
        title = project_data['title']
        node = Node(title=title, creator=creator)
        node.save()  # must save before adding contribs for auth reasons

        for contributor in project_data['contributors']:
            email = ''
            if contributor.get('email'):
                email = contributor.get('email').strip()
                email = email.split('\\u00a0')[0].split(',')[0]
                if '<' in email:
                    email = email.split('<')[1].replace('>', '')

            node.add_contributor_registered_or_not(
                Auth(creator),
                full_name=contributor['name'],
                email=email,
                permissions=WRITE,
                send_email='false')

        node.set_visible(creator, visible=False, log=False, save=True)

    return node
コード例 #2
0
def create_node_from_project_json(egap_assets_path, epag_project_dir, creator):
    with open(os.path.join(egap_assets_path, epag_project_dir, 'project.json'),
              'r') as fp:
        project_data = json.load(fp)
        title = project_data['title']
        node = Node(title=title, creator=creator)
        node.save()  # must save before adding contribs for auth reasons

        for contributor in project_data['contributors']:
            node.add_contributor_registered_or_not(
                Auth(creator),
                full_name=contributor['name'],
                email=contributor['email'],
                permissions=WRITE,
                send_email='false')

        node.set_visible(creator, visible=False, log=False, save=True)

    return node