pyscript-programming-language 1.15.2__py3-none-any.whl → 1.15.3__py3-none-any.whl

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.
pyscript/core/cache.py CHANGED
@@ -28,7 +28,7 @@ pys_sys.builtin_module_names = tuple(
28
28
  for module in os.listdir(LIBRARIES_PATH)
29
29
  if get_module_candidate(os.path.join(LIBRARIES_PATH, module)) is not None
30
30
  )
31
- pys_sys.path = [LIBRARIES_PATH, SITE_PACKAGES_PATH]
31
+ pys_sys.path = [LIBRARIES_PATH]
32
32
  pys_sys.loading_modules = set()
33
33
  pys_sys.modules = {}
34
34
  pys_sys.interns = {}
@@ -51,6 +51,9 @@ pys_sys.ps1 = '>>> '
51
51
  pys_sys.ps2 = '... '
52
52
  pys_sys._is_gil_enabled = lambda : pys_sys.gil
53
53
 
54
+ if SITE_PACKAGES_PATH is not None:
55
+ pys_sys.path.append(SITE_PACKAGES_PATH)
56
+
54
57
  for name in (
55
58
  '_clear_internal_caches', '_is_immortal', '_is_interned', 'byteorder', 'exit', 'float_info', 'float_repr_style',
56
59
  'get_int_max_str_digits', 'getallocatedblocks', 'getdefaultencoding', 'getfilesystemencodeerrors',
@@ -5,7 +5,8 @@ PYSCRIPT_PATH = os.path.sep.join(__file__.split(os.path.sep)[:-2])
5
5
  CORE_PATH = os.path.join(PYSCRIPT_PATH, 'core')
6
6
  LIBRARIES_PATH = os.path.join(PYSCRIPT_PATH, 'lib')
7
7
  OTHER_PATH = os.path.join(PYSCRIPT_PATH, 'other')
8
- SITE_PACKAGES_PATH = os.path.join(site.getusersitepackages(), 'pyscript')
8
+ SITE_PACKAGES_PATH = None if (site_path := site.getusersitepackages()) is None else \
9
+ os.path.join(site_path, 'pyscript', 'site-packages')
9
10
  ICON_PATH = os.path.join(OTHER_PATH, 'PyScript.ico')
10
11
  GLOBAL_HISTORY_PATH = os.path.join(os.path.expanduser('~'), '.pyscript_history')
11
12
  CONFIGURATIONS_PATH = os.path.join(OTHER_PATH, 'configurations.json')
@@ -88,6 +88,20 @@ try:
88
88
  text.see('insert')
89
89
  return 'break'
90
90
 
91
+ def on_dedent(event=None):
92
+ text = self.text
93
+
94
+ if text.get('insert-1c', 'insert') == '\t':
95
+ text.delete('insert-1c', 'insert')
96
+ refresh_line_numbers()
97
+ return 'break'
98
+
99
+ if text.get('insert linestart', 'insert linestart +1c') == '\t':
100
+ text.delete('insert linestart', 'insert linestart +1c')
101
+ refresh_line_numbers()
102
+
103
+ return 'break'
104
+
91
105
  def on_enter(event=None):
92
106
  text = self.text
93
107
  if text.tag_ranges('sel'):
@@ -188,7 +202,10 @@ try:
188
202
  self.text.edit_modified(False)
189
203
 
190
204
  self.text.bind('<<Modified>>', on_modified)
191
- self.text.bind('<Return>', on_enter)
205
+ self.text.bind('<Control-Return>', on_enter)
206
+ self.text.bind('<Control-j>', on_enter)
207
+ self.text.bind('<Shift-Tab>', on_dedent)
208
+ self.text.bind('<ISO_Left_Tab>', on_dedent)
192
209
  self.text.bind('<Prior>', on_page_up)
193
210
  self.text.bind('<Next>', on_page_down)
194
211
  self.text.bind('<KeyRelease>', refresh_line_numbers)
@@ -138,6 +138,22 @@ try:
138
138
  line = buffer.document.current_line_before_cursor
139
139
  buffer.insert_text('\n' + line[:len(line) - len(line.lstrip())])
140
140
 
141
+ @key_bindings.add('s-tab', filter=on_edit, eager=True)
142
+ def _(event):
143
+ buffer = self.text.buffer
144
+ document = buffer.document
145
+
146
+ if document.char_before_cursor == '\t':
147
+ buffer.delete_before_cursor(1)
148
+ return
149
+
150
+ elif document.current_line.startswith('\t'):
151
+ line_start = document.translate_row_col_to_index(document.cursor_position_row, 0)
152
+ old_position = buffer.cursor_position
153
+ buffer.cursor_position = line_start
154
+ buffer.delete(1)
155
+ buffer.cursor_position = max(line_start, old_position - 1)
156
+
141
157
  @key_bindings.add('c-w', filter=on_edit, eager=True)
142
158
  def _(event):
143
159
  self.set_configuration('wrap', not self.get_configuration('wrap', False))
pyscript/core/handlers.py CHANGED
@@ -5,7 +5,6 @@ from .position import PysPosition
5
5
  from .pystypes import PysFunction
6
6
  from .utils.generic import is_environ
7
7
 
8
- from site import ENABLE_USER_SITE
9
8
  from types import MethodType
10
9
  from typing import Any
11
10
 
@@ -13,12 +12,11 @@ import os
13
12
 
14
13
  wrapper_function = (MethodType, classmethod, staticmethod)
15
14
 
16
- if ENABLE_USER_SITE:
15
+ if SITE_PACKAGES_PATH is not None:
17
16
  try:
18
17
  if os.path.isfile(SITE_PACKAGES_PATH):
19
18
  os.remove(SITE_PACKAGES_PATH)
20
- if not os.path.exists(SITE_PACKAGES_PATH):
21
- os.mkdir(SITE_PACKAGES_PATH)
19
+ os.makedirs(SITE_PACKAGES_PATH, exist_ok=True)
22
20
  except:
23
21
  pass
24
22
 
pyscript/core/runner.py CHANGED
@@ -339,7 +339,7 @@ def pys_shell(
339
339
 
340
340
  if not (flags & NO_WARNING):
341
341
  for path in (LIBRARIES_PATH, OTHER_PATH, SITE_PACKAGES_PATH):
342
- if not os.path.isdir(path):
342
+ if not (path is None or os.path.isdir(path)):
343
343
  custom_print(f'WARNING: "{path}" directory not found', file=sys.stderr)
344
344
 
345
345
  custom_print(
pyscript/core/shell.py CHANGED
@@ -306,11 +306,23 @@ try:
306
306
  def _(event):
307
307
  self.default_buffer.insert_text('\t')
308
308
 
309
- @key_bindings.add('c-n', eager=True)
309
+ @key_bindings.add('s-tab', eager=True)
310
310
  def _(event):
311
- self.default_buffer.insert_text('\n')
311
+ buffer = self.default_buffer
312
+ document = buffer.document
312
313
 
313
- @key_bindings.add('s-tab', eager=True)
314
+ if document.char_before_cursor == '\t':
315
+ buffer.delete_before_cursor(1)
316
+ return
317
+
318
+ elif document.current_line.startswith('\t'):
319
+ line_start = document.translate_row_col_to_index(document.cursor_position_row, 0)
320
+ old_position = buffer.cursor_position
321
+ buffer.cursor_position = line_start
322
+ buffer.delete(1)
323
+ buffer.cursor_position = max(line_start, old_position - 1)
324
+
325
+ @key_bindings.add('c-n', eager=True)
314
326
  def _(event):
315
327
  newline_with_indent()
316
328
 
pyscript/core/version.py CHANGED
@@ -7,8 +7,8 @@ from re import match as match_regex
7
7
  from types import NotImplementedType
8
8
  from typing import Any
9
9
 
10
- __version__ = '1.15.2'
11
- __date__ = '08 November 2026, 12:30 UTC+7'
10
+ __version__ = '1.15.3'
11
+ __date__ = '10 November 2026, 14:30 UTC+7'
12
12
  __author__ = ('AzzamMuhyala',)
13
13
 
14
14
  version = pys_sys.version = f'{__version__} ({__date__})'
pyscript/lib/site.pys CHANGED
@@ -5,7 +5,12 @@ import explorer
5
5
  from '_pyscript>utils>module' import get_module_candidate
6
6
  from '_pyscript>utils>path' import normpath
7
7
 
8
- ENABLE_USER_SITE = pyimport('site').ENABLE_USER_SITE
8
+ (func getusersitepackages() {
9
+ global ENABLE_USER_SITE
10
+ path = sys.site_packages_path
11
+ ENABLE_USER_SITE = path is not none
12
+ return path
13
+ })()
9
14
 
10
15
  func removeduppaths() {
11
16
  path = []
@@ -23,27 +28,34 @@ func removeduppaths() {
23
28
  return known_paths
24
29
  }
25
30
 
26
- func getusersitepackages() => sys.site_packages_path
27
-
28
- func getsitepackages() => list(comprehension(
29
- os.listdir(sys.site_packages_path),
30
- func(package) => os.path.splitext(package)[0],
31
- func(package) => get_module_candidate(normpath(sys.site_packages_path, package)) is not None
32
- ))
31
+ func getsitepackages() {
32
+ site_path = getusersitepackages()
33
+ if (!ENABLE_USER_SITE)
34
+ throw Exception('user site is disabled')
35
+ return list(comprehension(
36
+ os.listdir(site_path),
37
+ func(package) => os.path.splitext(package)[0],
38
+ func(package) => get_module_candidate(normpath(site_path, package)) is not none
39
+ ))
40
+ }
33
41
 
34
42
  func addpackage(path) {
35
- valid = get_module_candidate(normpath(path))
36
- if (valid is None)
43
+ site_path = getusersitepackages()
44
+ if (!ENABLE_USER_SITE)
45
+ throw Exception('user site is disabled')
46
+ if (get_module_candidate(normpath(path)) is none)
37
47
  throw ModuleNotFoundError("invalid module")
38
- result = explorer.copy(path, sys.site_packages_path, metadata=False)
48
+ result = explorer.copy(path, site_path, metadata=False)
39
49
  if (!result.success)
40
50
  throw result.exception
41
51
  }
42
52
 
43
53
  func removepackage(name) {
44
- path = normpath(sys.site_packages_path, name)
45
- valid = get_module_candidate(path)
46
- if (valid is None)
54
+ site_path = getusersitepackages()
55
+ if (!ENABLE_USER_SITE)
56
+ throw Exception('user site is disabled')
57
+ path = normpath(site_path, name)
58
+ if (get_module_candidate(path) is none)
47
59
  throw ModuleNotFoundError("module not found")
48
60
  if (!os.path.exists(path))
49
61
  path += '.pys'
@@ -68,6 +80,12 @@ if (__name__ == '__main__') {
68
80
  description="PyScript's site module"
69
81
  )
70
82
 
83
+ parser.add_argument(
84
+ '--user-site',
85
+ action='store_true',
86
+ help='show the user site path'
87
+ )
88
+
71
89
  parser.add_argument(
72
90
  '-s',
73
91
  action='store_true',
@@ -107,7 +125,10 @@ if (__name__ == '__main__') {
107
125
  }
108
126
  }
109
127
 
110
- if (!ENABLE_USER_SITE)
128
+ if (args.user_site)
129
+ print(getusersitepackages())
130
+
131
+ elif (!ENABLE_USER_SITE)
111
132
  error('User site is disabled')
112
133
 
113
134
  elif (args.l)
@@ -69,4 +69,47 @@ my friends are all so mean auntiee (temanku semua pada jahat tantee)
69
69
  when i'm down they're never there (aku lagi susah mereka gak ada)
70
70
  [kenny died]
71
71
  but when i'm living the high life.. (coba kalau lagi jaya..)
72
- they'll be all over me auntiee (aku dipuja-pujanya tantee)
72
+ they'll be all over me auntiee (aku dipuja-pujanya tantee)
73
+
74
+ what is that?
75
+ a toilet?
76
+ that's right! it's a toilet clyde
77
+ and where is the toilet seat?
78
+ it's up! because you left it up, again!
79
+ we've been through this countless times clyde!
80
+ ok mom just not in front of my friends ok?
81
+ no not ok!
82
+ because you are getting the message!
83
+ what if i had fallen in,
84
+ start listening to me! put it down, put it down!
85
+ [seat placed down]
86
+
87
+ [intense crap]
88
+ [poop pops out]
89
+ [silent]
90
+ eric, did you just take a crap on my desk?
91
+ [pulling pants]
92
+ what's up? what's up?
93
+ i crapped on your desk, dawg
94
+ what's up with that?
95
+ [silent]
96
+ huh..
97
+
98
+ category is people who annoy you
99
+ audience keep quite please!
100
+ [cameraman glances]
101
+ uhh.. well uh..
102
+ ten seconds mr marsh
103
+ i know it but i dont think i should say it
104
+ five seconds mr marsh
105
+ alright, i'd like to solve the puzzle
106
+ N*GGERS!
107
+ [incorrect sound]
108
+ huh?
109
+ [NAGGERS]
110
+ ohh..
111
+ oww..
112
+ oh naggers of course, naggers..
113
+ uhh, can we cut to a..
114
+ can we cut to a-
115
+ [beep sound]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyscript-programming-language
3
- Version: 1.15.2
3
+ Version: 1.15.3
4
4
  Summary: PyScript Programming Language
5
5
  Home-page: https://azzammuhyala.github.io/pyscript
6
6
  Author: AzzamMuhyala
@@ -83,13 +83,6 @@ pip install -U pyscript-programming-language
83
83
  pip install -U pyscript-programming-language[other]
84
84
  ```
85
85
 
86
- And also, you can download PyScript with `git`:
87
- ```sh
88
- git clone https://github.com/azzammuhyala/pyscript
89
- cd pyscript
90
- pip install .
91
- ```
92
-
93
86
  After that, you can run the PyScript shell (_REPL_) with this command:
94
87
  ```sh
95
88
  python -m pyscript
@@ -6,12 +6,12 @@ pyscript/core/__init__.py,sha256=1sqE-oQXVak9zrWYrTrLOzthSQuLFFip3wAnRm76YE0,863
6
6
  pyscript/core/analyzer.py,sha256=FXYXmMaqM6Ld95_g0aIwlarZt18mLbD5q5S_j5iHYgo,15586
7
7
  pyscript/core/bases.py,sha256=btBhYS4jLD38mxmf1eY3InchzV3YgwkooFtTkpfc-XE,30
8
8
  pyscript/core/buffer.py,sha256=wKCwyNcNqr8MqZPr8-MIOBF_MvCRsiJM7SDXLTg9jEY,1140
9
- pyscript/core/cache.py,sha256=-oYN5ftp5cV6pzV0akhYRU9ytaWhdDqD0uvfLha8aSU,3012
9
+ pyscript/core/cache.py,sha256=LjNfsaAvrv7OdUnTNiSL10QlJLXv-xbs1TVeonvq3U8,3075
10
10
  pyscript/core/checks.py,sha256=6Sv1F_o1vddZ4iYtiaIWgxB5-SXp8ps9bAku7RrGUyY,1752
11
- pyscript/core/constants.py,sha256=u6Z76pLu_9-5QVGP1qI_Rk1tzpsuq8ZEkb_UNoPyvR4,2102
11
+ pyscript/core/constants.py,sha256=xX6cyFu7JJ1N9vXOoNOcMsZy_QMK99PP-7EahaluKdM,2189
12
12
  pyscript/core/context.py,sha256=WbGamnSy7QoNR2XiG20WM62Lqdf6T3K8OxLT4VALids,1664
13
13
  pyscript/core/exceptions.py,sha256=aJhBQGTzbofNrt66GZcgd71W69kyW59_RQvGrFZugwo,4099
14
- pyscript/core/handlers.py,sha256=lgYykLlhcDHgylTdcLINvTB-p4dz1XpBAwTxEGafhsc,2407
14
+ pyscript/core/handlers.py,sha256=_GKHyCGZ2_2oxt1wwP0DGgU7sp80mwtejVpHPLZTCjc,2348
15
15
  pyscript/core/highlight.py,sha256=VmAlHC0bUrCeGhyS9UjZC22fBt-ynTIDit2P8rN3hW0,20934
16
16
  pyscript/core/interpreter.py,sha256=UDlgNCx5L4AW6wTGvAboJkxYhpYI3TgBGV1uEm2F35Y,48395
17
17
  pyscript/core/lexer.py,sha256=HxS7fevqCNYCz1Q5pCUP9Znr5NCB2BKzDQtpwpcPT0k,28258
@@ -22,15 +22,15 @@ pyscript/core/position.py,sha256=sTsXi0pZLeKf4izK9S1RARhh0GLLGsygqpJGikA2sv4,445
22
22
  pyscript/core/pysbuiltins.py,sha256=iSKHeij6AFqTCbeq53veSls9mMuXQm9TVkqfDh7bQMs,23909
23
23
  pyscript/core/pystypes.py,sha256=OZEb87CWuVV5UykH9ewMIVA3tkm-YO3oYJedUfMofXs,11773
24
24
  pyscript/core/results.py,sha256=HLw5KizQ7YTljOZH31LfXhUix27-4kMLJatfJYdmMRM,5966
25
- pyscript/core/runner.py,sha256=kxO2N1-ZNdGIIN7KzOU2d0uD1THE1qkfIcuPJ59_4eA,13592
26
- pyscript/core/shell.py,sha256=9jtLLRmdcOVFeuF5FnSmMJoZzaCLv8IADHLnUpwppOA,14897
25
+ pyscript/core/runner.py,sha256=giV0N3uaAkTe8TBXLXzih1LTAUddK3YstUQMD3fseFY,13610
26
+ pyscript/core/shell.py,sha256=1fP5BcUvVeC9CitXVwb1pwkgOg-6REvRpU6li3XBTBU,15472
27
27
  pyscript/core/symtab.py,sha256=kUka8t6R7u275MSHua8fF2RxnLggfPlYH9F2nnuz1zY,3922
28
28
  pyscript/core/token.py,sha256=smCBhmBzXOZao3nlBMedKuY_1BGhueL5akPUL3-i6H4,4215
29
- pyscript/core/version.py,sha256=Y-aE59XGjVHG-QOldkYRwxY6YT9hmEiY0GDhIZr7b_A,3298
29
+ pyscript/core/version.py,sha256=atobaOdU8M1LOvMabBJwhdjaHyYsexDzhHi5nJKRJrU,3298
30
30
  pyscript/core/editor/__init__.py,sha256=fNSm0C7zsPgYiUiuEjOK05ZfJFdFz6z34wLATpnKbMk,786
31
31
  pyscript/core/editor/bases.py,sha256=26FC7K37hupwTY7BLewV7wuv7Dv3uTqb9yrtk6imFEc,2312
32
- pyscript/core/editor/gui.py,sha256=mGQIyBsKeKhtq1ZQ8EdLANCJxBoFWIMClTX2BF9OSmc,10831
33
- pyscript/core/editor/terminal.py,sha256=cNQvtHA4yF3rJcJ2VhaYP63whNApW9DCsuz5Nzxm4wM,8863
32
+ pyscript/core/editor/gui.py,sha256=iGPmp0cSrrQ91V6aOn1lYb5U7SJxMmuSPm-kwZ0611Q,11517
33
+ pyscript/core/editor/terminal.py,sha256=8otyNsDaz5D0Ad5PD4vAfDWmlsOgXal13aEe7TEcmjA,9587
34
34
  pyscript/core/utils/__init__.py,sha256=gBevG7aXEaijEZOW-NCvyCzvhbdRTT6DUr-f0NCaJww,289
35
35
  pyscript/core/utils/ansi.py,sha256=4fi-5OxVNMbxvwdHHDC2_9_urv6eLebJDLk9iYnlrmc,4693
36
36
  pyscript/core/utils/debug.py,sha256=JQSFK68xGJDdBgg9ty-T6NJQ8EPA0iTypKiKHc-7h0U,3086
@@ -53,7 +53,7 @@ pyscript/lib/keyword.pys,sha256=aC2dOtWvMyoM2iINK6CQQM5VahR6PGZW82SPtn475Ng,93
53
53
  pyscript/lib/opcode.pys,sha256=EUuhoaogFX8zKT0OeBXlpJR_qBSylPiW7EQrRv6Eczs,10
54
54
  pyscript/lib/parser.pys,sha256=fSpiibYQbNRvcpLrK3sU7Y3rkqE0WK1aigjqf1NytiE,5560
55
55
  pyscript/lib/pdisplay.pys,sha256=K7uzOyMiR363OoZoUjCXQqPSzV_cuOZJxlALZL8FgIw,416
56
- pyscript/lib/site.pys,sha256=1xlgH9cAcEJmVsacfK7jyqzTdIUcU8Ef8YjRENcrWzk,3242
56
+ pyscript/lib/site.pys,sha256=r5POQ0KBGdQFEn-x9oy_v4ifE5WpvzJAuaJU_w3dPKo,3778
57
57
  pyscript/lib/symtable.pys,sha256=SzQc2a9oI5OMhCJ_jkwEbk_Ih5UMmF-tjR1Dix9_wpo,98
58
58
  pyscript/lib/this.pys,sha256=qX6eBYq5bq2_hvpn76w1D4EvVktwwsr-iXysALroCaw,352
59
59
  pyscript/lib/token.pys,sha256=CP6NU3fD9_TrVNiEgmhHmNyqfxv39L31LllqATSNPC4,320
@@ -75,8 +75,8 @@ pyscript/other/PyScript.ico,sha256=8I6gC9ZB3iY5un5tQUZ_chj1XYj24XsIEJzqoXBLI48,8
75
75
  pyscript/other/copyright,sha256=Ov5gxRKrwwRweaYgYiFTP-rVGGgiWEDCJCi2SSpLYSA,54
76
76
  pyscript/other/credits,sha256=c49yrwp4dLyLtlrfAED7PJJ3aElkbRXz7Innu2x-Auc,159
77
77
  pyscript/other/license,sha256=ORU3AMOH_uOwOcEe1yAt6r56mvlYjZhvCDKBNB7SU0c,1088
78
- pyscript/other/message.txt,sha256=24pKZRoB12uZT7mcEKeCgRvV8BBvVfIjDAavqJlnMzo,2224
79
- pyscript_programming_language-1.15.2.dist-info/METADATA,sha256=Nza8J30P-TrgHpzf-IzY7OXFYmy8E3EjQGy2crpbB48,20142
80
- pyscript_programming_language-1.15.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
81
- pyscript_programming_language-1.15.2.dist-info/top_level.txt,sha256=17-G0eqhWERkkD2m3ZGUqOtJl9SoqFVyR3rdbImxyZI,9
82
- pyscript_programming_language-1.15.2.dist-info/RECORD,,
78
+ pyscript/other/message.txt,sha256=g9OVJHpblQRLlc4Ho5bakUoLkvG89xl8xxUDM_xrzBc,3175
79
+ pyscript_programming_language-1.15.3.dist-info/METADATA,sha256=V4j0qBMJ0IeEcF7uTCSWRDwEN3xALA_scbATz18E1VM,19999
80
+ pyscript_programming_language-1.15.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
81
+ pyscript_programming_language-1.15.3.dist-info/top_level.txt,sha256=17-G0eqhWERkkD2m3ZGUqOtJl9SoqFVyR3rdbImxyZI,9
82
+ pyscript_programming_language-1.15.3.dist-info/RECORD,,