wsba-hockey 1.0.2__py3-none-any.whl → 1.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wsba_hockey/data_pipelines.py +183 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/duckdb/vendor.py +146 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/flatted.py +149 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/test.py +63 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +367 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1270 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +690 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common.py +661 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +78 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +165 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +109 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +808 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1321 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +120 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +464 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +58 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2714 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3981 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2936 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1394 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input.py +3130 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +374 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3197 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/test_gyp.py +261 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/graphviz.py +102 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_gyp.py +156 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_sln.py +181 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +339 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/test/fixtures/test-charmap.py +31 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/update-gyp.py +64 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +367 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1270 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +666 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common.py +654 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +78 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +165 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +109 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +808 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1321 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +120 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +464 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +58 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2518 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3978 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2936 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +55 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1394 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input.py +3137 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1271 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +374 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3197 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/setup.py +42 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/test_gyp.py +260 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/graphviz.py +102 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_gyp.py +156 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_sln.py +181 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +339 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/test/fixtures/test-charmap.py +31 -0
- wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/update-gyp.py +46 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/app.py +401 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/name_fix.py +47 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/app.py +108 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/plot.py +93 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/rink_plot.py +245 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/app.py +145 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/plot.py +77 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/rink_plot.py +245 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/app.py +389 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/plot.py +70 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/rink_plot.py +245 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/app.py +110 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/plot.py +58 -0
- wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/rink_plot.py +245 -0
- wsba_hockey/tools/agg.py +242 -53
- wsba_hockey/tools/plotting.py +15 -20
- wsba_hockey/tools/scraping.py +149 -258
- wsba_hockey/tools/xg_model.py +370 -298
- wsba_hockey/workspace.py +22 -101
- wsba_hockey/wsba_main.py +494 -147
- {wsba_hockey-1.0.2.dist-info → wsba_hockey-1.0.4.dist-info}/METADATA +2 -2
- wsba_hockey-1.0.4.dist-info/RECORD +135 -0
- {wsba_hockey-1.0.2.dist-info → wsba_hockey-1.0.4.dist-info}/WHEEL +1 -1
- wsba_hockey/stats/calculate_viz/shot_impact.py +0 -2
- wsba_hockey-1.0.2.dist-info/RECORD +0 -19
- {wsba_hockey-1.0.2.dist-info → wsba_hockey-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {wsba_hockey-1.0.2.dist-info → wsba_hockey-1.0.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
|
3
|
+
# Copyright (c) 2012 Google Inc. All rights reserved.
|
4
|
+
# Use of this source code is governed by a BSD-style license that can be
|
5
|
+
# found in the LICENSE file.
|
6
|
+
|
7
|
+
"""Unit tests for the common.py file."""
|
8
|
+
|
9
|
+
import gyp.common
|
10
|
+
import unittest
|
11
|
+
import sys
|
12
|
+
|
13
|
+
|
14
|
+
class TestTopologicallySorted(unittest.TestCase):
|
15
|
+
def test_Valid(self):
|
16
|
+
"""Test that sorting works on a valid graph with one possible order."""
|
17
|
+
graph = {
|
18
|
+
"a": ["b", "c"],
|
19
|
+
"b": [],
|
20
|
+
"c": ["d"],
|
21
|
+
"d": ["b"],
|
22
|
+
}
|
23
|
+
|
24
|
+
def GetEdge(node):
|
25
|
+
return tuple(graph[node])
|
26
|
+
|
27
|
+
self.assertEqual(
|
28
|
+
gyp.common.TopologicallySorted(graph.keys(), GetEdge), ["a", "c", "d", "b"]
|
29
|
+
)
|
30
|
+
|
31
|
+
def test_Cycle(self):
|
32
|
+
"""Test that an exception is thrown on a cyclic graph."""
|
33
|
+
graph = {
|
34
|
+
"a": ["b"],
|
35
|
+
"b": ["c"],
|
36
|
+
"c": ["d"],
|
37
|
+
"d": ["a"],
|
38
|
+
}
|
39
|
+
|
40
|
+
def GetEdge(node):
|
41
|
+
return tuple(graph[node])
|
42
|
+
|
43
|
+
self.assertRaises(
|
44
|
+
gyp.common.CycleError, gyp.common.TopologicallySorted, graph.keys(), GetEdge
|
45
|
+
)
|
46
|
+
|
47
|
+
|
48
|
+
class TestGetFlavor(unittest.TestCase):
|
49
|
+
"""Test that gyp.common.GetFlavor works as intended"""
|
50
|
+
|
51
|
+
original_platform = ""
|
52
|
+
|
53
|
+
def setUp(self):
|
54
|
+
self.original_platform = sys.platform
|
55
|
+
|
56
|
+
def tearDown(self):
|
57
|
+
sys.platform = self.original_platform
|
58
|
+
|
59
|
+
def assertFlavor(self, expected, argument, param):
|
60
|
+
sys.platform = argument
|
61
|
+
self.assertEqual(expected, gyp.common.GetFlavor(param))
|
62
|
+
|
63
|
+
def test_platform_default(self):
|
64
|
+
self.assertFlavor("freebsd", "freebsd9", {})
|
65
|
+
self.assertFlavor("freebsd", "freebsd10", {})
|
66
|
+
self.assertFlavor("openbsd", "openbsd5", {})
|
67
|
+
self.assertFlavor("solaris", "sunos5", {})
|
68
|
+
self.assertFlavor("solaris", "sunos", {})
|
69
|
+
self.assertFlavor("linux", "linux2", {})
|
70
|
+
self.assertFlavor("linux", "linux3", {})
|
71
|
+
self.assertFlavor("linux", "linux", {})
|
72
|
+
|
73
|
+
def test_param(self):
|
74
|
+
self.assertFlavor("foobar", "linux2", {"flavor": "foobar"})
|
75
|
+
|
76
|
+
|
77
|
+
if __name__ == "__main__":
|
78
|
+
unittest.main()
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# Copyright (c) 2011 Google Inc. All rights reserved.
|
2
|
+
# Use of this source code is governed by a BSD-style license that can be
|
3
|
+
# found in the LICENSE file.
|
4
|
+
|
5
|
+
import sys
|
6
|
+
import re
|
7
|
+
import os
|
8
|
+
import locale
|
9
|
+
from functools import reduce
|
10
|
+
|
11
|
+
|
12
|
+
def XmlToString(content, encoding="utf-8", pretty=False):
|
13
|
+
""" Writes the XML content to disk, touching the file only if it has changed.
|
14
|
+
|
15
|
+
Visual Studio files have a lot of pre-defined structures. This function makes
|
16
|
+
it easy to represent these structures as Python data structures, instead of
|
17
|
+
having to create a lot of function calls.
|
18
|
+
|
19
|
+
Each XML element of the content is represented as a list composed of:
|
20
|
+
1. The name of the element, a string,
|
21
|
+
2. The attributes of the element, a dictionary (optional), and
|
22
|
+
3+. The content of the element, if any. Strings are simple text nodes and
|
23
|
+
lists are child elements.
|
24
|
+
|
25
|
+
Example 1:
|
26
|
+
<test/>
|
27
|
+
becomes
|
28
|
+
['test']
|
29
|
+
|
30
|
+
Example 2:
|
31
|
+
<myelement a='value1' b='value2'>
|
32
|
+
<childtype>This is</childtype>
|
33
|
+
<childtype>it!</childtype>
|
34
|
+
</myelement>
|
35
|
+
|
36
|
+
becomes
|
37
|
+
['myelement', {'a':'value1', 'b':'value2'},
|
38
|
+
['childtype', 'This is'],
|
39
|
+
['childtype', 'it!'],
|
40
|
+
]
|
41
|
+
|
42
|
+
Args:
|
43
|
+
content: The structured content to be converted.
|
44
|
+
encoding: The encoding to report on the first XML line.
|
45
|
+
pretty: True if we want pretty printing with indents and new lines.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
The XML content as a string.
|
49
|
+
"""
|
50
|
+
# We create a huge list of all the elements of the file.
|
51
|
+
xml_parts = ['<?xml version="1.0" encoding="%s"?>' % encoding]
|
52
|
+
if pretty:
|
53
|
+
xml_parts.append("\n")
|
54
|
+
_ConstructContentList(xml_parts, content, pretty)
|
55
|
+
|
56
|
+
# Convert it to a string
|
57
|
+
return "".join(xml_parts)
|
58
|
+
|
59
|
+
|
60
|
+
def _ConstructContentList(xml_parts, specification, pretty, level=0):
|
61
|
+
""" Appends the XML parts corresponding to the specification.
|
62
|
+
|
63
|
+
Args:
|
64
|
+
xml_parts: A list of XML parts to be appended to.
|
65
|
+
specification: The specification of the element. See EasyXml docs.
|
66
|
+
pretty: True if we want pretty printing with indents and new lines.
|
67
|
+
level: Indentation level.
|
68
|
+
"""
|
69
|
+
# The first item in a specification is the name of the element.
|
70
|
+
if pretty:
|
71
|
+
indentation = " " * level
|
72
|
+
new_line = "\n"
|
73
|
+
else:
|
74
|
+
indentation = ""
|
75
|
+
new_line = ""
|
76
|
+
name = specification[0]
|
77
|
+
if not isinstance(name, str):
|
78
|
+
raise Exception(
|
79
|
+
"The first item of an EasyXml specification should be "
|
80
|
+
"a string. Specification was " + str(specification)
|
81
|
+
)
|
82
|
+
xml_parts.append(indentation + "<" + name)
|
83
|
+
|
84
|
+
# Optionally in second position is a dictionary of the attributes.
|
85
|
+
rest = specification[1:]
|
86
|
+
if rest and isinstance(rest[0], dict):
|
87
|
+
for at, val in sorted(rest[0].items()):
|
88
|
+
xml_parts.append(f' {at}="{_XmlEscape(val, attr=True)}"')
|
89
|
+
rest = rest[1:]
|
90
|
+
if rest:
|
91
|
+
xml_parts.append(">")
|
92
|
+
all_strings = reduce(lambda x, y: x and isinstance(y, str), rest, True)
|
93
|
+
multi_line = not all_strings
|
94
|
+
if multi_line and new_line:
|
95
|
+
xml_parts.append(new_line)
|
96
|
+
for child_spec in rest:
|
97
|
+
# If it's a string, append a text node.
|
98
|
+
# Otherwise recurse over that child definition
|
99
|
+
if isinstance(child_spec, str):
|
100
|
+
xml_parts.append(_XmlEscape(child_spec))
|
101
|
+
else:
|
102
|
+
_ConstructContentList(xml_parts, child_spec, pretty, level + 1)
|
103
|
+
if multi_line and indentation:
|
104
|
+
xml_parts.append(indentation)
|
105
|
+
xml_parts.append(f"</{name}>{new_line}")
|
106
|
+
else:
|
107
|
+
xml_parts.append("/>%s" % new_line)
|
108
|
+
|
109
|
+
|
110
|
+
def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
|
111
|
+
win32=(sys.platform == "win32")):
|
112
|
+
""" Writes the XML content to disk, touching the file only if it has changed.
|
113
|
+
|
114
|
+
Args:
|
115
|
+
content: The structured content to be written.
|
116
|
+
path: Location of the file.
|
117
|
+
encoding: The encoding to report on the first line of the XML file.
|
118
|
+
pretty: True if we want pretty printing with indents and new lines.
|
119
|
+
"""
|
120
|
+
xml_string = XmlToString(content, encoding, pretty)
|
121
|
+
if win32 and os.linesep != "\r\n":
|
122
|
+
xml_string = xml_string.replace("\n", "\r\n")
|
123
|
+
|
124
|
+
default_encoding = locale.getdefaultlocale()[1]
|
125
|
+
if default_encoding and default_encoding.upper() != encoding.upper():
|
126
|
+
xml_string = xml_string.encode(encoding)
|
127
|
+
|
128
|
+
# Get the old content
|
129
|
+
try:
|
130
|
+
with open(path) as file:
|
131
|
+
existing = file.read()
|
132
|
+
except OSError:
|
133
|
+
existing = None
|
134
|
+
|
135
|
+
# It has changed, write it
|
136
|
+
if existing != xml_string:
|
137
|
+
with open(path, "wb") as file:
|
138
|
+
file.write(xml_string)
|
139
|
+
|
140
|
+
|
141
|
+
_xml_escape_map = {
|
142
|
+
'"': """,
|
143
|
+
"'": "'",
|
144
|
+
"<": "<",
|
145
|
+
">": ">",
|
146
|
+
"&": "&",
|
147
|
+
"\n": "
",
|
148
|
+
"\r": "
",
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
_xml_escape_re = re.compile("(%s)" % "|".join(map(re.escape, _xml_escape_map.keys())))
|
153
|
+
|
154
|
+
|
155
|
+
def _XmlEscape(value, attr=False):
|
156
|
+
""" Escape a string for inclusion in XML."""
|
157
|
+
|
158
|
+
def replace(match):
|
159
|
+
m = match.string[match.start() : match.end()]
|
160
|
+
# don't replace single quotes in attrs
|
161
|
+
if attr and m == "'":
|
162
|
+
return m
|
163
|
+
return _xml_escape_map[m]
|
164
|
+
|
165
|
+
return _xml_escape_re.sub(replace, value)
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
|
3
|
+
# Copyright (c) 2011 Google Inc. All rights reserved.
|
4
|
+
# Use of this source code is governed by a BSD-style license that can be
|
5
|
+
# found in the LICENSE file.
|
6
|
+
|
7
|
+
""" Unit tests for the easy_xml.py file. """
|
8
|
+
|
9
|
+
import gyp.easy_xml as easy_xml
|
10
|
+
import unittest
|
11
|
+
|
12
|
+
from io import StringIO
|
13
|
+
|
14
|
+
|
15
|
+
class TestSequenceFunctions(unittest.TestCase):
|
16
|
+
def setUp(self):
|
17
|
+
self.stderr = StringIO()
|
18
|
+
|
19
|
+
def test_EasyXml_simple(self):
|
20
|
+
self.assertEqual(
|
21
|
+
easy_xml.XmlToString(["test"]),
|
22
|
+
'<?xml version="1.0" encoding="utf-8"?><test/>',
|
23
|
+
)
|
24
|
+
|
25
|
+
self.assertEqual(
|
26
|
+
easy_xml.XmlToString(["test"], encoding="Windows-1252"),
|
27
|
+
'<?xml version="1.0" encoding="Windows-1252"?><test/>',
|
28
|
+
)
|
29
|
+
|
30
|
+
def test_EasyXml_simple_with_attributes(self):
|
31
|
+
self.assertEqual(
|
32
|
+
easy_xml.XmlToString(["test2", {"a": "value1", "b": "value2"}]),
|
33
|
+
'<?xml version="1.0" encoding="utf-8"?><test2 a="value1" b="value2"/>',
|
34
|
+
)
|
35
|
+
|
36
|
+
def test_EasyXml_escaping(self):
|
37
|
+
original = "<test>'\"\r&\nfoo"
|
38
|
+
converted = "<test>'"
&
foo"
|
39
|
+
converted_apos = converted.replace("'", "'")
|
40
|
+
self.assertEqual(
|
41
|
+
easy_xml.XmlToString(["test3", {"a": original}, original]),
|
42
|
+
'<?xml version="1.0" encoding="utf-8"?><test3 a="%s">%s</test3>'
|
43
|
+
% (converted, converted_apos),
|
44
|
+
)
|
45
|
+
|
46
|
+
def test_EasyXml_pretty(self):
|
47
|
+
self.assertEqual(
|
48
|
+
easy_xml.XmlToString(
|
49
|
+
["test3", ["GrandParent", ["Parent1", ["Child"]], ["Parent2"]]],
|
50
|
+
pretty=True,
|
51
|
+
),
|
52
|
+
'<?xml version="1.0" encoding="utf-8"?>\n'
|
53
|
+
"<test3>\n"
|
54
|
+
" <GrandParent>\n"
|
55
|
+
" <Parent1>\n"
|
56
|
+
" <Child/>\n"
|
57
|
+
" </Parent1>\n"
|
58
|
+
" <Parent2/>\n"
|
59
|
+
" </GrandParent>\n"
|
60
|
+
"</test3>\n",
|
61
|
+
)
|
62
|
+
|
63
|
+
def test_EasyXml_complex(self):
|
64
|
+
# We want to create:
|
65
|
+
target = (
|
66
|
+
'<?xml version="1.0" encoding="utf-8"?>'
|
67
|
+
"<Project>"
|
68
|
+
'<PropertyGroup Label="Globals">'
|
69
|
+
"<ProjectGuid>{D2250C20-3A94-4FB9-AF73-11BC5B73884B}</ProjectGuid>"
|
70
|
+
"<Keyword>Win32Proj</Keyword>"
|
71
|
+
"<RootNamespace>automated_ui_tests</RootNamespace>"
|
72
|
+
"</PropertyGroup>"
|
73
|
+
'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props"/>'
|
74
|
+
"<PropertyGroup "
|
75
|
+
"Condition=\"'$(Configuration)|$(Platform)'=="
|
76
|
+
'\'Debug|Win32\'" Label="Configuration">'
|
77
|
+
"<ConfigurationType>Application</ConfigurationType>"
|
78
|
+
"<CharacterSet>Unicode</CharacterSet>"
|
79
|
+
"</PropertyGroup>"
|
80
|
+
"</Project>"
|
81
|
+
)
|
82
|
+
|
83
|
+
xml = easy_xml.XmlToString(
|
84
|
+
[
|
85
|
+
"Project",
|
86
|
+
[
|
87
|
+
"PropertyGroup",
|
88
|
+
{"Label": "Globals"},
|
89
|
+
["ProjectGuid", "{D2250C20-3A94-4FB9-AF73-11BC5B73884B}"],
|
90
|
+
["Keyword", "Win32Proj"],
|
91
|
+
["RootNamespace", "automated_ui_tests"],
|
92
|
+
],
|
93
|
+
["Import", {"Project": "$(VCTargetsPath)\\Microsoft.Cpp.props"}],
|
94
|
+
[
|
95
|
+
"PropertyGroup",
|
96
|
+
{
|
97
|
+
"Condition": "'$(Configuration)|$(Platform)'=='Debug|Win32'",
|
98
|
+
"Label": "Configuration",
|
99
|
+
},
|
100
|
+
["ConfigurationType", "Application"],
|
101
|
+
["CharacterSet", "Unicode"],
|
102
|
+
],
|
103
|
+
]
|
104
|
+
)
|
105
|
+
self.assertEqual(xml, target)
|
106
|
+
|
107
|
+
|
108
|
+
if __name__ == "__main__":
|
109
|
+
unittest.main()
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# Copyright (c) 2011 Google Inc. All rights reserved.
|
3
|
+
# Use of this source code is governed by a BSD-style license that can be
|
4
|
+
# found in the LICENSE file.
|
5
|
+
|
6
|
+
"""These functions are executed via gyp-flock-tool when using the Makefile
|
7
|
+
generator. Used on systems that don't have a built-in flock."""
|
8
|
+
|
9
|
+
import fcntl
|
10
|
+
import os
|
11
|
+
import struct
|
12
|
+
import subprocess
|
13
|
+
import sys
|
14
|
+
|
15
|
+
|
16
|
+
def main(args):
|
17
|
+
executor = FlockTool()
|
18
|
+
executor.Dispatch(args)
|
19
|
+
|
20
|
+
|
21
|
+
class FlockTool:
|
22
|
+
"""This class emulates the 'flock' command."""
|
23
|
+
|
24
|
+
def Dispatch(self, args):
|
25
|
+
"""Dispatches a string command to a method."""
|
26
|
+
if len(args) < 1:
|
27
|
+
raise Exception("Not enough arguments")
|
28
|
+
|
29
|
+
method = "Exec%s" % self._CommandifyName(args[0])
|
30
|
+
getattr(self, method)(*args[1:])
|
31
|
+
|
32
|
+
def _CommandifyName(self, name_string):
|
33
|
+
"""Transforms a tool name like copy-info-plist to CopyInfoPlist"""
|
34
|
+
return name_string.title().replace("-", "")
|
35
|
+
|
36
|
+
def ExecFlock(self, lockfile, *cmd_list):
|
37
|
+
"""Emulates the most basic behavior of Linux's flock(1)."""
|
38
|
+
# Rely on exception handling to report errors.
|
39
|
+
# Note that the stock python on SunOS has a bug
|
40
|
+
# where fcntl.flock(fd, LOCK_EX) always fails
|
41
|
+
# with EBADF, that's why we use this F_SETLK
|
42
|
+
# hack instead.
|
43
|
+
fd = os.open(lockfile, os.O_WRONLY | os.O_NOCTTY | os.O_CREAT, 0o666)
|
44
|
+
if sys.platform.startswith("aix") or sys.platform == "os400":
|
45
|
+
# Python on AIX is compiled with LARGEFILE support, which changes the
|
46
|
+
# struct size.
|
47
|
+
op = struct.pack("hhIllqq", fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
|
48
|
+
else:
|
49
|
+
op = struct.pack("hhllhhl", fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
|
50
|
+
fcntl.fcntl(fd, fcntl.F_SETLK, op)
|
51
|
+
return subprocess.call(cmd_list)
|
52
|
+
|
53
|
+
|
54
|
+
if __name__ == "__main__":
|
55
|
+
sys.exit(main(sys.argv[1:]))
|
wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py
ADDED
File without changes
|