1- # coding=utf-8
2- from __future__ import unicode_literals
31import re
42import sys
53import json
6- import six
74
85
96def to_json (value , fn = None ):
@@ -44,7 +41,7 @@ def scalars_equal(node1, node2, ignored_fields):
4441 return node1 == node2
4542
4643
47- class BaseNode ( object ) :
44+ class BaseNode :
4845 """Base class for all Fluent AST nodes.
4946
5047 All productions described in the ASDL subclass BaseNode, including Span and
@@ -125,7 +122,7 @@ class SyntaxNode(BaseNode):
125122 """Base class for AST nodes which can have Spans."""
126123
127124 def __init__ (self , span = None , ** kwargs ):
128- super (SyntaxNode , self ).__init__ (** kwargs )
125+ super ().__init__ (** kwargs )
129126 self .span = span
130127
131128 def add_span (self , start , end ):
@@ -134,7 +131,7 @@ def add_span(self, start, end):
134131
135132class Resource (SyntaxNode ):
136133 def __init__ (self , body = None , ** kwargs ):
137- super (Resource , self ).__init__ (** kwargs )
134+ super ().__init__ (** kwargs )
138135 self .body = body or []
139136
140137
@@ -145,7 +142,7 @@ class Entry(SyntaxNode):
145142class Message (Entry ):
146143 def __init__ (self , id , value = None , attributes = None ,
147144 comment = None , ** kwargs ):
148- super (Message , self ).__init__ (** kwargs )
145+ super ().__init__ (** kwargs )
149146 self .id = id
150147 self .value = value
151148 self .attributes = attributes or []
@@ -155,7 +152,7 @@ def __init__(self, id, value=None, attributes=None,
155152class Term (Entry ):
156153 def __init__ (self , id , value , attributes = None ,
157154 comment = None , ** kwargs ):
158- super (Term , self ).__init__ (** kwargs )
155+ super ().__init__ (** kwargs )
159156 self .id = id
160157 self .value = value
161158 self .attributes = attributes or []
@@ -164,7 +161,7 @@ def __init__(self, id, value, attributes=None,
164161
165162class Pattern (SyntaxNode ):
166163 def __init__ (self , elements , ** kwargs ):
167- super (Pattern , self ).__init__ (** kwargs )
164+ super ().__init__ (** kwargs )
168165 self .elements = elements
169166
170167
@@ -174,13 +171,13 @@ class PatternElement(SyntaxNode):
174171
175172class TextElement (PatternElement ):
176173 def __init__ (self , value , ** kwargs ):
177- super (TextElement , self ).__init__ (** kwargs )
174+ super ().__init__ (** kwargs )
178175 self .value = value
179176
180177
181178class Placeable (PatternElement ):
182179 def __init__ (self , expression , ** kwargs ):
183- super (Placeable , self ).__init__ (** kwargs )
180+ super ().__init__ (** kwargs )
184181 self .expression = expression
185182
186183
@@ -191,7 +188,7 @@ class Expression(SyntaxNode):
191188class Literal (Expression ):
192189 """An abstract base class for literals."""
193190 def __init__ (self , value , ** kwargs ):
194- super (Literal , self ).__init__ (** kwargs )
191+ super ().__init__ (** kwargs )
195192 self .value = value
196193
197194 def parse (self ):
@@ -206,7 +203,7 @@ def from_escape_sequence(matchobj):
206203 return c
207204 codepoint = int (codepoint4 or codepoint6 , 16 )
208205 if codepoint <= 0xD7FF or 0xE000 <= codepoint :
209- return six . unichr (codepoint )
206+ return chr (codepoint )
210207 # Escape sequences reresenting surrogate code points are
211208 # well-formed but invalid in Fluent. Replace them with U+FFFD
212209 # REPLACEMENT CHARACTER.
@@ -235,98 +232,98 @@ def parse(self):
235232
236233class MessageReference (Expression ):
237234 def __init__ (self , id , attribute = None , ** kwargs ):
238- super (MessageReference , self ).__init__ (** kwargs )
235+ super ().__init__ (** kwargs )
239236 self .id = id
240237 self .attribute = attribute
241238
242239
243240class TermReference (Expression ):
244241 def __init__ (self , id , attribute = None , arguments = None , ** kwargs ):
245- super (TermReference , self ).__init__ (** kwargs )
242+ super ().__init__ (** kwargs )
246243 self .id = id
247244 self .attribute = attribute
248245 self .arguments = arguments
249246
250247
251248class VariableReference (Expression ):
252249 def __init__ (self , id , ** kwargs ):
253- super (VariableReference , self ).__init__ (** kwargs )
250+ super ().__init__ (** kwargs )
254251 self .id = id
255252
256253
257254class FunctionReference (Expression ):
258255 def __init__ (self , id , arguments , ** kwargs ):
259- super (FunctionReference , self ).__init__ (** kwargs )
256+ super ().__init__ (** kwargs )
260257 self .id = id
261258 self .arguments = arguments
262259
263260
264261class SelectExpression (Expression ):
265262 def __init__ (self , selector , variants , ** kwargs ):
266- super (SelectExpression , self ).__init__ (** kwargs )
263+ super ().__init__ (** kwargs )
267264 self .selector = selector
268265 self .variants = variants
269266
270267
271268class CallArguments (SyntaxNode ):
272269 def __init__ (self , positional = None , named = None , ** kwargs ):
273- super (CallArguments , self ).__init__ (** kwargs )
270+ super ().__init__ (** kwargs )
274271 self .positional = [] if positional is None else positional
275272 self .named = [] if named is None else named
276273
277274
278275class Attribute (SyntaxNode ):
279276 def __init__ (self , id , value , ** kwargs ):
280- super (Attribute , self ).__init__ (** kwargs )
277+ super ().__init__ (** kwargs )
281278 self .id = id
282279 self .value = value
283280
284281
285282class Variant (SyntaxNode ):
286283 def __init__ (self , key , value , default = False , ** kwargs ):
287- super (Variant , self ).__init__ (** kwargs )
284+ super ().__init__ (** kwargs )
288285 self .key = key
289286 self .value = value
290287 self .default = default
291288
292289
293290class NamedArgument (SyntaxNode ):
294291 def __init__ (self , name , value , ** kwargs ):
295- super (NamedArgument , self ).__init__ (** kwargs )
292+ super ().__init__ (** kwargs )
296293 self .name = name
297294 self .value = value
298295
299296
300297class Identifier (SyntaxNode ):
301298 def __init__ (self , name , ** kwargs ):
302- super (Identifier , self ).__init__ (** kwargs )
299+ super ().__init__ (** kwargs )
303300 self .name = name
304301
305302
306303class BaseComment (Entry ):
307304 def __init__ (self , content = None , ** kwargs ):
308- super (BaseComment , self ).__init__ (** kwargs )
305+ super ().__init__ (** kwargs )
309306 self .content = content
310307
311308
312309class Comment (BaseComment ):
313310 def __init__ (self , content = None , ** kwargs ):
314- super (Comment , self ).__init__ (content , ** kwargs )
311+ super ().__init__ (content , ** kwargs )
315312
316313
317314class GroupComment (BaseComment ):
318315 def __init__ (self , content = None , ** kwargs ):
319- super (GroupComment , self ).__init__ (content , ** kwargs )
316+ super ().__init__ (content , ** kwargs )
320317
321318
322319class ResourceComment (BaseComment ):
323320 def __init__ (self , content = None , ** kwargs ):
324- super (ResourceComment , self ).__init__ (content , ** kwargs )
321+ super ().__init__ (content , ** kwargs )
325322
326323
327324class Junk (SyntaxNode ):
328325 def __init__ (self , content = None , annotations = None , ** kwargs ):
329- super (Junk , self ).__init__ (** kwargs )
326+ super ().__init__ (** kwargs )
330327 self .content = content
331328 self .annotations = annotations or []
332329
@@ -336,14 +333,14 @@ def add_annotation(self, annot):
336333
337334class Span (BaseNode ):
338335 def __init__ (self , start , end , ** kwargs ):
339- super (Span , self ).__init__ (** kwargs )
336+ super ().__init__ (** kwargs )
340337 self .start = start
341338 self .end = end
342339
343340
344341class Annotation (SyntaxNode ):
345342 def __init__ (self , code , arguments = None , message = None , ** kwargs ):
346- super (Annotation , self ).__init__ (** kwargs )
343+ super ().__init__ (** kwargs )
347344 self .code = code
348345 self .arguments = arguments or []
349346 self .message = message
0 commit comments