diff --git a/LICENCE b/LICENCE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 948e06d..df59289 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ but if you need those methods you know where to find them.

- Installation + Installation💻 • - Examples + Examples💡 • - Licence + Licence📝

diff --git a/dreamutils/__init__.py b/dreamutils/__init__.py old mode 100644 new mode 100755 index e69de29..d3dbcb7 --- a/dreamutils/__init__.py +++ b/dreamutils/__init__.py @@ -0,0 +1,2 @@ +__author__ = 'ByteDream' +__version__ = '0.1.1' diff --git a/dreamutils/_internal.py b/dreamutils/_internal.py old mode 100644 new mode 100755 diff --git a/dreamutils/encoding.py b/dreamutils/encoding.py old mode 100644 new mode 100755 diff --git a/dreamutils/file.py b/dreamutils/file.py old mode 100644 new mode 100755 index d1d8a24..7dedb82 --- a/dreamutils/file.py +++ b/dreamutils/file.py @@ -1,18 +1,19 @@ #!/usr/bin/python3 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""" -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 Args: - directory (str): 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 + directory: 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 + only_files: If true only files but no directories are getting yielded Yields: 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] for path, subdirs, files in _os.walk(directory): - if full_path: - yield _os.path.join(path, _os.sep.join(subdirs)) - else: - if path.endswith(_os.sep): - path = path[:path.rfind(_os.sep)] - yield path[path.rfind(_os.sep) + 1:] + # yields the directory + if not only_files: + if full_path: + yield _os.path.join(path, _os.sep.join(subdirs)) + else: + if path.endswith(_os.sep): + path = path[:path.rfind(_os.sep)] + yield path[path.rfind(_os.sep) + 1:] + for name in files: + # yields the file if full_path: yield _os.path.join(path, name) 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: file.writelines(lines) - file.cl_ose() + file.close() diff --git a/dreamutils/net.py b/dreamutils/net.py old mode 100644 new mode 100755 diff --git a/dreamutils/os.py b/dreamutils/os.py old mode 100644 new mode 100755 diff --git a/dreamutils/python.py b/dreamutils/python.py old mode 100644 new mode 100755 diff --git a/dreamutils/sort.py b/dreamutils/sort.py old mode 100644 new mode 100755 diff --git a/dreamutils/types/__init__.py b/dreamutils/types/__init__.py old mode 100644 new mode 100755 diff --git a/dreamutils/types/dict.py b/dreamutils/types/dict.py old mode 100644 new mode 100755 diff --git a/dreamutils/types/string.py b/dreamutils/types/string.py old mode 100644 new mode 100755 diff --git a/dreamutils/types/xml.py b/dreamutils/types/xml.py old mode 100644 new mode 100755 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 1d3ba53..918df65 --- a/setup.py +++ b/setup.py @@ -1,20 +1,22 @@ #!/usr/bin/python3 +from dreamutils import __author__, __version__ from setuptools import find_packages, setup # with open('requirements.txt', 'r') as requirements: # required = requirements.read().splitlines() + with open('README.md', 'r') as readme: long_description = readme.read() setup( name='dreamutils', - version='0.1.0', + version=__version__, packages=find_packages(), - url='', + url='https://github.com/ByteDream/dreamutils', license='LGPL-3.0', - author='ByteDream', + author=__author__, author_email='', description='A collection of useful and often repeated python methods', long_description=long_description,