File tree 4 files changed +5
-25
lines changed
4 files changed +5
-25
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ passed to the ``FluentBundle`` constructor or to ``compile_messages``.
24
24
25
25
An ``escaper `` is an object that defines the following set of attributes. The
26
26
object could be a module, or a simple namespace object you could create using
27
- ``types.SimpleNamespace `` ( or `` fluent_compiler.utils.SimpleNamespace `` on Python 2), or
28
- an instance of a class with appropriate methods defined. The attributes are:
27
+ ``types.SimpleNamespace ``, or an instance of a class with appropriate
28
+ methods defined. The attributes are:
29
29
30
30
- ``name `` - a simple text value that is used in error messages.
31
31
Original file line number Diff line number Diff line change
1
+ from types import SimpleNamespace
2
+
1
3
from . import codegen
2
- from .utils import SimpleNamespace
3
4
4
5
5
6
def identity (value ):
Original file line number Diff line number Diff line change @@ -18,27 +18,6 @@ class Any:
18
18
Any = Any ()
19
19
20
20
21
- # On Python 3 we could get away with just using a class, but on Python 2
22
- # functions defined in the class body get wrapped with UnboundMethod, which
23
- # causes problems.
24
-
25
- try :
26
- from types import SimpleNamespace
27
- except ImportError :
28
- # Python 2 fallback
29
- class SimpleNamespace :
30
- def __init__ (self , ** kwargs ):
31
- self .__dict__ .update (kwargs )
32
-
33
- def __repr__ (self ):
34
- keys = sorted (self .__dict__ )
35
- items = (f"{ k } ={ self .__dict__ [k ]!r} " for k in keys )
36
- return f"{ type (self ).__name__ } ({ ', ' .join (items )} )"
37
-
38
- def __eq__ (self , other ):
39
- return self .__dict__ == other .__dict__
40
-
41
-
42
21
# From spec:
43
22
# NamedArgument ::= Identifier blank? ":" blank? (StringLiteral | NumberLiteral)
44
23
# Identifier ::= [a-zA-Z] [a-zA-Z0-9_-]*
Original file line number Diff line number Diff line change 1
1
import unittest
2
+ from types import SimpleNamespace
2
3
3
4
from markupsafe import Markup , escape
4
5
5
6
from fluent_compiler import codegen
6
7
from fluent_compiler .compiler import compile_messages
7
8
from fluent_compiler .errors import FluentCyclicReferenceError , FluentFormatError , FluentReferenceError
8
9
from fluent_compiler .resource import FtlResource
9
- from fluent_compiler .utils import SimpleNamespace
10
10
11
11
from .test_codegen import decompile_ast_list , normalize_python
12
12
from .utils import dedent_ftl
You can’t perform that action at this time.
0 commit comments