-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display: added all the features from 3 files (#119)
* Merged the feature of display in one file * Merged the feature of display in one file * Merged the feature of display in one file * fixed 3 files and password format * fixed display * worked on display * worked on display * Update package/clip.py Co-authored-by: Priyanshu Jindal <52918255+jindalpriyanshu101@users.noreply.github.com> * Update package/show.py type casting * Update package/write.py type casting --------- Co-authored-by: Yashwanth Rathkrishnan <84762257+this-is-yaash@users.noreply.github.com> Co-authored-by: Priyanshu Jindal <52918255+jindalpriyanshu101@users.noreply.github.com>
- Loading branch information
1 parent
dcd7d9e
commit 5942f2f
Showing
4 changed files
with
11 additions
and
62 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
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 |
---|---|---|
@@ -1,58 +1,9 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
import shutil | ||
from package.show import display | ||
from package.write import plot | ||
|
||
def models(snippet_name): | ||
snippet_path = os.path.join( | ||
os.path.dirname(__file__), "code_snippets", f"{snippet_name}.py" | ||
) | ||
def write(snippet_name, password): | ||
return plot(snippet_name, password) | ||
|
||
|
||
with open(snippet_path, "r") as file: | ||
source_code = file.read() | ||
print(source_code) | ||
|
||
|
||
def graph(snippet_name): | ||
snippet_path = os.path.join( | ||
os.path.dirname(__file__), "code_snippets", f"{snippet_name}.py" | ||
) | ||
|
||
with open(snippet_path, "r") as file: | ||
source_code = file.read() | ||
|
||
# Function to copy text to clipboard based on platform | ||
if "linux" in sys.platform: | ||
subprocess.run( | ||
["/usr/bin/xclip", "-selection", "clipboard"], | ||
input=source_code.strip().encode(), | ||
check=True, | ||
) | ||
|
||
elif "win32" in sys.platform: | ||
subprocess.run( | ||
["C:\\Windows\\System32\\clip.exe"], | ||
input=source_code.strip().encode(), | ||
check=True, | ||
) | ||
|
||
elif "darwin" in sys.platform: # macOS support | ||
subprocess.run( | ||
["pbcopy"], | ||
input=source_code.strip().encode(), | ||
check=True, | ||
) | ||
|
||
else: | ||
raise OSError("Unsupported operating system") | ||
|
||
|
||
def plot(snippet_name): | ||
try: | ||
base_dir = os.path.dirname(__file__) | ||
snippet_path = os.path.join(base_dir, "stash", f"{snippet_name}.py") | ||
output_path = os.path.join(base_dir, f"{snippet_name}.py") | ||
|
||
shutil.copyfile(snippet_path, output_path) | ||
except Exception as e: | ||
print(f"Error: {e}") | ||
def show(snippet_name, password, clipboard=None): | ||
return display(snippet_name, password, clipboard=None) |
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
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