-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b56f54f
commit a1263ef
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Allow values to be stored on Nspire""" | ||
from ti_system import recall_value, store_value | ||
|
||
|
||
class Path: | ||
def __init__(self, path): | ||
self.path = path | ||
|
||
def __getattr__(self, item): | ||
if item == "parent": | ||
return self | ||
|
||
def __truediv__(self, other): | ||
self.path = other | ||
return self | ||
|
||
def resolve(self): | ||
return self | ||
|
||
def exists(self): | ||
try: | ||
recall_value(self.path) | ||
except TypeError: | ||
return False | ||
else: | ||
return True | ||
|
||
def touch(self): | ||
if not self.exists: | ||
self.reset() | ||
|
||
def reset(self): | ||
store_value(self.path, 0) | ||
|
||
def read_text(self): | ||
return str(recall_value(self.path)) | ||
|
||
def write_text(self, text): | ||
store_value(self.path, int(text)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters