-
Notifications
You must be signed in to change notification settings - Fork 1
/
_validate_init.py
67 lines (51 loc) · 1.62 KB
/
_validate_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
DO NOT MODIFY
This file is used to validate your publish settings.
"""
from __future__ import print_function
import os
import sys
import importlib
components_package = 'dash_resizable_panels'
components_lib = importlib.import_module(components_package)
missing_dist_msg = 'Warning {} was not found in `{}.__init__.{}`!!!'
missing_manifest_msg = '''
Warning {} was not found in `MANIFEST.in`!
It will not be included in the build!
'''
with open('MANIFEST.in', 'r') as f:
manifest = f.read()
def check_dist(dist, filename):
# Support the dev bundle.
if filename.endswith('dev.js'):
return True
return any(
filename in x
for d in dist
for x in (
[d.get('relative_package_path')]
if not isinstance(d.get('relative_package_path'), list)
else d.get('relative_package_path')
)
)
def check_manifest(filename):
return filename in manifest
def check_file(dist, filename):
if not check_dist(dist, filename):
print(
missing_dist_msg.format(filename, components_package, '_js_dist'),
file=sys.stderr
)
if not check_manifest(filename):
print(missing_manifest_msg.format(filename),
file=sys.stderr)
for cur, _, files in os.walk(components_package):
for f in files:
if f.endswith('js'):
# noinspection PyProtectedMember
check_file(components_lib._js_dist, f)
elif f.endswith('css'):
# noinspection PyProtectedMember
check_file(components_lib._css_dist, f)
elif not f.endswith('py'):
check_manifest(f)