Download tabler-react/scripts/propscheck.py from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/scripts/propscheck.py
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/scripts/propscheck.py
-
curl -L -o propscheck.py https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/tabler-react/scripts/propscheck.py
1.5 kB
| #!/usr/bin/env python | |
| import os | |
| import re | |
| import sys | |
| import repoutils | |
| if not sys.platform.startswith('win32'): | |
| if not os.getcwd().endswith('/scripts'): | |
| print('[Error] Please run this script from the scripts dir!') | |
| sys.exit(1) | |
| else: | |
| if not os.getcwd().endswith('\scripts'): | |
| print('[Error] Please run this script from the scripts dir!') | |
| sys.exit(1) | |
| def propsValidator(filePath, contents): | |
| regex = re.compile('.*type Props\s?=\s?({.*?});.*', re.DOTALL) | |
| match = regex.match(contents) | |
| if match is None: | |
| return True | |
| props = match.group(1) | |
| if not (props.startswith('{|') and props.endswith('|}')): | |
| return False | |
| props = [x.strip() for x in props.replace( | |
| '{|', '').replace('|}', '').split(',')] | |
| props = [x for x in props if x != ''] | |
| for prop in props: | |
| if not prop.startswith('+'): | |
| if "<" in prop or ">" in prop or "//" or "..." in prop: | |
| return True | |
| else: | |
| return False | |
| return True | |
| def successCallback(filePath): | |
| pass | |
| def failureCallback(filePath): | |
| invalidPropFiles.append(filePath) | |
| invalidPropFiles = [] | |
| repoutils.walkFileContents(propsValidator, successCallback, failureCallback) | |
| if len(invalidPropFiles) > 0: | |
| print('The following files had invalid declarations of type Props:\n') | |
| print('\n'.join(invalidPropFiles)) | |
| else: | |
| print('All files checked!') | |