예제 #1
0
def process_structure_node(curs, curs_list, filename, parent, struct):
    section = None
    if struct.has_key('file'):
        print struct['file']
        jsonfile = os.path.dirname(filename) + "/" + struct['file']
        fp = open(jsonfile, 'r')
        data = json.load(fp)
        fp.close()
        section_id = insert_section(curs, curs_list, parent['section_id'],
                                    data)
        fetch_section(curs, section_id)
        section = curs.fetchone()
    else:
        find_section(curs, name=struct['name'], parent_id=parent['section_id'])
        section = curs.fetchone()
        if not section:
            section_id = append_child_section(
                curs, parent['section_id'], 'list', None, struct['name'], None,
                'PFSRD', None, None, None, None,
                generate_url(curs,
                             parent['section_id'],
                             struct['name'],
                             create_index=struct.get('create_index', True),
                             parent_url=parent['url']), False)
            fetch_section(curs, section_id)
            section = curs.fetchone()
    for child in struct.get('children', []):
        process_structure_node(curs, curs_list, filename, section, child)
예제 #2
0
def fetch_parent(curs, parent_name):
	if not parent_name:
		return fetch_top(curs)
	else:
		find_section(curs, name=parent_name, type='list')
		parent = curs.fetchone()
		if parent:
			return parent
		else:
			top = fetch_top(curs)
			section_id = append_child_section(curs, top['section_id'], 'list', None, parent_name, None, 'PFSRD', None, None)
			fetch_section(curs, section_id)
			return curs.fetchone()
예제 #3
0
def fetch_parent(curs, parent_name, source_name):
	if not parent_name:
		fetch_top(curs)
		return curs.fetchone()
	else:
		find_section(curs, name=parent_name, type='list')
		parent = curs.fetchone()
		if parent:
			return parent
		else:
			fetch_top(curs)
			top = curs.fetchone()
			section_id = append_child_section(curs, top['section_id'], 'list', None, parent_name, None, source_name, None, None, None, None, generate_url(curs, top['section_id'], parent_name), False)
			fetch_section(curs, section_id)
			return curs.fetchone()
예제 #4
0
def fetch_parent(curs, parent_name, source_name):
	if not parent_name:
		fetch_top(curs)
		return curs.fetchone()
	else:
		find_section(curs, name=parent_name, type='list')
		parent = curs.fetchone()
		if parent:
			return parent
		else:
			fetch_top(curs)
			top = curs.fetchone()
			section_id = append_child_section(curs, top['section_id'], 'list', None, parent_name, None, source_name, None, None, None, None, generate_url(curs, top['section_id'], parent_name), False)
			fetch_section(curs, section_id)
			return curs.fetchone()
예제 #5
0
def process_structure_node(curs, filename, parent, struct):
	section = None
	if struct.has_key('file'):
		jsonfile = os.path.dirname(filename) + "/" + struct['file']
		fp = open(jsonfile, 'r')
		data = json.load(fp)
		fp.close()
		section_id = insert_section(curs, parent['section_id'], data)
		fetch_section(curs, section_id)
		section = curs.fetchone()
	else:
		find_section(curs, name=struct['name'], parent_id=parent['section_id'])
		section = curs.fetchone()
		if not section:
			section_id = append_child_section(curs, parent['section_id'], 'list', None, struct['name'], None, 'PFSRD', None, None)
			fetch_section(curs, section_id)
			section = curs.fetchone()
	for child in struct.get('children', []):
		process_structure_node(curs, filename, section, child)