def init_project(path, skip_inspection=False): pythoscope_path = get_pythoscope_path(path) try: log.debug("Initializing .pythoscope directory: %s" % (os.path.abspath(pythoscope_path))) os.makedirs(pythoscope_path) os.makedirs(get_points_of_entry_path(path)) os.makedirs(get_code_trees_path(path)) except OSError, err: fail("Couldn't initialize Pythoscope directory: %s." % err.strerror)
def init_project(path, skip_inspection=False): pythoscope_path = get_pythoscope_path(path) try: log.debug("Initializing .pythoscope directory: %s" % (os.path.abspath(pythoscope_path))) os.makedirs(pythoscope_path) os.makedirs(get_points_of_entry_path(path)) os.makedirs(get_code_trees_path(path)) except OSError as err: fail("Couldn't initialize Pythoscope directory: %s." % err.strerror) project = Project.from_directory(path) if not skip_inspection: log.debug("Performing initial static inspection of the project source code.") inspect_project_statically(project) project.save()
def find_project_directory(path): """Try to find a pythoscope project directory for a given path, i.e. the closest directory that contains .pythoscope/ subdirectory. Will go up the directory tree and return the first matching path. """ path = os.path.realpath(path) if not os.path.isdir(path): return find_project_directory(os.path.dirname(path)) pythoscope_path = get_pythoscope_path(path) parent_path = os.path.join(path, os.path.pardir) # We reached the root. if samefile(path, parent_path): raise PythoscopeDirectoryMissing() elif os.path.isdir(pythoscope_path): return path else: return find_project_directory(os.path.join(path, os.path.pardir))