From 290256c9491b71c902b2b1c43183b537497528b2 Mon Sep 17 00:00:00 2001 From: Pyja Erskell Date: Fri, 25 Jun 2021 12:30:55 +0900 Subject: [PATCH] Hepager Hello Reverse String Example --- .../Global.py | 29 +++++++ .../210603-2155 Hello Reverse String/SToa.js | 79 +++++++++++++++++++ .../210603-2155 Hello Reverse String/SToa.py | 22 ++++++ 3 files changed, 130 insertions(+) create mode 100644 Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/Global.py create mode 100644 Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.js create mode 100644 Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.py diff --git a/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/Global.py b/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/Global.py new file mode 100644 index 0000000..518c94b --- /dev/null +++ b/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/Global.py @@ -0,0 +1,29 @@ +# +-----------------------------------------------------------------------+ +# : Pyja : +# : https://github.com/PyjaErskell : +# : made by Erskell (pyja.erskell@gmail.com) : +# : released under the GNU AGPL v3, see . : +# +-----------------------------------------------------------------------+ + +import sys +__gau_n = sys.modules ['__main__'] .__sau_n +gu_n = type ( '', (), { '__getattr__' : lambda self, x_attr : __gau_n [x_attr] } ) () +sys.argv = [gu_n.GC_TONO_HM] + +import os +import jep + +GC_FOSA = os.sep # (fo)lder (s)ep(a)rator +GC_PASA = os.pathsep # (pa)th (s)ep(a)rator + +def gf_te (x_str) : return eval (x_str) +def gf_jcls (x_it) : return jep .findClass (x_it) + +CjArrayList = gf_jcls ('java.util.ArrayList') + +def gf_2ja ( * x_args ) : # to (j)ava (a)rray + fu_al = CjArrayList () + for bu2_it in x_args : fu_al .add (bu2_it) + return fu_al .toArray () +def gf_nf ( x_nm, * x_args ) : return __gau_n .callMember ( x_nm, gf_2ja ( * x_args ) ) # call (n)ashorn (f)unction +def gf_nm ( x_oj, x_nm, * x_args ) : return x_oj .callMember ( x_nm, gf_2ja ( * x_args ) ) # call (n)ashorn object's (m)ethod diff --git a/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.js b/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.js new file mode 100644 index 0000000..4e258a7 --- /dev/null +++ b/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.js @@ -0,0 +1,79 @@ +// +-----------------------------------------------------------------------+ +// : Pyja : +// : https://github.com/PyjaErskell : +// : made by Erskell (pyja.erskell@gmail.com) : +// : released under the GNU AGPL v3, see . : +// +-----------------------------------------------------------------------+ + +//--------- +// Global +//--------- + +"use strict" + +var gu_n = this; // (n)ashorn + +var CjFile = java.io.File; +var CjSystem = java.lang.System; + +var GC_TONO_HM = new CjFile (__DIR__) .path; +var GC_FOSA = CjFile .separator; // (fo)lder (s)ep(a)rator +var GC_PASA = CjFile .pathSeparator; // (pa)th (s)ep(a)rator + +function gf_if (x_it) { return new CjFile (x_it) .isFile (); } // (i)s (f)ile +function gf_id (x_it) { return new CjFile (x_it) .isDirectory (); } // (i)s (d)irectory +function gf_xi (x_it) { return new CjFile (x_it) .exists (); } // e(xi)sts + +function gf_pj () { return Array.prototype.join .call ( arguments, GC_FOSA ); } // (p)ath (j)oin + +function gf_os_env (x_nm) { + var fu_it = CjSystem .getenv (x_nm); + if ( fu_it == null ) { throw "Cannot find environment variable => " + x_nm; } + return fu_it; +} + +function gp_add_jar (x_jar_fn) { + if ( ! gf_if (x_jar_fn) ) { throw ( "JAR file not found => " + x_jar_fn ); } + var CClassArray = Java.type ("java.lang.Class[]"); + var pu_parameters = new CClassArray (1); + pu_parameters [0] = java.net.URL .class; + var pu_add_url = java.net.URLClassLoader .class .getDeclaredMethod ( "addURL", pu_parameters ); + pu_add_url .setAccessible (true); + var pu_sys_cl = java.lang.ClassLoader .getSystemClassLoader (); + var CObjectArray = Java .type ("java.lang.Object[]"); + var pu_array = new CObjectArray (1); + pu_array [0] = new CjFile (x_jar_fn) .toURL (); + pu_add_url .invoke ( pu_sys_cl, pu_array ); +} + +function gp_add_java_library_path (x_java_library_pn) { + if ( ! ( gf_xi (x_java_library_pn) && gf_id (x_java_library_pn) ) ) { throw ( "Java library path not found => " + x_java_library_pn ); } + var pu_org_paths = CjSystem .getProperty ("java.library.path"); + if ( pu_org_paths .contains (x_java_library_pn) ) { return; } + CjSystem .setProperty ( "java.library.path", pu_org_paths + GC_PASA + x_java_library_pn ); + var pu_f = java.lang.ClassLoader .class .getDeclaredField ("sys_paths") + pu_f .setAccessible (true) + pu_f .set ( null, null ) +} + +gp_add_jar ( gf_os_env ("__SAC_JEP_JAR_FN") ); +gp_add_java_library_path ( gf_os_env ("__SAC_JEP_PN") ); + +var gu_t = new Packages.jep.Jep ( false, GC_TONO_HM ); // py(t)hon + +function gf_tf () { return gu_t .invoke ( arguments [0], Java .to ( Array.prototype .slice .call ( arguments, 1 ) ) ); } // invoke (f)unction +function gp_ts ( x_key, x_val ) { gu_t .set ( x_key, x_val ); } // (s)et value +function gf_tg (x_key) { return gu_t .getValue (x_key); } // (g)et value +function gp_tx (x_str) { return gu_t .eval (x_str); } // e(x)ecute statement +function gf_te (x_str) { return gf_tf ( 'gf_te', x_str ); } // (e)valuate expression +function gp_trs (x_fn) { gp_ts ( '__file__', x_fn ); gu_t .runScript (x_fn); } // (r)un (s)cript + +gp_tx ( 'import sys' ) +gp_tx ( 'sys.dont_write_bytecode = True' ) +gp_ts ( '__sau_n', gu_n ); + +//-------------- +// Your Source +//-------------- + +gp_trs ( gf_pj ( GC_TONO_HM, 'SToa.py' ) ); diff --git a/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.py b/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.py new file mode 100644 index 0000000..f45afbb --- /dev/null +++ b/Pyja-20.09.22/Pyja/20.09.22/Salak/Hepager/210603-2155 Hello Reverse String/SToa.py @@ -0,0 +1,22 @@ +# +-----------------------------------------------------------------------+ +# : Pyja : +# : https://github.com/PyjaErskell : +# : made by Erskell (pyja.erskell@gmail.com) : +# : released under the GNU AGPL v3, see . : +# +-----------------------------------------------------------------------+ + +from Global import * + +def sp_main () : + # reading the first line of the headers to be ignored + pv_ln = gu_n.br .readLine () + + # read file line by line + pv_ln = gu_n.br .readLine () + while pv_ln is not None : + bu2_str = "안녕)Hello( ]" + pv_ln + "[ )olleH(녕안" + bu2_to_write = bu2_str [::-1] + "\r\n" + gu_n.bw .write ( bu2_to_write, 0, len(bu2_to_write) ) + pv_ln = gu_n.br .readLine () + +sp_main ()