<commit_before>"""Module to find the Python files in a directory and parse them"""

import json
from networkx.readwrite import json_graph
from parchment import pkginfo
from atelier import draftsman

def draw(path):
	pkg_dirs = set(pkginfo.get_directories(path))
	project_modules = dict(pkginfo.get_modules(pkg_dirs))
	project_pkgs = dict(pkginfo.get_packages(pkg_dirs))
	builtin_modules = dict(pkginfo.get_builtin_modules(ignore=project_modules))
	builtin_pkgs = dict(pkginfo.get_builtin_packages(ignore=project_pkgs))

	graph = draftsman.sketch_blocks(project_modules, project_pkgs)
	# write json formatted data
	data = json_graph.node_link_data(graph)
	# write json file
	json.dump(data, open('canvas/data.json', 'w'))
	print('JSON data written to test_data.json')
	#print('----NODES------')
	#for node_id in graph.nodes_iter():
		#print(graph.node[node_id], '\n')
	#print('----EDGES------')
	#for from_id, to_id in graph.edges_iter():
		#print('from ', from_id, 'to ', to_id, '\n')

def search(path, name):
	""" find the function or class definition with the specidfied name """
	for path in find_pyFiles(path):
		tree = pyPeephole.parse(path)
		match = pyPeephole.find(tree, name)
		if match:
			print(pyPeephole.to_string(match), " FILE: " + path)
			break
	else:
		print("\n I couldn't found the definition called {name}.\n".format(name=name),
			  "Check if the name is correct")<commit_msg>builtin_modules and pkgs variables deleted as unused. daVinci now writes the JSON file to an absolute path instead of the relative path used before.<commit_after>"""Module to find the Python files in a directory and parse them"""

import os
import json
from networkx.readwrite import json_graph
from parchment import pkginfo
from atelier import draftsman

def draw(path):
	pkg_dirs = set(pkginfo.get_directories(path))
	project_modules = dict(pkginfo.get_modules(pkg_dirs))
	project_pkgs = dict(pkginfo.get_packages(pkg_dirs))

	graph = draftsman.sketch_blocks(project_modules, project_pkgs)
	# write json formatted data
	data = json_graph.node_link_data(graph)
	# write json file
	daVinci_dir = os.path.dirname(os.path.abspath(__file__))
	data_filepath = os.path.join(daVinci_dir, 'canvas/data.json')
	json.dump(data, open(data_filepath, 'w'))
	print('\nJSON data written to:', data_filepath, '\n')
	#print('----NODES------')
	#for node_id in graph.nodes_iter():
		#print(graph.node[node_id], '\n')
	#print('----EDGES------')
	#for from_id, to_id in graph.edges_iter():
		#print('from ', from_id, 'to ', to_id, '\n')

def search(path, name):
	""" find the function or class definition with the specidfied name """
	for path in find_pyFiles(path):
		tree = pyPeephole.parse(path)
		match = pyPeephole.find(tree, name)
		if match:
			print(pyPeephole.to_string(match), " FILE: " + path)
			break
	else:
		print("\n I couldn't found the definition called {name}.\n".format(name=name),
			  "Check if the name is correct")
{'fraction_non_alphanumeric': 0.13335618786424408, 'fraction_numerical': 0.0, 'mean_word_length': 5.016494845360825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2670308', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1000, 'n_words': 264}