Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin committed Jul 26, 2024
1 parent d7b5621 commit 235725b
Show file tree
Hide file tree
Showing 75 changed files with 134 additions and 238 deletions.
Binary file modified .github/.DS_Store
Binary file not shown.
3 changes: 0 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@
'.md': 'markdown',
}

import os
import inspect
from sphinx.util import logging

logger = logging.getLogger(__name__)

import time


def linkcode_resolve(domain, info):
Expand Down
4 changes: 1 addition & 3 deletions evdspy/EVDSlocal/common/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
}
# success_stories = (default_styles["success"], default_styles["success2"], default_styles["creating"])
#
from typing import Tuple, Any
from typing import Any
def make_flat(x: tuple, y: tuple) -> tuple:
return tuple([x1 for x1 in x] + [y1 for y1 in y])
def combine_similar_ones(*item_list: any) -> tuple:
Expand Down Expand Up @@ -99,7 +97,7 @@ def print_get_input_style(*msg: str):
print_with_style(*msg, style=default_styles["input"])
def print_menu_item_style(*msg: str):
print_with_style(*msg, style=default_styles["menu_item"])
rf"""
r"""
????????????????????????????????????????????????????????????????????????????
? ? 0 ? "black" ? ? ?
? ? 1 ? "red" ? ? ?
Expand Down
19 changes: 0 additions & 19 deletions evdspy/EVDSlocal/common/common_imports.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@

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
2 changes: 2 additions & 0 deletions evdspy/EVDSlocal/common/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from ..common.common_imports import *
from typing import Union
from pathlib import Path
import os
import time
class WriteContext:
def __init__(self, fname, content, msg, mode="w"):
self.mode = mode
Expand Down
1 change: 0 additions & 1 deletion evdspy/EVDSlocal/common/prog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

from rich import print
import time
from rich.progress import track
def rich_sim(num , msg ):
Expand Down
1 change: 0 additions & 1 deletion evdspy/EVDSlocal/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def show(self, content: str, title: str, columns: tuple, skiprow=1):
console.print(table)
import typing as t
from typing import List
import typing as t
@dataclass
class Table2_:
def get_color(self, items):
Expand Down
4 changes: 2 additions & 2 deletions evdspy/EVDSlocal/components/api_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from dataclasses import dataclass, field
from abc import ABC, abstractmethod
from dataclasses import dataclass
from abc import ABC
from enum import Enum
from typing import Callable, List, Tuple, Union
from datetime import datetime
Expand Down
18 changes: 8 additions & 10 deletions evdspy/EVDSlocal/components/bucket_from_series.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@

from ..common.common_imports import *
# from ..common.common_imports import *
from ..common.files import *
from dataclasses import dataclass
from dataclasses import dataclass , field
import os
from pathlib import Path
from evdspy.EVDSlocal.messages.error_classes import BucketFromSeriesFolderCreateError
from evdspy.EVDSlocal.config.config import *
from ..initial.start_args import Args
from ..components.options_class import Options, load_options, SingletonOptions
from ..components.options_class import SingletonOptions
from evdspy.EVDSlocal.initial.start_options import default_data_folder_name
from evdspy.EVDSlocal.common.folder_name_checks import check_remove_back_slash
from dataclasses import dataclass
import os
from pathlib import Path
from evdspy.EVDSlocal.components.api_params import FrequencyEnum, Frequency, AggregationEnum, Aggregations, \
get_enum_with_value, FormulasEnum, Formulas
from evdspy.EVDSlocal.components.api_params import FrequencyEnum, AggregationEnum, get_enum_with_value, FormulasEnum




