Gigahawk / canvas-file-scraper

Python script to scrape files from Canvas
GNU General Public License v3.0
15 stars 10 forks source link

Class and module names with invalid characters throws an error #1

Open MikeFindsThings opened 5 years ago

MikeFindsThings commented 5 years ago

https://github.com/Gigahawk/canvas-file-scraper/blob/ca39011ed5f5c53f3c29f0562a53d6219d5efff0/canvas-scraper.py#L52

Expected Behavior: To create /file/className/moduleName

Current Behavior: Correctly creates /file/className/ but returns the following error when trying to create the module name Traceback (most recent call last): File "D:/Python/projects/canvas-file-scraper/canvas-scraper.py", line 52, in os.makedirs(module_path, exist_ok=True) File "D:\Python\lib\os.py", line 221, in makedirs mkdir(name, mode) NotADirectoryError: [WinError 267] The directory name is invalid: '.\./files\className\January 14-20: Introduction and Welcome Module'

Possible Solution: Parse class and module names for characters not allowed in directory names.

Context: Win10, Python 3.7

Detailed Description: When running canvas-scraper, python throws an error when it encounters a class or module name containing characters that are not valid for directory names.

Gigahawk commented 5 years ago

Feel free to make a pull request, I haven't run into this particular issue because I'm not using NTFS and none of my profs are using invalid characters in their classes.

This looks like a good start.

staylorx commented 3 years ago

I might try to PR in santize_filename from pathvalidate when I can find time.