-
Notifications
You must be signed in to change notification settings - Fork 1
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
abe9835
commit 0502cee
Showing
108 changed files
with
7,063 additions
and
8,677 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
|
@@ -215,3 +215,7 @@ cython_debug/ | |
#.idea/ | ||
/_version.py | ||
/EVDSlocal/APIKEY_FOLDER/ | ||
pickles/ | ||
logs/ | ||
SeriesData/ | ||
*.cfg |
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 +1 @@ | ||
#1.1.17 | ||
#1.1.19 |
Large diffs are not rendered by default.
Oops, something went wrong.
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,23 +1,21 @@ | ||
from dataclasses import dataclass, field | ||
from collections import namedtuple | ||
import requests | ||
import sys | ||
import pandas as pd | ||
from pathlib import Path | ||
from rich import print, inspect | ||
from typing import List, Dict, Optional | ||
import os | ||
from pathlib import Path | ||
import time | ||
from abc import ABC, abstractmethod | ||
from typing import Optional | ||
from typing import TypeVar | ||
import base64 | ||
from datetime import date, datetime | ||
from enum import Enum | ||
import functools | ||
|
||
from evdspy.EVDSlocal.helper.print_m import * | ||
|
||
from evdspy.EVDSlocal.log_classes.log_template import deb, deb2, debug | ||
|
||
|
||
from dataclasses import dataclass, field | ||
from collections import namedtuple | ||
import requests | ||
import sys | ||
import pandas as pd | ||
from pathlib import Path | ||
from rich import print, inspect | ||
from typing import List, Dict, Optional | ||
import os | ||
from pathlib import Path | ||
import time | ||
from abc import ABC, abstractmethod | ||
from typing import Optional | ||
from typing import TypeVar | ||
import base64 | ||
from datetime import date, datetime | ||
from enum import Enum | ||
import functools | ||
from evdspy.EVDSlocal.helper.print_m import * | ||
from evdspy.EVDSlocal.log_classes.log_template import deb, deb2, debug |
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,165 +1,126 @@ | ||
from .colors import * | ||
|
||
filename = 't.txt' | ||
content = 'aaa' | ||
from ..common.common_imports import * | ||
from typing import Union | ||
from pathlib import Path | ||
|
||
|
||
class WriteContext: | ||
def __init__(self, fname, content, msg, mode="w"): | ||
self.mode = mode | ||
self.fname = fname | ||
self.content = content | ||
self.msg = msg | ||
|
||
def __enter__(self): | ||
self.file_ = open(self.fname, self.mode, encoding='utf-8') | ||
self.file_.write(self.content) | ||
return self | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.file_.close() | ||
if exc_tb: | ||
print_with_failure_style(exc_tb) | ||
print_with_failure_style(self.msg) | ||
return True | ||
|
||
|
||
def Write(fname="test.txt", content="test", msg="Error"): | ||
info = f"{fname}" | ||
|
||
result = False, "File was not created" | ||
with WriteContext(fname, content, msg): | ||
result = True, f"File was created... : {info}" | ||
return result, f"File was created.. : {info}" | ||
|
||
|
||
def WriteAdd(fname="test.txt", content="test", msg="Error"): | ||
info = f"{fname}" | ||
content = "\n" + content | ||
|
||
result = False, "File was not created" | ||
with WriteContext(fname, content, msg, mode="a"): | ||
result = True, f"File was created... : {info}" | ||
return result, f"File was created.. : {info}" | ||
|
||
|
||
class ReadContext: | ||
def __init__(self, fname, msg): | ||
self.fname = fname | ||
self.msg = msg | ||
|
||
def __enter__(self): | ||
# self.file_ = open(self.fname, "r", encoding='utf-8') | ||
self.file_ = open(self.fname, "r", encoding='utf_8_sig') | ||
return self.file_ | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.file_.close() | ||
if exc_tb: | ||
print_with_failure_style(exc_tb) | ||
print_with_failure_style(self.msg) | ||
return False | ||
return True | ||
|
||
|
||
def Read(file_name: Union[str, Path], msg="Error"): | ||
if isinstance(file_name, str): | ||
file_name = Path(file_name) | ||
content = "" | ||
with ReadContext(file_name, msg) as file_: | ||
content = file_.read() | ||
return content | ||
|
||
|
||
def create_folder(folder_name: Union[str, Path]): | ||
if isinstance(folder_name, str): | ||
folder_name = Path(folder_name) | ||
try: | ||
os.makedirs(folder_name) | ||
except FileExistsError: | ||
print_with_updating_style("folder {} already exists".format(folder_name)) | ||
except Exception as e: | ||
print_with_failure_style(e) | ||
|
||
|
||
def is_file(path_: str): | ||
d = Path(path_) | ||
return d.is_file() | ||
|
||
|
||
def is_dir(path_: str): | ||
d = Path(path_) | ||
return d.is_dir() | ||
|
||
|
||
def WriteBytes(file_name: str, content_bytes: bytes): | ||
with open(file_name, 'wb') as f: | ||
f.write(content_bytes) | ||
|
||
|
||
def WriteBytesAdd(file_name: str, content_bytes: bytes): | ||
with open(file_name, 'ab') as f: | ||
f.write(content_bytes) | ||
|
||
|
||
def ReadBytes(file_name: str): | ||
with open(file_name, "rb") as f: | ||
return f.read() | ||
|
||
|
||
def make_indented(content: str, indent=" " * 10) -> str: | ||
content_tup: tuple = tuple(f"{indent}{x}" for x in content.splitlines()) | ||
content = "\n".join(content_tup) | ||
return content | ||
|
||
|
||
def add_one_line(cont_tuple: tuple, line: str) -> tuple: | ||
cont: list = list(cont_tuple) | ||
new_cont = cont + [line] | ||
return tuple(new_cont) | ||
|
||
|
||
# def content_continues_line(content: str) -> str: | ||
# content = make_indented(content) | ||
# content = make_it_summary(content, add_continue=True) | ||
# return content | ||
def line_continues_fn(skipped=0): | ||
def cont_fn(): | ||
lns = "lines" | ||
if skipped == 1: | ||
lns = "line" | ||
if skipped > 0: | ||
msg = f"{skipped} {lns} more..." | ||
# skipped_msg = "" if skipped > 0 else f"{skipped} line more..." | ||
cont = "." * 15 + f"{msg}" + "." * 15 | ||
print_with_style(f"{cont}\n") | ||
... | ||
|
||
return cont_fn | ||
|
||
|
||
def make_it_summary(content: str, max_line_num: int = 10, add_continue: bool = False) -> tuple: | ||
content_tup: tuple = tuple(f"{x}" for x in content.splitlines()) | ||
new_content_tup: tuple = content_tup[0:max_line_num] | ||
skipped_lines = len(content_tup) - max_line_num if len(content_tup) - max_line_num > 0 else 0 | ||
new_content_tup = add_one_line(new_content_tup, "." * 15) | ||
return "\n".join(new_content_tup), skipped_lines | ||
|
||
|
||
def file_exists_show_and_return(file_name: Union[str, Path]) -> bool: | ||
if isinstance(file_name, str): | ||
file_name = Path(file_name) | ||
if file_name.is_file(): | ||
content_ = Read(file_name) | ||
print_with_updating_style(f"file {file_name} exists, not replacing...\n") | ||
print_with_color("content: \n -------\n", "blue") | ||
cont_msg, skipped = make_it_summary(make_indented(content_), add_continue=False, max_line_num=10) | ||
print(cont_msg) | ||
"""print fn will return """ | ||
line_continues_fn(skipped)() | ||
time.sleep(1) | ||
return True | ||
return False | ||
|
||
from .colors import * | ||
filename = 't.txt' | ||
content = 'aaa' | ||
from ..common.common_imports import * | ||
from typing import Union | ||
from pathlib import Path | ||
class WriteContext: | ||
def __init__(self, fname, content, msg, mode="w"): | ||
self.mode = mode | ||
self.fname = fname | ||
self.content = content | ||
self.msg = msg | ||
def __enter__(self): | ||
self.file_ = open(self.fname, self.mode, encoding='utf-8') | ||
self.file_.write(self.content) | ||
return self | ||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.file_.close() | ||
if exc_tb: | ||
print_with_failure_style(exc_tb) | ||
print_with_failure_style(self.msg) | ||
return True | ||
def Write(fname="test.txt", content="test", msg="Error"): | ||
info = f"{fname}" | ||
result = False, "File was not created" | ||
with WriteContext(fname, content, msg): | ||
result = True, f"File was created... : {info}" | ||
return result, f"File was created.. : {info}" | ||
def WriteAdd(fname="test.txt", content="test", msg="Error"): | ||
info = f"{fname}" | ||
content = "\n" + content | ||
result = False, "File was not created" | ||
with WriteContext(fname, content, msg, mode="a"): | ||
result = True, f"File was created... : {info}" | ||
return result, f"File was created.. : {info}" | ||
class ReadContext: | ||
def __init__(self, fname, msg): | ||
self.fname = fname | ||
self.msg = msg | ||
def __enter__(self): | ||
# self.file_ = open(self.fname, "r", encoding='utf-8') | ||
self.file_ = open(self.fname, "r", encoding='utf_8_sig') | ||
return self.file_ | ||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.file_.close() | ||
if exc_tb: | ||
print_with_failure_style(exc_tb) | ||
print_with_failure_style(self.msg) | ||
return False | ||
return True | ||
def Read(file_name: Union[str, Path], msg="Error"): | ||
if isinstance(file_name, str): | ||
file_name = Path(file_name) | ||
content = "" | ||
with ReadContext(file_name, msg) as file_: | ||
content = file_.read() | ||
return content | ||
def create_folder(folder_name: Union[str, Path]): | ||
if isinstance(folder_name, str): | ||
folder_name = Path(folder_name) | ||
try: | ||
os.makedirs(folder_name) | ||
except FileExistsError: | ||
print_with_updating_style("folder {} already exists".format(folder_name)) | ||
except Exception as e: | ||
print_with_failure_style(e) | ||
def is_file(path_: str): | ||
d = Path(path_) | ||
return d.is_file() | ||
def is_dir(path_: str): | ||
d = Path(path_) | ||
return d.is_dir() | ||
def WriteBytes(file_name: str, content_bytes: bytes): | ||
with open(file_name, 'wb') as f: | ||
f.write(content_bytes) | ||
def WriteBytesAdd(file_name: str, content_bytes: bytes): | ||
with open(file_name, 'ab') as f: | ||
f.write(content_bytes) | ||
def ReadBytes(file_name: str): | ||
with open(file_name, "rb") as f: | ||
return f.read() | ||
def make_indented(content: str, indent=" " * 10) -> str: | ||
content_tup: tuple = tuple(f"{indent}{x}" for x in content.splitlines()) | ||
content = "\n".join(content_tup) | ||
return content | ||
def add_one_line(cont_tuple: tuple, line: str) -> tuple: | ||
cont: list = list(cont_tuple) | ||
new_cont = cont + [line] | ||
return tuple(new_cont) | ||
# def content_continues_line(content: str) -> str: | ||
# content = make_indented(content) | ||
# content = make_it_summary(content, add_continue=True) | ||
# return content | ||
def line_continues_fn(skipped=0): | ||
def cont_fn(): | ||
lns = "lines" | ||
if skipped == 1: | ||
lns = "line" | ||
if skipped > 0: | ||
msg = f"{skipped} {lns} more..." | ||
# skipped_msg = "" if skipped > 0 else f"{skipped} line more..." | ||
cont = "." * 15 + f"{msg}" + "." * 15 | ||
print_with_style(f"{cont}\n") | ||
... | ||
return cont_fn | ||
def make_it_summary(content: str, max_line_num: int = 10, add_continue: bool = False) -> tuple: | ||
content_tup: tuple = tuple(f"{x}" for x in content.splitlines()) | ||
new_content_tup: tuple = content_tup[0:max_line_num] | ||
skipped_lines = len(content_tup) - max_line_num if len(content_tup) - max_line_num > 0 else 0 | ||
new_content_tup = add_one_line(new_content_tup, "." * 15) | ||
return "\n".join(new_content_tup), skipped_lines | ||
def file_exists_show_and_return(file_name: Union[str, Path]) -> bool: | ||
if isinstance(file_name, str): | ||
file_name = Path(file_name) | ||
if file_name.is_file(): | ||
content_ = Read(file_name) | ||
print_with_updating_style(f"file {file_name} exists, not replacing...\n") | ||
print_with_color("content: \n -------\n", "blue") | ||
cont_msg, skipped = make_it_summary(make_indented(content_), add_continue=False, max_line_num=10) | ||
print(cont_msg) | ||
"""print fn will return """ | ||
line_continues_fn(skipped)() | ||
time.sleep(1) | ||
return True | ||
return False |
Oops, something went wrong.