# ------------------------------------------------------------------------------
# /*
# BucketFromSeriesFile
Expand Down
9 changes: 5 additions & 4 deletions evdspy/EVDSlocal/components/evds_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
from ..utils.utils_general import *
from ..requests_.my_cache import MyCache
from ..components.options_class import Options, load_options
from ..components.evds_seri_files import EvdsSeriesRequest, test_series_
from ..components.evds_seri_files import EvdsSeriesRequest
from evdspy.EVDSlocal.requests_.ev_request import EVRequest
from ..config.credentials_file import Credentials
from ..initial.start_args import *
from ..config.apikey_class import *
from dataclasses import dataclass
from typing import Union, List, Tuple
from typing import Tuple
from ..common.colors import *
from abc import ABC

import os
# ------------------------------------------------------------------------------
m_cache = MyCache()
number = 0
Expand All @@ -30,7 +33,6 @@
from evdspy.EVDSlocal.components.request_or_cache import RequestOrCacheResultInfo
from evdspy.EVDSlocal.state.current_state import CurrentState
from evdspy.EVDSlocal.components.url_class import URLClass
from evdspy.EVDSlocal.components.api_params import Series, DateStart, DateEnd
current_state = CurrentState()
class DfColumnsDoesNotMatch(BaseException):
"""DfColumnsDoNotMatch"""
Expand Down Expand Up @@ -232,7 +234,6 @@ def get_items_json(self):
"""not implemented"""
# return self.convert_csv_df(self.get_json(self.create_url()))
def save_excel(self, file_name=None):
deb("not writing... evds_files. 175")
return True
# ---------------------------------------------------------- / EvdsSorgu
# ------------------------------------------------------------------------------
Expand Down
13 changes: 4 additions & 9 deletions evdspy/EVDSlocal/components/evds_seri_files.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@

from ..common.common_imports import *
from ..common.files import *
from dataclasses import dataclass
import os
from pathlib import Path
from evdspy.EVDSlocal.messages.error_classes import BucketFromSeriesFolderCreateError
from dataclasses import dataclass , field
from evdspy.EVDSlocal.config.config import *
from ..config.apikey_class import ApikeyClass
from ..initial.start_args import Args
from ..components.options_class import Options, load_options, SingletonOptions, read_user_options_on_load
from evdspy.EVDSlocal.initial.start_options import default_data_folder_name, Default_Prefix_
from evdspy.EVDSlocal.initial.start_options import Default_Prefix_
from evdspy.EVDSlocal.components.bucket_from_series import BucketFromSeriesFile, null_BucketFromSeriesFile
from evdspy.EVDSlocal.components.url_class import URLClass
from evdspy.EVDSlocal.components.api_params import Series, DateStart, DateEnd, dataTypeParam, dataTypeEnum
from typing import Tuple, Union, List
from rich import inspect
from typing import Tuple , Optional

# ------------------------------------------------------------------------------
# -------------------------------------------------EvdsSeri----------------------
@dataclass
Expand Down Expand Up @@ -88,7 +84,6 @@ def update_url_instance(self):
#
# ------------------------------------------------------------------------------
# */
from abc import ABC, abstractmethod
@dataclass
class EvdsSeriesRequestWrapper():
name: str
Expand Down
5 changes: 2 additions & 3 deletions evdspy/EVDSlocal/components/excel_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
# ---------------------------------------------------------- ExcelSaveClass
from dataclasses import dataclass
import pandas as pd
from evdspy.EVDSlocal.common.colors import print_with_creating_style, print_with_failure_style, \
from evdspy.EVDSlocal.common.colors import print_with_failure_style, \
print_excel_created_style
from evdspy.EVDSlocal.utils.utils_general import *
from typing import List
from evdspy.EVDSlocal.common.common_imports import *
def replace_all(name, char, nchar):
if not char in name:
if char not in name:
return name
name = name.replace(char, nchar)
return replace_all(name, char, nchar)
import time
def name_ext_format(name, ext):
if "." + ext in name:
return Path(f"{name}")
Expand Down
2 changes: 1 addition & 1 deletion evdspy/EVDSlocal/components/options_class.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from evdspy.EVDSlocal.common.files import Read
from pathlib import Path

from typing import Union, List
from typing import Union

