Skip to content

Commit

Permalink
✨No invalid characters in new project directory name (#278)
Browse files Browse the repository at this point in the history
* Added check for valid directory name when creating a project

* Removed pyinstaller from requirements.txt

* Revert "Removed pyinstaller from requirements.txt"

This reverts commit ea02936.

* Revert "Added check for valid directory name when creating a project"

This reverts commit d4ec163.

* Added check for invalid new project directory name

* Added check for invalid directory characters

* Added check for non-ASCII characters

---------

Co-authored-by: Andrew Chen <[email protected]>
Co-authored-by: Andrew Chen <[email protected]>
  • Loading branch information
3 people authored Apr 17, 2023
1 parent f8ba997 commit 39a05b0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pros/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ def remove_template(project: Project, identifier: Union[str, BaseTemplate], remo
def new_project(self, path: str, no_default_libs: bool = False, **kwargs) -> Project:
if Path(path).exists() and Path(path).samefile(os.path.expanduser('~')):
raise dont_send(ValueError('Will not create a project in user home directory'))
for char in str(Path(path)):
if char in ['/', '?', '<', '>', '\\', ':', '*', '|', '^', '#', '%', '&', '$', '+', '!', '`', '\'', '=',
'@', '\'', '{', '}', '[', ']', '(', ')', '~'] or ord(char) > 127:
raise dont_send(ValueError(f'Invalid character found in directory name: \'{char}\''))
proj = Project(path=path, create=True)
if 'target' in kwargs:
proj.target = kwargs['target']
Expand Down

0 comments on commit 39a05b0

Please sign in to comment.