scratch-syntax 0.7.4__tar.gz → 0.8.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scratch_syntax
3
- Version: 0.7.4
3
+ Version: 0.8.1
4
4
  Summary: A syntax library designed to help scratch users transition to python
5
5
  Author-email: Cade <cadey.matignas@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cadeymatignas-source/scratch_syntax
@@ -27,7 +27,7 @@ you can do anything with this library, mod it, break it, anything, but don't sue
27
27
 
28
28
  ## Update 0.2.0 notes
29
29
 
30
- I removed the forever and repeat functions because they didnt work and added the stop_all() function. You can use **for_ in range(): **for repeat and** while True:** for forever
30
+ I removed the forever and repeat functions because they didnt work and added the `stop_all()` function. You can use `for_ in range():` for repeat and `while True:` for forever
31
31
 
32
32
  # Updating
33
33
 
@@ -41,13 +41,13 @@ pip install --upgrade scratch_syntax
41
41
 
42
42
  ## Update 0.4.0 notes
43
43
 
44
- ### Added new say_for_seconds() function
44
+ - Added new say_for_seconds() function
45
45
 
46
46
  - I also added Github Respitory
47
47
 
48
48
  ## Update 0.5.0
49
49
 
50
- - Added new wait_until() function
50
+ - Added new `wait_until()` function
51
51
 
52
52
  ## Update 0.6.0\. ReRun's UPDATE!!!
53
53
 
@@ -61,11 +61,11 @@ pip install --upgrade scratch_syntax
61
61
  repeat_until(lambda: say("do you like this?"), lambda: condition())
62
62
  ```
63
63
 
64
- Also btw don't forget to put from scratch_syntax import * so the functions run correctly as is
64
+ Also btw don't forget to put from `scratch_syntax import *`so the functions run correctly as is
65
65
 
66
66
  ## Update 0.7.0 notes. Keyboard update!!!
67
67
 
68
- - Added keyboard function (when_key_pressed())!!!
68
+ - Added keyboard function `when_key_pressed()`!!!
69
69
 
70
70
  ## Update 0.7.2 note:
71
71
 
@@ -77,12 +77,21 @@ Also btw don't forget to put from scratch_syntax import * so the functions run c
77
77
 
78
78
  ## UPDATE 0.7.4: minor fixes
79
79
 
80
- - Fixed the wait_until a bitl
80
+ - Fixed the `wait_unti()` a bitl
81
+
82
+ ## Update 0.8.0: New function
83
+
84
+ - I added the `when_key_pressed_any()` function
85
+ - I fixed the `wait_until()` function a bit
86
+
87
+ ## Update 0.8.1: Minor fix
88
+
89
+ - I just fixed the changelog... thats it.
81
90
 
82
91
  ## All Functions
83
92
 
84
93
  ```bash
85
- say(), ask(), wait(), pick_random_number_from(), stop_all(), add_to_list(), insert_in_list(), delete_from_list(), delete_all_from_list(), replace_from_list(), answer(), say_for_seconds(), wait_until(), repeat(), forever(), repeat_until(), when_key_pressed()
94
+ say(), ask(), wait(), pick_random_number_from(), stop_all(), add_to_list(), insert_in_list(), delete_from_list(), delete_all_from_list(), replace_from_list(), answer(), say_for_seconds(), wait_until(), repeat(), forever(), repeat_until(), when_key_pressed(), when_key_pressed_any()
86
95
  ```
87
96
 
88
97
  Also heres an example code
@@ -105,5 +114,7 @@ say("done!")
105
114
  say("now it is time for us to part!")
106
115
  repeat_until(lambda: ask("would you like to leave?"), lambda: answer() == "yes")
107
116
  wait(1)
108
- stop_all()
117
+ say("press any key to exit")
118
+ if when_key_pressed_any():
119
+ stop_all()
109
120
  ```
@@ -12,7 +12,7 @@ you can do anything with this library, mod it, break it, anything, but don't sue
12
12
 
13
13
  ## Update 0.2.0 notes
14
14
 
