Skip to content

Commit

Permalink
refractor
Browse files Browse the repository at this point in the history
  • Loading branch information
bitranox committed Aug 15, 2020
1 parent 6e06fb7 commit adc2074
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .docs/README_template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ igittigitt
==========


Version v1.0.6 as of 2020-08-14 see `Changelog`_
Version v1.0.6 as of 2020-08-15 see `Changelog`_


.. include:: ./badges.rst
Expand Down
44 changes: 44 additions & 0 deletions .docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@
:start-after: # IgnoreParserExamples{{{
:end-before: # IgnoreParserExamples}}}

--------------------------------

- add rules by rule files (the default method)

.. include:: ../igittigitt/igittigitt.py
:code: python
:start-after: # parse_rule_files{{{
:end-before: # parse_rule_files}}}


.. code-block:: python
>>> # import all .gitignore recursively from base directory
>>> ignore_parser.parse_rule_files(base_dir=path_source_dir)
>>> # import all .gitignore recursively from base directory
>>> # use another rule filename
>>> ignore_parser.parse_rule_files(base_dir=path_source_dir, filename='my_ignore_rules')
--------------------------------

- add a rule by string

.. include:: ../igittigitt/igittigitt.py
Expand All @@ -21,3 +42,26 @@
:code: python
:start-after: # add_rule_Example{{{
:end-before: # add_rule_Example}}}

--------------------------------

- match a file

.. include:: ../igittigitt/igittigitt.py
:code: python
:start-after: # match{{{
:end-before: # match}}}

--------------------------------

- shutil ignore function

.. include:: ../igittigitt/igittigitt.py
:code: python
:start-after: # shutil_ignore{{{
:end-before: # shutil_ignore}}}

.. include:: ../tests/test_pytest.py
:code: python
:start-after: # test_shutil_ignore_function_Example{{{
:end-before: # test_shutil_ignore_function_Example}}}
65 changes: 64 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ igittigitt
==========


Version v1.0.6 as of 2020-08-14 see `Changelog`_
Version v1.0.6 as of 2020-08-15 see `Changelog`_

|travis_build| |license| |jupyter| |pypi| |black|

Expand Down Expand Up @@ -155,6 +155,38 @@ Usage
... print(parser)
<...IgnoreParser object at ...>
--------------------------------

- add rules by rule files (the default method)

.. code-block:: python
def parse_rule_files(
self, base_dir: PathLikeOrString, filename: str = ".gitignore"
) -> None:
"""
get all the rule files (default = '.gitignore') from the base_dir
all subdirectories will be searched for <filename> and the rules will be appended
Parameter
---------
path_base_dir
the base directory - all subdirectories will be searched for <filename>
filename
the rule filename, default = '.gitignore'
"""
.. code-block:: python
>>> # import all .gitignore recursively from base directory
>>> ignore_parser.parse_rule_files(base_dir=path_source_dir)
>>> # import all .gitignore recursively from base directory
>>> # use another rule filename
>>> ignore_parser.parse_rule_files(base_dir=path_source_dir, filename='my_ignore_rules')
--------------------------------

- add a rule by string

.. code-block:: python
Expand All @@ -177,6 +209,36 @@ Usage
>>> parser = igittigitt.IgnoreParser()
>>> parser.add_rule('*.py[cod]', base_path='/home/michael')
--------------------------------

- match a file

.. code-block:: python
def match(self, file_path: PathLikeOrString) -> bool:
"""
returns True if the path matches the rules
"""
--------------------------------

- shutil ignore function

.. code-block:: python
def shutil_ignore(self, base_dir: str, file_names: List[str]) -> Set[str]:
"""
Ignore function for shutil.copy_tree
"""
.. code-block:: python
>>> path_source_dir = path_test_dir / "example"
>>> path_target_dir = path_test_dir / "target"
>>> ignore_parser = igittigitt.IgnoreParser()
>>> ignore_parser.parse_rule_files(base_dir=path_source_dir, filename=".test_gitignore")
>>> shutil.copytree(path_source_dir, path_target_dir, ignore=ignore_parser.shutil_ignore)
Usage from Commandline
------------------------

Expand Down Expand Up @@ -275,6 +337,7 @@ following modules will be automatically installed :
attrs
click
cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git
wcmatch
Acknowledgements
----------------
Expand Down
Loading

0 comments on commit adc2074

Please sign in to comment.