Pathvalidate (#1408)

* Update requirements.txt

Adding `pathvalidate` to requrements

* Update __init__.py

Adding `pathvalidate` to make  correct filename on other then ascii encodings.

* Updating with sanitize_filename

* Removing unused variable.
This commit is contained in:
Yaroslav Nakonechnikov
2021-08-23 23:04:11 +03:00
committed by GitHub
parent 95beb8e62a
commit 7f51e35bd4
3 changed files with 3 additions and 3 deletions

View File

@ -33,6 +33,7 @@ import http.client as http_client
from multiprocessing import Pool as mp_pool from multiprocessing import Pool as mp_pool
from multiprocessing import Lock as mp_lock from multiprocessing import Lock as mp_lock
from urllib.parse import quote, urlencode, urlparse from urllib.parse import quote, urlencode, urlparse
from pathvalidate import sanitize_filename
import dateutil.parser import dateutil.parser
import googleapiclient import googleapiclient
@ -4064,8 +4065,7 @@ def downloadDriveFile(users):
if targetName: if targetName:
safe_file_title = targetName safe_file_title = targetName
else: else:
safe_file_title = ''.join(c for c in result['title'] safe_file_title = sanitize_filename(result['title'])
if c in FILENAME_SAFE_CHARS)
if not safe_file_title: if not safe_file_title:
safe_file_title = fileId safe_file_title = fileId
filename = os.path.join(targetFolder, safe_file_title) filename = os.path.join(targetFolder, safe_file_title)

View File

@ -895,7 +895,6 @@ RT_TAG_REPLACE_PATTERN = re.compile(r'{(.*?)}')
LOWERNUMERIC_CHARS = string.ascii_lowercase + string.digits LOWERNUMERIC_CHARS = string.ascii_lowercase + string.digits
ALPHANUMERIC_CHARS = LOWERNUMERIC_CHARS + string.ascii_uppercase ALPHANUMERIC_CHARS = LOWERNUMERIC_CHARS + string.ascii_uppercase
URL_SAFE_CHARS = ALPHANUMERIC_CHARS + '-._~' URL_SAFE_CHARS = ALPHANUMERIC_CHARS + '-._~'
FILENAME_SAFE_CHARS = ALPHANUMERIC_CHARS + '-_.() '
FILTER_ADD_LABEL_TO_ARGUMENT_MAP = { FILTER_ADD_LABEL_TO_ARGUMENT_MAP = {
'IMPORTANT': 'important', 'IMPORTANT': 'important',

View File

@ -10,3 +10,4 @@ importlib.metadata; python_version < '3.8'
passlib>=1.7.2 passlib>=1.7.2
python-dateutil python-dateutil
yubikey-manager>=4.0.0 yubikey-manager>=4.0.0
pathvalidate