Skip to content

Commit

Permalink
fix: remove now-redundant check for project-inside-project
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Apr 22, 2020
1 parent cd6a33e commit 2b6f460
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
20 changes: 4 additions & 16 deletions brownie/project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from tqdm import tqdm

from brownie._config import (
BROWNIE_FOLDER,
CONFIG,
_get_data_folder,
_load_project_compiler_config,
Expand Down Expand Up @@ -386,12 +385,12 @@ def new(
Args:
project_path: Path to initialize the project at. If not exists, it will be created.
ignore_subfolder: If True, will not raise if initializing in a project subdirectory.
ignore_subfolder: (deprecated)
ignore_existing: If True, will not raise when initiating in a non-empty directory.
Returns the path to the project as a string.
"""
project_path = _new_checks(project_path_str, ignore_subfolder)
project_path = Path(project_path_str).resolve()
if not ignore_existing and project_path.exists() and list(project_path.glob("*")):
raise FileExistsError(f"Directory is not empty: {project_path}")
project_path.mkdir(exist_ok=True)
Expand All @@ -409,15 +408,15 @@ def from_brownie_mix(
Args:
project_path: Path to initialize the project at.
ignore_subfolders: If True, will not raise if initializing in a project subfolder.
ignore_subfolders: (deprecated)
Returns the path to the project as a string.
"""
project_name = str(project_name).replace("-mix", "")
url = MIXES_URL.format(project_name)
if project_path is None:
project_path = Path(".").joinpath(project_name)
project_path = _new_checks(project_path, ignore_subfolder)
project_path = Path(project_path).resolve()
if project_path.exists() and list(project_path.glob("*")):
raise FileExistsError(f"Folder already exists - {project_path}")

Expand Down Expand Up @@ -449,17 +448,6 @@ def from_ethpm(uri: str) -> "TempProject":
return project


def _new_checks(project_path: Union[Path, str], ignore_subfolder: bool) -> Path:
project_path = Path(project_path).resolve()
if str(BROWNIE_FOLDER) in str(project_path):
raise SystemError("Cannot make a new project inside the main brownie installation folder.")
if not ignore_subfolder:
check = check_for_project(project_path)
if check and check != project_path:
raise SystemError("Cannot make a new project in a subfolder of an existing project.")
return project_path


def compile_source(
source: str,
solc_version: Optional[str] = None,
Expand Down
2 changes: 0 additions & 2 deletions tests/project/test_brownie_mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ def test_from_brownie_mix_raises(project, tmp_path):
project.new(tmp_path.joinpath("token"))
with pytest.raises(FileExistsError):
project.from_brownie_mix("token")
with pytest.raises(SystemError):
project.from_brownie_mix(tmp_path.joinpath("token/contracts"))

0 comments on commit 2b6f460

Please sign in to comment.