From 96525c83e08367f26052f1675f3e2d5fb21f29c8 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Mon, 13 Sep 2021 21:54:09 -0700 Subject: [PATCH 1/5] Auto generated project name includes numerics --- brownie/project/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/project/main.py b/brownie/project/main.py index cf9f6b3ed..051fbd621 100644 --- a/brownie/project/main.py +++ b/brownie/project/main.py @@ -735,7 +735,7 @@ 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()) + 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") From d2e8e06690e7b160bd615087f956b9128f1f9e00 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Wed, 15 Sep 2021 06:44:06 +0000 Subject: [PATCH 2/5] Add vim swapfiles to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 135d8ec85..86d52b9cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ +*.swp .vscode .history .coverage From 9c96d723913097038cb0cb9f279082e7ba518cc6 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Wed, 15 Sep 2021 06:50:38 +0000 Subject: [PATCH 3/5] Error on bad project name --- brownie/exceptions.py | 3 +++ brownie/project/main.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/brownie/exceptions.py b/brownie/exceptions.py index fc8d953e6..379fbfcb9 100644 --- a/brownie/exceptions.py +++ b/brownie/exceptions.py @@ -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: diff --git a/brownie/project/main.py b/brownie/project/main.py index 051fbd621..17649b994 100644 --- a/brownie/project/main.py +++ b/brownie/project/main.py @@ -39,6 +39,7 @@ PragmaError, ProjectAlreadyLoaded, ProjectNotFound, + BadProjectName, ) from brownie.network import web3 from brownie.network.contract import ( @@ -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") From 286183752e703a824f3bfe48c34018e995e3bafc Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Wed, 15 Sep 2021 07:10:52 +0000 Subject: [PATCH 4/5] Add newline --- brownie/exceptions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/brownie/exceptions.py b/brownie/exceptions.py index 379fbfcb9..aa7452b55 100644 --- a/brownie/exceptions.py +++ b/brownie/exceptions.py @@ -168,6 +168,7 @@ class ProjectAlreadyLoaded(Exception): class ProjectNotFound(Exception): pass + class BadProjectName(Exception): pass From 4774595328a0d3c1c299127774a9f3afa41f8f89 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Wed, 15 Sep 2021 07:29:42 +0000 Subject: [PATCH 5/5] Reorder imports --- brownie/project/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/project/main.py b/brownie/project/main.py index 17649b994..377ff6941 100644 --- a/brownie/project/main.py +++ b/brownie/project/main.py @@ -34,12 +34,12 @@ ) from brownie._expansion import expand_posix_vars from brownie.exceptions import ( + BadProjectName, BrownieEnvironmentWarning, InvalidPackage, PragmaError, ProjectAlreadyLoaded, ProjectNotFound, - BadProjectName, ) from brownie.network import web3 from brownie.network.contract import (