Update 0.1.1

This commit is contained in:
bytedream 2021-01-09 14:25:59 +01:00
parent 51d22ceb77
commit 41931338b0
15 changed files with 26 additions and 17 deletions

0
LICENCE Normal file → Executable file
View File

6
README.md Normal file → Executable file
View File

@ -11,11 +11,11 @@ but if you need those methods you know where to find them.
<p align="center"> <p align="center">
<a href="#Installation">Installation</a> <a href="#Installation">Installation💻</a>
<a href="#Examples">Examples</a> <a href="#Examples">Examples💡</a>
<a href="#Licence">Licence</a> <a href="#Licence">Licence📝</a>
</p> </p>

2
dreamutils/__init__.py Normal file → Executable file
View File

@ -0,0 +1,2 @@
__author__ = 'ByteDream'
__version__ = '0.1.1'

0
dreamutils/_internal.py Normal file → Executable file
View File

0
dreamutils/encoding.py Normal file → Executable file
View File

27
dreamutils/file.py Normal file → Executable file
View File

@ -1,18 +1,19 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os as _os import os as _os
from typing import Generator as _Generator, List as _List, Union as _Union from typing import Iterator as _Iterator, List as _List, Union as _Union
"""This file contains utils for file manipulation""" """This file contains utils for file manipulation"""
def recursive_directory_data(directory: str, full_path=True) -> _Generator[str]: def recursive_directory_data(directory: str, full_path=True, only_files=False) -> _Iterator[str]:
""" """
_Lists every subfile and subdirectory of the given directory _Lists every subfile and subdirectory of the given directory
Args: Args:
directory (str): Path of directory from which you want to get the subfiles /- directories directory: Path of directory from which you want to get the subfiles /- directories
full_path (bool, optional): If True the full path of the files gets returned. If False the relative path full_path: If True the full path of the files gets returned. If False the relative path
only_files: If true only files but no directories are getting yielded
Yields: Yields:
str: The next recursive file or directory in the given directory str: The next recursive file or directory in the given directory
@ -26,13 +27,17 @@ def recursive_directory_data(directory: str, full_path=True) -> _Generator[str]:
directory = directory[:-1] directory = directory[:-1]
for path, subdirs, files in _os.walk(directory): for path, subdirs, files in _os.walk(directory):
if full_path: # yields the directory
yield _os.path.join(path, _os.sep.join(subdirs)) if not only_files:
else: if full_path:
if path.endswith(_os.sep): yield _os.path.join(path, _os.sep.join(subdirs))
path = path[:path.rfind(_os.sep)] else:
yield path[path.rfind(_os.sep) + 1:] if path.endswith(_os.sep):
path = path[:path.rfind(_os.sep)]
yield path[path.rfind(_os.sep) + 1:]
for name in files: for name in files:
# yields the file
if full_path: if full_path:
yield _os.path.join(path, name) yield _os.path.join(path, name)
else: else:
@ -95,4 +100,4 @@ def replace_line(file: str, to_replace: _Union[int, str, _List[int], _List[str]]
with open(file, 'w') as file: with open(file, 'w') as file:
file.writelines(lines) file.writelines(lines)
file.cl_ose() file.close()

0
dreamutils/net.py Normal file → Executable file
View File

0
dreamutils/os.py Normal file → Executable file
View File

0
dreamutils/python.py Normal file → Executable file
View File

0
dreamutils/sort.py Normal file → Executable file
View File

0
dreamutils/types/__init__.py Normal file → Executable file
View File

0
dreamutils/types/dict.py Normal file → Executable file
View File

0
dreamutils/types/string.py Normal file → Executable file
View File

0
dreamutils/types/xml.py Normal file → Executable file
View File

8
setup.py Normal file → Executable file
View File

@ -1,20 +1,22 @@
#!/usr/bin/python3 #!/usr/bin/python3
from dreamutils import __author__, __version__
from setuptools import find_packages, setup from setuptools import find_packages, setup
# with open('requirements.txt', 'r') as requirements: # with open('requirements.txt', 'r') as requirements:
# required = requirements.read().splitlines() # required = requirements.read().splitlines()
with open('README.md', 'r') as readme: with open('README.md', 'r') as readme:
long_description = readme.read() long_description = readme.read()
setup( setup(
name='dreamutils', name='dreamutils',
version='0.1.0', version=__version__,
packages=find_packages(), packages=find_packages(),
url='', url='https://github.com/ByteDream/dreamutils',
license='LGPL-3.0', license='LGPL-3.0',
author='ByteDream', author=__author__,
author_email='', author_email='',
description='A collection of useful and often repeated python methods', description='A collection of useful and often repeated python methods',
long_description=long_description, long_description=long_description,