kgcss 1.0.0__tar.gz

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 (119) hide show
  1. kgcss-1.0.0/LICENSE +28 -0
  2. kgcss-1.0.0/MANIFEST.in +3 -0
  3. kgcss-1.0.0/PKG-INFO +55 -0
  4. kgcss-1.0.0/README.md +33 -0
  5. kgcss-1.0.0/csrc/color.c +1103 -0
  6. kgcss-1.0.0/csrc/kgcss.h +99 -0
  7. kgcss-1.0.0/csrc/module.c +155 -0
  8. kgcss-1.0.0/csrc/objects.h +165 -0
  9. kgcss-1.0.0/csrc/properties.c +194 -0
  10. kgcss-1.0.0/csrc/select.c +1485 -0
  11. kgcss-1.0.0/csrc/selectors.c +1020 -0
  12. kgcss-1.0.0/csrc/selectors.h +55 -0
  13. kgcss-1.0.0/csrc/serialize.c +148 -0
  14. kgcss-1.0.0/csrc/syntax.c +833 -0
  15. kgcss-1.0.0/csrc/tokenizer.c +158 -0
  16. kgcss-1.0.0/csrc/tokenizer_impl.h +512 -0
  17. kgcss-1.0.0/csrc/tokens.h +167 -0
  18. kgcss-1.0.0/csrc/types.c +657 -0
  19. kgcss-1.0.0/csrc/urls.c +193 -0
  20. kgcss-1.0.0/csrc/values.c +376 -0
  21. kgcss-1.0.0/csrc/writer.c +983 -0
  22. kgcss-1.0.0/pyproject.toml +144 -0
  23. kgcss-1.0.0/setup.cfg +4 -0
  24. kgcss-1.0.0/setup.py +73 -0
  25. kgcss-1.0.0/src/kgcss/__init__.py +161 -0
  26. kgcss-1.0.0/src/kgcss/_encodings.py +411 -0
  27. kgcss-1.0.0/src/kgcss/_kgcss.pyi +284 -0
  28. kgcss-1.0.0/src/kgcss/_version.py +3 -0
  29. kgcss-1.0.0/src/kgcss/colors.py +133 -0
  30. kgcss-1.0.0/src/kgcss/compat.py +924 -0
  31. kgcss-1.0.0/src/kgcss/cssom/__init__.py +103 -0
  32. kgcss-1.0.0/src/kgcss/cssom/build.py +389 -0
  33. kgcss-1.0.0/src/kgcss/cssom/declarations.py +610 -0
  34. kgcss-1.0.0/src/kgcss/cssom/exceptions.py +29 -0
  35. kgcss-1.0.0/src/kgcss/cssom/imports.py +255 -0
  36. kgcss-1.0.0/src/kgcss/cssom/rules.py +1081 -0
  37. kgcss-1.0.0/src/kgcss/cssom/selector_list.py +402 -0
  38. kgcss-1.0.0/src/kgcss/cssom/serializer.py +871 -0
  39. kgcss-1.0.0/src/kgcss/cssom/state.py +149 -0
  40. kgcss-1.0.0/src/kgcss/cssom/stylesheet.py +358 -0
  41. kgcss-1.0.0/src/kgcss/cssom/urls.py +290 -0
  42. kgcss-1.0.0/src/kgcss/cssom/values.py +381 -0
  43. kgcss-1.0.0/src/kgcss/decode.py +121 -0
  44. kgcss-1.0.0/src/kgcss/enums.py +40 -0
  45. kgcss-1.0.0/src/kgcss/escaping.py +18 -0
  46. kgcss-1.0.0/src/kgcss/fonts.py +242 -0
  47. kgcss-1.0.0/src/kgcss/grammar.py +282 -0
  48. kgcss-1.0.0/src/kgcss/matching.py +127 -0
  49. kgcss-1.0.0/src/kgcss/media.py +461 -0
  50. kgcss-1.0.0/src/kgcss/py.typed +0 -0
  51. kgcss-1.0.0/src/kgcss/selectors.py +528 -0
  52. kgcss-1.0.0/src/kgcss/shorthands.py +296 -0
  53. kgcss-1.0.0/src/kgcss/syntax.py +86 -0
  54. kgcss-1.0.0/src/kgcss/tokenizer.py +14 -0
  55. kgcss-1.0.0/src/kgcss.egg-info/PKG-INFO +55 -0
  56. kgcss-1.0.0/src/kgcss.egg-info/SOURCES.txt +117 -0
  57. kgcss-1.0.0/src/kgcss.egg-info/dependency_links.txt +1 -0
  58. kgcss-1.0.0/src/kgcss.egg-info/top_level.txt +1 -0
  59. kgcss-1.0.0/tests/__init__.py +0 -0
  60. kgcss-1.0.0/tests/conftest.py +28 -0
  61. kgcss-1.0.0/tests/css-parsing-tests/An+B.json +158 -0
  62. kgcss-1.0.0/tests/css-parsing-tests/LICENSE +8 -0
  63. kgcss-1.0.0/tests/css-parsing-tests/README.rst +296 -0
  64. kgcss-1.0.0/tests/css-parsing-tests/VENDORED +1 -0
  65. kgcss-1.0.0/tests/css-parsing-tests/blocks_contents.json +63 -0
  66. kgcss-1.0.0/tests/css-parsing-tests/color_function_4.json +221 -0
  67. kgcss-1.0.0/tests/css-parsing-tests/color_functions_5.json +22 -0
  68. kgcss-1.0.0/tests/css-parsing-tests/color_hexadecimal_3.json +83 -0
  69. kgcss-1.0.0/tests/css-parsing-tests/color_hexadecimal_4.json +326 -0
  70. kgcss-1.0.0/tests/css-parsing-tests/color_hsl_3.json +258 -0
  71. kgcss-1.0.0/tests/css-parsing-tests/color_hsl_4.json +502 -0
  72. kgcss-1.0.0/tests/css-parsing-tests/color_hwb_4.json +502 -0
  73. kgcss-1.0.0/tests/css-parsing-tests/color_keywords_3.json +162 -0
  74. kgcss-1.0.0/tests/css-parsing-tests/color_keywords_4.json +3 -0
  75. kgcss-1.0.0/tests/css-parsing-tests/color_lab_4.json +1502 -0
  76. kgcss-1.0.0/tests/css-parsing-tests/color_lch_4.json +1502 -0
  77. kgcss-1.0.0/tests/css-parsing-tests/color_oklab_4.json +1502 -0
  78. kgcss-1.0.0/tests/css-parsing-tests/color_oklch_4.json +1502 -0
  79. kgcss-1.0.0/tests/css-parsing-tests/component_value_list.json +443 -0
  80. kgcss-1.0.0/tests/css-parsing-tests/declaration_list.json +44 -0
  81. kgcss-1.0.0/tests/css-parsing-tests/one_component_value.json +27 -0
  82. kgcss-1.0.0/tests/css-parsing-tests/one_declaration.json +40 -0
  83. kgcss-1.0.0/tests/css-parsing-tests/one_rule.json +36 -0
  84. kgcss-1.0.0/tests/css-parsing-tests/rule_list.json +48 -0
  85. kgcss-1.0.0/tests/css-parsing-tests/stylesheet.json +44 -0
  86. kgcss-1.0.0/tests/css-parsing-tests/stylesheet_bytes.json +146 -0
  87. kgcss-1.0.0/tests/data/css_selectors_shakespeare.html +309 -0
  88. kgcss-1.0.0/tests/selector_oracle.py +330 -0
  89. kgcss-1.0.0/tests/strategies.py +67 -0
  90. kgcss-1.0.0/tests/suite.py +186 -0
  91. kgcss-1.0.0/tests/test_colors.py +669 -0
  92. kgcss-1.0.0/tests/test_compat.py +252 -0
  93. kgcss-1.0.0/tests/test_css_parsing_suite.py +170 -0
  94. kgcss-1.0.0/tests/test_cssom_declarations.py +404 -0
  95. kgcss-1.0.0/tests/test_cssom_imports.py +404 -0
  96. kgcss-1.0.0/tests/test_cssom_mutation.py +430 -0
  97. kgcss-1.0.0/tests/test_cssom_properties.py +359 -0
  98. kgcss-1.0.0/tests/test_cssom_rules.py +443 -0
  99. kgcss-1.0.0/tests/test_cssom_serialize.py +431 -0
  100. kgcss-1.0.0/tests/test_cssom_urls.py +154 -0
  101. kgcss-1.0.0/tests/test_cssom_values.py +212 -0
  102. kgcss-1.0.0/tests/test_decode.py +150 -0
  103. kgcss-1.0.0/tests/test_fonts.py +260 -0
  104. kgcss-1.0.0/tests/test_grammar.py +167 -0
  105. kgcss-1.0.0/tests/test_media.py +397 -0
  106. kgcss-1.0.0/tests/test_native.py +26 -0
  107. kgcss-1.0.0/tests/test_properties.py +231 -0
  108. kgcss-1.0.0/tests/test_readme.py +14 -0
  109. kgcss-1.0.0/tests/test_safety.py +144 -0
  110. kgcss-1.0.0/tests/test_select.py +792 -0
  111. kgcss-1.0.0/tests/test_select_vs_css_selectors.py +168 -0
  112. kgcss-1.0.0/tests/test_selectors.py +969 -0
  113. kgcss-1.0.0/tests/test_serialize.py +55 -0
  114. kgcss-1.0.0/tests/test_shorthands.py +412 -0
  115. kgcss-1.0.0/tests/test_syntax.py +355 -0
  116. kgcss-1.0.0/tests/test_threads.py +549 -0
  117. kgcss-1.0.0/tests/test_tokenizer.py +361 -0
  118. kgcss-1.0.0/tests/test_values.py +222 -0
  119. kgcss-1.0.0/tests/test_writer.py +218 -0
