wsba-hockey 1.1.9__py3-none-any.whl → 1.2.1__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.
Files changed (144) hide show
  1. wsba_hockey/tools/scraping.py +146 -170
  2. wsba_hockey/tools/utils/__init__.py +0 -1
  3. wsba_hockey/tools/utils/shared.py +14 -389
  4. wsba_hockey/tools/xg_model.py +6 -1
  5. wsba_hockey/wsba_main.py +47 -14
  6. {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/METADATA +16 -15
  7. wsba_hockey-1.2.1.dist-info/RECORD +15 -0
  8. wsba_hockey/api/api/index.py +0 -162
  9. wsba_hockey/data_pipelines.py +0 -247
  10. wsba_hockey/evidence/weakside-breakout/node_modules/duckdb/vendor.py +0 -146
  11. wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/flatted.py +0 -149
  12. wsba_hockey/evidence/weakside-breakout/node_modules/flatted/python/test.py +0 -63
  13. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  14. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -367
  15. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  16. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1270
  17. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  18. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  19. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  20. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  21. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  22. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -690
  23. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -661
  24. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -78
  25. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -165
  26. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -109
  27. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  28. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  29. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -808
  30. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  31. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1321
  32. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -120
  33. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  34. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -464
  35. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  36. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -58
  37. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2714
  38. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3981
  39. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  40. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2936
  41. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -55
  42. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1394
  43. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  44. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3130
  45. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  46. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  47. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1271
  48. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  49. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  50. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -374
  51. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1939
  52. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  53. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3197
  54. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  55. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/test_gyp.py +0 -261
  56. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/graphviz.py +0 -102
  57. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_gyp.py +0 -156
  58. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_sln.py +0 -181
  59. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +0 -339
  60. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/test/fixtures/test-charmap.py +0 -31
  61. wsba_hockey/evidence/weakside-breakout/node_modules/node-gyp/update-gyp.py +0 -64
  62. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  63. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -367
  64. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  65. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1270
  66. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  67. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  68. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  69. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  70. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  71. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -666
  72. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -654
  73. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -78
  74. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -165
  75. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -109
  76. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  77. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  78. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -808
  79. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  80. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1321
  81. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -120
  82. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  83. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -464
  84. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  85. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -58
  86. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2518
  87. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3978
  88. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  89. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2936
  90. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -55
  91. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1394
  92. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  93. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3137
  94. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  95. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  96. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1271
  97. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  98. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  99. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -374
  100. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1939
  101. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  102. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3197
  103. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  104. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/setup.py +0 -42
  105. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/test_gyp.py +0 -260
  106. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/graphviz.py +0 -102
  107. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_gyp.py +0 -156
  108. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_sln.py +0 -181
  109. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/gyp/tools/pretty_vcproj.py +0 -339
  110. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/test/fixtures/test-charmap.py +0 -31
  111. wsba_hockey/evidence/weakside-breakout/node_modules/sqlite3/node_modules/node-gyp/update-gyp.py +0 -46
  112. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/duos/app.py +0 -210
  113. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/duos/calc.py +0 -163
  114. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/app.py +0 -401
  115. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/game_stats/name_fix.py +0 -47
  116. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/goalie/app.py +0 -101
  117. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/goalie/plot.py +0 -71
  118. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/goalie/rink_plot.py +0 -245
  119. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/app.py +0 -108
  120. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/plot.py +0 -95
  121. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/heatmaps/rink_plot.py +0 -245
  122. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/line-combos/app.py +0 -245
  123. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/line-combos/plot.py +0 -275
  124. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/line-combos/rink_plot.py +0 -245
  125. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/app.py +0 -145
  126. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/plot.py +0 -79
  127. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/matchups/rink_plot.py +0 -245
  128. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/app.py +0 -406
  129. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/plot.py +0 -79
  130. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/pbp/rink_plot.py +0 -245
  131. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/app.py +0 -110
  132. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/plot.py +0 -59
  133. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/skater/rink_plot.py +0 -245
  134. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/team_heatmaps/app.py +0 -103
  135. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/team_heatmaps/plot.py +0 -95
  136. wsba_hockey/evidence/weakside-breakout/wsba_nhl_apps/wsba_nhl_apps/team_heatmaps/rink_plot.py +0 -245
  137. wsba_hockey/flask/app.py +0 -77
  138. wsba_hockey/tools/utils/config.py +0 -14
  139. wsba_hockey/tools/utils/save_pages.py +0 -133
  140. wsba_hockey/workspace.py +0 -28
  141. wsba_hockey-1.1.9.dist-info/RECORD +0 -148
  142. {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/WHEEL +0 -0
  143. {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/licenses/LICENSE +0 -0
  144. {wsba_hockey-1.1.9.dist-info → wsba_hockey-1.2.1.dist-info}/top_level.txt +0 -0
@@ -1,78 +0,0 @@
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()
@@ -1,165 +0,0 @@
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
- '"': "&quot;",
143
- "'": "&apos;",
144
- "<": "&lt;",
145
- ">": "&gt;",
146
- "&": "&amp;",
147
- "\n": "&#xA;",
148
- "\r": "&#xD;",
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)
@@ -1,109 +0,0 @@
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 = "&lt;test&gt;'&quot;&#xD;&amp;&#xA;foo"
39
- converted_apos = converted.replace("'", "&apos;")
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()
@@ -1,55 +0,0 @@
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:]))