dsl-python 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/npython +5 -5
- data/docs/pybirras-2026.md +109 -0
- data/lib/dsl/python/ansi.rb +10 -5
- data/lib/dsl/python/cli.rb +22 -22
- data/lib/dsl/python/functions/etc.rb +2 -3
- data/lib/dsl/python/functions/import.rb +16 -9
- data/lib/dsl/python/klasses.rb +0 -1
- data/lib/dsl/python/repl/copyright.rb +3 -4
- data/lib/dsl/python/repl/credits.rb +4 -5
- data/lib/dsl/python/repl/etc.rb +3 -3
- data/lib/dsl/python/repl/license.rb +57 -58
- data/lib/dsl/python/repl/zen.rb +22 -22
- data/lib/dsl/python/types/array.rb +45 -13
- data/lib/dsl/python/types/boolean.rb +0 -1
- data/lib/dsl/python/types/hash.rb +1 -1
- data/lib/dsl/python/types/integer.rb +16 -16
- data/lib/dsl/python/types/range.rb +1 -1
- data/lib/dsl/python/types/string.rb +17 -25
- data/lib/dsl/python/version.rb +2 -2
- data/lib/dsl/python.rb +2 -3
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79b4ff2a17e321801b7d0f6f1f0ede3803b05560caca9602c2d7d190483c3a81
|
|
4
|
+
data.tar.gz: 4773c0bdc56d29aff9507ea1a9147abd566632b28088ed982e8882d9ce18d1ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ae9e7d3899600e11d18fe39f8f7e2013ff818c546598c0f8944dbf4374e152d7362a470cac93622dd878f884b353290967aa295b9cc1b52c4cf84dddb0835038
|
|
7
|
+
data.tar.gz: c5be922b1ab00dc12affa16cd5cf9375a71507c183260f4873c5db9f5c2c6d964752db11803dffed1213bb51e9978f79c9f7c2c005523a06b3f7ed7430c14b7a
|
data/bin/npython
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
|
4
4
|
require "dsl/python/cli"
|
|
5
5
|
|
|
6
6
|
if ARGV.size.zero?
|
|
7
|
-
Dsl::Python
|
|
7
|
+
Dsl::Python.open_repl
|
|
8
8
|
elsif ["v", "-v", "--version", "-V"].include? ARGV.first
|
|
9
|
-
Dsl::Python
|
|
9
|
+
Dsl::Python.show_version
|
|
10
10
|
elsif ["h", "-h", "--help", "-?"].include? ARGV.first
|
|
11
|
-
Dsl::Python
|
|
11
|
+
Dsl::Python.show_help
|
|
12
12
|
else
|
|
13
|
-
|
|
13
|
+
run_program ARGV.first
|
|
14
14
|
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
# PiByrras 202605
|
|
3
|
+
|
|
4
|
+
* Abrir REPL python3 y npython
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
name = "Obiwan"
|
|
8
|
+
len(name)
|
|
9
|
+
type(name)
|
|
10
|
+
name.__len__()
|
|
11
|
+
|
|
12
|
+
>>> name = name + " Kenobi"
|
|
13
|
+
>>> name
|
|
14
|
+
'Obiwan Kenobi'
|
|
15
|
+
>>> name = name.__add__(" Kenobi")
|
|
16
|
+
>>> name
|
|
17
|
+
'Obiwan Kenobi Kenobi'
|
|
18
|
+
>>> print(name)
|
|
19
|
+
Obiwan Kenobi Kenobi
|
|
20
|
+
>>> len(name)
|
|
21
|
+
20
|
|
22
|
+
>>>
|
|
23
|
+
True
|
|
24
|
+
>>> id(16)
|
|
25
|
+
140717975471496
|
|
26
|
+
>>> id(16)
|
|
27
|
+
140717975471496
|
|
28
|
+
>>> id(16)
|
|
29
|
+
140717975471496
|
|
30
|
+
>>> id(256)
|
|
31
|
+
140717975479176
|
|
32
|
+
>>> id(256)
|
|
33
|
+
140717975479176
|
|
34
|
+
>>> id(257)
|
|
35
|
+
2647436846352
|
|
36
|
+
>>> id(257)
|
|
37
|
+
2647436845104
|
|
38
|
+
>>> id(257)
|
|
39
|
+
2647436845232
|
|
40
|
+
>>> id(257)
|
|
41
|
+
2647436845328
|
|
42
|
+
>>> a = "obiwan"
|
|
43
|
+
>>> b = "obiwan"
|
|
44
|
+
>>> id(a)
|
|
45
|
+
2647432805904
|
|
46
|
+
>>> id(b)
|
|
47
|
+
2647432805904
|
|
48
|
+
>>>
|
|
49
|
+
|
|
50
|
+
--
|
|
51
|
+
Crear método .__ para "mostrar" todos los métodos "ocultos" de broma.
|
|
52
|
+
crear función id que invoque a object_id.
|
|
53
|
+
---
|
|
54
|
+
Trabajar con las clases:
|
|
55
|
+
crear un alias de initialize a __init__... es posible?
|
|
56
|
+
hacer metaprogramación para self.name= name
|
|
57
|
+
cree @name = name
|
|
58
|
+
|
|
59
|
+
>>> class Persona:
|
|
60
|
+
... def __init__(self, name, age):
|
|
61
|
+
... self.name = name
|
|
62
|
+
... self.age = age
|
|
63
|
+
...
|
|
64
|
+
>>> obiwan = Persona("Obiwan")
|
|
65
|
+
Traceback (most recent call last):
|
|
66
|
+
File "<python-input-59>", line 1, in <module>
|
|
67
|
+
obiwan = Persona("Obiwan")
|
|
68
|
+
TypeError: Persona.__init__() missing 1 required positional argument: 'age'
|
|
69
|
+
>>> obiwan = Persona("Obiwan", 55)
|
|
70
|
+
>>> print(obiwan)
|
|
71
|
+
<__main__.Persona object at 0x000002686780A210>
|
|
72
|
+
|
|
73
|
+
>>> type(obiwan)
|
|
74
|
+
<class '__main__.Persona'>
|
|
75
|
+
>>>
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
>>> type(obiwan)
|
|
79
|
+
<class '__main__.Persona'>
|
|
80
|
+
>>> class Persona:
|
|
81
|
+
... class Persona:
|
|
82
|
+
... print("hola")
|
|
83
|
+
...
|
|
84
|
+
hola
|
|
85
|
+
>>> class Persona:
|
|
86
|
+
... class Persona:
|
|
87
|
+
... print("hola")
|
|
88
|
+
... a = Persona()
|
|
89
|
+
... print(a)
|
|
90
|
+
... print(type(a))
|
|
91
|
+
...
|
|
92
|
+
hola
|
|
93
|
+
<__main__.Persona.Persona object at 0x00000268678A86E0>
|
|
94
|
+
<class '__main__.Persona.Persona'>
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
>>> obiwan.age
|
|
99
|
+
55
|
|
100
|
+
>>> obiwan.age= 56
|
|
101
|
+
>>> obiwan.age
|
|
102
|
+
56
|
|
103
|
+
>>> if obiwan.age > 18:
|
|
104
|
+
... print("Adulto")
|
|
105
|
+
...
|
|
106
|
+
Adulto
|
|
107
|
+
>>>
|
|
108
|
+
--
|
|
109
|
+
```
|
data/lib/dsl/python/ansi.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "io/console"
|
|
3
4
|
|
|
4
5
|
# Códigos ANSI de color:
|
|
@@ -51,22 +52,26 @@ class ANSI
|
|
|
51
52
|
print "\e[0m"
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def self.print_text_at(row, col, text)
|
|
55
|
+
def self.print_text_at(row, col, text)
|
|
55
56
|
print "\033[#{row + 1};#{col}H"
|
|
56
57
|
print text
|
|
57
58
|
print "\e[0m"
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def self.pressed_key
|
|
61
|
-
char =
|
|
62
|
+
char = begin
|
|
63
|
+
STDIN.read_nonblock(3)
|
|
64
|
+
rescue
|
|
65
|
+
nil
|
|
66
|
+
end
|
|
62
67
|
return nil unless char
|
|
63
|
-
|
|
68
|
+
|
|
64
69
|
case char
|
|
65
70
|
when "\e[A" then :up
|
|
66
71
|
when "\e[B" then :down
|
|
67
72
|
when "\e[C" then :right
|
|
68
73
|
when "\e[D" then :left
|
|
69
|
-
when "q"
|
|
74
|
+
when "q" then :quit
|
|
70
75
|
else char
|
|
71
76
|
end
|
|
72
77
|
end
|
|
@@ -80,4 +85,4 @@ class ANSI
|
|
|
80
85
|
STDIN.cooked!
|
|
81
86
|
STDIN.echo = true
|
|
82
87
|
end
|
|
83
|
-
end
|
|
88
|
+
end
|
data/lib/dsl/python/cli.rb
CHANGED
|
@@ -7,39 +7,39 @@ module Dsl
|
|
|
7
7
|
module Python
|
|
8
8
|
def self.open_repl
|
|
9
9
|
text = <<~TEXT
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
nPython #{VERSION} (main, Nov 16 1970) [GCC] on linux
|
|
11
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
|
12
12
|
TEXT
|
|
13
13
|
puts text
|
|
14
14
|
system("irb --nobanner --prompt simple --nocolorize --noecho-on-assignment -Ilib -rdsl/python")
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
def self.show_version
|
|
18
18
|
puts "npython #{VERSION}"
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
def self.show_help
|
|
22
22
|
text = <<~TEXT
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
usage: npython [option | file ]
|
|
24
|
+
Options:
|
|
25
|
+
-h : print this help message and exit (also -? or --help)
|
|
26
|
+
-v : show current version (also -V or --version)
|
|
27
|
+
|
|
28
|
+
Arguments:
|
|
29
|
+
file : program read from script file
|
|
30
30
|
TEXT
|
|
31
|
-
puts text
|
|
31
|
+
puts text
|
|
32
32
|
end
|
|
33
|
-
|
|
34
|
-
def self.run_program(name)
|
|
35
|
-
unless File.exist? name
|
|
36
|
-
puts "npython: can't open file '#{name}': [Errno 2] No such file or directory"
|
|
37
|
-
exit 1
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
content = File.read(name)
|
|
41
|
-
eval(content)
|
|
42
|
-
end
|
|
43
33
|
end
|
|
44
34
|
end
|
|
45
35
|
|
|
36
|
+
def run_program(filepath)
|
|
37
|
+
unless File.exist? filepath
|
|
38
|
+
puts "npython: can't open file '#{filepath}': [Errno 2] No such file or directory"
|
|
39
|
+
exit 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
$main_filepath = filepath
|
|
43
|
+
content = File.read(filepath)
|
|
44
|
+
eval(content)
|
|
45
|
+
end
|
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../repl/zen"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
$main_binding = binding
|
|
6
|
+
|
|
7
|
+
def import(filename)
|
|
8
|
+
filename.to_s
|
|
9
|
+
dirbase = File.dirname($main_filepath)
|
|
10
|
+
filepath = File.join(dirbase, filename + ".py")
|
|
11
|
+
|
|
12
|
+
if filename.to_s == "this"
|
|
13
|
+
Dsl::Python.show_zen
|
|
14
|
+
elsif filename.to_s == "that"
|
|
15
|
+
Dsl::Python.show_zen(ofuscate: true)
|
|
16
|
+
elsif File.exist? filepath
|
|
17
|
+
|
|
18
|
+
content = File.read(filepath)
|
|
19
|
+
eval(content, $main_binding)
|
|
13
20
|
else
|
|
14
|
-
puts "npython: can't open file '#{
|
|
21
|
+
puts "npython: can't open file '#{filepath}': [Errno 2] No such file or directory"
|
|
15
22
|
end
|
|
16
23
|
end
|
data/lib/dsl/python/klasses.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
def copyright
|
|
3
|
+
def copyright
|
|
4
4
|
text = <<~TEXT
|
|
5
|
-
Copyright (c) 2025-2025 nPython Software Foundation.
|
|
6
|
-
All Rights Reserved.
|
|
5
|
+
Copyright (c) 2025-2025 nPython Software Foundation.
|
|
6
|
+
All Rights Reserved.
|
|
7
7
|
TEXT
|
|
8
8
|
puts text
|
|
9
9
|
"(Copyright)"
|
|
10
10
|
end
|
|
11
|
-
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
def credits
|
|
3
|
+
def credits
|
|
4
4
|
text = <<~TEXT
|
|
5
|
-
Thanks to Free Software, Yukuhiro Matzumoto, David Vargas Ruiz
|
|
6
|
-
and a cast of thousands for supporting nPython
|
|
7
|
-
|
|
5
|
+
Thanks to Free Software, Yukuhiro Matzumoto, David Vargas Ruiz
|
|
6
|
+
and a cast of thousands for supporting nPython development.
|
|
7
|
+
See 'github.com/dvarrui/dsl-python' for more information.
|
|
8
8
|
TEXT
|
|
9
9
|
puts text
|
|
10
|
-
"(Credits)"
|
|
11
10
|
end
|
data/lib/dsl/python/repl/etc.rb
CHANGED
|
@@ -1,65 +1,64 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
def license
|
|
3
|
+
def license
|
|
4
4
|
text = <<~TEXT
|
|
5
|
-
nPython is copyrighted free software by David Vargas Ruiz <dvarrui@proton.me>.
|
|
6
|
-
You can redistribute it and/or modify it under either the terms of the
|
|
7
|
-
2-clause BSDL (see the file BSDL), or the conditions below:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
5
|
+
nPython is copyrighted free software by David Vargas Ruiz <dvarrui@proton.me>.
|
|
6
|
+
You can redistribute it and/or modify it under either the terms of the
|
|
7
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
|
8
|
+
|
|
9
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
10
|
+
software without restriction, provided that you duplicate all of the
|
|
11
|
+
original copyright notices and associated disclaimers.
|
|
12
|
+
|
|
13
|
+
2. You may modify your copy of the software in any way, provided that
|
|
14
|
+
you do at least ONE of the following:
|
|
15
|
+
|
|
16
|
+
a) place your modifications in the Public Domain or otherwise
|
|
17
|
+
make them Freely Available, such as by posting said
|
|
18
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
19
|
+
the author to include your modifications in the software.
|
|
20
|
+
|
|
21
|
+
b) use the modified software only within your corporation or
|
|
22
|
+
organization.
|
|
23
|
+
|
|
24
|
+
c) give non-standard binaries non-standard names, with
|
|
25
|
+
instructions on where to get the original software distribution.
|
|
26
|
+
|
|
27
|
+
d) make other distribution arrangements with the author.
|
|
28
|
+
|
|
29
|
+
3. You may distribute the software in object code or binary form,
|
|
30
|
+
provided that you do at least ONE of the following:
|
|
31
|
+
|
|
32
|
+
a) distribute the binaries and library files of the software,
|
|
33
|
+
together with instructions (in the manual page or equivalent)
|
|
34
|
+
on where to get the original distribution.
|
|
35
|
+
|
|
36
|
+
b) accompany the distribution with the machine-readable source of
|
|
37
|
+
the software.
|
|
38
|
+
|
|
39
|
+
c) give non-standard binaries non-standard names, with
|
|
40
|
+
instructions on where to get the original software distribution.
|
|
41
|
+
|
|
42
|
+
d) make other distribution arrangements with the author.
|
|
43
|
+
|
|
44
|
+
4. You may modify and include the part of the software into any other
|
|
45
|
+
software (possibly commercial). But some files in the distribution
|
|
46
|
+
are not written by the author, so that they are not under these terms.
|
|
47
|
+
|
|
48
|
+
For the list of those files and their copying conditions, see the
|
|
49
|
+
file LEGAL.
|
|
50
|
+
|
|
51
|
+
5. The scripts and library files supplied as input to or produced as
|
|
52
|
+
output from the software do not automatically fall under the
|
|
53
|
+
copyright of the software, but belong to whomever generated them,
|
|
54
|
+
and may be sold commercially, and may be aggregated with this
|
|
55
|
+
software.
|
|
56
|
+
|
|
57
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
58
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
59
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
60
|
+
PURPOSE.
|
|
61
61
|
TEXT
|
|
62
62
|
puts text
|
|
63
63
|
"(License)"
|
|
64
64
|
end
|
|
65
|
-
|
data/lib/dsl/python/repl/zen.rb
CHANGED
|
@@ -11,31 +11,31 @@ def that
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def zen
|
|
14
|
-
Dsl::Python
|
|
14
|
+
Dsl::Python.show_zen
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
module Dsl
|
|
18
18
|
module Python
|
|
19
19
|
def self.show_zen(ofuscate: false)
|
|
20
20
|
text = <<~TEXT
|
|
21
|
-
|
|
21
|
+
El Zen de nPython (Inspirado por Matz)
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
1. La felicidad del programador es el fin último.
|
|
24
|
+
2. Lo natural es mejor que lo explícito.
|
|
25
|
+
3. La libertad es mejor que la restricción.
|
|
26
|
+
4. La elegancia supera a la brevedad.
|
|
27
|
+
5. Muchos caminos son mejores que uno solo (TIMTOWTDI).
|
|
28
|
+
6. Si el código se lee como prosa, es buen código.
|
|
29
|
+
7. No castigues al programador por ser inteligente.
|
|
30
|
+
8. La pureza del objeto es sagrada.
|
|
31
|
+
9. La metaprogramación es un superpoder, úsalo con sabiduría.
|
|
32
|
+
10. El lenguaje debe adaptarse al humano, no el humano al lenguaje.
|
|
33
|
+
11. Un bloque es a menudo la respuesta.
|
|
34
|
+
12. Los símbolos son mejores que los strings para la identidad.
|
|
35
|
+
13. El principio de Menor Sorpresa es subjetivo, pero vital.
|
|
36
|
+
14. Si te hace sonreír al escribirlo, es Ruby.
|
|
37
37
|
TEXT
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
lines = text.split("\n")
|
|
40
40
|
lines.each_with_index do |line, index|
|
|
41
41
|
if line.empty?
|
|
@@ -43,16 +43,16 @@ module Dsl
|
|
|
43
43
|
next
|
|
44
44
|
end
|
|
45
45
|
words = line.split
|
|
46
|
-
if index.zero?
|
|
47
|
-
|
|
46
|
+
index = if index.zero?
|
|
47
|
+
words.shift
|
|
48
48
|
else
|
|
49
|
-
|
|
49
|
+
ANSI.new.green(words.shift)
|
|
50
50
|
end
|
|
51
51
|
text = words.join(" ")
|
|
52
|
-
text = text.gsub(/[^\d\s]/,
|
|
52
|
+
text = text.gsub(/[^\d\s]/, "*") if ofuscate
|
|
53
53
|
puts " #{index} #{text}"
|
|
54
54
|
end
|
|
55
55
|
nil
|
|
56
|
-
end
|
|
56
|
+
end
|
|
57
57
|
end
|
|
58
58
|
end
|
|
@@ -1,23 +1,55 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
require "io/console"
|
|
2
3
|
|
|
3
4
|
class Array
|
|
5
|
+
def append(item)
|
|
6
|
+
self.<<(item)
|
|
7
|
+
end
|
|
8
|
+
|
|
4
9
|
def __
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
names = %w[
|
|
11
|
+
list.__add__( list.__ge__( list.__iter__() list.__reversed__()
|
|
12
|
+
list.__class__( list.__getattribute__( list.__le__( list.__rmul__(
|
|
13
|
+
list.__class_getitem__( list.__getitem__( list.__len__() list.__setattr__(
|
|
14
|
+
list.__contains__( list.__getstate__() list.__lt__( list.__setitem__(
|
|
15
|
+
list.__delattr__( list.__gt__( list.__mul__( list.__sizeof__()
|
|
16
|
+
list.__delitem__( list.__hash__( list.__ne__( list.__str__(
|
|
17
|
+
list.__dir__() list.__iadd__( list.__new__( list.__subclasshook__(
|
|
18
|
+
list.__doc__( list.__imul__( list.__reduce__() list.__eq__(
|
|
19
|
+
list.__init__( list.__reduce_ex__() list.__format__( list.__init_subclass__()
|
|
20
|
+
list.__repr__()]
|
|
21
|
+
Dsl::Python.puts_in_columns(names.sort)
|
|
17
22
|
end
|
|
18
23
|
|
|
24
|
+
def __add__(other) = self.concat(other)
|
|
25
|
+
def __getitem__(index) = self.at(index)
|
|
26
|
+
def __len__ = self.length
|
|
27
|
+
def __sizeof__ = 40 + self.count * 8
|
|
28
|
+
# require 'objspace'
|
|
29
|
+
# mi_array = ["npython", "cli", "version"]
|
|
30
|
+
# puts ObjectSpace.memsize_of(mi_array)
|
|
31
|
+
def __str__ = self.to_s
|
|
32
|
+
|
|
19
33
|
def to_s
|
|
20
|
-
|
|
34
|
+
inspect
|
|
21
35
|
end
|
|
22
36
|
end
|
|
23
37
|
|
|
38
|
+
module Dsl
|
|
39
|
+
module Python
|
|
40
|
+
def self.puts_in_columns(values)
|
|
41
|
+
space = " "
|
|
42
|
+
tab = space * 3
|
|
43
|
+
max_value = values.map {_1.length}.max
|
|
44
|
+
max_value += tab.size
|
|
45
|
+
|
|
46
|
+
max_screen = IO.console.winsize[1]
|
|
47
|
+
max_col = max_screen / max_value
|
|
48
|
+
values.each_slice(max_col) do |items|
|
|
49
|
+
words = items.map { _1 + space * (max_value - _1.length)}
|
|
50
|
+
puts words.join
|
|
51
|
+
end
|
|
52
|
+
nil
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
class Integer
|
|
4
4
|
def __
|
|
5
|
-
puts
|
|
6
|
-
int.__abs__() int.__floordiv__( int.__le__( int.__rdivmod__( int.__rsub__(
|
|
7
|
-
int.__add__( int.__format__( int.__lshift__( int.__reduce__() int.__rtruediv__(
|
|
8
|
-
int.__and__( int.__ge__( int.__lt__( int.__reduce_ex__( int.__rxor__(
|
|
9
|
-
int.__bool__() int.__getattribute__( int.__mod__( int.__repr__() int.__setattr__(
|
|
10
|
-
int.__ceil__() int.__getnewargs__() int.__mul__( int.__rfloordiv__( int.__sizeof__()
|
|
11
|
-
int.__class__( int.__getstate__() int.__ne__( int.__rlshift__( int.__str__()
|
|
12
|
-
int.__delattr__( int.__gt__( int.__neg__() int.__rmod__( int.__sub__(
|
|
13
|
-
int.__dir__() int.__hash__() int.__new__( int.__rmul__( int.__subclasshook__(
|
|
14
|
-
int.__divmod__( int.__index__() int.__or__( int.__ror__( int.__truediv__(
|
|
15
|
-
int.__doc__ int.__init__( int.__pos__() int.__round__( int.__trunc__()
|
|
16
|
-
int.__eq__( int.__init_subclass__() int.__pow__( int.__rpow__( int.__xor__(
|
|
17
|
-
int.__float__() int.__int__() int.__radd__( int.__rrshift__(
|
|
18
|
-
int.__floor__() int.__invert__() int.__rand__( int.__rshift__(
|
|
19
|
-
|
|
5
|
+
puts <<~TEXT
|
|
6
|
+
int.__abs__() int.__floordiv__( int.__le__( int.__rdivmod__( int.__rsub__(
|
|
7
|
+
int.__add__( int.__format__( int.__lshift__( int.__reduce__() int.__rtruediv__(
|
|
8
|
+
int.__and__( int.__ge__( int.__lt__( int.__reduce_ex__( int.__rxor__(
|
|
9
|
+
int.__bool__() int.__getattribute__( int.__mod__( int.__repr__() int.__setattr__(
|
|
10
|
+
int.__ceil__() int.__getnewargs__() int.__mul__( int.__rfloordiv__( int.__sizeof__()
|
|
11
|
+
int.__class__( int.__getstate__() int.__ne__( int.__rlshift__( int.__str__()
|
|
12
|
+
int.__delattr__( int.__gt__( int.__neg__() int.__rmod__( int.__sub__(
|
|
13
|
+
int.__dir__() int.__hash__() int.__new__( int.__rmul__( int.__subclasshook__(
|
|
14
|
+
int.__divmod__( int.__index__() int.__or__( int.__ror__( int.__truediv__(
|
|
15
|
+
int.__doc__ int.__init__( int.__pos__() int.__round__( int.__trunc__()
|
|
16
|
+
int.__eq__( int.__init_subclass__() int.__pow__( int.__rpow__( int.__xor__(
|
|
17
|
+
int.__float__() int.__int__() int.__radd__( int.__rrshift__(
|
|
18
|
+
int.__floor__() int.__invert__() int.__rand__( int.__rshift__(
|
|
19
|
+
TEXT
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def __add__(other)
|
|
@@ -34,4 +34,4 @@ int.__floor__() int.__invert__() int.__rand__( int._
|
|
|
34
34
|
def __sub__(other)
|
|
35
35
|
self - other
|
|
36
36
|
end
|
|
37
|
-
end
|
|
37
|
+
end
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
|
|
2
1
|
class String
|
|
3
2
|
def format(arg)
|
|
4
3
|
self % arg
|
|
5
4
|
end
|
|
6
5
|
|
|
7
|
-
def join(list)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def
|
|
12
|
-
self.downcase
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def upper
|
|
16
|
-
self.upcase
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def replace(a, b)
|
|
20
|
-
self.tr(a, b)
|
|
21
|
-
end
|
|
6
|
+
def join(list) = list.join(self)
|
|
7
|
+
def lower = downcase
|
|
8
|
+
def replace(a, b) = tr(a, b)
|
|
9
|
+
def title = capitalize
|
|
10
|
+
def upper = upcase
|
|
22
11
|
|
|
23
12
|
def __
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
names = %w[
|
|
14
|
+
str.__add__( str.__getattribute__( str.__le__( str.__repr__()
|
|
15
|
+
str.__class__( str.__getitem__( str.__len__() str.__rmod__(
|
|
16
|
+
str.__contains__( str.__getnewargs__() str.__lt__( str.__rmul__(
|
|
17
|
+
str.__delattr__( str.__getstate__() str.__mod__( str.__setattr__(
|
|
18
|
+
str.__dir__() str.__gt__( str.__mul__( str.__sizeof__()
|
|
19
|
+
str.__doc__ str.__hash__() str.__ne__( str.__str__()
|
|
20
|
+
str.__eq__( str.__init__( str.__new__( str.__subclasshook__(
|
|
21
|
+
str.__format__( str.__init_subclass__() str.__reduce__()
|
|
22
|
+
str.__ge__( str.__iter__() str.__reduce_ex__(
|
|
23
|
+
]
|
|
24
|
+
Dsl::Python.puts_in_columns(names.sort)
|
|
33
25
|
end
|
|
34
26
|
end
|
data/lib/dsl/python/version.rb
CHANGED
data/lib/dsl/python.rb
CHANGED
|
@@ -23,16 +23,15 @@ require_relative "python/version"
|
|
|
23
23
|
def print(*args)
|
|
24
24
|
if args.is_a? Array
|
|
25
25
|
if args.count == 1
|
|
26
|
-
puts args.first
|
|
26
|
+
puts args.first
|
|
27
27
|
else
|
|
28
|
-
puts args.join " "
|
|
28
|
+
puts args.join " "
|
|
29
29
|
end
|
|
30
30
|
else
|
|
31
31
|
puts(args)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
36
35
|
module Dsl
|
|
37
36
|
module Python
|
|
38
37
|
class Error < StandardError; end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dsl-python
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Vargas Ruiz
|
|
@@ -18,10 +18,12 @@ extensions: []
|
|
|
18
18
|
extra_rdoc_files:
|
|
19
19
|
- LICENSE
|
|
20
20
|
- README.md
|
|
21
|
+
- docs/pybirras-2026.md
|
|
21
22
|
files:
|
|
22
23
|
- LICENSE
|
|
23
24
|
- README.md
|
|
24
25
|
- bin/npython
|
|
26
|
+
- docs/pybirras-2026.md
|
|
25
27
|
- lib/dsl/python.rb
|
|
26
28
|
- lib/dsl/python/ansi.rb
|
|
27
29
|
- lib/dsl/python/cli.rb
|