15
- I removed the forever and repeat functions because they didnt work and added the stop_all() function. You can use **for_ in range(): **for repeat and** while True:** for forever
15
+ I removed the forever and repeat functions because they didnt work and added the `stop_all()` function. You can use `for_ in range():` for repeat and `while True:` for forever
16
16
 
17
17
  # Updating
18
18
 
@@ -26,13 +26,13 @@ pip install --upgrade scratch_syntax
26
26
 
27
27
  ## Update 0.4.0 notes
28
28
 
29
- ### Added new say_for_seconds() function
29
+ - Added new say_for_seconds() function
30
30
 
31
31
  - I also added Github Respitory
32
32
 
33
33
  ## Update 0.5.0
34
34
 
35
- - Added new wait_until() function
35
+ - Added new `wait_until()` function
36
36
 
37
37
  ## Update 0.6.0\. ReRun's UPDATE!!!
38
38
 
@@ -46,11 +46,11 @@ pip install --upgrade scratch_syntax
46
46
  repeat_until(lambda: say("do you like this?"), lambda: condition())
47
47
  ```
48
48
 
49
- Also btw don't forget to put from scratch_syntax import * so the functions run correctly as is
49
+ Also btw don't forget to put from `scratch_syntax import *`so the functions run correctly as is
50
50
 
51
51
  ## Update 0.7.0 notes. Keyboard update!!!
52
52
 
53
- - Added keyboard function (when_key_pressed())!!!
53
+ - Added keyboard function `when_key_pressed()`!!!
54
54
 
55
55
  ## Update 0.7.2 note:
56
56
 
@@ -62,12 +62,21 @@ Also btw don't forget to put from scratch_syntax import * so the functions run c
62
62
 
63
63
  ## UPDATE 0.7.4: minor fixes
64
64
 
65
- - Fixed the wait_until a bitl
65
+ - Fixed the `wait_unti()` a bitl
66
+
67
+ ## Update 0.8.0: New function
68
+
69
+ - I added the `when_key_pressed_any()` function
70
+ - I fixed the `wait_until()` function a bit
71
+
72
+ ## Update 0.8.1: Minor fix
73
+
74
+ - I just fixed the changelog... thats it.
66
75
 
67
76
  ## All Functions
68
77
 
69
78
  ```bash
