a.leo 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.20210124200516.2"><vh>API de mailing list</vh></v>
  10. <v t="caminhante.20200313155940.1"><vh>@settings</vh>
  11. <v t="caminhante.20200618180759.1"><vh>@command terminal-here @key=Alt-T</vh></v>
  12. <v t="caminhante.20200619162742.1"><vh>@command open-url-here @key=Ctrl-U</vh></v>
  13. <v t="caminhante.20200313155940.2"><vh>command mk_path_image_nodes</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.20200619213937.1"><vh>@node|@node .* [X]</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="caminhante.20200912185313.1"><vh>@lua|@lua .* [X]</vh></v>
  22. <v t="caminhante.20200618203115.1"><vh>@run|@run .* [X]</vh></v>
  23. <v t="caminhante.20200619154823.1"><vh>@web *</vh></v>
  24. </v>
  25. </v>
  26. <v t="caminhante.20210214143542.1"><vh>@run status</vh>
  27. <v t="caminhante.20210214143548.1"><vh>@run status</vh></v>
  28. </v>
  29. <v t="caminhante.20210214144036.1"><vh>@path include</vh>
  30. <v t="caminhante.20210214143558.1"><vh>@file server.js</vh></v>
  31. </v>
  32. </vnodes>
  33. <tnodes>
  34. <t tx="caminhante.20200313155940.1"></t>
  35. <t tx="caminhante.20200313155940.2">@language python
  36. @tabwidth -2
  37. import os
  38. image_extensions = ('.png','.jpg','.jpeg')
  39. web_prefixes = ('http:','https:')
  40. if c.p.b.startswith('@path') or c.p.h.startswith('@path'):
  41. for child in c.p.children():
  42. firstline = child.b.split('\n')[0]
  43. headline = child.h
  44. for a in web_prefixes:
  45. if a in firstline:
  46. firstline = firstline.split('?')[0]
  47. break
  48. if a in headline:
  49. headline = headline.split('?')[0]
  50. break
  51. fnb, extb = os.path.splitext(firstline)
  52. fnh, exth = os.path.splitext(headline)
  53. if extb in image_extensions or exth in image_extensions:
  54. if not firstline:
  55. child.b = child.h
  56. child.h = '@image ' + child.h
  57. </t>
  58. <t tx="caminhante.20200313155940.99">@language python
  59. </t>
  60. <t tx="caminhante.20200604232050.1">import subprocess
  61. def execute (cmd):
  62. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  63. if c.isChanged(): c.save()
  64. path = c.getNodePath(c.p)
  65. g.os.chdir(path)
  66. command = ''.join(c.p.h.split('@cmd ')[1:])
  67. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | bash\n"+command+'\nEOFEOFEOFEOFEOFEOF'
  68. g.es(c.p.h)
  69. c.p.b += execute(command)
  70. c.save()
  71. </t>
  72. <t tx="caminhante.20200618180759.1">@language python
  73. import subprocess
  74. def execute (cmd):
  75. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  76. if c.isChanged(): c.save()
  77. path = c.getNodePath(c.p)
  78. execute('terminator --working-directory="'+path+'" --new-tab')
  79. </t>
  80. <t tx="caminhante.20200618203115.1">@language python
  81. import subprocess
  82. # def getpath (p):
  83. # dict = c.scanAllDirectives(p)
  84. # d = dict.get("path")
  85. # if p.isAnyAtFileNode():
  86. # filename = p.anyAtFileNodeName()
  87. # filename = g.os_path_join(d,filename)
  88. # if filename:
  89. # d = g.os_path_dirname(filename)
  90. # if d is None:
  91. # return ""
  92. # else:
  93. # return g.os_path_normpath(d)
  94. # if c.isChanged(): c.save()
  95. def execute (cmd):
  96. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  97. path = c.getNodePath(c.p)
  98. g.os.chdir(path)
  99. w = c.frame.body.wrapper
  100. s1,s2 = w.getSelectionRange()
  101. if s1 == s2:
  102. code = c.p.b
  103. else:
  104. linebr = c.p.b.find('\n',s2)
  105. if linebr == -1: linebr = len(c.p.b)
  106. code = c.p.b[s1:s2]
  107. g.es(c.p.h)
  108. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | bash\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  109. # if s1 == s2:
  110. # c.p.b += '\n' + execute(command)
  111. # else:
  112. # c.p.b = c.p.b[0:linebr] + '\n' + execute(command) + c.p.b[linebr:]
  113. cpc = c.p.copy()
  114. novoNo = cpc.insertAsLastChild()
  115. novoNo.h = c.p.h
  116. novoNo.b = execute(command)
  117. c.redraw()
  118. c.save()
  119. w.setSelectionRange(s1,s2)
  120. </t>
  121. <t tx="caminhante.20200619154823.1">import subprocess
  122. def execute (cmd):
  123. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  124. if c.isChanged(): c.save()
  125. url = ''.join(c.p.h.split('@web ')[1:])
  126. command = 'lynx -image_links -dump "'+url+'"'
  127. g.es(c.p.h)
  128. c.p.b = execute(command)
  129. c.save()
  130. </t>
  131. <t tx="caminhante.20200619155412.1">import subprocess
  132. import urllib.parse
  133. def execute (cmd):
  134. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  135. if c.isChanged(): c.save()
  136. search = ''.join(c.p.h.split('@duck ')[1:])
  137. searchenc = urllib.parse.quote(search)
  138. command = 'lynx -dump "https://duckduckgo.com/html/?q='+searchenc+'&amp;t=seamonkey"'
  139. g.es(c.p.h)
  140. c.p.b = execute(command)
  141. c.save()
  142. </t>
  143. <t tx="caminhante.20200619161501.1">import subprocess
  144. def execute (cmd):
  145. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  146. if c.isChanged(): c.save()
  147. path = c.getNodePath(c.p)
  148. g.os.chdir(path)
  149. url = ''.join(c.p.h.split('@download ')[1:])
  150. command = 'wget --no-config --continue --no-verbose --adjust-extension --tries=3 --content-on-error "'+url+'"'
  151. g.es(c.p.h)
  152. c.p.b += execute(command)
  153. c.save()
  154. </t>
  155. <t tx="caminhante.20200619162742.1">@language python
  156. # if c.isChanged(): c.save()
  157. w = c.frame.body.wrapper
  158. b = c.p.b
  159. i,j = w.getSelectionRange()
  160. selecao = b[i:j]
  161. cpc = c.p.copy()
  162. novoNo = cpc.insertAsLastChild()
  163. c.setHeadString(novoNo, '@web '+selecao)
  164. c.selectPosition(novoNo)
  165. c.redraw()
  166. </t>
  167. <t tx="caminhante.20200619213937.1">import subprocess
  168. import re
  169. def execute (cmd):
  170. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  171. path = c.getNodePath(c.p)
  172. g.os.chdir(path)
  173. code = re.sub(r'^#|\n+#', '\n///', g.getScript(c,c.p))
  174. g.es(c.p.h)
  175. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | node\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  176. c.p.b += '\n' + execute(command)
  177. </t>
  178. <t tx="caminhante.20200808174417.1">import subprocess
  179. import re
  180. def execute (cmd):
  181. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  182. path = c.getNodePath(c.p)
  183. g.os.chdir(path)
  184. code = re.sub(r'^#|\n+#', '\n///', g.getScript(c,c.p))
  185. g.es(c.p.h)
  186. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | js\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  187. c.p.b += '\n' + execute(command)
  188. </t>
  189. <t tx="caminhante.20200912185313.1">import subprocess
  190. import re
  191. def execute (cmd):
  192. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  193. path = c.getNodePath(c.p)
  194. g.os.chdir(path)
  195. code = re.sub(r'^#|\n+#', '\n---', g.getScript(c,c.p))
  196. g.es(c.p.h)
  197. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | lua\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  198. c.p.b += '\n' + execute(command)
  199. </t>
  200. <t tx="caminhante.20200927204806.1">import subprocess
  201. import re
  202. def execute (cmd):
  203. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  204. path = c.getNodePath(c.p)
  205. g.os.chdir(path)
  206. code = re.sub(r'^#@|\n+#@', '\n///', g.getScript(c,c.p))
  207. args = ''.join(c.p.h.split('@gcc ')[1:])
  208. g.es(c.p.h)
  209. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | gcc -x c - -o t &amp;&amp; ./t "+args+"\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  210. c.p.b += '\n' + execute(command)
  211. </t>
  212. <t tx="caminhante.20210124200516.2"></t>
  213. <t tx="caminhante.20210214143542.1">git status</t>
  214. <t tx="caminhante.20210214143548.1">On branch master
  215. Your branch is up to date with 'origin/master'.
  216. Changes to be committed:
  217. (use "git reset HEAD &lt;file&gt;..." to unstage)
  218. new file: a.leo
  219. </t>
  220. <t tx="caminhante.20210214144036.1">@tabwidth -2</t>
  221. </tnodes>
  222. </leo_file>