Compare commits

..

No commits in common. "master" and "v0.1.0" have entirely different histories.

15 changed files with 17 additions and 26 deletions

0
LICENCE Executable file → Normal file
View File

6
README.md Executable file → Normal 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 Executable file → Normal file
View File

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

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

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

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

@ -1,19 +1,18 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os as _os import os as _os
from typing import Iterator as _Iterator, List as _List, Union as _Union from typing import Generator as _Generator, 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, only_files=False) -> _Iterator[str]: def recursive_directory_data(directory: str, full_path=True) -> _Generator[str]:
""" """
_Lists every subfile and subdirectory of the given directory _Lists every subfile and subdirectory of the given directory
Args: Args:
directory: Path of directory from which you want to get the subfiles /- directories directory (str): Path of directory from which you want to get the subfiles /- directories
full_path: If True the full path of the files gets returned. If False the relative path full_path (bool, optional): 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
@ -27,17 +26,13 @@ def recursive_directory_data(directory: str, full_path=True, only_files=False) -
directory = directory[:-1] directory = directory[:-1]
for path, subdirs, files in _os.walk(directory): for path, subdirs, files in _os.walk(directory):
# yields the directory if full_path:
if not only_files: yield _os.path.join(path, _os.sep.join(subdirs))
if full_path: else:
yield _os.path.join(path, _os.sep.join(subdirs)) if path.endswith(_os.sep):
else: path = path[:path.rfind(_os.sep)]
if path.endswith(_os.sep): yield path[path.rfind(_os.sep) + 1:]
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:
@ -100,4 +95,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.close() file.cl_ose()

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

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

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

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

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

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

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

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

8
setup.py Executable file → Normal file
View File

@ -1,22 +1,20 @@
#!/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=__version__, version='0.1.0',
packages=find_packages(), packages=find_packages(),
url='https://github.com/ByteDream/dreamutils', url='',
license='LGPL-3.0', license='LGPL-3.0',
author=__author__, author='ByteDream',
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,