xforth.leo 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Created by Leo: http://leoeditor.com/leo_toc.html -->
  3. <leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
  4. <leo_header file_format="2"/>
  5. <globals/>
  6. <preferences/>
  7. <find_panel_settings/>
  8. <vnodes>
  9. <v t="caminhante.20200313155940.1"><vh>@settings</vh>
  10. <v t="caminhante.20200313155940.3"><vh>@data abbreviations</vh></v>
  11. <v t="caminhante.20200313155940.4"><vh>@outline-data tree-abbreviations</vh></v>
  12. <v t="caminhante.20200618180759.1"><vh>@command terminal-here @key=Alt-T</vh></v>
  13. <v t="caminhante.20200619162742.1"><vh>@command open-url-here @key=Ctrl-U</vh></v>
  14. <v t="caminhante.20200313155940.99"><vh>nodeActions</vh>
  15. <v t="caminhante.20200604232050.1"><vh>@cmd *</vh></v>
  16. <v t="caminhante.20200619161501.1"><vh>@download *</vh></v>
  17. <v t="caminhante.20200619155412.1"><vh>@duck *</vh></v>
  18. <v t="caminhante.20211214151759.1"><vh>@files Makefile</vh></v>
  19. <v t="caminhante.20200927204806.1"><vh>@gcc|@gcc .* [X]</vh></v>
  20. <v t="caminhante.20200808174417.1"><vh>@js|@js .* [X]</vh></v>
  21. <v t="knoppix.20200918114306.1"><vh>@kml *</vh></v>
  22. <v t="knoppix.20200918115239.1"><vh>@kmlfolder *</vh></v>
  23. <v t="knoppix.20200918115703.1"><vh>@latlon *</vh></v>
  24. <v t="knoppix.20200918120617.1"><vh>@latlonh *</vh></v>
  25. <v t="caminhante.20200912185313.1"><vh>@lua|@lua .* [X]</vh></v>
  26. <v t="caminhante.20210430163831.1"><vh>@mkdir *</vh></v>
  27. <v t="caminhante.20210430170244.1"><vh>@mv file://*</vh></v>
  28. <v t="caminhante.20200619213937.1"><vh>@node|@node .* [X]</vh></v>
  29. <v t="caminhante.20210608171556.1"><vh>@odt *</vh></v>
  30. <v t="caminhante.20210905232208.1"><vh>@rm *</vh></v>
  31. <v t="caminhante.20210430164404.1"><vh>@rmdir /*/</vh></v>
  32. <v t="caminhante.20200618203115.1"><vh>@run|@run .* [X]</vh></v>
  33. <v t="caminhante.20200619154823.1"><vh>@web *</vh></v>
  34. </v>
  35. </v>
  36. <v t="caminhante.20211214150936.2"><vh>XForth</vh>
  37. <v t="caminhante.20211214151142.1"><vh>@path .</vh>
  38. <v t="caminhante.20211214151146.9"><vh>/.git/</vh></v>
  39. <v t="caminhante.20211214151146.7"><vh>@clean Makefile</vh></v>
  40. <v t="caminhante.20211214151146.8"><vh>@edit LICENSE</vh></v>
  41. <v t="caminhante.20211214151146.6"><vh>@file primitives.asm</vh></v>
  42. <v t="caminhante.20211214151146.5"><vh>structs.inc</vh></v>
  43. <v t="caminhante.20211214151146.4"><vh>structs_v.inc</vh></v>
  44. <v t="caminhante.20211214151146.3"><vh>symbols.inc</vh></v>
  45. <v t="caminhante.20211214151146.2"><vh>xforth.asm</vh></v>
  46. <v t="caminhante.20211214151146.1"><vh>xforth.leo</vh></v>
  47. </v>
  48. </v>
  49. </vnodes>
  50. <tnodes>
  51. <t tx="caminhante.20200313155940.1"></t>
  52. <t tx="caminhante.20200313155940.3">@tabwidth -2
  53. </t>
  54. <t tx="caminhante.20200313155940.4"></t>
  55. <t tx="caminhante.20200313155940.99">@language python
  56. </t>
  57. <t tx="caminhante.20200604232050.1">import subprocess
  58. def execute (cmd):
  59. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  60. if c.isChanged(): c.save()
  61. path = c.getNodePath(c.p)
  62. g.os.chdir(path)
  63. command = ''.join(c.p.h.split('@cmd ')[1:])
  64. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | bash\n"+command+'\nEOFEOFEOFEOFEOFEOF'
  65. g.es(c.p.h)
  66. c.p.b += execute(command)
  67. c.save()
  68. </t>
  69. <t tx="caminhante.20200618180759.1">@language python
  70. import subprocess
  71. def execute (cmd):
  72. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  73. if c.isChanged(): c.save()
  74. path = c.getNodePath(c.p)
  75. execute('x-terminal-emulator --working-directory="'+path+'"')
  76. </t>
  77. <t tx="caminhante.20200618203115.1">@language python
  78. import subprocess
  79. def execute (cmd):
  80. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  81. path = c.getNodePath(c.p)
  82. g.os.chdir(path)
  83. w = c.frame.body.wrapper
  84. s1,s2 = w.getSelectionRange()
  85. if s1 == s2:
  86. code = c.p.b
  87. else:
  88. linebr = c.p.b.find('\n',s2)
  89. if linebr == -1: linebr = len(c.p.b)
  90. code = c.p.b[s1:s2]
  91. g.es(c.p.h)
  92. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | bash\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  93. cpc = c.p.copy()
  94. novoNo = cpc.insertAsLastChild()
  95. novoNo.h = c.p.h
  96. novoNo.b = execute(command)
  97. c.redraw()
  98. c.save()
  99. w.setSelectionRange(s1,s2)
  100. </t>
  101. <t tx="caminhante.20200619154823.1">import subprocess
  102. def execute (cmd):
  103. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  104. if c.isChanged(): c.save()
  105. url = ''.join(c.p.h.split('@web ')[1:])
  106. command = 'lynx -image_links -dump "'+url+'"'
  107. g.es(c.p.h)
  108. c.p.b = execute(command)
  109. c.save()
  110. </t>
  111. <t tx="caminhante.20200619155412.1">import subprocess
  112. import urllib.parse
  113. def execute (cmd):
  114. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  115. if c.isChanged(): c.save()
  116. search = ''.join(c.p.h.split('@duck ')[1:])
  117. searchenc = urllib.parse.quote(search)
  118. command = 'lynx -dump "https://duckduckgo.com/html/?q='+searchenc+'&amp;t=seamonkey"'
  119. g.es(c.p.h)
  120. c.p.b = execute(command)
  121. c.save()
  122. </t>
  123. <t tx="caminhante.20200619161501.1">import subprocess
  124. def execute (cmd):
  125. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  126. if c.isChanged(): c.save()
  127. path = c.getNodePath(c.p)
  128. g.os.chdir(path)
  129. url = ''.join(c.p.h.split('@download ')[1:])
  130. command = 'wget --no-config --continue --no-verbose --adjust-extension --tries=3 --content-on-error "'+url+'"'
  131. g.es(c.p.h)
  132. c.p.b += execute(command)
  133. c.save()
  134. </t>
  135. <t tx="caminhante.20200619162742.1">@language python
  136. w = c.frame.body.wrapper
  137. b = c.p.b
  138. i,j = w.getSelectionRange()
  139. selecao = b[i:j]
  140. cpc = c.p.copy()
  141. novoNo = cpc.insertAsLastChild()
  142. c.setHeadString(novoNo, '@web '+selecao)
  143. c.selectPosition(novoNo)
  144. c.redraw()
  145. </t>
  146. <t tx="caminhante.20200619213937.1">import subprocess
  147. import re
  148. def execute (cmd):
  149. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  150. path = c.getNodePath(c.p)
  151. g.os.chdir(path)
  152. code = re.sub(r'^#|\n+#', '\n///', g.getScript(c,c.p))
  153. g.es(c.p.h)
  154. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | node\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  155. c.p.b += '\n' + execute(command)
  156. </t>
  157. <t tx="caminhante.20200808174417.1">import subprocess
  158. import re
  159. def execute (cmd):
  160. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  161. path = c.getNodePath(c.p)
  162. g.os.chdir(path)
  163. code = re.sub(r'^#|\n+#', '\n///', g.getScript(c,c.p))
  164. g.es(c.p.h)
  165. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | js\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  166. c.p.b += '\n' + execute(command)
  167. </t>
  168. <t tx="caminhante.20200912185313.1">import subprocess
  169. import re
  170. def execute (cmd):
  171. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  172. path = c.getNodePath(c.p)
  173. g.os.chdir(path)
  174. code = re.sub(r'^#|\n+#', '\n---', g.getScript(c,c.p))
  175. g.es(c.p.h)
  176. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | lua\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  177. c.p.b += '\n' + execute(command)
  178. </t>
  179. <t tx="caminhante.20200927204806.1">import subprocess
  180. import re
  181. def execute (cmd):
  182. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  183. path = c.getNodePath(c.p)
  184. g.os.chdir(path)
  185. code = re.sub(r'^#@|\n+#@', '\n///', g.getScript(c,c.p))
  186. args = ''.join(c.p.h.split('@gcc ')[1:])
  187. g.es(c.p.h)
  188. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | gcc -Wall -Werror -std=gnu11 -x c - -o t &amp;&amp; ./t "+args+"\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  189. c.p.b += '\n' + execute(command)
  190. </t>
  191. <t tx="caminhante.20210430163831.1">import subprocess
  192. def execute (cmd):
  193. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  194. path = c.getNodePath(c.p)
  195. g.os.chdir(path)
  196. path = ''.join(c.p.h.split('@mkdir ')[1:])
  197. cmd = 'mkdir -p "' + path + '"'
  198. g.es(c.p.h)
  199. execute(cmd)
  200. c.p.h = '/'+path+'/'
  201. c.p.b = '@path ' + path</t>
  202. <t tx="caminhante.20210430164404.1">import subprocess
  203. import shutil
  204. def execute (cmd):
  205. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  206. ps = c.p.parents()
  207. for par in ps:
  208. break
  209. path = c.getNodePath(par)
  210. g.os.chdir(path)
  211. path = ''.join(c.p.h.split('@rmdir /')[1:]).split('/')[0]
  212. shutil.rmtree(path)</t>
  213. <t tx="caminhante.20210430170244.1">import subprocess
  214. def execute (cmd):
  215. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  216. path = c.getNodePath(c.p)
  217. g.os.chdir(path)
  218. path = ''.join(c.p.h.split('@mv file://')[1:])
  219. cmd = 'mv -v "' + path + '" ./'
  220. g.es(c.p.h)
  221. g.es(execute(cmd))</t>
  222. <t tx="caminhante.20210608171556.1">import subprocess
  223. import re
  224. def execute (cmd):
  225. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  226. def writeFile (_file,_content):
  227. f = open(_file, "w")
  228. f.write(_content)
  229. f.close()
  230. path = c.getNodePath(c.p)
  231. g.os.chdir(path)
  232. docName = ''.join(c.p.h.split('@odt ')[1:])
  233. docPath = './.odt/'+docName+'/'
  234. manifest_xml = """&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  235. &lt;manifest:manifest
  236. xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2"
  237. xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"&gt;
  238. &lt;manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.text"/&gt;
  239. &lt;manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml"/&gt;
  240. &lt;manifest:file-entry manifest:full-path="meta.xml" manifest:media-type="text/xml"/&gt;
  241. &lt;manifest:file-entry manifest:full-path="manifest.rdf" manifest:media-type="application/rdf+xml"/&gt;
  242. &lt;manifest:file-entry manifest:full-path="styles.xml" manifest:media-type="text/xml"/&gt;
  243. &lt;/manifest:manifest&gt;
  244. """
  245. mimetype = "application/vnd.oasis.opendocument.text"
  246. content_xml = (
  247. """&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  248. &lt;office:document-content
  249. xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  250. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  251. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  252. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  253. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  254. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  255. xmlns:xlink="http://www.w3.org/1999/xlink"
  256. xmlns:dc="http://purl.org/dc/elements/1.1/"
  257. xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  258. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  259. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  260. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  261. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  262. xmlns:math="http://www.w3.org/1998/Math/MathML"
  263. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  264. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  265. xmlns:ooo="http://openoffice.org/2004/office"
  266. xmlns:ooow="http://openoffice.org/2004/writer"
  267. xmlns:oooc="http://openoffice.org/2004/calc"
  268. xmlns:dom="http://www.w3.org/2001/xml-events"
  269. xmlns:xforms="http://www.w3.org/2002/xforms"
  270. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  271. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  272. xmlns:rpt="http://openoffice.org/2005/report"
  273. xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
  274. xmlns:xhtml="http://www.w3.org/1999/xhtml"
  275. xmlns:grddl="http://www.w3.org/2003/g/data-view#"
  276. xmlns:officeooo="http://openoffice.org/2009/office"
  277. xmlns:tableooo="http://openoffice.org/2009/table"
  278. xmlns:drawooo="http://openoffice.org/2010/draw"
  279. xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
  280. xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
  281. xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"
  282. xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
  283. xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"&gt;
  284. &lt;office:body&gt;
  285. &lt;office:text&gt;
  286. """,
  287. re.sub(r'^#@[^\n]+|\n+#@[^\n]+', '', g.getScript(c,c.p)),
  288. """
  289. &lt;/office:text&gt;
  290. &lt;/office:body&gt;
  291. &lt;/office:document-content&gt;
  292. """
  293. )
  294. manifest_rdf = """&lt;?xml version="1.0" encoding="utf-8"?&gt;
  295. &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
  296. &lt;rdf:Description rdf:about="styles.xml"&gt;
  297. &lt;rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/odf#StylesFile"/&gt;
  298. &lt;/rdf:Description&gt;
  299. &lt;rdf:Description rdf:about=""&gt;
  300. &lt;ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="styles.xml"/&gt;
  301. &lt;/rdf:Description&gt;
  302. &lt;rdf:Description rdf:about="content.xml"&gt;
  303. &lt;rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/odf#ContentFile"/&gt;
  304. &lt;/rdf:Description&gt;
  305. &lt;rdf:Description rdf:about=""&gt;
  306. &lt;ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="content.xml"/&gt;
  307. &lt;/rdf:Description&gt;
  308. &lt;rdf:Description rdf:about=""&gt;
  309. &lt;rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document"/&gt;
  310. &lt;/rdf:Description&gt;
  311. &lt;/rdf:RDF&gt;
  312. """
  313. meta_xml = f"""&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  314. &lt;office:document-meta
  315. xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  316. xmlns:xlink="http://www.w3.org/1999/xlink"
  317. xmlns:dc="http://purl.org/dc/elements/1.1/"
  318. xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  319. xmlns:ooo="http://openoffice.org/2004/office"
  320. xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2"&gt;
  321. &lt;office:meta&gt;
  322. &lt;meta:generator&gt;LeoEditor/6.4$Linux_x64&lt;/meta:generator&gt;
  323. &lt;dc:title&gt;{docName}&lt;/dc:title&gt;
  324. &lt;/office:meta&gt;
  325. &lt;/office:document-meta&gt;
  326. """
  327. generate_odt = f"""cp -f styles.xml '{docPath}/styles.xml'; cd '{docPath}'; zip -q9ru doc.odt META-INF manifest.rdf meta.xml content.xml styles.xml mimetype"""
  328. generate_pdf = f"""libreoffice --headless --convert-to pdf '{docPath}/doc.odt' &amp;&amp; mv 'doc.pdf' '{docName}.pdf'"""
  329. execute('mkdir -p "'+docPath+'/META-INF/"')
  330. writeFile(docPath+'/META-INF/manifest.xml', manifest_xml)
  331. writeFile(docPath+'/mimetype', mimetype)
  332. writeFile(docPath+'/content.xml',''.join(content_xml))
  333. writeFile(docPath+'/manifest.rdf', manifest_rdf)
  334. writeFile(docPath+'/meta.xml', meta_xml)
  335. # writeFile(docPath+'/styles.xml', styles_xml)
  336. execute(generate_odt)
  337. g.es(execute(generate_pdf))
  338. </t>
  339. <t tx="caminhante.20210905232208.1">import subprocess
  340. def execute (cmd):
  341. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  342. path = c.getNodePath(c.p)
  343. g.os.chdir(path)
  344. filename = ''.join(c.p.h.split('@rm ')[1:])
  345. cmd = 'rm -vf "' + filename + '"'
  346. g.es(c.p.h)
  347. g.es(execute(cmd))
  348. </t>
  349. <t tx="caminhante.20211214150936.2"></t>
  350. <t tx="caminhante.20211214151142.1"></t>
  351. <t tx="caminhante.20211214151146.1"></t>
  352. <t tx="caminhante.20211214151146.2"></t>
  353. <t tx="caminhante.20211214151146.3"></t>
  354. <t tx="caminhante.20211214151146.4"></t>
  355. <t tx="caminhante.20211214151146.5"></t>
  356. <t tx="caminhante.20211214151146.7">@tabwidth 4
  357. all: xforth
  358. xforth: xforth.asm $(wildcard *.asm) $(wildcard *.inc)
  359. fasm xforth.asm
  360. clean:
  361. rm xforth
  362. </t>
  363. <t tx="caminhante.20211214151146.9">@path .git</t>
  364. <t tx="caminhante.20211214151759.1">import subprocess
  365. def execute (cmd):
  366. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  367. if c.isChanged(): c.save()
  368. path = c.getNodePath(c.p)
  369. g.os.chdir(path)
  370. g.es(execute('make'))</t>
  371. <t tx="knoppix.20200918114306.1">nome = ''.join(c.p.h.split('@kml ')[1:])
  372. c.p.h = f"@file {nome}.kml"
  373. c.p.b = f"""@language xml
  374. ##@tabwidth -2
  375. &lt;kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"&gt;
  376. &lt;Document&gt;
  377. &lt;name&gt;{nome}&lt;/name&gt;
  378. &lt;Style id="poi"&gt;
  379. &lt;IconStyle&gt;
  380. &lt;Icon&gt;
  381. &lt;href&gt;/usr/share/marble/data/bitmaps/annotation.png&lt;/href&gt;
  382. &lt;scale&gt;0.5&lt;/scale&gt;
  383. &lt;/Icon&gt;
  384. &lt;/IconStyle&gt;
  385. &lt;BalloonStyle&gt;
  386. &lt;bgColor&gt;ffffaabb&lt;/bgColor&gt;
  387. &lt;text&gt;$[description]&lt;/text&gt;
  388. &lt;/BalloonStyle&gt;
  389. &lt;/Style&gt;
  390. ##@others
  391. &lt;/Document&gt;
  392. &lt;/kml&gt;""".replace("##","")
  393. </t>
  394. <t tx="knoppix.20200918115239.1">nome = ''.join(c.p.h.split('@kmlfolder ')[1:])
  395. c.p.b = f"""@language xml
  396. &lt;Folder&gt;
  397. &lt;name&gt;{nome}&lt;/name&gt;
  398. ##@others
  399. &lt;/Folder&gt;""".replace("##","")
  400. </t>
  401. <t tx="knoppix.20200918115703.1">import re
  402. a = c.p.h
  403. b = re.match(r'^@latlon\s+(-?\d+(\.\d+)?)\s*,\s*(-?\d+(\.\d+)?)\s*(.*)$',a)
  404. title = (lambda: b.groups()[4] if b else a)()
  405. lat = (lambda: b.groups()[0] if b else '&lt;|latitude|&gt;')()
  406. lon = (lambda: b.groups()[2] if b else '&lt;|longitude|&gt;')()
  407. c.p.b = f"""@language xml
  408. &lt;Placemark&gt;
  409. &lt;name&gt;{title}&lt;/name&gt;
  410. &lt;description&gt;&lt;![CDATA[
  411. ##@others
  412. ]]&gt;&lt;/description&gt;
  413. &lt;LookAt&gt;
  414. &lt;longitude&gt;{lon}&lt;/longitude&gt;
  415. &lt;latitude&gt;{lat}&lt;/latitude&gt;
  416. &lt;altitude&gt;0.0000000000&lt;/altitude&gt;
  417. &lt;range&gt;100&lt;/range&gt;
  418. &lt;/LookAt&gt;
  419. &lt;styleUrl&gt;#poi&lt;/styleUrl&gt;
  420. &lt;Point&gt;
  421. &lt;coordinates&gt; {lon},{lat} &lt;/coordinates&gt;
  422. &lt;/Point&gt;
  423. &lt;/Placemark&gt;""".replace("##","")
  424. </t>
  425. <t tx="knoppix.20200918120617.1">import re
  426. a = c.p.h
  427. b = re.match(r'^@latlonh\s+(-?\d+(\.\d+)?)\s*,\s*(-?\d+(\.\d+)?)\s*(.*)$',a)
  428. title = (lambda: b.groups()[4] if b else a)()
  429. lat = (lambda: b.groups()[0] if b else '&lt;|latitude|&gt;')()
  430. lon = (lambda: b.groups()[2] if b else '&lt;|longitude|&gt;')()
  431. try:
  432. lt=float(lat)
  433. ln=float(lon)
  434. nslat=(lambda: 'N'+lat if lt&gt;0 else 'S'+lat[1:])()
  435. welon=(lambda: 'E'+lon if ln&gt;0 else 'W'+lon[1:])()
  436. c.p.b = f"""@language xml
  437. &lt;Placemark&gt;
  438. &lt;name&gt;{title}&lt;/name&gt;
  439. &lt;description&gt;&lt;![CDATA[
  440. &lt;html&gt;&lt;body&gt;
  441. &lt;pre style="white-space:pre-line;"&gt;
  442. ##@others
  443. &lt;/pre&gt;
  444. &lt;p&gt;&lt;a href="https://wego.here.com/directions/mix/{nslat},{welon}?map={lat},{lon},15,normal" target="_blank"&gt;Abrir no HERE Maps&lt;/a&gt;&lt;/p&gt;
  445. &lt;/body&gt;&lt;/html&gt;
  446. ]]&gt;&lt;/description&gt;
  447. &lt;LookAt&gt;
  448. &lt;longitude&gt;{lon}&lt;/longitude&gt;
  449. &lt;latitude&gt;{lat}&lt;/latitude&gt;
  450. &lt;altitude&gt;0.0000000000&lt;/altitude&gt;
  451. &lt;range&gt;100&lt;/range&gt;
  452. &lt;/LookAt&gt;
  453. &lt;styleUrl&gt;#poi&lt;/styleUrl&gt;
  454. &lt;iconUrl&gt;imovel.png&lt;/iconUrl&gt;
  455. &lt;Point&gt;
  456. &lt;coordinates&gt;{lon},{lat}&lt;/coordinates&gt;
  457. &lt;/Point&gt;
  458. &lt;/Placemark&gt;""".replace("##","")
  459. except:
  460. c.p.b = f"""title: {title}
  461. lat: {lat}
  462. lon: {lon}
  463. """
  464. </t>
  465. </tnodes>
  466. </leo_file>