kgcss-1.0.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Kovid Goyal <kovid at kovidgoyal.net>
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,3 @@
1
+ # The whole test suite, so that it can be run from the sdist (setuptools only adds tests/test_*.py by itself)
2
+ graft tests
3
+ global-exclude *.py[cod] __pycache__
kgcss-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: kgcss
3
+ Version: 1.0.0
4
+ Summary: Fast and comprehensive CSS handling: tokenizing, parsing, a mutable object model, serialization, selector matching, media queries, colors, fonts and shorthands, with a C99 backend
5
+ Author-email: Kovid Goyal <kovid@kovidgoyal.net>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Documentation, https://kgcss.readthedocs.io
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Programming Language :: C
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Python :: 3.15
14
+ Classifier: Programming Language :: Python :: Implementation :: CPython
15
+ Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
16
+ Classifier: Topic :: Text Processing :: Markup
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.14
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ # kgcss
24
+
25
+ [![CI](https://github.com/kovidgoyal/kgcss/actions/workflows/ci.yml/badge.svg)](https://github.com/kovidgoyal/kgcss/actions/workflows/ci.yml)
26
+ [![Documentation](https://readthedocs.org/projects/kgcss/badge/?version=latest)](https://kgcss.readthedocs.io/en/latest/)
27
+ [![PyPI](https://img.shields.io/pypi/v/kgcss)](https://pypi.org/project/kgcss/)
28
+ [![Python versions](https://img.shields.io/pypi/pyversions/kgcss)](https://pypi.org/project/kgcss/)
29
+
30
+ A fast and comprehensive CSS library for Python, with a C99 backend. It
31
+ parses CSS as browsers do, gives a mutable object model of sheets, rules,
32
+ selectors, declarations and values, and writes it back, reformatted or
33
+ byte for byte. It also rewrites URLs and handles `@import`, matches
34
+ Selectors Level 4 against lxml and ElementTree trees, and covers media
35
+ queries, colors, fonts and shorthand properties. It runs on regular and
36
+ free-threaded Python 3.14 and later.
37
+
38
+ ```python
39
+ >>> import kgcss
40
+ >>> sheet = kgcss.parse_stylesheet('a { color: #ff0000; margin: 0px }')
41
+ >>> print(sheet.css_text)
42
+ a {
43
+ color: #f00;
44
+ margin: 0;
45
+ }
46
+
47
+ ```
48
+
49
+ **Documentation: <https://kgcss.readthedocs.io>**: installation, a guide to
50
+ every part, the API reference, migrating from css_parser, tinycss and
51
+ css_selectors, and development.
52
+
53
+ ## License
54
+
55
+ BSD 3-Clause. See [LICENSE](LICENSE).
kgcss-1.0.0/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # kgcss
2
+
3
+ [![CI](https://github.com/kovidgoyal/kgcss/actions/workflows/ci.yml/badge.svg)](https://github.com/kovidgoyal/kgcss/actions/workflows/ci.yml)
4
+ [![Documentation](https://readthedocs.org/projects/kgcss/badge/?version=latest)](https://kgcss.readthedocs.io/en/latest/)
5
+ [![PyPI](https://img.shields.io/pypi/v/kgcss)](https://pypi.org/project/kgcss/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/kgcss)](https://pypi.org/project/kgcss/)
7
+
8
+ A fast and comprehensive CSS library for Python, with a C99 backend. It
9
+ parses CSS as browsers do, gives a mutable object model of sheets, rules,
10
+ selectors, declarations and values, and writes it back, reformatted or
11
+ byte for byte. It also rewrites URLs and handles `@import`, matches
12
+ Selectors Level 4 against lxml and ElementTree trees, and covers media
13
+ queries, colors, fonts and shorthand properties. It runs on regular and
14
+ free-threaded Python 3.14 and later.
15
+
16
+ ```python
17
+ >>> import kgcss
18
+ >>> sheet = kgcss.parse_stylesheet('a { color: #ff0000; margin: 0px }')
19
+ >>> print(sheet.css_text)
20
+ a {
21
+ color: #f00;
22
+ margin: 0;
23
+ }
24
+
25
+ ```
26
+
27
+ **Documentation: <https://kgcss.readthedocs.io>**: installation, a guide to
28
+ every part, the API reference, migrating from css_parser, tinycss and
29
+ css_selectors, and development.
30
+
31
+ ## License
32
+
33
+ BSD 3-Clause. See [LICENSE](LICENSE).