Skip to content

Commit

Permalink
- fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
maycuatroi committed Jun 8, 2023
1 parent a199ace commit c724b1b
Show file tree
Hide file tree
Showing 27 changed files with 28 additions and 312 deletions.
27 changes: 0 additions & 27 deletions evoflow/entities/common/Function/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions evoflow/entities/common/Step/CATIA/GetObjectsByName.py

This file was deleted.

6 changes: 0 additions & 6 deletions evoflow/entities/common/Step/CATIA/__init__.py

This file was deleted.

181 changes: 0 additions & 181 deletions evoflow/entities/common/Step/CATIA/export.py

This file was deleted.

10 changes: 0 additions & 10 deletions evoflow/entities/common/Step/CNavi/ReadInputFile.py

This file was deleted.

29 changes: 0 additions & 29 deletions evoflow/entities/common/Step/FileOperator/OpenCATIAFile.py

This file was deleted.

This file was deleted.

Empty file.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,34 @@ def update_to(self, b=1, bsize=1, tsize=None):


@evoflow.Step()
def download_urls(urls: list = None, download_dir: str = 'Downloads') -> object:
def download_urls(urls: list = None, download_dir: str = "Downloads") -> object:
"""
@param urls: List of urls to download
@param download_dir: Download directory
@return: download_paths: List path to downloaded files
@rtype: dict
Args:
urls (list, optional): List of urls to download. Defaults to None.
download_dir (str, optional): Download directory. Defaults to 'Downloads'.
download_paths (list, optional): List path to downloaded files. Defaults to None.
Returns:
dict: download_paths: List path to downloaded files
"""
download_paths = []
pathlib.Path(download_dir).mkdir(parents=True, exist_ok=True)
progres_bar = tqdm(urls)

for url in progres_bar:
progres_bar.set_description(f'Downloading: {url}')
progres_bar.set_description(f"Downloading: {url}")
try:
res = requests.get(url)
filename = 'zasdvadf'
with TqdmDownload(unit='B', unit_scale=True, unit_divisor=1024, miniters=1, desc=filename) as t:
download_path, result = urlretrieve(url, f'{download_dir}/miniconda.exe')
filename = "zasdvadf"
with TqdmDownload(unit="B", unit_scale=True, unit_divisor=1024, miniters=1, desc=filename) as t:
download_path, result = urlretrieve(url, f"{download_dir}/miniconda.exe")
download_paths.append(download_path)

except:
logger.error(f"Can't access : {url}")

return {'download_paths': download_path}
return {"download_paths": download_path}


@evoflow.Step()
Expand All @@ -70,23 +73,23 @@ def download_urls(urls: list = None, download_dir: str = None) -> object:
"""
download_paths = []
df = pd.DataFrame(columns=['URL', 'FILE_NAME'])
df = pd.DataFrame(columns=["URL", "FILE_NAME"])
if download_dir:
pathlib.Path(download_dir).mkdir(parents=True, exist_ok=True)
for i, url in tqdm(enumerate(urls), total=len(urls)):
try:
res = requests.get(url)
with TqdmDownload(unit='B', unit_scale=True, unit_divisor=1024, miniters=1, desc=url) as t:
with TqdmDownload(unit="B", unit_scale=True, unit_divisor=1024, miniters=1, desc=url) as t:
download_path, result = urlretrieve(url)
file_name = os.path.split(download_path)[1]
if download_dir:
shutil.move(download_path, f'{download_dir}/{file_name}')
download_path = f'{download_dir}/{file_name}'
shutil.move(download_path, f"{download_dir}/{file_name}")
download_path = f"{download_dir}/{file_name}"
download_paths.append(download_path)

df.loc[i] = [url, download_path]
df.to_csv(f'{download_dir}/downloader_log.csv', encoding='utf-8', index=False)
df.to_csv(f"{download_dir}/downloader_log.csv", encoding="utf-8", index=False)
except Exception as e:
logger.error(f"{e}")

return {'download_files': download_path}
return {"download_files": download_path}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from evoflow.Controller.DataManipulate.FileOperator import FileOperator
from evoflow.Entities.Core.Step import Step
from evoflow.controller.data_manipulate.file_operator import FileOperator
from evoflow.entities.core.step import Step


class OpenExcelFile(Step):

def __init__(self, file_path='', **kwargs):
def __init__(self, file_path=None, **kwargs):
"""
@param file_path:
@param kwargs: pandas params
Open excel file
Args:
file_path: path to excel file
**kwargs:
"""
super().__init__(name='Open excel file', **kwargs)
super().__init__(name="Open excel file", **kwargs)
self.file_path = file_path
self.kwars = kwargs

Expand All @@ -28,11 +29,4 @@ def __info__(self, **kwargs) -> dict:
def action(self, **kwargs):
reader = FileOperator()
file = reader.read(file_path=self.file_path, **self.kwars)
return {'file': file}


if __name__ == '__main__':
step_open_excel = OpenExcelFile(file_path='data/Input.xlsx', header=12)
results = step_open_excel.action()
summary = results['file'].summary()
print(summary)
return {"file": file}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c724b1b

Please sign in to comment.