Skip to content

Commit

Permalink
fix things from review
Browse files Browse the repository at this point in the history
  • Loading branch information
bleudev committed Jun 28, 2024
1 parent 12f6fa1 commit 1022a76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
5 changes: 1 addition & 4 deletions ufpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@

# Typing package
__typ_version__ = '0.1'
from ufpy import typ
from ufpy.typ import *

# Path package
__path_version__ = '0.1'
from ufpy import path
from ufpy.path import *

# GitHub package
__github_version__ = '0.1'
from ufpy import github
from ufpy.github import UGithubDownloader, download_file, download_folder, download_repo
from ufpy.github import *
2 changes: 1 addition & 1 deletion ufpy/github/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def repo(repo: str, download_path: str, branch_name: str = 'main'):
gd.download_repo()


def format_paths(*paths: str | list[str]) -> list[str] | list[list[str]] | list[str | list[str]] | str:
def format_paths(*paths: str | list[str]) -> list[str] | list[list[str]]:
new_paths = []
for path in paths:
if isinstance(path, list):
Expand Down
13 changes: 6 additions & 7 deletions ufpy/path/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ def __init__(
self.__encoding = encoding

def __enter__(self):
directory = '/'.join(self.__path.split('/')[:-1])
if not directory:
directory = '\\'.join(self.__path.split('\\')[:-1])
directory = '/'.join(self.__path.split('/')[:-1]) or '\\'.join(self.__path.split('\\')[:-1])

if not os.path.exists(directory):
os.makedirs(directory)
os.makedirs(directory, exist_ok=True)

self.__f = open(file=self.__path, mode=self.__mode, encoding=self.__encoding)
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.__f.close()
if not self.__f.closed:
self.__f.close()

def __del__(self):
self.__f.close()
if not self.__f.closed:
self.__f.close()

def write(self, data: AnyStr):
self.__f.write(data)
Expand Down

0 comments on commit 1022a76

Please sign in to comment.