"""
Usage :
Expand Down
2 changes: 1 addition & 1 deletion evdspy/EVDSlocal/components/request_or_cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from dataclasses import dataclass, field
from dataclasses import field
from enum import Enum
from evdspy.EVDSlocal.components.url_class import URLClass
class RequestType(Enum):
Expand Down
4 changes: 1 addition & 3 deletions evdspy/EVDSlocal/components/url_class.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

from dataclasses import dataclass, field
from typing import List, Tuple, Union
from evdspy.EVDSlocal.components.api_params import UrlParam, convert_list_params_to_str, EVDSApiDomain, Apikey, \
Frequency, \
from evdspy.EVDSlocal.components.api_params import UrlParam, convert_list_params_to_str, EVDSApiDomain, Frequency, \
get_enum_with_value, FrequencyEnum, FormulasEnum, Formulas, AggregationEnum, Aggregations
from evdspy.EVDSlocal.components.api_params import *
import typing as t
from enum import Enum
from .api_params_enums import get_enum_with_value
from ..config.apikey_class import ApikeyClass
class ApiParamsNotExpectedFormat(BaseException):
"""ApiParamsNotExpectedFormat"""
@dataclass
Expand Down
4 changes: 2 additions & 2 deletions evdspy/EVDSlocal/config/apikey_class.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..common.common_imports import *
from dataclasses import dataclass, field
from dataclasses import dataclass
from typing import Union
from enum import Enum, auto
from ..config.config import config
Expand Down Expand Up @@ -63,7 +63,7 @@ def post_init(cls):
cls.current_key_using: Union[str, bool] = cls.APIKEYDict.runtime_apikey.value

def no_api_msg(self):
template = f"""
template = """
Api Key not set yet.
--------------------------------------------
how to set api key?
Expand Down
3 changes: 2 additions & 1 deletion evdspy/EVDSlocal/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from ..initial.start_options import *
from ..common.files import Read
from ..common.colors import *
from dataclasses import dataclass
from abc import ABC
def get_develop_vers_main():
parent = Path(__file__).parent
v = Read(Path(parent / ".." / ".." / "__version__.py"))
Expand All @@ -27,7 +29,6 @@ def version_display():
# print_with_info_style(f"evdspy {v} {f} {site_pack}")
v = f"evdspy {v} {f} {site_pack}"
print_with_info_style(v)
import warnings
@dataclass
class ConfigBase(ABC):
cancel_request_temp: bool = False
Expand Down
4 changes: 3 additions & 1 deletion evdspy/EVDSlocal/config/credentials_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from dataclasses import dataclass, field
from ..utils.utils_general import *
from ..components.options_class import Options
from ..messages.error_classes import OptionsFileNotLoadedError
from evdspy.EVDSlocal.initial_setup.api_key_save import get_api_key_from_file_improved
from evdspy.EVDSlocal.config.apikey_class import *
from ..components.options_class import load_options
from typing import Optional


def get_if_attr_exist(pred, f):
if pred:
return f(pred)
Expand Down
5 changes: 2 additions & 3 deletions evdspy/EVDSlocal/console/menu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

from ..common.common_imports import *
from collections import namedtuple
from dataclasses import dataclass, field
from ..config.config import *
from evdspy.EVDSlocal.console.screen import *
Expand All @@ -10,7 +9,7 @@
indent = " " * 15
# MenuItem = namedtuple("MenuItem", "func disp sleeptime clear")
# MenuItem = namedtuple("MenuItem", "func disp sleeptime clear")
from typing import Union, List, Tuple, Callable
from typing import Union, List, Callable
do_nothing = lambda: True
@dataclass
class MenuItem:
Expand Down Expand Up @@ -45,7 +44,7 @@ def get_screen_clear_bool(self):
class MenuMaker:
menu_items: field(default_factory=List[MenuItem])
# menu_items_display : field(default_factory=list)
message: str = "\n" + " " * 25 + f"Selection ? "
message: str = "\n" + " " * 25 + "Selection ? "
exit_item: bool = True
exit_: bool = False
exit_menu_call_back: Callable = do_nothing
Expand Down
2 changes: 0 additions & 2 deletions evdspy/EVDSlocal/helper/print_m.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

from inspect import getframeinfo, stack
import inspect as ins
import sys
import builtins as __builtin__
from evdspy.EVDSlocal.initial.start_options import *
if DEBUG_PRINT :
Expand Down
2 changes: 0 additions & 2 deletions evdspy/EVDSlocal/index_requests/categories.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

from .index_classes import GeneralIndexesCategories
from ..components.options_class import load_options
from ..manual_requests.prepare import PrepareUrl
from evdspy.EVDSlocal.common.files import Write, Read
from ..requests_.ev_request import EVRequest
def get_categories() -> str:
"""get_categories"""
Expand Down
8 changes: 1 addition & 7 deletions evdspy/EVDSlocal/index_requests/datagroup_individual.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@

import pandas as pd
from .datagroups_initial import data_models_dict, data_strategy
from .index_classes import GeneralIndexesDatagroups, GeneralIndexesDatagroupIndividual, \
from .index_classes import GeneralIndexesDatagroupIndividual, \
GeneralIndexesDatagroupSeriesList
from .error_classes_index import ContentFunctionError
from .df_operations import DFOperations
from .index_util_funcs import json_to_excel, json_to_df, make_df_float
from ..common.table import Table2_
from ..components.api_params import DateStart, DateEnd
from ..components.options_class import SingletonOptions
from ..config.apikey_class import ApikeyClass
from ..config.config import ConfigBase
from ..initial.start_options import default_data_folder_name, Default_Prefix_
from ..requests_.ev_request import EVRequest
Expand Down
3 changes: 0 additions & 3 deletions evdspy/EVDSlocal/index_requests/datagroups.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

import pandas as pd
from .datagroups_initial import data_models_dict, data_strategy
from .index_classes import GeneralIndexesDatagroups
from .error_classes_index import ContentFunctionError
from .df_operations import DFOperations
from ..common.table import Table2_
from ..components.options_class import SingletonOptions
from ..config.config import ConfigBase
Expand Down
7 changes: 2 additions & 5 deletions evdspy/EVDSlocal/index_requests/datagroups_extra.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

from rich import inspect
from .datagroups_initial import data_models_dict , data_strategy , GID_json , GID_csv
from .index_classes import GeneralIndexesDatagroups
from .error_classes_index import ContentFunctionError
from .df_operations import DFOperations
from evdspy.EVDSlocal.common.files import Write, Read
from .datagroups_initial import data_strategy
from evdspy.EVDSlocal.common.files import Write
import typing as t
import json
from .datagroups import get_datagroups_df
Expand Down
5 changes: 1 addition & 4 deletions evdspy/EVDSlocal/index_requests/datagroups_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

from .index_classes import GeneralIndexesDatagroups
from evdspy.EVDSlocal.common.files import Write, Read
from .data_models import DataModel, DataModelCSV, DataModelJSON
from .df_operations import DFOperations
from .error_classes_index import ContentFunctionError
from .data_models import DataModelCSV, DataModelJSON
from ..components.options_class import SingletonOptions
from ..requests_.ev_request import EVRequest
# GID_csv = lambda x: GeneralIndexesDatagroups().get_csv
Expand Down
2 changes: 1 addition & 1 deletion evdspy/EVDSlocal/index_requests/df_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
from ..components.evds_files import DfColumnsDoesNotMatch
from ..config.config import config
from ..common.colors import print_with_failure_style, print_with_updating_style, print_with_info_style
from ..common.colors import print_with_failure_style, print_with_info_style
from .data_models import *
from dataclasses import dataclass
@dataclass
Expand Down
Loading

0 comments on commit 235725b

Please sign in to comment.