casbin-async-django-orm-adapter 1.0.0__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 (74) hide show
  1. async_casbin_adapter/__init__.py +0 -0
  2. async_casbin_adapter/adapter.py +100 -0
  3. async_casbin_adapter/apps.py +24 -0
  4. async_casbin_adapter/enforcer.py +81 -0
  5. async_casbin_adapter/migrations/0001_initial.py +37 -0
  6. async_casbin_adapter/migrations/__init__.py +0 -0
  7. async_casbin_adapter/models.py +48 -0
  8. async_casbin_adapter/utils.py +25 -0
  9. casbin_async_django_orm_adapter-1.0.0.dist-info/METADATA +116 -0
  10. casbin_async_django_orm_adapter-1.0.0.dist-info/RECORD +74 -0
  11. casbin_async_django_orm_adapter-1.0.0.dist-info/WHEEL +5 -0
  12. casbin_async_django_orm_adapter-1.0.0.dist-info/licenses/LICENSE +201 -0
  13. casbin_async_django_orm_adapter-1.0.0.dist-info/top_level.txt +3 -0
  14. node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py +45 -0
  15. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
  16. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
  17. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1272 -0
  18. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
  19. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
  20. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +152 -0
  21. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +270 -0
  22. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
  23. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +704 -0
  24. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py +709 -0
  25. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +173 -0
  26. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +169 -0
  27. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
  28. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
  29. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  30. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +805 -0
  31. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1172 -0
  32. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1319 -0
  33. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +128 -0
  34. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +104 -0
  35. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +462 -0
  36. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
  37. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +56 -0
  38. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2745 -0
  39. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3976 -0
  40. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
  41. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2965 -0
  42. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
  43. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1391 -0
  44. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +26 -0
  45. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py +3112 -0
  46. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +99 -0
  47. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +767 -0
  48. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1260 -0
  49. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
  50. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
  51. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +373 -0
  52. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
  53. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +54 -0
  54. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +303 -0
  55. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3196 -0
  56. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
  57. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
  58. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +108 -0
  59. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
  60. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
  61. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
  62. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
  63. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
  64. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/markers.py +252 -0
  65. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +825 -0
  66. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  67. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
  68. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
  69. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
  70. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
  71. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
  72. node_modules/npm/node_modules/node-gyp/gyp/test_gyp.py +261 -0
  73. node_modules/semantic-release-pypi/dist/py/set_version.py +32 -0
  74. node_modules/semantic-release-pypi/dist/py/verify_setup.py +24 -0
