Skip to content

Commit 554768a

Browse files
committed
Updated pathmanipulation.py
1 parent 1b75675 commit 554768a

File tree

1 file changed

+4
-6
lines changed
  • Path Manipulation/Path Manipulation while File Upload/python/pythonapp/pathmanipulation/src

1 file changed

+4
-6
lines changed

Path Manipulation/Path Manipulation while File Upload/python/pythonapp/pathmanipulation/src/pathmanipulation.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,26 @@
88

99

1010
"""This function checks if the filename is valid and doesn't contain any dot character in the name."""
11-
def is_valid_name(filename):
11+
def is_valid_name(filename: str) -> bool:
1212
name = filename.rsplit('.', 1)[0]
1313
regex_match = re.search(FILENAME_REGEX_PATTERN, name)
1414
return True if(regex_match != None) else False
1515

1616
"""This function checks for the valid file extensions."""
17-
def is_valid_extension(filename):
17+
def is_valid_extension(filename: str) -> bool:
1818
ext = filename.rsplit(".", 1)[1]
1919
return True if (ext in ALLOWED_EXTENSIONS) else False
2020

21-
def valid_filename(filename):
21+
def valid_filename(filename: str) -> str:
2222
name, ext = filename.rsplit('.', 1)
2323
name = re.sub(r"\.", "", name)
2424
name = re.sub(r"\%[A-Za-z0-9]+", "", name)
2525
ext = re.sub(r"\%[A-Za-z0-9]+", "", ext)
2626
regex_match = re.search(FILENAME_REGEX_PATTERN, name)
2727
return f"{regex_match.group(0)}.{ext}" # returns the sanitized filename with the extension for upload
2828

29-
def get_unique_filename(directory, filename):
29+
def get_unique_filename(directory: str, filename:str) -> str:
3030
name, ext = filename.rsplit(".", 1)
31-
# name = valid_filename(name)
32-
3331
unique_filename = f"{name}.{ext}"
3432
count = 1
3533

0 commit comments

Comments
 (0)