70
- say(), ask(), wait(), pick_random_number_from(), stop_all(), add_to_list(), insert_in_list(), delete_from_list(), delete_all_from_list(), replace_from_list(), answer(), say_for_seconds(), wait_until(), repeat(), forever(), repeat_until(), when_key_pressed()
79
+ say(), ask(), wait(), pick_random_number_from(), stop_all(), add_to_list(), insert_in_list(), delete_from_list(), delete_all_from_list(), replace_from_list(), answer(), say_for_seconds(), wait_until(), repeat(), forever(), repeat_until(), when_key_pressed(), when_key_pressed_any()
71
80
  ```
72
81
 
73
82
  Also heres an example code
@@ -90,5 +99,7 @@ say("done!")
90
99
  say("now it is time for us to part!")
91
100
  repeat_until(lambda: ask("would you like to leave?"), lambda: answer() == "yes")
92
101
  wait(1)
93
- stop_all()
102
+ say("press any key to exit")
103
+ if when_key_pressed_any():
104
+ stop_all()
94
105
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scratch_syntax"
7
- version = "0.7.4"
7
+ version = "0.8.1"
8
8
  authors = [
9
9
  { name="Cade", email="cadey.matignas@gmail.com" },
10
10
  ]
@@ -0,0 +1,104 @@
1
+ __lazy_modules__ = ["random", "time", "sys", "keyboard"]
2
+
3
+ import sys
4
+ from random import randint
5
+ from time import sleep
6
+
7
+ from keyboard import is_pressed, read_key
8
+
9
+ _scratch_data = {"answer": ""}
10
+
11
+
12
+ def say(text):
13
+ """This function says text. etc. say("hello")"""
14
+ print(text)
15
+
16
+
17
+ def say_for_seconds(texty, secs):
18
+ """This function is basically saying text then waiting. etc. say_for_seconds("hello", 2)"""
19
+ print(texty)
20
+ sleep(secs)
21
+
22
+
23
+ def ask(question):
24
+ """This one is like scratch's ask then wait function"""
25
+ _scratch_data["answer"] = input(question)
26
+ return _scratch_data["answer"]
27
+
28
+
29
+ def answer():
30
+ return _scratch_data["answer"]
31
+
32
+
33
+ def wait(seconds):
34
+ """This function waits. etc. wait(1)"""
35
+ sleep(seconds)
36
+
37
+
38
+ def pick_random_number_from(a, b):
39
+ """Picks a random number. example: pick_random_numer_from(1,100)"""
40
+ return randint(a, b)
41
+
42
+
43
+ def stop_all():
44
+ sys.exit(0)
45
+
46
+
47
+ def add_to_list(listname, item):
48
+ listname.append(item)
49
+
50
+
51
+ def insert_in_list(listname, index, item):
52
+ listname.insert(index, item)
53
+
54
+
55
+ def delete_from_list(listname, index):
56
+ listname.pop(index)
57
+
58
+
59
+ def delete_all_from_list(listname):
60
+ listname.clear()
61
+
62
+
63
+ def replace_in_list(listname, index, item):
64
+ listname[index] = item
65
+
66
+
67
+ def wait_until(condit):
68
+ while not condit:
69
+ sleep(0.01)
70
+
71
+
72
+ def repeat(action, timy):
73
+ for _ in range(timy):
74
+ action()
75
+
76
+
77
+ def forever(actiono):
78
+ while True:
79
+ actiono()
80
+
81
+
82
+ def repeat_until(actionon, condition):
83
+ """This one repeats until condition becomes true"""
84
+ while True:
85
+ actionon()
86
+ if condition():
87
+ break
88
+
89
+
90
+ def when_key_pressed(key):
91
+ """This function checks when key is pressed"""
92
+ if is_pressed(key):
93
+ sleep(0.01)
94
+ return True
95
+ return False
96
+
97
+
98
+ def when_key_pressed_any():
99
+ """This function checks when any key is pressed"""
100
+ key = read_key()
101
+ if key:
102
+ sleep(0.01)
103
+ return True
104
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scratch_syntax
3
- Version: 0.7.4
3
+ Version: 0.8.1
4
4
  Summary: A syntax library designed to help scratch users transition to python
5
5
  Author-email: Cade <cadey.matignas@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/cadeymatignas-source/scratch_syntax
@@ -27,7 +27,7 @@ you can do anything with this library, mod it, break it, anything, but don't sue
27
27
 
28
28
  ## Update 0.2.0 notes
29
29
 
30
- I removed the forever and repeat functions because they didnt work and added the stop_all() function. You can use **for_ in range(): **for repeat and** while True:** for forever
30
+ I removed the forever and repeat functions because they didnt work and added the `stop_all()` function. You can use `for_ in range():` for repeat and `while True:` for forever
31
31
 
32
32
  # Updating
33
33
 
@@ -41,13 +41,13 @@ pip install --upgrade scratch_syntax
41
41
 
42
42
  ## Update 0.4.0 notes
43
43
 
44
- ### Added new say_for_seconds() function
44
+ - Added new say_for_seconds() function
45
45
 
46
46
  - I also added Github Respitory
47
47
 
48
48
  ## Update 0.5.0
49
49
 
50
- - Added new wait_until() function
50
+ - Added new `wait_until()` function
51
51
 
52
52
  ## Update 0.6.0\. ReRun's UPDATE!!!
53
53
 
@@ -61,11 +61,11 @@ pip install --upgrade scratch_syntax
61
61
  repeat_until(lambda: say("do you like this?"), lambda: condition())
62
62
  ```
63
63
 
64
- Also btw don't forget to put from scratch_syntax import * so the functions run correctly as is
64
+ Also btw don't forget to put from `scratch_syntax import *`so the functions run correctly as is
65
65
 
66
66
  ## Update 0.7.0 notes. Keyboard update!!!
67
67
 
68
- - Added keyboard function (when_key_pressed())!!!
68
+ - Added keyboard function `when_key_pressed()`!!!
69
69
 
70
70
  ## Update 0.7.2 note:
71
71
 