@@ -0,0 +1,173 @@
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 os
10
+ import sys
11
+ import unittest
12
+ from unittest.mock import MagicMock, patch
13
+
14
+ import gyp.common
15
+
16
+
17
+ class TestTopologicallySorted(unittest.TestCase):
18
+ def test_Valid(self):
19
+ """Test that sorting works on a valid graph with one possible order."""
20
+ graph = {
21
+ "a": ["b", "c"],
22
+ "b": [],
23
+ "c": ["d"],
24
+ "d": ["b"],
25
+ }
26
+
27
+ def GetEdge(node):
28
+ return tuple(graph[node])
29
+
30
+ assert gyp.common.TopologicallySorted(
31
+ graph.keys(), GetEdge) == ["a", "c", "d", "b"]
32
+
33
+ def test_Cycle(self):
34
+ """Test that an exception is thrown on a cyclic graph."""
35
+ graph = {
36
+ "a": ["b"],
37
+ "b": ["c"],
38
+ "c": ["d"],
39
+ "d": ["a"],
40
+ }
41
+
42
+ def GetEdge(node):
43
+ return tuple(graph[node])
44
+
45
+ self.assertRaises(
46
+ gyp.common.CycleError, gyp.common.TopologicallySorted, graph.keys(), GetEdge
47
+ )
48
+
49
+
50
+ class TestGetFlavor(unittest.TestCase):
51
+ """Test that gyp.common.GetFlavor works as intended"""
52
+
53
+ original_platform = ""
54
+
55
+ def setUp(self):
56
+ self.original_platform = sys.platform
57
+
58
+ def tearDown(self):
59
+ sys.platform = self.original_platform
60
+
61
+ def assertFlavor(self, expected, argument, param):
62
+ sys.platform = argument
63
+ assert expected == gyp.common.GetFlavor(param)
64
+
65
+ def test_platform_default(self):
66
+ self.assertFlavor("freebsd", "freebsd9", {})
67
+ self.assertFlavor("freebsd", "freebsd10", {})
68
+ self.assertFlavor("openbsd", "openbsd5", {})
69
+ self.assertFlavor("solaris", "sunos5", {})
70
+ self.assertFlavor("solaris", "sunos", {})
71
+ self.assertFlavor("linux", "linux2", {})
72
+ self.assertFlavor("linux", "linux3", {})
73
+ self.assertFlavor("linux", "linux", {})
74
+
75
+ def test_param(self):
76
+ self.assertFlavor("foobar", "linux2", {"flavor": "foobar"})
77
+
78
+ class MockCommunicate:
79
+ def __init__(self, stdout):
80
+ self.stdout = stdout
81
+
82
+ def decode(self, encoding):
83
+ return self.stdout
84
+
85
+ @patch("os.close")
86
+ @patch("os.unlink")
87
+ @patch("tempfile.mkstemp")
88
+ def test_GetCrossCompilerPredefines(self, mock_mkstemp, mock_unlink, mock_close):
89
+ mock_close.return_value = None
90
+ mock_unlink.return_value = None
91
+ mock_mkstemp.return_value = (0, "temp.c")
92
+
93
+ def mock_run(env, defines_stdout, expected_cmd):
94
+ with patch("subprocess.run") as mock_run:
95
+ mock_process = MagicMock()
96
+ mock_process.returncode = 0
97
+ mock_process.stdout = TestGetFlavor.MockCommunicate(defines_stdout)
98
+ mock_run.return_value = mock_process
99
+ expected_input = "temp.c" if sys.platform == "win32" else "/dev/null"
100
+ with patch.dict(os.environ, env):
101
+ defines = gyp.common.GetCrossCompilerPredefines()
102
+ flavor = gyp.common.GetFlavor({})
103
+ if env.get("CC_target"):
104
+ mock_run.assert_called_with(
105
+ [
106
+ *expected_cmd,
107
+ "-dM", "-E", "-x", "c", expected_input
108
+ ],
109
+ shell=sys.platform == "win32",
110
+ capture_output=True, check=True)
111
+ return [defines, flavor]
112
+
113
+ [defines1, _] = mock_run({}, "", [])
114
+ assert defines1 == {}
115
+
116
+ [defines2, flavor2] = mock_run(
117
+ { "CC_target": "/opt/wasi-sdk/bin/clang" },
118
+ "#define __wasm__ 1\n#define __wasi__ 1\n",
119
+ ["/opt/wasi-sdk/bin/clang"]
120
+ )
121
+ assert defines2 == { "__wasm__": "1", "__wasi__": "1" }
122
+ assert flavor2 == "wasi"
123
+
124
+ [defines3, flavor3] = mock_run(
125
+ { "CC_target": "/opt/wasi-sdk/bin/clang --target=wasm32" },
126
+ "#define __wasm__ 1\n",
127
+ ["/opt/wasi-sdk/bin/clang", "--target=wasm32"]
128
+ )
129
+ assert defines3 == { "__wasm__": "1" }
130
+ assert flavor3 == "wasm"
131
+
132
+ [defines4, flavor4] = mock_run(
133
+ { "CC_target": "/emsdk/upstream/emscripten/emcc" },
134
+ "#define __EMSCRIPTEN__ 1\n",
135
+ ["/emsdk/upstream/emscripten/emcc"]
136
+ )
137
+ assert defines4 == { "__EMSCRIPTEN__": "1" }
138
+ assert flavor4 == "emscripten"
139
+
140
+ # Test path which include white space
141
+ [defines5, flavor5] = mock_run(
142
+ {
143
+ "CC_target": "\"/Users/Toyo Li/wasi-sdk/bin/clang\" -O3",
144
+ "CFLAGS": "--target=wasm32-wasi-threads -pthread"
145
+ },
146
+ "#define __wasm__ 1\n#define __wasi__ 1\n#define _REENTRANT 1\n",
147
+ [
148
+ "/Users/Toyo Li/wasi-sdk/bin/clang",
149
+ "-O3",
150
+ "--target=wasm32-wasi-threads",
151
+ "-pthread"
152
+ ]
153
+ )
154
+ assert defines5 == {
155
+ "__wasm__": "1",
156
+ "__wasi__": "1",
157
+ "_REENTRANT": "1"
158
+ }
159
+ assert flavor5 == "wasi"
160
+
161
+ original_sep = os.sep
162
+ os.sep = "\\"
163
+ [defines6, flavor6] = mock_run(
164
+ { "CC_target": "\"C:\\Program Files\\wasi-sdk\\clang.exe\"" },
165
+ "#define __wasm__ 1\n#define __wasi__ 1\n",
166
+ ["C:/Program Files/wasi-sdk/clang.exe"]
167
+ )
168
+ os.sep = original_sep
169
+ assert defines6 == { "__wasm__": "1", "__wasi__": "1" }
170
+ assert flavor6 == "wasi"
171
+
172
+ if __name__ == "__main__":
173
+ unittest.main()
@@ -0,0 +1,169 @@
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 locale
6
+ import os
7
+ import re
8
+ import sys
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
+ try: # getdefaultlocale() was removed in Python 3.11
125
+ default_encoding = locale.getdefaultlocale()[1]
126
+ except AttributeError:
127
+ default_encoding = locale.getencoding()
128
+
129
+ if default_encoding and default_encoding.upper() != encoding.upper():
130
+ xml_string = xml_string.encode(encoding)
131
+
132
+ # Get the old content
133
+ try:
134
+ with open(path) as file:
135
+ existing = file.read()
136
+ except OSError:
137
+ existing = None
138
+
139
+ # It has changed, write it
140
+ if existing != xml_string:
141
+ with open(path, "wb") as file:
142
+ file.write(xml_string)
143
+
144
+
145
+ _xml_escape_map = {
146
+ '"': "&quot;",
147
+ "'": "&apos;",
148
+ "<": "&lt;",
149
+ ">": "&gt;",
150
+ "&": "&amp;",
151
+ "\n": "&#xA;",
152
+ "\r": "&#xD;",
153
+ }
154
+
155
+
156
+ _xml_escape_re = re.compile("(%s)" % "|".join(map(re.escape, _xml_escape_map.keys())))
157
+
158
+
159
+ def _XmlEscape(value, attr=False):
160
+ """ Escape a string for inclusion in XML."""
161
+
162
+ def replace(match):
163
+ m = match.string[match.start() : match.end()]
164
+ # don't replace single quotes in attrs
165
+ if attr and m == "'":
166
+ return m
167
+ return _xml_escape_map[m]
168
+
169
+ return _xml_escape_re.sub(replace, value)
@@ -0,0 +1,113 @@
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 unittest
10
+ from io import StringIO
11
+
12
+ from gyp import easy_xml
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
+ "<SpectreMitigation>SpectreLoadCF</SpectreMitigation>"
80
+ "<VCToolsVersion>14.36.32532</VCToolsVersion>"
81
+ "</PropertyGroup>"
82
+ "</Project>"
83
+ )
84
+
85
+ xml = easy_xml.XmlToString(
86
+ [
87
+ "Project",
88
+ [
89
+ "PropertyGroup",
90
+ {"Label": "Globals"},
91
+ ["ProjectGuid", "{D2250C20-3A94-4FB9-AF73-11BC5B73884B}"],
92
+ ["Keyword", "Win32Proj"],
93
+ ["RootNamespace", "automated_ui_tests"],
94
+ ],
95
+ ["Import", {"Project": "$(VCTargetsPath)\\Microsoft.Cpp.props"}],
96
+ [
97
+ "PropertyGroup",
98
+ {
99
+ "Condition": "'$(Configuration)|$(Platform)'=='Debug|Win32'",
100
+ "Label": "Configuration",
101
+ },
102
+ ["ConfigurationType", "Application"],
103
+ ["CharacterSet", "Unicode"],
104
+ ["SpectreMitigation", "SpectreLoadCF"],
105
+ ["VCToolsVersion", "14.36.32532"],
106
+ ],
107
+ ]
108
+ )
109
+ self.assertEqual(xml, target)
110
+
111
+
112
+ if __name__ == "__main__":
113
+ 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:]))