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

Auto generated project name includes numerics #1254

Merged
merged 6 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
4 changes: 4 additions & 0 deletions brownie/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class ProjectNotFound(Exception):
pass


class BadProjectName(Exception):
pass


class CompilerError(Exception):
def __init__(self, e: Type[psutil.Popen], compiler: str = "Compiler") -> None:
self.compiler = compiler
Expand Down
5 changes: 4 additions & 1 deletion brownie/project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
from brownie._expansion import expand_posix_vars
from brownie.exceptions import (
BadProjectName,
BrownieEnvironmentWarning,
InvalidPackage,
PragmaError,
Expand Down Expand Up @@ -735,7 +736,9 @@ 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"
name = "".join(i for i in name.title() if i.isalpha())
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