@@ -77,12 +77,21 @@ Also btw don't forget to put from scratch_syntax import * so the functions run c
77
77
 
78
78
  ## UPDATE 0.7.4: minor fixes
79
79
 
80
- - Fixed the wait_until a bitl
80
+ - Fixed the `wait_unti()` a bitl
81
+
82
+ ## Update 0.8.0: New function
83
+
84
+ - I added the `when_key_pressed_any()` function
85
+ - I fixed the `wait_until()` function a bit
86
+
87
+ ## Update 0.8.1: Minor fix
88
+
89
+ - I just fixed the changelog... thats it.
81
90
 
82
91
  ## All Functions
83
92
 
84
93
  ```bash
85
- say(), ask(), wait(), pick_random_number_from(), stop_all(), add_to_list(), insert_in_list(), delete_from_list(), delete_all_from_list(), replace_from_list(), answer(), say_for_seconds(), wait_until(), repeat(), forever(), repeat_until(), when_key_pressed()
94
+ say(), ask(), wait(), pick_random_number_from(), stop_all(), add_to_list(), insert_in_list(), delete_from_list(), delete_all_from_list(), replace_from_list(), answer(), say_for_seconds(), wait_until(), repeat(), forever(), repeat_until(), when_key_pressed(), when_key_pressed_any()
86
95
  ```
87
96
 
88
97
  Also heres an example code
@@ -105,5 +114,7 @@ say("done!")
105
114
  say("now it is time for us to part!")
106
115
  repeat_until(lambda: ask("would you like to leave?"), lambda: answer() == "yes")
107
116
  wait(1)
108
- stop_all()
117
+ say("press any key to exit")
118
+ if when_key_pressed_any():
119
+ stop_all()
109
120
  ```
@@ -1,95 +0,0 @@
1
- __lazy_modules__ = ["random", "time", "sys", "keyboard"]
2
-
3
- import sys
4
- from random import randint
5
- from time import sleep
6
-
7
- from keyboard import is_pressed
8
-
9
- _scratch_data = {"answer": ""}
10
-
11
-
12
- def say(text):
13
- """This function says text. etc. say("hello")"""
14
- print(text)
15
-
16
-
17
- def say_for_seconds(texty, secs):
18
- """This function is basically saying text then waiting. etc. say_for_seconds("hello", 2)"""
19
- print(texty)
20
- sleep(secs)
21
-
22
-
23
- def ask(question):
24
- """This one is like scratch's ask then wait function"""
25
- _scratch_data["answer"] = input(question)
26
- return _scratch_data["answer"]
27
-
28
-
29
- def answer():
30
- return _scratch_data["answer"]
31
-
32
-
33
- def wait(seconds):
34
- """This function waits. etc. wait(1)"""
35
- sleep(seconds)
36
-
37
-
38
- def pick_random_number_from(a, b):
39
- """Picks a random number. example: pick_random_numer_from(1,100)"""
40
- return randint(a, b)
41
-
42
-
43
- def stop_all():
44
- sys.exit(0)
45
-
46
-
47
- def add_to_list(listname, item):
48
- listname.append(item)
49
-
50
-
51
- def insert_in_list(listname, index, item):
52
- listname.insert(index, item)
53
-
54
-
55
- def delete_from_list(listname, index):
56
- listname.pop(index)
57
-
58
-
59
- def delete_all_from_list(listname):
60
- listname.clear()
61
-
62
-
63
- def replace_in_list(listname, index, item):
64
- listname[index] = item
65
-
66
-
67
- def wait_until(condit):
68
- while not condit():
69
- sleep(0.01)
70
-
71
-
72
- def repeat(action, timy):
73
- for _ in range(timy):
74
- action()
75
-
76
-
77
- def forever(actiono):
78
- while True:
79
- actiono()
80
-
81
-
82
- def repeat_until(actionon, condition):
83
- """This one repeats until condition becomes true"""
84
- while True:
85
- actionon()
86
- if condition():
87
- break
88
-
89
-
90
- def when_key_pressed(key):
91
- """This function checks when key is pressed"""
92
- if is_pressed(key):
93
- sleep(0.01)
94
- return True
95
- return False
File without changes
File without changes