rapydscript-ns 0.8.0
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.
- package/.agignore +1 -0
- package/.gitattributes +4 -0
- package/.github/workflows/ci.yml +38 -0
- package/.github/workflows/web-repl-page-deploy.yml +42 -0
- package/=template.pyj +5 -0
- package/CHANGELOG.md +456 -0
- package/CONTRIBUTORS +13 -0
- package/HACKING.md +103 -0
- package/LICENSE +24 -0
- package/README.md +2512 -0
- package/TODO.md +327 -0
- package/add-toc-to-readme +2 -0
- package/bin/export +75 -0
- package/bin/rapydscript +70 -0
- package/bin/web-repl-export +102 -0
- package/build +3 -0
- package/package.json +46 -0
- package/publish.py +37 -0
- package/release/baselib-plain-pretty.js +4370 -0
- package/release/baselib-plain-ugly.js +3 -0
- package/release/compiler.js +18394 -0
- package/release/signatures.json +31 -0
- package/session.vim +4 -0
- package/setup.cfg +2 -0
- package/src/ast.pyj +1356 -0
- package/src/baselib-builtins.pyj +279 -0
- package/src/baselib-containers.pyj +723 -0
- package/src/baselib-errors.pyj +37 -0
- package/src/baselib-internal.pyj +421 -0
- package/src/baselib-itertools.pyj +97 -0
- package/src/baselib-str.pyj +798 -0
- package/src/compiler.pyj +36 -0
- package/src/errors.pyj +30 -0
- package/src/lib/aes.pyj +646 -0
- package/src/lib/collections.pyj +695 -0
- package/src/lib/elementmaker.pyj +83 -0
- package/src/lib/encodings.pyj +126 -0
- package/src/lib/functools.pyj +148 -0
- package/src/lib/gettext.pyj +569 -0
- package/src/lib/itertools.pyj +580 -0
- package/src/lib/math.pyj +193 -0
- package/src/lib/numpy.pyj +2101 -0
- package/src/lib/operator.pyj +11 -0
- package/src/lib/pythonize.pyj +20 -0
- package/src/lib/random.pyj +118 -0
- package/src/lib/re.pyj +470 -0
- package/src/lib/traceback.pyj +63 -0
- package/src/lib/uuid.pyj +77 -0
- package/src/monaco-language-service/analyzer.js +526 -0
- package/src/monaco-language-service/builtins.js +543 -0
- package/src/monaco-language-service/completions.js +498 -0
- package/src/monaco-language-service/diagnostics.js +643 -0
- package/src/monaco-language-service/dts.js +550 -0
- package/src/monaco-language-service/hover.js +121 -0
- package/src/monaco-language-service/index.js +386 -0
- package/src/monaco-language-service/scope.js +162 -0
- package/src/monaco-language-service/signature.js +144 -0
- package/src/output/__init__.pyj +0 -0
- package/src/output/classes.pyj +296 -0
- package/src/output/codegen.pyj +492 -0
- package/src/output/comments.pyj +45 -0
- package/src/output/exceptions.pyj +105 -0
- package/src/output/functions.pyj +491 -0
- package/src/output/literals.pyj +109 -0
- package/src/output/loops.pyj +444 -0
- package/src/output/modules.pyj +329 -0
- package/src/output/operators.pyj +429 -0
- package/src/output/statements.pyj +463 -0
- package/src/output/stream.pyj +309 -0
- package/src/output/treeshake.pyj +182 -0
- package/src/output/utils.pyj +72 -0
- package/src/parse.pyj +3106 -0
- package/src/string_interpolation.pyj +72 -0
- package/src/tokenizer.pyj +702 -0
- package/src/unicode_aliases.pyj +576 -0
- package/src/utils.pyj +192 -0
- package/test/_import_one.pyj +37 -0
- package/test/_import_two/__init__.pyj +11 -0
- package/test/_import_two/level2/__init__.pyj +0 -0
- package/test/_import_two/level2/deep.pyj +4 -0
- package/test/_import_two/other.pyj +6 -0
- package/test/_import_two/sub.pyj +13 -0
- package/test/aes_vectors.pyj +421 -0
- package/test/annotations.pyj +80 -0
- package/test/baselib.pyj +319 -0
- package/test/classes.pyj +452 -0
- package/test/collections.pyj +152 -0
- package/test/decorators.pyj +77 -0
- package/test/dict_spread.pyj +76 -0
- package/test/docstrings.pyj +39 -0
- package/test/elementmaker_test.pyj +45 -0
- package/test/ellipsis.pyj +49 -0
- package/test/functions.pyj +151 -0
- package/test/generators.pyj +41 -0
- package/test/generic.pyj +370 -0
- package/test/imports.pyj +72 -0
- package/test/internationalization.pyj +73 -0
- package/test/lint.pyj +164 -0
- package/test/loops.pyj +85 -0
- package/test/numpy.pyj +734 -0
- package/test/omit_function_metadata.pyj +20 -0
- package/test/regexp.pyj +55 -0
- package/test/repl.pyj +121 -0
- package/test/scoped_flags.pyj +76 -0
- package/test/starargs.pyj +506 -0
- package/test/starred_assign.pyj +104 -0
- package/test/str.pyj +198 -0
- package/test/subscript_tuple.pyj +53 -0
- package/test/unit/fixtures/fibonacci_expected.js +46 -0
- package/test/unit/index.js +2989 -0
- package/test/unit/language-service-builtins.js +815 -0
- package/test/unit/language-service-completions.js +1067 -0
- package/test/unit/language-service-dts.js +543 -0
- package/test/unit/language-service-hover.js +455 -0
- package/test/unit/language-service-scope.js +833 -0
- package/test/unit/language-service-signature.js +458 -0
- package/test/unit/language-service.js +705 -0
- package/test/unit/run-language-service.js +41 -0
- package/test/unit/web-repl.js +484 -0
- package/tools/build-language-service.js +190 -0
- package/tools/cli.js +547 -0
- package/tools/compile.js +219 -0
- package/tools/compiler.js +108 -0
- package/tools/completer.js +131 -0
- package/tools/embedded_compiler.js +251 -0
- package/tools/export.js +316 -0
- package/tools/gettext.js +185 -0
- package/tools/ini.js +65 -0
- package/tools/lint.js +705 -0
- package/tools/msgfmt.js +187 -0
- package/tools/repl.js +223 -0
- package/tools/self.js +162 -0
- package/tools/test.js +118 -0
- package/tools/utils.js +128 -0
- package/tools/web_repl.js +95 -0
- package/try +41 -0
- package/web-repl/env.js +74 -0
- package/web-repl/index.html +163 -0
- package/web-repl/language-service.js +4084 -0
- package/web-repl/main.js +254 -0
- package/web-repl/prism.css +139 -0
- package/web-repl/prism.js +113 -0
- package/web-repl/rapydscript.js +435 -0
- package/web-repl/sha1.js +25 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# vim:fileencoding=utf-8
|
|
2
|
+
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
3
|
+
# globals: writefile
|
|
4
|
+
from __python__ import hash_literals
|
|
5
|
+
|
|
6
|
+
from output.statements import declare_vars, display_body
|
|
7
|
+
from output.stream import OutputStream
|
|
8
|
+
from output.utils import create_doctring
|
|
9
|
+
from output.comments import print_comments, output_comments
|
|
10
|
+
from output.functions import set_module_name
|
|
11
|
+
from parse import get_compiler_version
|
|
12
|
+
from utils import cache_file_name, has_prop
|
|
13
|
+
from ast import (AST_Function, AST_Class, AST_SimpleStatement, AST_Assign,
|
|
14
|
+
AST_SymbolRef, is_node_type)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def write_imports(module, output):
|
|
18
|
+
imports = []
|
|
19
|
+
for import_id in Object.keys(module.imports):
|
|
20
|
+
imports.push(module.imports[import_id])
|
|
21
|
+
imports.sort(def(a, b):
|
|
22
|
+
a, b = a.import_order, b.import_order
|
|
23
|
+
return -1 if a < b else (1 if a > b else 0)
|
|
24
|
+
)
|
|
25
|
+
if imports.length > 1:
|
|
26
|
+
output.indent()
|
|
27
|
+
output.print('var ρσ_modules = {};')
|
|
28
|
+
output.newline()
|
|
29
|
+
|
|
30
|
+
# Declare all variable names exported from the modules as global symbols
|
|
31
|
+
nonlocalvars = {}
|
|
32
|
+
for module_ in imports:
|
|
33
|
+
for name in module_.nonlocalvars:
|
|
34
|
+
nonlocalvars[name] = True
|
|
35
|
+
nonlocalvars = Object.getOwnPropertyNames(nonlocalvars).join(', ')
|
|
36
|
+
if nonlocalvars.length:
|
|
37
|
+
output.indent()
|
|
38
|
+
output.print('var ' + nonlocalvars)
|
|
39
|
+
output.semicolon()
|
|
40
|
+
output.newline()
|
|
41
|
+
|
|
42
|
+
# Create the module objects
|
|
43
|
+
for module_ in imports:
|
|
44
|
+
module_id = module_.module_id
|
|
45
|
+
if module_id is not '__main__':
|
|
46
|
+
output.indent()
|
|
47
|
+
if module_id.indexOf('.') is -1:
|
|
48
|
+
output.print('ρσ_modules.' + module_id)
|
|
49
|
+
else:
|
|
50
|
+
output.print('ρσ_modules["' + module_id + '"]')
|
|
51
|
+
output.space(), output.print('='), output.space(), output.print('{}')
|
|
52
|
+
output.end_statement()
|
|
53
|
+
|
|
54
|
+
# Output module code
|
|
55
|
+
for module_ in imports:
|
|
56
|
+
if module_.module_id is not '__main__':
|
|
57
|
+
print_module(module_, output)
|
|
58
|
+
|
|
59
|
+
def write_main_name(output):
|
|
60
|
+
if output.options.write_name:
|
|
61
|
+
output.newline()
|
|
62
|
+
output.indent()
|
|
63
|
+
output.print('var __name__ = "__main__"')
|
|
64
|
+
output.semicolon()
|
|
65
|
+
output.newline()
|
|
66
|
+
output.newline()
|
|
67
|
+
|
|
68
|
+
def const_decl(js_version):
|
|
69
|
+
# return 'const' if js_version > 5 else 'var'
|
|
70
|
+
# Workaround for bug in Chrome eval(). eval() barfs if it sees const before a function.
|
|
71
|
+
# See https://github.com/kovidgoyal/rapydscript-ng/issues/29
|
|
72
|
+
return 'var'
|
|
73
|
+
|
|
74
|
+
def declare_exports(module_id, exports, output, docstrings):
|
|
75
|
+
seen = {}
|
|
76
|
+
if output.options.keep_docstrings and docstrings and docstrings.length:
|
|
77
|
+
exports.push({'name':'__doc__', 'refname': 'ρσ_module_doc__'})
|
|
78
|
+
output.newline(), output.indent()
|
|
79
|
+
v = const_decl(output.options.js_version)
|
|
80
|
+
output.assign(v + ' ρσ_module_doc__'), output.print(JSON.stringify(create_doctring(docstrings)))
|
|
81
|
+
output.end_statement()
|
|
82
|
+
output.newline()
|
|
83
|
+
for symbol in exports:
|
|
84
|
+
if not Object.prototype.hasOwnProperty.call(seen, symbol.name):
|
|
85
|
+
output.indent()
|
|
86
|
+
if module_id.indexOf('.') is -1:
|
|
87
|
+
output.print('ρσ_modules.' + module_id + '.' + symbol.name)
|
|
88
|
+
else:
|
|
89
|
+
output.print('ρσ_modules["' + module_id + '"].' + symbol.name)
|
|
90
|
+
output.space(), output.print('='), output.space(), output.print(symbol.refname or symbol.name)
|
|
91
|
+
seen[symbol.name] = True
|
|
92
|
+
output.end_statement()
|
|
93
|
+
|
|
94
|
+
def _inject_pythonize_strings(output):
|
|
95
|
+
str_funcs = ('capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase title'
|
|
96
|
+
' center count endswith startswith find rfind index rindex format join ljust rjust'
|
|
97
|
+
' partition rpartition splitlines zfill').split(' ')
|
|
98
|
+
output.newline()
|
|
99
|
+
output.indent()
|
|
100
|
+
output.print('(function(){var _f=' + JSON.stringify(str_funcs) + ';for(var _i=0;_i<_f.length;_i++)String.prototype[_f[_i]]=\u03c1\u03c3_str.prototype[_f[_i]];})()')
|
|
101
|
+
output.end_statement()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def prologue(module, output):
|
|
105
|
+
# any code that should appear before the main body
|
|
106
|
+
if output.options.omit_baselib:
|
|
107
|
+
if output.options.pythonize_strings:
|
|
108
|
+
_inject_pythonize_strings(output)
|
|
109
|
+
return
|
|
110
|
+
output.indent()
|
|
111
|
+
v = const_decl(output.options.js_version)
|
|
112
|
+
output.print(v), output.space()
|
|
113
|
+
output.spaced.apply(output, (('ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256"'.split(' '))))
|
|
114
|
+
output.end_statement()
|
|
115
|
+
output.indent(), output.print(v), output.space()
|
|
116
|
+
output.spaced.apply(output, (('ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256"'.split(' '))))
|
|
117
|
+
output.end_statement()
|
|
118
|
+
output.indent(), output.spaced('var', 'ρσ_cond_temp,', 'ρσ_expr_temp,', 'ρσ_last_exception'), output.end_statement()
|
|
119
|
+
output.indent(), output.spaced('var', 'ρσ_object_counter', '=', '0'), output.end_statement()
|
|
120
|
+
if output.options.js_version > 5:
|
|
121
|
+
# Needed for Chrome < 51 and Edge as of August 2016
|
|
122
|
+
output.indent(), output.spaced('if(', 'typeof', 'HTMLCollection', '!==', '"undefined"', '&&', 'typeof', 'Symbol', '===', '"function")',
|
|
123
|
+
'NodeList.prototype[Symbol.iterator]', '=', 'HTMLCollection.prototype[Symbol.iterator]', '=', 'NamedNodeMap.prototype[Symbol.iterator]', '=', 'Array.prototype[Symbol.iterator]')
|
|
124
|
+
output.end_statement()
|
|
125
|
+
needs_yield = output.options.js_version < 6 and module.baselib['yield']
|
|
126
|
+
if needs_yield:
|
|
127
|
+
output.dump_yield()
|
|
128
|
+
# output the baselib
|
|
129
|
+
if not output.options.baselib_plain:
|
|
130
|
+
raise ValueError('The baselib is missing! Remember to set the baselib_plain field on the options for OutputStream')
|
|
131
|
+
output.print(output.options.baselib_plain)
|
|
132
|
+
output.end_statement()
|
|
133
|
+
if output.options.pythonize_strings:
|
|
134
|
+
_inject_pythonize_strings(output)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def print_top_level(self, output):
|
|
138
|
+
set_module_name(self.module_id)
|
|
139
|
+
is_main = self.module_id is '__main__'
|
|
140
|
+
|
|
141
|
+
def write_docstrings():
|
|
142
|
+
if is_main and output.options.keep_docstrings and self.docstrings and self.docstrings.length:
|
|
143
|
+
output.newline(), output.indent()
|
|
144
|
+
v = const_decl(output.options.js_version)
|
|
145
|
+
output.assign(v + ' ρσ_module_doc__'), output.print(JSON.stringify(create_doctring(self.docstrings)))
|
|
146
|
+
output.end_statement()
|
|
147
|
+
|
|
148
|
+
if output.options.private_scope and is_main:
|
|
149
|
+
output.with_parens(def():
|
|
150
|
+
output.print("function()")
|
|
151
|
+
output.with_block(def():
|
|
152
|
+
# strict mode is more verbose about errors, and less forgiving about them
|
|
153
|
+
# kind of like Python
|
|
154
|
+
output.indent()
|
|
155
|
+
output.print('"use strict"')
|
|
156
|
+
output.end_statement()
|
|
157
|
+
|
|
158
|
+
prologue(self, output)
|
|
159
|
+
write_imports(self, output)
|
|
160
|
+
output.newline()
|
|
161
|
+
output.indent()
|
|
162
|
+
output.with_parens(def():
|
|
163
|
+
output.print("function()")
|
|
164
|
+
output.with_block(def():
|
|
165
|
+
write_main_name(output)
|
|
166
|
+
output.newline()
|
|
167
|
+
declare_vars(self.localvars, output)
|
|
168
|
+
display_body(self.body, True, output)
|
|
169
|
+
output.newline()
|
|
170
|
+
write_docstrings()
|
|
171
|
+
if self.comments_after and self.comments_after.length:
|
|
172
|
+
output.indent()
|
|
173
|
+
output_comments(self.comments_after, output)
|
|
174
|
+
output.newline()
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
output.print("();")
|
|
178
|
+
output.newline()
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
output.print("();")
|
|
182
|
+
output.print("")
|
|
183
|
+
else:
|
|
184
|
+
if is_main:
|
|
185
|
+
prologue(self, output)
|
|
186
|
+
write_imports(self, output)
|
|
187
|
+
write_main_name(output)
|
|
188
|
+
|
|
189
|
+
declare_vars(self.localvars, output)
|
|
190
|
+
display_body(self.body, True, output)
|
|
191
|
+
if self.comments_after and self.comments_after.length:
|
|
192
|
+
output_comments(self.comments_after, output)
|
|
193
|
+
set_module_name()
|
|
194
|
+
|
|
195
|
+
def get_top_level_name(stmt):
|
|
196
|
+
if is_node_type(stmt, AST_Function) or is_node_type(stmt, AST_Class):
|
|
197
|
+
if stmt.name:
|
|
198
|
+
return stmt.name.name
|
|
199
|
+
return None
|
|
200
|
+
if is_node_type(stmt, AST_SimpleStatement):
|
|
201
|
+
body = stmt.body
|
|
202
|
+
if is_node_type(body, AST_Assign):
|
|
203
|
+
lhs = body.left
|
|
204
|
+
if is_node_type(lhs, AST_SymbolRef):
|
|
205
|
+
return lhs.name
|
|
206
|
+
return None
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def filter_body_for_tree_shaking(body, needed):
|
|
210
|
+
result = []
|
|
211
|
+
for stmt in body:
|
|
212
|
+
name = get_top_level_name(stmt)
|
|
213
|
+
if name is None or has_prop(needed, name):
|
|
214
|
+
result.push(stmt)
|
|
215
|
+
return result
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def filter_exports_for_tree_shaking(exports, needed):
|
|
219
|
+
result = []
|
|
220
|
+
for sym in exports:
|
|
221
|
+
if has_prop(needed, sym.name):
|
|
222
|
+
result.push(sym)
|
|
223
|
+
return result
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def print_module(self, output):
|
|
227
|
+
set_module_name(self.module_id)
|
|
228
|
+
|
|
229
|
+
def output_module(output):
|
|
230
|
+
body = filter_body_for_tree_shaking(self.body, self.needed_names) if self.needed_names else self.body
|
|
231
|
+
exports = filter_exports_for_tree_shaking(self.exports, self.needed_names) if self.needed_names else self.exports
|
|
232
|
+
declare_vars(self.localvars, output)
|
|
233
|
+
display_body(body, True, output)
|
|
234
|
+
declare_exports(self.module_id, exports, output, self.docstrings)
|
|
235
|
+
|
|
236
|
+
output.newline()
|
|
237
|
+
output.indent()
|
|
238
|
+
output.with_parens(def():
|
|
239
|
+
output.print("function()")
|
|
240
|
+
output.with_block(def():
|
|
241
|
+
# dump the logic of this module
|
|
242
|
+
print_comments(self, output)
|
|
243
|
+
if output.options.write_name:
|
|
244
|
+
output.indent()
|
|
245
|
+
output.print('var ')
|
|
246
|
+
output.assign('__name__')
|
|
247
|
+
output.print('"' + self.module_id + '"')
|
|
248
|
+
output.semicolon()
|
|
249
|
+
output.newline()
|
|
250
|
+
def output_key(beautify, keep_docstrings, js_version):
|
|
251
|
+
return 'beautify:' + beautify + ' keep_docstrings:' + keep_docstrings + ' js_version:' + js_version
|
|
252
|
+
okey = output_key(output.options.beautify, output.options.keep_docstrings, output.options.js_version)
|
|
253
|
+
if self.is_cached and okey in self.outputs and not self.needed_names:
|
|
254
|
+
output.print(self.outputs[okey])
|
|
255
|
+
else:
|
|
256
|
+
output_module(output)
|
|
257
|
+
if self.srchash and self.filename and not self.needed_names:
|
|
258
|
+
cached = {
|
|
259
|
+
'version':get_compiler_version(), 'signature':self.srchash, 'classes': {}, 'baselib':self.baselib,
|
|
260
|
+
'nonlocalvars':self.nonlocalvars, 'imported_module_ids':self.imported_module_ids, 'exports':[],
|
|
261
|
+
'outputs':{}, 'discard_asserts': v'!!output.options.discard_asserts'
|
|
262
|
+
}
|
|
263
|
+
for cname in Object.keys(self.classes):
|
|
264
|
+
cobj = self.classes[cname]
|
|
265
|
+
cached.classes[cname] = {'name':{'name':cobj.name.name}, 'static':cobj.static, 'bound':cobj.bound, 'classvars':cobj.classvars}
|
|
266
|
+
for symdef in self.exports:
|
|
267
|
+
cached.exports.push({'name':symdef.name})
|
|
268
|
+
for beautify in [True, False]:
|
|
269
|
+
for keep_docstrings in [True, False]:
|
|
270
|
+
for js_version in [5, 6]:
|
|
271
|
+
co = OutputStream({
|
|
272
|
+
'beautify':beautify, 'keep_docstrings':keep_docstrings,
|
|
273
|
+
'js_version':js_version, 'private_scope':False,
|
|
274
|
+
'write_name':False, 'discard_asserts':output.options.discard_asserts
|
|
275
|
+
})
|
|
276
|
+
co.with_indent(output.indentation(), def():
|
|
277
|
+
output_module(co)
|
|
278
|
+
)
|
|
279
|
+
raw = co.get()
|
|
280
|
+
cached.outputs[output_key(beautify, keep_docstrings, js_version)] = raw
|
|
281
|
+
try:
|
|
282
|
+
writefile(cache_file_name(self.filename, output.options.module_cache_dir), JSON.stringify(cached, None, '\t'))
|
|
283
|
+
except Error as e:
|
|
284
|
+
console.error('Failed to write output cache file:', self.filename + '-cached', 'with error:', e)
|
|
285
|
+
)
|
|
286
|
+
)
|
|
287
|
+
output.print("()")
|
|
288
|
+
output.semicolon()
|
|
289
|
+
output.newline()
|
|
290
|
+
set_module_name()
|
|
291
|
+
|
|
292
|
+
def print_imports(container, output):
|
|
293
|
+
is_first_aname = True
|
|
294
|
+
def add_aname(aname, key, from_import):
|
|
295
|
+
nonlocal is_first_aname
|
|
296
|
+
if is_first_aname:
|
|
297
|
+
is_first_aname = False
|
|
298
|
+
else:
|
|
299
|
+
output.indent()
|
|
300
|
+
output.print('var ')
|
|
301
|
+
output.assign(aname)
|
|
302
|
+
if key.indexOf('.') is -1:
|
|
303
|
+
output.print('ρσ_modules.'), output.print(key)
|
|
304
|
+
else:
|
|
305
|
+
output.print('ρσ_modules["'), output.print(key), output.print('"]')
|
|
306
|
+
if from_import:
|
|
307
|
+
output.print('.')
|
|
308
|
+
output.print(from_import)
|
|
309
|
+
output.end_statement()
|
|
310
|
+
|
|
311
|
+
for self in container.imports:
|
|
312
|
+
if self.argnames:
|
|
313
|
+
# A from import
|
|
314
|
+
for argname in self.argnames:
|
|
315
|
+
akey = argname.alias.name if argname.alias else argname.name
|
|
316
|
+
add_aname(akey, self.key, argname.name)
|
|
317
|
+
else:
|
|
318
|
+
if self.alias:
|
|
319
|
+
add_aname(self.alias.name, self.key, False)
|
|
320
|
+
else:
|
|
321
|
+
parts = self.key.split('.')
|
|
322
|
+
for i, part in enumerate(parts):
|
|
323
|
+
if i is 0:
|
|
324
|
+
add_aname(part, part, False)
|
|
325
|
+
else:
|
|
326
|
+
q = parts[:i+1].join('.')
|
|
327
|
+
output.indent()
|
|
328
|
+
output.spaced(q, '=', 'ρσ_modules["' + q + '"]')
|
|
329
|
+
output.end_statement()
|