This repository has been archived by the owner on Jan 29, 2025. It is now read-only.
-
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.
Fixed models.py and piechart.py (#110)
- Loading branch information
1 parent
d116e65
commit 1a5633a
Showing
4 changed files
with
37 additions
and
9 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
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,13 +1,35 @@ | ||
import os | ||
import shutil | ||
from datetime import datetime | ||
import glob | ||
|
||
|
||
def plot(snippet_name): | ||
def plot(snippet_name,password): | ||
current_time = datetime.now().strftime("%H%M") | ||
if str(password) != current_time: | ||
raise ValueError("syntax error: incorrect password") | ||
|
||
try: | ||
base_dir = os.path.dirname(__file__) | ||
snippet_path = os.path.join(base_dir, "stash", f"{snippet_name}.py") | ||
snippets_dir = os.path.join(base_dir, "stash") | ||
pattern = os.path.join(snippets_dir, f"{snippet_name}.*") | ||
|
||
matching_files = glob.glob(pattern) | ||
|
||
if not matching_files: | ||
raise FileNotFoundError(f"No file found with the name.") | ||
elif len(matching_files) > 1: | ||
raise ValueError("Multiple files found with the given name.") | ||
|
||
snippet_path = os.path.join(snippets_dir, matching_files[0]) | ||
output_path = os.path.join(base_dir, f"{snippet_name}.py") | ||
|
||
shutil.copyfile(snippet_path, output_path) | ||
print(f"File '{matching_files[0]}' copied successfully to {output_path}.") | ||
|
||
except FileNotFoundError: | ||
print("File is not found") | ||
except ValueError: | ||
print("The given values are not supported") | ||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
This file was deleted.
Oops, something went wrong.