asnkit-gen-python 2.0.0rc8__tar.gz → 2.0.0rc9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: asnkit-gen-python
3
- Version: 2.0.0rc8
3
+ Version: 2.0.0rc9
4
4
  Summary: asnkit plugin that makes Python code with data classes from ASN.1
5
5
  Author: xadaemon
6
6
  Author-email: xadaemon <mxavier@boxtheta.com>
@@ -10,7 +10,7 @@ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Topic :: Software Development :: Code Generators
13
- Requires-Dist: asnkitrt==2.0.0rc8
13
+ Requires-Dist: asnkitrt==2.0.0rc9
14
14
  Requires-Python: >=3.13
15
15
  Project-URL: source, https://github.com/boxtheta/asnkit
16
16
  Description-Content-Type: text/x-rst
@@ -20,9 +20,10 @@ asnkit-gen-python
20
20
 
21
21
  A plugin for `asnkitcc`_ that generates Python code from ASN.1. The
22
22
  generated module imports `asnkitrt`_ and, by default, embeds the compiled
23
- specification as bytes. It has a data class for each ``SEQUENCE`` and
24
- ``SET``, an enumeration for each ``ENUMERATED`` and a class for each
25
- alternative of a ``CHOICE``, all with methods to encode and decode.
23
+ specification as bytes. It has a data class for each ``SEQUENCE``, ``SET``
24
+ and ``CHARACTER STRING``, the last of its associated type, an enumeration
25
+ for each ``ENUMERATED`` and a class for each alternative of a ``CHOICE``,
26
+ all with methods to encode and decode.
26
27
 
27
28
  .. code-block:: text
28
29
 
@@ -3,9 +3,10 @@ asnkit-gen-python
3
3
 
4
4
  A plugin for `asnkitcc`_ that generates Python code from ASN.1. The
5
5
  generated module imports `asnkitrt`_ and, by default, embeds the compiled
6
- specification as bytes. It has a data class for each ``SEQUENCE`` and
7
- ``SET``, an enumeration for each ``ENUMERATED`` and a class for each
8
- alternative of a ``CHOICE``, all with methods to encode and decode.
6
+ specification as bytes. It has a data class for each ``SEQUENCE``, ``SET``
7
+ and ``CHARACTER STRING``, the last of its associated type, an enumeration
8
+ for each ``ENUMERATED`` and a class for each alternative of a ``CHOICE``,
9
+ all with methods to encode and decode.
9
10
 
10
11
  .. code-block:: text
11
12
 
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "asnkit-gen-python"
3
- version = "2.0.0rc8"
3
+ version = "2.0.0rc9"
4
4
  description = "asnkit plugin that makes Python code with data classes from ASN.1"
5
5
  readme = "README.rst"
6
6
  requires-python = ">=3.13"
7
- dependencies = ["asnkitrt==2.0.0rc8"]
7
+ dependencies = ["asnkitrt==2.0.0rc9"]
8
8
  license = "Apache-2.0"
9
9
  license-files = ["LICENSE-COMPILER"]
10
10
  classifiers = [
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "asnkit-gen-python"
3
- version = "2.0.0rc8"
3
+ version = "2.0.0rc9"
4
4
  description = "asnkit plugin that makes Python code with data classes from ASN.1"
5
5
  readme = "README.rst"
6
6
  authors = [
@@ -8,7 +8,7 @@ authors = [
8
8
  ]
9
9
  requires-python = ">=3.13"
10
10
  dependencies = [
11
- "asnkitrt==2.0.0rc8",
11
+ "asnkitrt==2.0.0rc9",
12
12
  ]
13
13
  license = "Apache-2.0"
14
14
  license-files = ["LICENSE-COMPILER"]
@@ -20,6 +20,7 @@ from asnkitrt import syntax
20
20
 
21
21
  # The resolved dictionaries are not part of the API of asnkitrt, which is
22
22
  # released with this plugin.
23
+ from asnkitrt.codecs.compiler import character_string_type_descriptor
23
24
  from asnkitrt.syntax.convert import _compiled_to_dict
24
25
 
25
26
  DEFAULT_CODEC = "ber"
@@ -408,7 +409,7 @@ class Generator:
408
409
  def kind_of(self, descriptor: dict[str, Any]) -> str:
409
410
  type_name = descriptor["type"]
410
411
 
411
- if type_name in ("SEQUENCE", "SET"):
412
+ if type_name in ("SEQUENCE", "SET", "CHARACTER STRING"):
412
413
  return "sequence"
413
414
 
414
415
  if type_name == "CHOICE":
@@ -460,7 +461,7 @@ class Generator:
460
461
  # A field of an object class.
461
462
  return "Any", "None"
462
463
 
463
- if type_name in ("SEQUENCE", "SET"):
464
+ if type_name in ("SEQUENCE", "SET", "CHARACTER STRING"):
464
465
  name = self.take(camel(context), "the type in " + context)
465
466
  self.sequence(name, descriptor, module_name, None)
466
467
 
@@ -540,6 +541,10 @@ class Generator:
540
541
  module_name: str,
541
542
  type_name: str | None,
542
543
  ) -> None:
544
+ if descriptor["type"] == "CHARACTER STRING":
545
+ # Its associated type (X.680 44.5), as the runtime has it.
546
+ descriptor = character_string_type_descriptor()
547
+
543
548
  lines = [
544
549
  "@dataclasses.dataclass(kw_only=True)",
545
550
  "class {}(_Methods):".format(name),
@@ -2,4 +2,4 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- __version__ = "2.0.0rc8"
5
+ __version__ = "2.0.0rc9"