Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.
| 1 | import re |
| 2 | |
| 3 | class IllegalNameCheck: |
| 4 | @staticmethod |
| 5 | def is_valid_file_name(expression, platform_independent): |
| 6 | s_pattern = r"^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*:\";|/]+$" |
| 7 | if platform_independent: |
| 8 | s_pattern = r"^(([a-zA-Z]:|\\)\\)?(((\.)|(\.\.)|([^\\/:\*\?\"<>\. ](([^\\/:\*\?\"<>\. ])|([^\\/:\*\?\"<>]*[^\\/:\*\?\"<>\. ]))?))\\)*[^\\/:\*\?\"<>\. ](([^\\/:\*\?\"<>\. ])|([^\\/:\*\?\"<>]*[^\\/:\*\?\"<>\. ]))?$" |
| 9 | return re.match(s_pattern, expression) is not None |