<s> __version__ = '<STR_LIT>' <EOL> import os , sys , subprocess , hashlib , time <EOL> import tempfile <EOL> import webbrowser <EOL> RUSTHON_LIB_ROOT = os . path . dirname ( unicode ( os . path . realpath ( __file__ ) , sys . getfilesystemencoding ( ) ) ) <EOL> GO_EXE = None <EOL> if os . path . isfile ( '<STR_LIT>' ) : <EOL> GO_EXE = '<STR_LIT>' <EOL> elif os . path . isfile ( '<STR_LIT>' ) : <EOL> GO_EXE = '<STR_LIT>' <EOL> elif os . path . isfile ( os . path . expanduser ( '<STR_LIT>' ) ) : <EOL> GO_EXE = os . path . expanduser ( '<STR_LIT>' ) <EOL> nodewebkit_runnable = False <EOL> nodewebkit = os . path . expanduser ( '<STR_LIT>' ) <EOL> if os . path . isfile ( nodewebkit ) : nodewebkit_runnable = True <EOL> else : <EOL> nodewebkit = os . path . expanduser ( '<STR_LIT>' ) <EOL> if os . path . isfile ( nodewebkit ) : nodewebkit_runnable = True <EOL> if sys . platform == '<STR_LIT>' : <EOL> nodewebkit = os . path . expanduser ( '<STR_LIT>' ) <EOL> if os . path . isfile ( nodewebkit ) : <EOL> nodewebkit_runnable = True <EOL> CHROME_EXE = None <EOL> nodejs_exe = '<STR_LIT>' <EOL> if os . path . isfile ( '<STR_LIT>' ) : <EOL> if os . path . isfile ( '<STR_LIT>' ) : <EOL> if os . path . realpath ( '<STR_LIT>' ) == '<STR_LIT>' : <EOL> nodejs_exe = '<STR_LIT>' <EOL> JS_WEBWORKER_HEADER = u'''<STR_LIT>''' <EOL> OPENSHIFT_PY = [ <EOL> u'''<STR_LIT>''' , <EOL> u'''<STR_LIT>''' ] <EOL> def compile_js ( script , module_path , main_name = '<STR_LIT>' , directjs = False , directloops = False ) : <EOL> '''<STR_LIT>''' <EOL> fastjs = True <EOL> result = { } <EOL> pyjs = python_to_pythonjs ( <EOL> script , <EOL> module_path = module_path , <EOL> fast_javascript = fastjs , <EOL> pure_javascript = directjs <EOL> ) <EOL> if isinstance ( pyjs , dict ) : <EOL> workers = [ ] <EOL> mainjs = None <EOL> for jsfile in pyjs : <EOL> js = translate_to_javascript ( <EOL> pyjs [ jsfile ] , <EOL> webworker = jsfile == '<STR_LIT>' , <EOL> requirejs = False , <EOL> insert_runtime = False , <EOL> fast_javascript = fastjs , <EOL> fast_loops = directloops , <EOL> runtime_checks = '<STR_LIT>' not in sys . argv <EOL> ) <EOL> result [ jsfile ] = js <EOL> if jsfile == '<STR_LIT>' : <EOL> workers . append ( js ) <EOL> else : <EOL> mainjs = jsfile <EOL> src = [ '<STR_LIT>' ] <EOL> a = JS_WEBWORKER_HEADER . encode ( '<STR_LIT:utf-8>' ) + workers [ <NUM_LIT:0> ] <EOL> for line in a . strip ( ) . splitlines ( ) : <EOL> src . append ( '<STR_LIT>' % line . replace ( '<STR_LIT:">' , '<STR_LIT>' ) ) <EOL> src . append ( '<STR_LIT:]>' ) <EOL> src . append ( result [ mainjs ] ) <EOL> result [ mainjs ] = '<STR_LIT:\n>' . join ( src ) <EOL> else : <EOL> code = translate_to_javascript ( <EOL> pyjs , <EOL> as_module = '<STR_LIT>' in sys . argv , <EOL> requirejs = False , <EOL> insert_runtime = False , <EOL> fast_javascript = fastjs , <EOL> fast_loops = directloops , <EOL> runtime_checks = '<STR_LIT>' not in sys . argv <EOL> ) <EOL> if isinstance ( code , dict ) : <EOL> result . update ( code ) <EOL> else : <EOL> result [ '<STR_LIT>' ] = code <EOL> if main_name != '<STR_LIT>' : <EOL> result [ main_name ] = result . pop ( '<STR_LIT>' ) <EOL> return result <EOL> def compile_java ( javafiles ) : <EOL> assert '<STR_LIT>' in os . environ <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> cmd = [ '<STR_LIT>' ] <EOL> cmd . extend ( javafiles ) <EOL> print ( '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> subprocess . check_call ( cmd , cwd = tmpdir ) <EOL> classfiles = [ jfile . replace ( '<STR_LIT>' , '<STR_LIT>' ) for jfile in javafiles ] <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> cmd . extend ( classfiles ) <EOL> print ( '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> subprocess . check_call ( cmd , cwd = tmpdir ) <EOL> jarfile = os . path . join ( tmpdir , '<STR_LIT>' ) <EOL> assert os . path . isfile ( jarfile ) <EOL> return { '<STR_LIT>' : classfiles , '<STR_LIT>' : jarfile } <EOL> def compile_giws_bindings ( xml ) : <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> tmpfile = os . path . join ( tmpdir , '<STR_LIT>' ) <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( xml ) <EOL> cmd = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + tmpfile , <EOL> '<STR_LIT>' + tmpdir , <EOL> '<STR_LIT>' , <EOL> ] <EOL> proc = subprocess . Popen ( cmd , stderr = subprocess . PIPE , stdout = subprocess . PIPE ) <EOL> proc . wait ( ) <EOL> if proc . returncode : <EOL> raise RuntimeError ( proc . stderr . read ( ) ) <EOL> else : <EOL> headers = [ ] <EOL> impls = [ ] <EOL> for line in proc . stdout . read ( ) . splitlines ( ) : <EOL> if line . endswith ( '<STR_LIT>' ) : <EOL> name = line . split ( ) [ <NUM_LIT:0> ] <EOL> if name . endswith ( '<STR_LIT>' ) : <EOL> headers . append ( name ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> impls . append ( name ) <EOL> code = [ ] <EOL> for header in headers : <EOL> data = open ( os . path . join ( tmpdir , header ) , '<STR_LIT:rb>' ) . read ( ) <EOL> code . append ( data ) <EOL> for impl in impls : <EOL> data = open ( os . path . join ( tmpdir , impl ) , '<STR_LIT:rb>' ) . read ( ) <EOL> lines = [ '<STR_LIT>' % impl ] <EOL> includes = [ ] <EOL> for line in data . splitlines ( ) : <EOL> if line . startswith ( '<STR_LIT>' ) : <EOL> includes . append ( line ) <EOL> else : <EOL> lines . append ( line ) <EOL> code . append ( '<STR_LIT:\n>' . join ( lines ) ) <EOL> return '<STR_LIT:\n>' . join ( code ) <EOL> def java_to_rusthon ( input ) : <EOL> j2pybin = '<STR_LIT>' <EOL> if os . path . isfile ( os . path . expanduser ( '<STR_LIT>' ) ) : <EOL> j2pybin = os . path . expanduser ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' % j2pybin ) <EOL> j2py = subprocess . Popen ( [ j2pybin , '<STR_LIT>' ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) <EOL> stdout , stderr = j2py . communicate ( input ) <EOL> if stderr : raise RuntimeError ( stderr ) <EOL> if j2py . returncode : raise RuntimeError ( '<STR_LIT>' ) <EOL> print ( stdout ) <EOL> print ( '<STR_LIT>' ) <EOL> rcode = typedpython . transform_source ( stdout . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:\t>' ) ) <EOL> print ( rcode ) <EOL> print ( '<STR_LIT>' ) <EOL> return rcode <EOL> def new_module ( ) : <EOL> return { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT:c>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT:html>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> } <EOL> def import_md ( url , modules = None , index_offset = <NUM_LIT:0> , force_tagname = None ) : <EOL> assert modules is not None <EOL> doc = [ ] <EOL> code = [ ] <EOL> code_links = [ ] <EOL> code_idirs = [ ] <EOL> code_defines = [ ] <EOL> lang = False <EOL> in_code = False <EOL> index = <NUM_LIT:0> <EOL> prevline = None <EOL> tag = force_tagname or None <EOL> fences = <NUM_LIT:0> <EOL> base_path , markdown_name = os . path . split ( url ) <EOL> import codecs <EOL> data = codecs . open ( url , '<STR_LIT:r>' , '<STR_LIT:utf-8>' ) . read ( ) <EOL> for line in data . splitlines ( ) : <EOL> if line . startswith ( '<STR_LIT>' ) : <EOL> code_links . append ( os . path . expanduser ( line . split ( '<STR_LIT::>' ) [ - <NUM_LIT:1> ] ) ) <EOL> elif line . startswith ( '<STR_LIT>' ) : <EOL> code_idirs . append ( os . path . expanduser ( line . split ( '<STR_LIT::>' ) [ - <NUM_LIT:1> ] ) ) <EOL> elif line . startswith ( '<STR_LIT>' ) : <EOL> code_defines . extend ( line . split ( '<STR_LIT::>' ) [ - <NUM_LIT:1> ] . strip ( ) . split ( ) ) <EOL> elif line . strip ( ) . startswith ( '<STR_LIT>' ) : <EOL> fences += <NUM_LIT:1> <EOL> if in_code : <EOL> if lang : <EOL> if lang == '<STR_LIT>' and '<STR_LIT>' in code : <EOL> rusthonpy = [ ] <EOL> for rln in open ( __file__ , '<STR_LIT:rb>' ) . read ( ) . splitlines ( ) : <EOL> if rln == '<STR_LIT>' : <EOL> break <EOL> else : <EOL> rusthonpy . append ( rln ) <EOL> rusthonpy = '<STR_LIT:\n>' . join ( rusthonpy ) <EOL> utfheader = u'<STR_LIT>' <EOL> code . insert ( <NUM_LIT:0> , utfheader + BOOTSTRAPED + '<STR_LIT:\n>' + rusthonpy . decode ( '<STR_LIT:utf-8>' ) ) <EOL> code . pop ( code . index ( '<STR_LIT>' ) ) <EOL> p , n = os . path . split ( url ) <EOL> mod = { <EOL> '<STR_LIT:path>' : p , <EOL> '<STR_LIT>' : url , <EOL> '<STR_LIT:code>' : '<STR_LIT:\n>' . join ( code ) , <EOL> '<STR_LIT:index>' : index + index_offset , <EOL> '<STR_LIT>' : tag , <EOL> '<STR_LIT>' : code_links , <EOL> '<STR_LIT>' : code_idirs , <EOL> '<STR_LIT>' : code_defines , <EOL> } <EOL> if tag and '<STR_LIT:.>' in tag : <EOL> ext = tag . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] . lower ( ) <EOL> mod [ '<STR_LIT:name>' ] = tag <EOL> modules [ lang ] . append ( mod ) <EOL> in_code = False <EOL> code = [ ] <EOL> code_links = [ ] <EOL> code_idirs = [ ] <EOL> index += <NUM_LIT:1> <EOL> else : <EOL> in_code = True <EOL> if prevline and prevline . strip ( ) . startswith ( '<STR_LIT:@>' ) : <EOL> tag = prevline . strip ( ) [ <NUM_LIT:1> : ] <EOL> else : <EOL> tag = None <EOL> lang = line . strip ( ) . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] <EOL> elif in_code : <EOL> code . append ( line ) <EOL> else : <EOL> if line . startswith ( '<STR_LIT>' ) and '<STR_LIT>' in line and line . count ( '<STR_LIT:[>' ) == <NUM_LIT:1> and line . count ( '<STR_LIT:]>' ) == <NUM_LIT:1> and line . count ( '<STR_LIT:(>' ) == <NUM_LIT:1> and line . count ( '<STR_LIT:)>' ) == <NUM_LIT:1> : <EOL> submarkdown = line . split ( '<STR_LIT:(>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:)>' ) [ <NUM_LIT:0> ] . strip ( ) <EOL> subpath = os . path . join ( base_path , submarkdown ) <EOL> if not os . path . isfile ( subpath ) : <EOL> raise RuntimeError ( '<STR_LIT>' + subpath ) <EOL> index += import_md ( subpath , modules , index_offset = index ) <EOL> doc . append ( line ) <EOL> prevline = line <EOL> modules [ '<STR_LIT>' ] += '<STR_LIT:\n>' . join ( doc ) <EOL> if fences % <NUM_LIT:2> : <EOL> raise SyntaxError ( '<STR_LIT>' % url ) <EOL> return index <EOL> def hack_nim_stdlib ( code ) : <EOL> '''<STR_LIT>''' <EOL> out = [ ] <EOL> for line in code . splitlines ( ) : <EOL> if '<STR_LIT>' in line or '<STR_LIT>' in line or '<STR_LIT>' in line : <EOL> pass <EOL> else : <EOL> out . append ( line ) <EOL> return '<STR_LIT:\n>' . join ( out ) <EOL> def is_restricted_bash ( line ) : <EOL> if '<STR_LIT>' in line : <EOL> return False <EOL> if "<STR_LIT>" in line : <EOL> return False <EOL> if '<STR_LIT:">' in line : <EOL> return False <EOL> okcmds = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ] <EOL> cmd = line . split ( ) [ <NUM_LIT:0> ] <EOL> if cmd == '<STR_LIT>' : cmd = line . split ( ) [ <NUM_LIT:1> ] <EOL> if cmd in okcmds : <EOL> return True <EOL> else : <EOL> return False <EOL> GITCACHE = os . path . expanduser ( '<STR_LIT>' ) <EOL> def build ( modules , module_path , datadirs = None ) : <EOL> if '<STR_LIT>' in sys . argv : <EOL> raise RuntimeError ( modules ) <EOL> output = { '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT:c>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT:html>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : datadirs , '<STR_LIT>' : { } } <EOL> python_main = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : [ ] } <EOL> go_main = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:source>' : [ ] } <EOL> tagged = { } <EOL> link = [ ] <EOL> giws = [ ] <EOL> java2rusthon = [ ] <EOL> nim_wrappers = [ ] <EOL> libdl = False <EOL> cached_json = { } <EOL> gyp_builds = { } <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in mod and mod [ '<STR_LIT>' ] : <EOL> tag = mod [ '<STR_LIT>' ] <EOL> if tag . startswith ( '<STR_LIT>' ) or tag . startswith ( '<STR_LIT>' ) : <EOL> if not tag . endswith ( '<STR_LIT>' ) : <EOL> raise SyntaxError ( '<STR_LIT>' + tag ) <EOL> if not os . path . isdir ( GITCACHE ) : <EOL> print '<STR_LIT>' + GITCACHE <EOL> os . mkdir ( GITCACHE ) <EOL> gitname = tag . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] [ : - <NUM_LIT:4> ] <EOL> projectdir = os . path . join ( GITCACHE , gitname ) <EOL> rebuild = True <EOL> if gitname not in os . listdir ( GITCACHE ) : <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' , tag ] <EOL> subprocess . check_call ( cmd , cwd = GITCACHE ) <EOL> elif '<STR_LIT>' in sys . argv : <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> subprocess . check_call ( cmd , cwd = projectdir ) <EOL> else : <EOL> rebuild = False <EOL> if rebuild or '<STR_LIT>' in sys . argv : <EOL> print '<STR_LIT>' + tag <EOL> for line in mod [ '<STR_LIT:code>' ] . splitlines ( ) : <EOL> if not line . strip ( ) : continue <EOL> if not is_restricted_bash ( line ) : <EOL> raise SyntaxError ( '<STR_LIT>' + line ) <EOL> else : <EOL> print '<STR_LIT>' + line <EOL> subprocess . check_call ( line . split ( ) , cwd = projectdir ) <EOL> else : <EOL> output [ '<STR_LIT>' ] [ tag ] = mod [ '<STR_LIT:code>' ] <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in mod and mod [ '<STR_LIT>' ] : <EOL> if not mod [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> output [ '<STR_LIT>' ] [ '<STR_LIT>' ] = mod [ '<STR_LIT:code>' ] <EOL> gypcfg = json . loads ( mod [ '<STR_LIT:code>' ] . replace ( "<STR_LIT:'>" , '<STR_LIT:">' ) ) <EOL> for gtarget in gypcfg [ '<STR_LIT>' ] : <EOL> for gsrc in gtarget [ '<STR_LIT>' ] : <EOL> gyp_builds [ gsrc ] = { <EOL> '<STR_LIT>' : mod [ '<STR_LIT:code>' ] , <EOL> '<STR_LIT:src>' : None <EOL> } <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in mod and mod [ '<STR_LIT>' ] : <EOL> tagged [ mod [ '<STR_LIT>' ] ] = mod [ '<STR_LIT:code>' ] <EOL> if '<STR_LIT:.>' in mod [ '<STR_LIT>' ] : <EOL> output [ '<STR_LIT>' ] [ mod [ '<STR_LIT>' ] ] = mod [ '<STR_LIT:code>' ] <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> cached_json [ mod [ '<STR_LIT:name>' ] ] = mod [ '<STR_LIT:code>' ] <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> tmpelm = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> tmpjs = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> open ( tmpelm , '<STR_LIT:wb>' ) . write ( mod [ '<STR_LIT:code>' ] ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , tmpelm , '<STR_LIT>' , tmpjs ] ) <EOL> elmdata = open ( tmpjs , '<STR_LIT:rb>' ) . read ( ) <EOL> output [ '<STR_LIT>' ] [ mod [ '<STR_LIT>' ] ] = elmdata <EOL> tagged [ mod [ '<STR_LIT>' ] ] = elmdata <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> tmpcoff = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> tmpjs = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> open ( tmpcoff , '<STR_LIT:wb>' ) . write ( mod [ '<STR_LIT:code>' ] ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , tmpjs , tmpcoff ] ) <EOL> coffdata = open ( tmpjs + '<STR_LIT>' , '<STR_LIT:rb>' ) . read ( ) <EOL> output [ '<STR_LIT>' ] [ mod [ '<STR_LIT>' ] ] = coffdata <EOL> tagged [ mod [ '<STR_LIT>' ] ] = coffdata <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> tmprapyd = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> tmpjs = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> open ( tmprapyd , '<STR_LIT:wb>' ) . write ( mod [ '<STR_LIT:code>' ] . encode ( '<STR_LIT:utf-8>' ) ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , tmprapyd , '<STR_LIT>' , '<STR_LIT>' , tmpjs ] ) <EOL> rapydata = open ( tmpjs , '<STR_LIT:rb>' ) . read ( ) <EOL> output [ '<STR_LIT>' ] [ mod [ '<STR_LIT>' ] ] = rapydata <EOL> tagged [ mod [ '<STR_LIT>' ] ] = rapydata <EOL> if modules [ '<STR_LIT>' ] : <EOL> libdl = True <EOL> compile_nim_lib = True <EOL> nimbin = os . path . expanduser ( '<STR_LIT>' ) <EOL> niminclude = os . path . expanduser ( '<STR_LIT>' ) <EOL> if os . path . isfile ( nimbin ) : <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> if mod [ '<STR_LIT>' ] : <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> else : <EOL> tmpfile = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> nimsrc = mod [ '<STR_LIT:code>' ] . replace ( '<STR_LIT:\t>' , '<STR_LIT:U+0020>' ) <EOL> gen_nim_wrappers ( nimsrc , nim_wrappers ) <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( nimsrc ) <EOL> if compile_nim_lib : <EOL> cmd = [ nimbin , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> else : <EOL> cmd = [ <EOL> nimbin , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> if '<STR_LIT>' in nimsrc : <EOL> cmd . append ( '<STR_LIT>' ) <EOL> cmd . append ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> subprocess . check_call ( cmd , cwd = tempfile . gettempdir ( ) ) <EOL> if compile_nim_lib : <EOL> libname = '<STR_LIT>' <EOL> link . append ( libname ) <EOL> output [ '<STR_LIT:c>' ] . append ( <EOL> { '<STR_LIT:source>' : mod [ '<STR_LIT:code>' ] , '<STR_LIT>' : libname + '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' % libname } <EOL> ) <EOL> else : <EOL> nimcache = os . path . join ( tempfile . gettempdir ( ) , '<STR_LIT>' ) <EOL> nim_stdlib = hack_nim_stdlib ( <EOL> open ( os . path . join ( nimcache , '<STR_LIT>' ) , '<STR_LIT:rb>' ) . read ( ) <EOL> ) <EOL> nim_code = hack_nim_code ( <EOL> open ( os . path . join ( nimcache , '<STR_LIT>' ) , '<STR_LIT:rb>' ) . read ( ) <EOL> ) <EOL> cfg = { <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : [ nimcache , niminclude ] , <EOL> '<STR_LIT:index>' : mod [ '<STR_LIT:index>' ] , <EOL> '<STR_LIT:code>' : '<STR_LIT:\n>' . join ( [ nim_stdlib , nim_code ] ) <EOL> } <EOL> modules [ '<STR_LIT:c>' ] . append ( cfg ) <EOL> else : <EOL> print ( '<STR_LIT>' ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> javafiles = [ ] <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> for mod in mods_sorted_by_index : <EOL> if mod [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> rcode = java_to_rusthon ( mod [ '<STR_LIT:code>' ] ) <EOL> java2rusthon . append ( rcode ) <EOL> elif '<STR_LIT:name>' in mod : <EOL> jpath = os . path . join ( tmpdir , mod [ '<STR_LIT:name>' ] ) <EOL> if '<STR_LIT:/>' in mod [ '<STR_LIT:name>' ] : <EOL> jdir , jname = os . path . split ( jpath ) <EOL> if not os . path . isdir ( jdir ) : <EOL> os . makedirs ( jdir ) <EOL> open ( jpath , '<STR_LIT:wb>' ) . write ( mod [ '<STR_LIT:code>' ] ) <EOL> javafiles . append ( jpath ) <EOL> else : <EOL> raise SyntaxError ( '<STR_LIT>' ) <EOL> if javafiles : <EOL> output [ '<STR_LIT>' ] . append ( compile_java ( javafiles ) ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> if mod [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> giws . append ( mod [ '<STR_LIT:code>' ] ) <EOL> bindings = compile_giws_bindings ( mod [ '<STR_LIT:code>' ] ) <EOL> modules [ '<STR_LIT>' ] . append ( { '<STR_LIT:code>' : bindings , '<STR_LIT:index>' : mod [ '<STR_LIT:index>' ] } ) <EOL> else : <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> js_merge = [ ] <EOL> cpp_merge = [ ] <EOL> cpp_links = [ ] <EOL> cpp_idirs = [ ] <EOL> cpp_defines = [ ] <EOL> compile_mode = '<STR_LIT>' <EOL> exename = '<STR_LIT>' <EOL> tagged_trans_src = { } <EOL> if modules [ '<STR_LIT>' ] : <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> script = mod [ '<STR_LIT:code>' ] <EOL> index = mod . get ( '<STR_LIT:index>' ) <EOL> header = script . splitlines ( ) [ <NUM_LIT:0> ] <EOL> backend = '<STR_LIT>' <EOL> if header . startswith ( '<STR_LIT>' ) : <EOL> backend = header . split ( '<STR_LIT::>' ) [ - <NUM_LIT:1> ] . strip ( ) <EOL> if '<STR_LIT:U+0020>' in backend : <EOL> backend , compile_mode = backend . split ( '<STR_LIT:U+0020>' ) <EOL> if '<STR_LIT:\t>' in backend : <EOL> backend , compile_mode = backend . split ( '<STR_LIT:\t>' ) <EOL> if backend not in '<STR_LIT>' . split ( ) : <EOL> raise SyntaxError ( '<STR_LIT>' % backend ) <EOL> if compile_mode and compile_mode not in '<STR_LIT>' . split ( ) : <EOL> raise SyntaxError ( '<STR_LIT>' % backend ) <EOL> if backend == '<STR_LIT>' : <EOL> vcode = translate_to_verilog ( script ) <EOL> modules [ '<STR_LIT>' ] . append ( { '<STR_LIT:code>' : vcode , '<STR_LIT:index>' : index } ) <EOL> elif backend == '<STR_LIT>' : <EOL> if mod [ '<STR_LIT>' ] and mod [ '<STR_LIT>' ] and '<STR_LIT:.>' not in mod [ '<STR_LIT>' ] : <EOL> exename = mod [ '<STR_LIT>' ] <EOL> if mod [ '<STR_LIT>' ] and ( mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) or mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) or mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) or mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) ) : <EOL> pyjs = python_to_pythonjs ( script , cpp = True , module_path = module_path ) <EOL> use_try = True <EOL> if '<STR_LIT>' in sys . argv : <EOL> use_try = False <EOL> elif mod [ '<STR_LIT>' ] in gyp_builds . keys ( ) : <EOL> use_try = False <EOL> pak = translate_to_cpp ( <EOL> pyjs , <EOL> cached_json_files = cached_json , <EOL> insert_runtime = mod [ '<STR_LIT>' ] in gyp_builds . keys ( ) , <EOL> use_try = use_try <EOL> ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> raise RuntimeError ( pak ) <EOL> output [ '<STR_LIT>' ] [ mod [ '<STR_LIT>' ] ] = pak [ '<STR_LIT>' ] <EOL> if mod [ '<STR_LIT>' ] in gyp_builds . keys ( ) : <EOL> gyp_builds [ mod [ '<STR_LIT>' ] ] [ '<STR_LIT:src>' ] = pak [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in pak : <EOL> for classtag in pak [ '<STR_LIT>' ] . keys ( ) : <EOL> classheader = pak [ '<STR_LIT>' ] [ classtag ] <EOL> headerfile = classheader [ '<STR_LIT:file>' ] <EOL> if headerfile in output [ '<STR_LIT>' ] : <EOL> output [ '<STR_LIT>' ] [ headerfile ] += '<STR_LIT:\n>' + '<STR_LIT:\n>' . join ( classheader [ '<STR_LIT:source>' ] ) <EOL> else : <EOL> output [ '<STR_LIT>' ] [ headerfile ] = '<STR_LIT:\n>' + '<STR_LIT:\n>' . join ( classheader [ '<STR_LIT:source>' ] ) <EOL> else : <EOL> cpp_merge . append ( script ) <EOL> if '<STR_LIT>' in mod : <EOL> cpp_links . extend ( mod [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in mod : <EOL> cpp_idirs . extend ( mod [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in mod : <EOL> cpp_defines . extend ( mod [ '<STR_LIT>' ] ) <EOL> elif backend == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( script , rust = True , module_path = module_path ) <EOL> rustcode = translate_to_rust ( pyjs ) <EOL> modules [ '<STR_LIT>' ] . append ( { '<STR_LIT:code>' : rustcode , '<STR_LIT:index>' : index } ) <EOL> elif backend == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( script , go = True , module_path = module_path ) <EOL> gocode = translate_to_go ( pyjs ) <EOL> go_main [ '<STR_LIT:source>' ] . append ( gocode ) <EOL> elif backend == '<STR_LIT>' : <EOL> if mod [ '<STR_LIT>' ] and mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) : <EOL> js = compile_js ( mod [ '<STR_LIT:code>' ] , module_path , main_name = mod [ '<STR_LIT>' ] ) <EOL> mod [ '<STR_LIT>' ] = { '<STR_LIT>' : js [ mod [ '<STR_LIT>' ] ] } <EOL> tagged [ mod [ '<STR_LIT>' ] ] = js [ mod [ '<STR_LIT>' ] ] <EOL> tagged_trans_src [ mod [ '<STR_LIT>' ] ] = mod [ '<STR_LIT:code>' ] <EOL> for name in js : <EOL> output [ '<STR_LIT>' ] . append ( { '<STR_LIT:name>' : name , '<STR_LIT>' : js [ name ] , '<STR_LIT:index>' : index } ) <EOL> else : <EOL> js_merge . append ( mod ) <EOL> elif backend == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( script , lua = True , module_path = module_path ) <EOL> luacode = translate_to_lua ( pyjs ) <EOL> name = '<STR_LIT>' <EOL> if mod [ '<STR_LIT>' ] : name = mod [ '<STR_LIT>' ] <EOL> if not name . endswith ( '<STR_LIT>' ) : name += '<STR_LIT>' <EOL> output [ '<STR_LIT>' ] . append ( { '<STR_LIT:name>' : name , '<STR_LIT>' : luacode , '<STR_LIT:index>' : index } ) <EOL> elif backend == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( script , dart = True , module_path = module_path ) <EOL> dartcode = translate_to_dart ( pyjs ) <EOL> name = '<STR_LIT>' <EOL> if mod [ '<STR_LIT>' ] : name = mod [ '<STR_LIT>' ] <EOL> if not name . endswith ( '<STR_LIT>' ) : name += '<STR_LIT>' <EOL> output [ '<STR_LIT>' ] . append ( { '<STR_LIT:name>' : name , '<STR_LIT>' : dartcode , '<STR_LIT:index>' : index } ) <EOL> if js_merge : <EOL> taggroups = { } <EOL> for mod in js_merge : <EOL> tagname = mod [ '<STR_LIT>' ] <EOL> if tagname not in taggroups : <EOL> taggroups [ tagname ] = [ ] <EOL> src = taggroups [ tagname ] <EOL> src . append ( mod [ '<STR_LIT:code>' ] ) <EOL> for tagname in taggroups . keys ( ) : <EOL> groupsrc = '<STR_LIT:\n>' . join ( taggroups [ tagname ] ) <EOL> js = compile_js ( groupsrc , module_path , main_name = tagname ) <EOL> tagged [ tagname ] = js [ tagname ] <EOL> tagged_trans_src [ tagname ] = groupsrc <EOL> for name in js : <EOL> output [ '<STR_LIT>' ] . append ( { '<STR_LIT:name>' : name , '<STR_LIT>' : js [ name ] , '<STR_LIT:index>' : index } ) <EOL> cpyembed = [ ] <EOL> nuitka = [ ] <EOL> nuitka_include_path = None <EOL> nuitka_module_name = '<STR_LIT>' <EOL> if modules [ '<STR_LIT>' ] : <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> if mod [ '<STR_LIT>' ] : <EOL> name = mod [ '<STR_LIT>' ] <EOL> if name == '<STR_LIT>' or name . startswith ( '<STR_LIT>' ) : <EOL> if '<STR_LIT::>' in name : <EOL> nuitka_module_name = name . split ( '<STR_LIT::>' ) [ - <NUM_LIT:1> ] <EOL> if not len ( nuitka ) : <EOL> cpyembed . append ( '<STR_LIT>' ) <EOL> cpyembed . append ( '<STR_LIT>' ) <EOL> cpyembed . append ( '<STR_LIT>' % nuitka_module_name ) <EOL> nuitka . append ( mod [ '<STR_LIT:code>' ] ) <EOL> elif name == '<STR_LIT>' or name == '<STR_LIT>' : <EOL> cpyembed . append ( mod [ '<STR_LIT:code>' ] ) <EOL> else : <EOL> if not name . endswith ( '<STR_LIT>' ) : <EOL> name += '<STR_LIT>' <EOL> output [ '<STR_LIT>' ] . append ( { '<STR_LIT:name>' : name , '<STR_LIT>' : mod [ '<STR_LIT:code>' ] } ) <EOL> else : <EOL> if len ( output [ '<STR_LIT>' ] ) == <NUM_LIT:0> : <EOL> python_main [ '<STR_LIT>' ] . append ( mod [ '<STR_LIT:code>' ] ) <EOL> else : <EOL> output [ '<STR_LIT>' ] [ - <NUM_LIT:1> ] [ '<STR_LIT>' ] += '<STR_LIT:\n>' + mod [ '<STR_LIT:code>' ] <EOL> if cpp_merge : <EOL> merge = [ ] <EOL> nuitka_funcs = [ ] <EOL> if java2rusthon : <EOL> merge . extend ( java2rusthon ) <EOL> java2rusthon = None <EOL> if nim_wrappers : <EOL> nim_wrappers . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> nim_wrappers . insert ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> merge . extend ( nim_wrappers ) <EOL> if nuitka : <EOL> nsrc = '<STR_LIT:\n>' . join ( nuitka ) <EOL> output [ '<STR_LIT>' ] . append ( <EOL> { <EOL> '<STR_LIT>' : nuitka_compile ( nsrc , nuitka_module_name ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:source>' : nsrc , <EOL> } <EOL> ) <EOL> merge . extend ( cpp_merge ) <EOL> script = '<STR_LIT:\n>' . join ( merge ) <EOL> pyjs = python_to_pythonjs ( script , cpp = True , module_path = module_path ) <EOL> pak = translate_to_cpp ( pyjs , cached_json_files = cached_json ) <EOL> n = len ( modules [ '<STR_LIT>' ] ) + len ( giws ) <EOL> cppcode = pak [ '<STR_LIT>' ] <EOL> if cpyembed : <EOL> inlinepy = ( '<STR_LIT:\n>' . join ( cpyembed ) ) . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) . replace ( '<STR_LIT:">' , '<STR_LIT>' ) <EOL> staticstr = '<STR_LIT>' % inlinepy <EOL> cppcode = staticstr + cppcode <EOL> modules [ '<STR_LIT>' ] . append ( <EOL> { '<STR_LIT:code>' : cppcode , '<STR_LIT:index>' : n + <NUM_LIT:1> , '<STR_LIT>' : cpp_links , '<STR_LIT>' : cpp_idirs , '<STR_LIT>' : cpp_defines } <EOL> ) <EOL> if modules [ '<STR_LIT:html>' ] : <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT:html>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> html = [ ] <EOL> for line in mod [ '<STR_LIT:code>' ] . splitlines ( ) : <EOL> if line . strip ( ) . startswith ( '<STR_LIT>' ) and line . strip ( ) . endswith ( '<STR_LIT>' ) and '<STR_LIT>' in line : <EOL> url = line . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:">' ) [ <NUM_LIT:0> ] <EOL> url = os . path . expanduser ( url ) <EOL> if os . path . isfile ( url ) : <EOL> html . append ( '<STR_LIT>' ) <EOL> html . append ( open ( url , '<STR_LIT:rb>' ) . read ( ) . decode ( '<STR_LIT:utf-8>' ) ) <EOL> html . append ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in line : <EOL> giturl = line . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:">' ) [ <NUM_LIT:0> ] <EOL> print '<STR_LIT>' + giturl <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' , giturl ] <EOL> subprocess . check_call ( cmd , cwd = os . environ [ '<STR_LIT>' ] ) <EOL> assert os . path . isfile ( url ) <EOL> html . append ( '<STR_LIT>' ) <EOL> html . append ( open ( url , '<STR_LIT:rb>' ) . read ( ) . decode ( '<STR_LIT:utf-8>' ) ) <EOL> html . append ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in line : <EOL> srcurl = line . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:">' ) [ <NUM_LIT:0> ] <EOL> print '<STR_LIT>' + srcurl <EOL> import urllib <EOL> srcdata = urllib . urlopen ( srcurl ) . read ( ) <EOL> srcpath = os . path . split ( url ) [ <NUM_LIT:0> ] <EOL> if not os . path . isdir ( srcpath ) : <EOL> os . makedirs ( srcpath ) <EOL> open ( url , '<STR_LIT:wb>' ) . write ( srcdata ) <EOL> assert os . path . isfile ( url ) <EOL> html . append ( '<STR_LIT>' ) <EOL> html . append ( open ( url , '<STR_LIT:rb>' ) . read ( ) . decode ( '<STR_LIT:utf-8>' ) ) <EOL> html . append ( '<STR_LIT>' ) <EOL> else : <EOL> print ( '<STR_LIT>' % url ) <EOL> html . append ( line ) <EOL> elif line . strip ( ) . startswith ( '<STR_LIT>' ) and ( '<STR_LIT>' in line or "<STR_LIT>" in line ) : <EOL> zipurl = None <EOL> if '<STR_LIT>' in line : <EOL> zipurl = line . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:">' ) [ <NUM_LIT:0> ] <EOL> if '<STR_LIT>' in line : <EOL> url = line . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:">' ) [ <NUM_LIT:0> ] <EOL> else : <EOL> url = line . split ( "<STR_LIT>" ) [ - <NUM_LIT:1> ] . split ( "<STR_LIT:'>" ) [ <NUM_LIT:0> ] <EOL> url = os . path . expanduser ( url ) <EOL> if os . path . isfile ( url ) : <EOL> html . append ( '<STR_LIT>' ) <EOL> html . append ( open ( url , '<STR_LIT:rb>' ) . read ( ) ) <EOL> html . append ( '<STR_LIT>' ) <EOL> elif zipurl : <EOL> import urllib <EOL> print '<STR_LIT>' + zipurl <EOL> zipdata = urllib . urlopen ( zipurl ) . read ( ) <EOL> open ( '<STR_LIT>' , '<STR_LIT:wb>' ) . write ( zipdata ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' ] , cwd = os . environ [ '<STR_LIT>' ] ) <EOL> html . append ( '<STR_LIT>' ) <EOL> html . append ( open ( url , '<STR_LIT:rb>' ) . read ( ) ) <EOL> html . append ( '<STR_LIT>' ) <EOL> else : <EOL> print ( '<STR_LIT>' % url ) <EOL> html . append ( line ) <EOL> else : <EOL> html . append ( line ) <EOL> html = unicode ( '<STR_LIT:\n>' . join ( html ) ) <EOL> for tagname in tagged : <EOL> tag = u'<STR_LIT>' % tagname <EOL> js = tagged [ tagname ] <EOL> if tag in html : <EOL> try : <EOL> xxx = u'<STR_LIT>' % ( tagname , js ) <EOL> except UnicodeDecodeError : <EOL> xxx = u'<STR_LIT>' % ( tagname , js . decode ( '<STR_LIT:utf-8>' ) ) <EOL> html = html . replace ( tag , xxx ) <EOL> if tagname in tagged_trans_src . keys ( ) : <EOL> stag = u'<STR_LIT>' % tagname <EOL> py = tagged_trans_src [ tagname ] <EOL> if stag in html : <EOL> try : <EOL> xxx = u'<STR_LIT>' % ( tagname , py ) <EOL> except UnicodeDecodeError : <EOL> xxx = u'<STR_LIT>' % ( tagname , py . decode ( '<STR_LIT:utf-8>' ) ) <EOL> html = html . replace ( stag , xxx ) <EOL> mod [ '<STR_LIT:code>' ] = html <EOL> output [ '<STR_LIT:html>' ] . append ( mod ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> import base64 <EOL> bcoded = base64 . b64encode ( mod [ '<STR_LIT:code>' ] . encode ( '<STR_LIT:utf-8>' ) ) <EOL> wsgi = [ OPENSHIFT_PY [ <NUM_LIT:0> ] % bcoded , OPENSHIFT_PY [ <NUM_LIT:1> ] ] <EOL> output [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:\n>' . join ( wsgi ) . encode ( '<STR_LIT:utf-8>' ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> source = [ ] <EOL> mainmod = None <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> source . append ( mod [ '<STR_LIT:code>' ] ) <EOL> if '<STR_LIT:name>' in mod and mod [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> mainmod = mod <EOL> elif mainmod is None : <EOL> mainmod = mod <EOL> source = '<STR_LIT:\n>' . join ( source ) <EOL> mod = { } <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> if os . path . isfile ( '<STR_LIT>' ) or os . path . isfile ( '<STR_LIT>' ) : <EOL> mod [ '<STR_LIT:source>' ] = source <EOL> mod [ '<STR_LIT>' ] = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> mod [ '<STR_LIT:name>' ] = '<STR_LIT>' <EOL> output [ '<STR_LIT>' ] . append ( mod [ '<STR_LIT>' ] ) <EOL> tmpfile = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( source ) <EOL> cmd = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> tmpfile <EOL> ] <EOL> p = subprocess . Popen ( cmd , cwd = tempfile . gettempdir ( ) , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <EOL> p . wait ( ) <EOL> if p . returncode != <NUM_LIT:0> : <EOL> srclines = source . splitlines ( ) <EOL> err = p . stderr . read ( ) <EOL> errors = [ ] <EOL> for line in err . splitlines ( ) : <EOL> if '<STR_LIT>' in line : <EOL> errors . append ( '<STR_LIT>' ) <EOL> lineno = int ( line . split ( '<STR_LIT::>' ) [ - <NUM_LIT:2> ] ) <EOL> e = [ <EOL> '<STR_LIT>' % lineno , <EOL> ] <EOL> if lineno - <NUM_LIT:2> < len ( srclines ) : <EOL> e . append ( srclines [ lineno - <NUM_LIT:2> ] ) <EOL> if lineno - <NUM_LIT:1> < len ( srclines ) : <EOL> e . append ( srclines [ lineno - <NUM_LIT:1> ] ) <EOL> if lineno < len ( srclines ) : <EOL> e . append ( srclines [ lineno ] ) <EOL> errors . extend ( e ) <EOL> else : <EOL> errors . append ( line ) <EOL> msg = [ '<STR_LIT:U+0020>' . join ( cmd ) ] <EOL> for i , line in enumerate ( source . splitlines ( ) ) : <EOL> msg . append ( '<STR_LIT>' % ( i + <NUM_LIT:1> , line ) ) <EOL> msg . extend ( errors ) <EOL> raise RuntimeError ( '<STR_LIT:\n>' . join ( msg ) ) <EOL> else : <EOL> print ( '<STR_LIT>' ) <EOL> mod [ '<STR_LIT:code>' ] = source <EOL> if modules [ '<STR_LIT>' ] : <EOL> for mod in modules [ '<STR_LIT>' ] : <EOL> if '<STR_LIT:name>' in mod : <EOL> name = mod [ '<STR_LIT:name>' ] <EOL> if name == '<STR_LIT>' : <EOL> go_main [ '<STR_LIT:source>' ] . append ( mod [ '<STR_LIT:code>' ] ) <EOL> else : <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> else : <EOL> go_main [ '<STR_LIT:source>' ] . append ( mod [ '<STR_LIT:code>' ] ) <EOL> if go_main [ '<STR_LIT:source>' ] : <EOL> go_main [ '<STR_LIT:source>' ] = '<STR_LIT:\n>' . join ( go_main [ '<STR_LIT:source>' ] ) <EOL> output [ '<STR_LIT>' ] . insert ( <NUM_LIT:0> , go_main ) <EOL> if output [ '<STR_LIT>' ] : <EOL> source = [ mod [ '<STR_LIT:source>' ] for mod in output [ '<STR_LIT>' ] ] <EOL> tmpfile = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( '<STR_LIT:\n>' . join ( source ) ) <EOL> if GO_EXE : <EOL> cmd = [ GO_EXE , '<STR_LIT>' , tmpfile ] <EOL> subprocess . check_call ( [ GO_EXE , '<STR_LIT>' , tmpfile ] , cwd = tempfile . gettempdir ( ) ) <EOL> mod [ '<STR_LIT>' ] = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> output [ '<STR_LIT>' ] . append ( tempfile . gettempdir ( ) + '<STR_LIT>' ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> source = [ ] <EOL> mainmod = None <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> source . append ( mod [ '<STR_LIT:code>' ] ) <EOL> if '<STR_LIT:name>' in mod and mod [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> mainmod = mod <EOL> elif mainmod is None : <EOL> mainmod = mod <EOL> tmpfile = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> data = '<STR_LIT:\n>' . join ( source ) <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( data ) <EOL> pak = None <EOL> if modules [ '<STR_LIT>' ] : <EOL> libname = '<STR_LIT>' % len ( output [ '<STR_LIT>' ] ) <EOL> link . append ( libname ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , tempfile . gettempdir ( ) + '<STR_LIT:/>' + libname , tmpfile ] ) <EOL> pak = { '<STR_LIT:source>' : data , '<STR_LIT>' : libname , '<STR_LIT:name>' : '<STR_LIT>' + libname + '<STR_LIT>' } <EOL> else : <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , tempfile . gettempdir ( ) + '<STR_LIT>' , tmpfile ] ) <EOL> pak = { '<STR_LIT:source>' : data , '<STR_LIT>' : tempfile . gettempdir ( ) + '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' } <EOL> output [ '<STR_LIT>' ] . append ( tempfile . gettempdir ( ) + '<STR_LIT>' ) <EOL> assert pak <EOL> mainmod [ '<STR_LIT>' ] = pak <EOL> output [ '<STR_LIT>' ] . append ( pak ) <EOL> if modules [ '<STR_LIT:c>' ] : <EOL> dynamiclib = False <EOL> source = [ ] <EOL> cinclude = [ ] <EOL> cbuild = [ ] <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT:c>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> if '<STR_LIT>' in mod and mod [ '<STR_LIT>' ] : <EOL> dynamiclib = True <EOL> if '<STR_LIT>' in mod : <EOL> cinclude . extend ( mod [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in mod : <EOL> for bdir in mod [ '<STR_LIT>' ] : <EOL> for fname in os . listdir ( bdir ) : <EOL> if fname . endswith ( '<STR_LIT>' ) : <EOL> cbuild . append ( os . path . join ( bdir , fname ) ) <EOL> if '<STR_LIT:code>' in mod and mod [ '<STR_LIT:code>' ] : <EOL> source . append ( mod [ '<STR_LIT:code>' ] ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> if source : <EOL> data = '<STR_LIT:\n>' . join ( source ) <EOL> cpak = { '<STR_LIT:source>' : data } <EOL> output [ '<STR_LIT:c>' ] . append ( cpak ) <EOL> libname = '<STR_LIT>' % len ( output [ '<STR_LIT:c>' ] ) <EOL> link . append ( libname ) <EOL> dynamic_path = tempfile . gettempdir ( ) + '<STR_LIT>' + libname + '<STR_LIT>' <EOL> static_path = tempfile . gettempdir ( ) + '<STR_LIT>' + libname + '<STR_LIT>' <EOL> object_path = tempfile . gettempdir ( ) + '<STR_LIT:/>' + libname + '<STR_LIT>' <EOL> tmpfile = tempfile . gettempdir ( ) + '<STR_LIT>' <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( data ) <EOL> cmd = [ '<STR_LIT>' ] <EOL> for idir in cinclude : <EOL> cmd . append ( '<STR_LIT>' + idir ) <EOL> cmd . extend ( [ '<STR_LIT:-c>' , tmpfile ] ) <EOL> if dynamiclib : <EOL> cmd . extend ( <EOL> [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , object_path <EOL> ] <EOL> ) <EOL> subprocess . check_call ( cmd ) <EOL> cmd = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' % libname , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , dynamic_path , <EOL> object_path <EOL> ] <EOL> subprocess . check_call ( cmd ) <EOL> cpak [ '<STR_LIT>' ] = dynamic_path <EOL> cpak [ '<STR_LIT:name>' ] = '<STR_LIT>' % libname <EOL> else : <EOL> if cbuild : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> cmd . extend ( [ '<STR_LIT>' , object_path ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> subprocess . check_call ( cmd ) <EOL> print ( '<STR_LIT>' ) <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' , static_path , object_path ] <EOL> subprocess . check_call ( cmd ) <EOL> cpak [ '<STR_LIT>' ] = libname + '<STR_LIT>' <EOL> cpak [ '<STR_LIT:name>' ] = libname + '<STR_LIT>' <EOL> if modules [ '<STR_LIT>' ] : <EOL> links = [ ] <EOL> idirs = [ ] <EOL> source = [ ] <EOL> defines = [ ] <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> mainmod = None <EOL> builddir = tempfile . gettempdir ( ) <EOL> for mod in mods_sorted_by_index : <EOL> if '<STR_LIT>' in mod and mod [ '<STR_LIT>' ] and ( mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) or mod [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) ) : <EOL> open ( <EOL> os . path . join ( builddir , mod [ '<STR_LIT>' ] ) , '<STR_LIT:wb>' <EOL> ) . write ( mod [ '<STR_LIT:code>' ] ) <EOL> output [ '<STR_LIT>' ] . append ( mod ) <EOL> else : <EOL> source . append ( mod [ '<STR_LIT:code>' ] ) <EOL> if '<STR_LIT:name>' in mod and mod [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> mainmod = mod <EOL> elif mainmod is None : <EOL> mainmod = mod <EOL> if '<STR_LIT>' in mod : <EOL> links . extend ( mod [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in mod : <EOL> idirs . extend ( mod [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in mod : <EOL> defines . extend ( mod [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in mod and mod [ '<STR_LIT>' ] and '<STR_LIT:.>' not in mod [ '<STR_LIT>' ] : <EOL> exename = mod [ '<STR_LIT>' ] <EOL> tmpfile = builddir + '<STR_LIT>' <EOL> data = '<STR_LIT:\n>' . join ( source ) <EOL> open ( tmpfile , '<STR_LIT:wb>' ) . write ( data ) <EOL> cmd = [ '<STR_LIT>' ] <EOL> if compile_mode == '<STR_LIT>' : <EOL> cmd . extend ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' + tempfile . gettempdir ( ) ] ) <EOL> cmd . append ( '<STR_LIT>' ) <EOL> cmd . append ( '<STR_LIT>' ) <EOL> cmd . append ( tmpfile ) <EOL> if '<STR_LIT:/>' in exename and not os . path . isdir ( os . path . join ( builddir , os . path . split ( exename ) [ <NUM_LIT:0> ] ) ) : <EOL> os . makedirs ( os . path . join ( builddir , os . path . split ( exename ) [ <NUM_LIT:0> ] ) ) <EOL> if compile_mode == '<STR_LIT>' : <EOL> cmd . extend ( [ '<STR_LIT>' , os . path . join ( builddir , exename ) ] ) <EOL> elif compile_mode == '<STR_LIT>' : <EOL> cmd . extend ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ) <EOL> exename += '<STR_LIT>' <EOL> cmd . extend ( [ '<STR_LIT>' , os . path . join ( builddir , exename ) ] ) <EOL> cmd . extend ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ) <EOL> for D in defines : <EOL> cmd . append ( '<STR_LIT>' % D ) <EOL> if nuitka : <EOL> cmd . append ( '<STR_LIT>' ) <EOL> cmd . append ( '<STR_LIT>' ) <EOL> if idirs : <EOL> for idir in idirs : <EOL> cmd . append ( '<STR_LIT>' + idir ) <EOL> if links : <EOL> for lib in links : <EOL> cmd . append ( '<STR_LIT>' + lib ) <EOL> cmd . append ( '<STR_LIT>' ) <EOL> if link or giws : <EOL> if giws : <EOL> cmd . append ( '<STR_LIT>' ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> for jrepath in '<STR_LIT>' . split ( ) : <EOL> cmd . append ( '<STR_LIT>' % ( os . environ [ '<STR_LIT>' ] , jrepath ) ) <EOL> for jrepath in '<STR_LIT>' . split ( ) : <EOL> cmd . append ( '<STR_LIT>' % ( os . environ [ '<STR_LIT>' ] , jrepath ) ) <EOL> os . environ [ '<STR_LIT>' ] += '<STR_LIT>' % ( os . environ [ '<STR_LIT>' ] , jrepath ) <EOL> if link : <EOL> cmd . append ( '<STR_LIT>' + tempfile . gettempdir ( ) + '<STR_LIT>' ) <EOL> for libname in link : <EOL> cmd . append ( '<STR_LIT>' + libname ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT:U+0020>' . join ( cmd ) ) <EOL> subprocess . check_call ( cmd ) <EOL> mainmod [ '<STR_LIT>' ] = { <EOL> '<STR_LIT:source>' : data , <EOL> '<STR_LIT>' : tempfile . gettempdir ( ) + '<STR_LIT:/>' + exename , <EOL> '<STR_LIT:name>' : exename <EOL> } <EOL> if compile_mode == '<STR_LIT>' : <EOL> output [ '<STR_LIT>' ] . append ( mainmod [ '<STR_LIT>' ] ) <EOL> output [ '<STR_LIT>' ] . append ( tempfile . gettempdir ( ) + '<STR_LIT:/>' + exename ) <EOL> else : <EOL> output [ '<STR_LIT>' ] [ exename ] = open ( tempfile . gettempdir ( ) + '<STR_LIT:/>' + exename , '<STR_LIT:rb>' ) . read ( ) <EOL> if python_main [ '<STR_LIT>' ] : <EOL> python_main [ '<STR_LIT>' ] = '<STR_LIT:\n>' . join ( python_main [ '<STR_LIT>' ] ) <EOL> output [ '<STR_LIT>' ] . append ( python_main ) <EOL> if modules [ '<STR_LIT>' ] : <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> open ( tmpdir + '<STR_LIT>' , '<STR_LIT:wb>' ) <EOL> for filename in output [ '<STR_LIT>' ] . keys ( ) : <EOL> open ( tmpdir + '<STR_LIT:/>' + filename , '<STR_LIT:wb>' ) . write ( output [ '<STR_LIT>' ] [ filename ] ) <EOL> bazelbuilds = [ ] <EOL> mods_sorted_by_index = sorted ( modules [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> bazelconfig = mod [ '<STR_LIT:code>' ] <EOL> open ( tmpdir + '<STR_LIT>' , '<STR_LIT:wb>' ) . write ( bazelconfig ) <EOL> for chk in bazelconfig . split ( '<STR_LIT:U+002C>' ) : <EOL> chk = chk . strip ( ) <EOL> words = chk . split ( ) <EOL> if chk . endswith ( '<STR_LIT:">' ) and '<STR_LIT:name>' in words and '<STR_LIT:=>' in words : <EOL> chk = chk . split ( ) <EOL> bazelbuilds . append ( chk [ - <NUM_LIT:1> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> assert len ( bazelbuilds ) == <NUM_LIT:1> <EOL> buildname = bazelbuilds [ <NUM_LIT:0> ] <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT::>' + buildname ] , cwd = tmpdir ) <EOL> if gyp_builds : <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> for gname in gyp_builds . keys ( ) : <EOL> gbuild = gyp_builds [ gname ] <EOL> if gbuild [ '<STR_LIT:src>' ] : <EOL> open ( tmpdir + '<STR_LIT>' , '<STR_LIT:wb>' ) . write ( gbuild [ '<STR_LIT>' ] ) <EOL> open ( tmpdir + '<STR_LIT:/>' + gname , '<STR_LIT:wb>' ) . write ( gbuild [ '<STR_LIT:src>' ] ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , cwd = tmpdir ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' ] , cwd = tmpdir ) <EOL> node_module = open ( tmpdir + '<STR_LIT>' , '<STR_LIT:rb>' ) . read ( ) <EOL> output [ '<STR_LIT>' ] [ '<STR_LIT>' ] = node_module <EOL> return output <EOL> def get_first_build_from_package ( package ) : <EOL> for lang in '<STR_LIT>' . split ( ) : <EOL> for pak in package [ lang ] : <EOL> return pak <EOL> def save_tar ( package , path = '<STR_LIT>' ) : <EOL> import tarfile <EOL> import StringIO <EOL> tar = tarfile . TarFile ( path , "<STR_LIT:w>" ) <EOL> if package [ '<STR_LIT>' ] : <EOL> for datadir in package [ '<STR_LIT>' ] : <EOL> if os . path . isdir ( datadir ) : <EOL> for name in os . listdir ( datadir ) : <EOL> a = os . path . join ( datadir , name ) <EOL> tar . add ( a ) <EOL> elif os . path . isfile ( datadir ) : <EOL> tar . add ( datadir ) <EOL> if package [ '<STR_LIT>' ] : <EOL> for fpath in package [ '<STR_LIT>' ] : <EOL> fdata = package [ '<STR_LIT>' ] [ fpath ] <EOL> s = StringIO . StringIO ( ) <EOL> s . write ( fdata ) <EOL> s . seek ( <NUM_LIT:0> ) <EOL> ti = tarfile . TarInfo ( name = fpath ) <EOL> ti . size = len ( s . buf ) <EOL> tar . addfile ( tarinfo = ti , fileobj = s ) <EOL> exts = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:html>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> for lang in '<STR_LIT>' . split ( ) : <EOL> for info in package [ lang ] : <EOL> name = '<STR_LIT>' <EOL> if '<STR_LIT:name>' in info and info [ '<STR_LIT:name>' ] : <EOL> name = info [ '<STR_LIT:name>' ] <EOL> source = False <EOL> is_bin = False <EOL> s = StringIO . StringIO ( ) <EOL> if '<STR_LIT>' in info : <EOL> s . write ( open ( info [ '<STR_LIT>' ] , '<STR_LIT:rb>' ) . read ( ) ) <EOL> if '<STR_LIT:source>' in info : <EOL> source = info [ '<STR_LIT:source>' ] <EOL> elif '<STR_LIT>' in info : <EOL> s . write ( open ( info [ '<STR_LIT>' ] , '<STR_LIT:rb>' ) . read ( ) ) <EOL> if '<STR_LIT:source>' in info : <EOL> source = info [ '<STR_LIT:source>' ] <EOL> elif '<STR_LIT>' in info : <EOL> s . write ( open ( info [ '<STR_LIT>' ] , '<STR_LIT:rb>' ) . read ( ) ) <EOL> source = info [ '<STR_LIT:source>' ] <EOL> is_bin = True <EOL> elif '<STR_LIT:code>' in info : <EOL> if lang == '<STR_LIT>' : print ( info [ '<STR_LIT:code>' ] ) <EOL> s . write ( info [ '<STR_LIT:code>' ] . encode ( '<STR_LIT:utf-8>' ) ) <EOL> elif '<STR_LIT>' in info : <EOL> s . write ( info [ '<STR_LIT>' ] ) <EOL> s . seek ( <NUM_LIT:0> ) <EOL> if not is_bin and not source and not name . endswith ( exts [ lang ] ) and '<STR_LIT:.>' not in name : <EOL> name += exts [ lang ] <EOL> ti = tarfile . TarInfo ( name = name ) <EOL> ti . size = len ( s . buf ) <EOL> if is_bin : <EOL> ti . mode = <NUM_LIT> <EOL> try : <EOL> tar . addfile ( tarinfo = ti , fileobj = s ) <EOL> except UnicodeEncodeError as err : <EOL> s . seek ( <NUM_LIT:0> ) <EOL> print s . getvalue ( ) <EOL> raise err <EOL> if source : <EOL> s = StringIO . StringIO ( ) <EOL> s . write ( source ) <EOL> s . seek ( <NUM_LIT:0> ) <EOL> if '<STR_LIT>' in info : <EOL> ti = tarfile . TarInfo ( name = info [ '<STR_LIT>' ] ) <EOL> else : <EOL> ti = tarfile . TarInfo ( name = name + '<STR_LIT>' + exts [ lang ] ) <EOL> ti . size = len ( s . buf ) <EOL> tar . addfile ( tarinfo = ti , fileobj = s ) <EOL> tar . close ( ) <EOL> NW_DEVTOOLS_HACK = '''<STR_LIT>''' <EOL> NW_STARTUP_HACK = '''<STR_LIT>''' <EOL> def main ( ) : <EOL> if len ( sys . argv ) == <NUM_LIT:1> or '<STR_LIT>' in sys . argv : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> for backend in '<STR_LIT>' . split ( ) : <EOL> print ( '<STR_LIT:U+0020>' + backend ) <EOL> return <EOL> modules = new_module ( ) <EOL> save = False <EOL> paths = [ ] <EOL> scripts = [ ] <EOL> markdowns = [ ] <EOL> gen_md = False <EOL> output_tar = '<STR_LIT>' <EOL> output_dir = None <EOL> output_file = None <EOL> launch = [ ] <EOL> datadirs = [ ] <EOL> j2r = False <EOL> anaconda = False <EOL> convert2py = False <EOL> for arg in sys . argv [ <NUM_LIT:1> : ] : <EOL> if os . path . isdir ( arg ) : <EOL> paths . append ( arg ) <EOL> elif arg . startswith ( '<STR_LIT>' ) : <EOL> datadirs . extend ( arg . split ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:U+002C>' ) ) <EOL> elif arg . startswith ( '<STR_LIT>' ) : <EOL> launch . extend ( arg . split ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:U+002C>' ) ) <EOL> save = True <EOL> elif arg . startswith ( '<STR_LIT>' ) : <EOL> output_file = arg . split ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] <EOL> elif arg . startswith ( '<STR_LIT>' ) : <EOL> output_dir = arg . split ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] <EOL> if output_dir . startswith ( '<STR_LIT>' ) : <EOL> output_dir = os . path . expanduser ( output_dir ) <EOL> elif arg . startswith ( '<STR_LIT>' ) : <EOL> convert2py = arg . split ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] <EOL> elif arg . endswith ( '<STR_LIT>' ) : <EOL> scripts . append ( arg ) <EOL> elif arg . endswith ( '<STR_LIT>' ) : <EOL> markdowns . append ( arg ) <EOL> elif arg . endswith ( '<STR_LIT>' ) : <EOL> output_tar = arg <EOL> save = True <EOL> elif arg == '<STR_LIT>' : <EOL> gen_md = True <EOL> elif arg == '<STR_LIT>' : <EOL> save = True <EOL> elif arg == '<STR_LIT>' : <EOL> j2r = True <EOL> elif arg == '<STR_LIT>' : <EOL> anaconda = True <EOL> datadirs = [ os . path . expanduser ( dd ) for dd in datadirs ] <EOL> if j2r : <EOL> for path in paths : <EOL> m = convert_to_markdown_project ( path , java = True , java2rusthon = True ) <EOL> raise RuntimeError ( '<STR_LIT>' % m ) <EOL> if gen_md : <EOL> for path in paths : <EOL> mds = convert_to_markdown_project ( path ) <EOL> if not output_file : <EOL> raise RuntimeError ( '<STR_LIT>' % mds ) <EOL> elif os . path . isdir ( output_file ) : <EOL> for m in mds : <EOL> if m [ '<STR_LIT:name>' ] . count ( '<STR_LIT:.>' ) == <NUM_LIT:1> : <EOL> mname = m [ '<STR_LIT:name>' ] . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> else : <EOL> mname = m [ '<STR_LIT:name>' ] + '<STR_LIT>' <EOL> mpath = os . path . join ( output_file , mname ) <EOL> print ( '<STR_LIT>' % mpath ) <EOL> open ( mpath , '<STR_LIT:wb>' ) . write ( m [ '<STR_LIT>' ] ) <EOL> else : <EOL> if not output_file . endswith ( '<STR_LIT>' ) : <EOL> output_file += '<STR_LIT>' <EOL> md = '<STR_LIT:\n>' . join ( [ m [ '<STR_LIT>' ] for m in mds ] ) <EOL> open ( output_file , '<STR_LIT:wb>' ) . write ( md ) <EOL> sys . exit ( ) <EOL> if convert2py : <EOL> if not len ( scripts ) : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> if len ( scripts ) != <NUM_LIT:1> : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> a = typedpython . transform_source ( <EOL> open ( scripts [ <NUM_LIT:0> ] , '<STR_LIT:rb>' ) . read ( ) , <EOL> strip = True <EOL> ) <EOL> open ( convert2py , '<STR_LIT:wb>' ) . write ( a ) <EOL> sys . exit ( ) <EOL> base_path = None <EOL> singleout = None <EOL> for path in scripts : <EOL> script = open ( path , '<STR_LIT:rb>' ) . read ( ) <EOL> if '<STR_LIT>' in sys . argv : script = '<STR_LIT>' + script <EOL> elif '<STR_LIT>' in sys . argv : script = '<STR_LIT>' + script <EOL> elif '<STR_LIT>' in sys . argv : script = '<STR_LIT>' + script <EOL> elif '<STR_LIT>' in sys . argv : script = '<STR_LIT>' + script <EOL> elif '<STR_LIT>' in sys . argv : raise RuntimeError ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in sys . argv : raise RuntimeError ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in sys . argv : script = '<STR_LIT>' + script <EOL> else : script = '<STR_LIT>' + script <EOL> fpath , fname = os . path . split ( path ) <EOL> tag = fname . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] <EOL> singlemod = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : tag , '<STR_LIT:code>' : script } <EOL> modules [ '<STR_LIT>' ] . append ( singlemod ) <EOL> if base_path is None : <EOL> base_path = os . path . split ( path ) [ <NUM_LIT:0> ] <EOL> if singleout is None and output_file : <EOL> singleout = singlemod <EOL> for path in markdowns : <EOL> import_md ( path , modules = modules ) <EOL> if base_path is None : <EOL> base_path = os . path . split ( path ) [ <NUM_LIT:0> ] <EOL> package = build ( modules , base_path , datadirs = datadirs ) <EOL> if singleout : <EOL> pak = get_first_build_from_package ( package ) <EOL> if '<STR_LIT:source>' in pak : <EOL> open ( output_file , '<STR_LIT:wb>' ) . write ( pak [ '<STR_LIT:source>' ] ) <EOL> elif '<STR_LIT:code>' in pak : <EOL> open ( output_file , '<STR_LIT:wb>' ) . write ( pak [ '<STR_LIT:code>' ] ) <EOL> elif '<STR_LIT>' in pak : <EOL> open ( output_file , '<STR_LIT:wb>' ) . write ( pak [ '<STR_LIT>' ] ) <EOL> else : <EOL> raise RuntimeError ( pak ) <EOL> print ( '<STR_LIT>' % output_file ) <EOL> elif not save : <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> for p in datadirs : <EOL> if '<STR_LIT:.>' in p : <EOL> dpath , dname = os . path . split ( p ) <EOL> open ( os . path . join ( tmpdir , dname ) , '<STR_LIT:wb>' ) . write ( open ( p , '<STR_LIT:rb>' ) . read ( ) ) <EOL> for exe in package [ '<STR_LIT>' ] : <EOL> print ( '<STR_LIT>' % exe ) <EOL> subprocess . check_call ( <EOL> exe , <EOL> cwd = tmpdir <EOL> ) <EOL> if package [ '<STR_LIT:html>' ] : <EOL> for i , page in enumerate ( package [ '<STR_LIT:html>' ] ) : <EOL> tname = '<STR_LIT>' % i <EOL> if '<STR_LIT:name>' in page and page [ '<STR_LIT:name>' ] : <EOL> tname = page [ '<STR_LIT:name>' ] <EOL> tmp = tempfile . gettempdir ( ) + '<STR_LIT:/>' + tname <EOL> if sys . platform == '<STR_LIT>' : <EOL> tmp = '<STR_LIT>' + tname <EOL> open ( tmp , '<STR_LIT:wb>' ) . write ( page [ '<STR_LIT:code>' ] . encode ( '<STR_LIT>' ) ) <EOL> if i < len ( package [ '<STR_LIT:html>' ] ) - <NUM_LIT:1> : <EOL> pass <EOL> elif sys . platform == '<STR_LIT>' and not nodewebkit_runnable : <EOL> subprocess . call ( [ '<STR_LIT>' , tmp ] ) <EOL> elif nodewebkit_runnable : <EOL> nwcfg = '<STR_LIT>' % os . path . split ( tmp ) [ <NUM_LIT:1> ] <EOL> if '<STR_LIT>' in sys . argv : <EOL> nwcfg += '<STR_LIT>' <EOL> elif '<STR_LIT>' in sys . argv : <EOL> nwcfg += '<STR_LIT>' <EOL> else : <EOL> nwcfg += '<STR_LIT>' <EOL> open ( os . path . join ( tmpdir , "<STR_LIT>" ) , '<STR_LIT:wb>' ) . write ( nwcfg ) <EOL> nwcmd = [ nodewebkit ] <EOL> if '<STR_LIT>' in sys . argv : <EOL> nwcmd . append ( '<STR_LIT>' ) <EOL> if sys . platform == '<STR_LIT>' and '<STR_LIT>' in sys . argv : <EOL> nwcmd . extend ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> nwcmd . append ( tmpdir ) <EOL> subprocess . Popen ( nwcmd , cwd = tmpdir ) <EOL> else : <EOL> webbrowser . open ( tmp ) <EOL> elif package [ '<STR_LIT>' ] : <EOL> tmpdir = tempfile . gettempdir ( ) <EOL> for pak in package [ '<STR_LIT>' ] : <EOL> fname = pak [ '<STR_LIT:name>' ] <EOL> if fname is None : <EOL> fname = '<STR_LIT>' <EOL> elif not fname . endswith ( '<STR_LIT>' ) : <EOL> fname += '<STR_LIT>' <EOL> fpath = os . path . join ( tmpdir , fname ) <EOL> open ( fpath , '<STR_LIT:wb>' ) . write ( pak [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> subprocess . check_call ( [ nodejs_exe , '<STR_LIT>' , fpath ] ) <EOL> else : <EOL> subprocess . check_call ( [ nodejs_exe , fpath ] ) <EOL> else : <EOL> save_tar ( package , output_tar ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( output_tar ) <EOL> if launch : <EOL> tmpdir = output_dir or tempfile . gettempdir ( ) <EOL> tmptar = os . path . join ( tmpdir , '<STR_LIT>' ) <EOL> open ( tmptar , '<STR_LIT:wb>' ) . write ( <EOL> open ( output_tar , '<STR_LIT:rb>' ) . read ( ) <EOL> ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , tmptar ] , cwd = tmpdir ) <EOL> run = subprocess . call <EOL> for name in launch : <EOL> if name == launch [ - <NUM_LIT:1> ] : <EOL> run = subprocess . check_call <EOL> else : <EOL> run = subprocess . Popen <EOL> if name . endswith ( '<STR_LIT>' ) : <EOL> firstline = open ( os . path . join ( tmpdir , name ) , '<STR_LIT:rb>' ) . readlines ( ) [ <NUM_LIT:0> ] <EOL> python = '<STR_LIT>' <EOL> if firstline . startswith ( '<STR_LIT>' ) : <EOL> if '<STR_LIT>' in firstline : <EOL> python = '<STR_LIT>' <EOL> if anaconda : <EOL> anabin = os . path . expanduser ( '<STR_LIT>' ) <EOL> if not os . path . isdir ( anabin ) : <EOL> raise RuntimeError ( '<STR_LIT>' % anabin ) <EOL> run ( [ os . path . join ( anabin , python ) , name ] , cwd = tmpdir ) <EOL> else : <EOL> run ( [ python , name ] , cwd = tmpdir ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> run ( [ '<STR_LIT>' , name ] , cwd = tmpdir , env = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> run ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , name ] , cwd = tmpdir ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> run ( [ '<STR_LIT>' , '<STR_LIT>' , name ] , cwd = tmpdir ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> run ( [ '<STR_LIT>' , name ] , cwd = tmpdir ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> dartbin = os . path . expanduser ( '<STR_LIT>' ) <EOL> run ( [ dartbin , name ] , cwd = tmpdir ) <EOL> elif name . endswith ( '<STR_LIT>' ) : <EOL> if sys . platform == '<STR_LIT>' : <EOL> subprocess . call ( [ '<STR_LIT>' , tmpdir + '<STR_LIT:/>' + name ] ) <EOL> elif nodewebkit_runnable : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> subprocess . call ( [ nodewebkit , tmp ] , cwd = tmpdir ) <EOL> else : <EOL> webbrowser . open ( tmpdir + '<STR_LIT:/>' + name ) <EOL> else : <EOL> print '<STR_LIT>' % name <EOL> run ( [ os . path . join ( tmpdir , name ) ] , cwd = tmpdir ) <EOL> BOOTSTRAPED = None <EOL> class rusthon ( object ) : <EOL> @ classmethod <EOL> def translate ( cls , code , mode = '<STR_LIT>' ) : <EOL> if mode == '<STR_LIT>' : <EOL> js = compile_js ( code , '<STR_LIT>' , main_name = '<STR_LIT>' ) <EOL> return js [ '<STR_LIT>' ] <EOL> elif mode == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( code , cpp = True ) <EOL> pak = translate_to_cpp ( <EOL> pyjs , <EOL> insert_runtime = False <EOL> ) <EOL> return pak [ '<STR_LIT>' ] <EOL> elif mode == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( code , go = True ) <EOL> return translate_to_go ( pyjs ) <EOL> elif mode == '<STR_LIT>' : <EOL> pyjs = python_to_pythonjs ( code , rust = True ) <EOL> return translate_to_rust ( pyjs ) <EOL> else : <EOL> base_path = None <EOL> package = build ( modules , base_path ) <EOL> raise RuntimeError ( package ) <EOL> return <EOL> def bootstrap_rusthon ( ) : <EOL> global BOOTSTRAPED <EOL> localdir = os . path . dirname ( unicode ( os . path . realpath ( __file__ ) , sys . getfilesystemencoding ( ) ) ) <EOL> mods = new_module ( ) <EOL> import_md ( os . path . join ( localdir , '<STR_LIT>' ) , modules = mods ) <EOL> src = [ ] <EOL> mods_sorted_by_index = sorted ( mods [ '<STR_LIT>' ] , key = lambda mod : mod . get ( '<STR_LIT:index>' ) ) <EOL> for mod in mods_sorted_by_index : <EOL> src . append ( mod [ '<STR_LIT:code>' ] ) <EOL> src = '<STR_LIT:\n>' . join ( src ) <EOL> BOOTSTRAPED = src <EOL> if '<STR_LIT>' in sys . argv : open ( '<STR_LIT>' , '<STR_LIT:wb>' ) . write ( src . encode ( '<STR_LIT:utf-8>' ) ) <EOL> exec ( src , globals ( ) ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> test_typedpython ( ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> print ( '<STR_LIT>' ) <EOL> jsruntime = generate_js_runtime ( ) <EOL> if os . path . isdir ( '<STR_LIT>' ) : <EOL> print '<STR_LIT>' <EOL> open ( '<STR_LIT>' , '<STR_LIT:wb>' ) . write ( jsruntime ) <EOL> return jsruntime <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> bootstrap_rusthon ( ) <EOL> main ( ) </s>
