Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project naming #1

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__pycache__
*.swp
.vscode
.history
.coverage
Expand Down
3 changes: 3 additions & 0 deletions brownie/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class ProjectAlreadyLoaded(Exception):
class ProjectNotFound(Exception):
pass

class BadProjectName(Exception):
pass


class CompilerError(Exception):
def __init__(self, e: Type[psutil.Popen], compiler: str = "Compiler") -> None:
Expand Down
3 changes: 3 additions & 0 deletions brownie/project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
PragmaError,
ProjectAlreadyLoaded,
ProjectNotFound,
BadProjectName,
)
from brownie.network import web3
from brownie.network.contract import (
Expand Down Expand Up @@ -735,6 +736,8 @@ def load(project_path: Union[Path, str, None] = None, name: Optional[str] = None
name = project_path.name
if not name.lower().endswith("project"):
name += " project"
if not name[0].isalpha():
raise BadProjectName("Project must start with an alphabetic character")
name = "".join(i for i in name.title() if i.isalnum())
if next((True for i in _loaded_projects if i._name == name), False):
raise ProjectAlreadyLoaded("There is already a project loaded with this name")
Expand Down