Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinVignal committed Apr 27, 2020
1 parent 840df97 commit d5a4899
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ This class aims to simplify high level operations with path

# Context and history

I'm a Computing Student tired of creating again and again the same functions through all my projects to do the exact same thing... :tired_face:
I'm a Computing Student tired of creating again and again the same functions through all my projects to do the exact same things... :tired_face:
Indeed, in every of my projects I create files, delete them, create folders and delete them *blablabla* ...
To solve this boring problem, I decided to create my own library that I can create one and only one time to use and reuse as many time as I wish to.
To solve this boring problem, I decided to create my own library that I can create one and only one time to use and reuse as many times as I wish to.
And because I'm trying to be nice to this cruel world I share this *Epic* project with all of you :heart:
So feel free to download, use and give feedback about this ***epic*** creation. :+1:
So feel free to download it, use it and give feedback about this ***epic*** creation. :+1:


# Description
Expand Down
72 changes: 71 additions & 1 deletion doc/EpicPath.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ EpicPath('a/b/c/d/e/f/g/h/i/j/k/l')

## Add string to the path

`EpicPath` also support the `+` operator:
`EpicPath` also supports the `+` operator:

```python
>>> p1 = EPath('a', 'b')
Expand Down Expand Up @@ -238,3 +238,73 @@ This is the in place version of the method `.get_unique()`:
>>> p1
EpicPath('text_1.txt')
```

# Get context information

**`.listdir(t='epicpath', concat=False)`**

The method `listdir(t='epicpath', concat=False)` lists all the files and folder in a directory
- The parameter `t` allows you to choose what type you want in the output list (`'epicpath'` (default) for `EpicPath`, `'path'` for `Path` and `'str'` for `str`)
- The parameter `concat=False` can be set to `True` to automatically include the current folder path in the output.

```python
>>> p = EPath('a')

>>> p.listdir()
[EpicPath('b'), EpicPath('setup.py'), EpicPath('file.txt')]
>>> p.listdir(t='path')
[WindowsPath('b'), WindowsPath('setup.py'), WindowsPath('file.txt')]
>>> p.listdir(t='str')
['b', 'setup.py', 'file.txt']

>>> p.listdir(concat=True)
[EpicPath('a/b'), EpicPath('a/setup.py'), EpicPath('a/file.txt')]

```

**`.walk(t='epic')`**

This method yields a generator as the function `os.walk`. The returned types are `EpicPath` for `t='epic'` (default), `Path` for `t='path'` and `str` for `t='str'`.

```python
>>> path = EPath('a')
>>> for p in path.walk():
... print(p)
(EpicPath('a'), [EpicPath('b')], [EpicPath('setup.py'), EpicPath('file.txt')])
(EpicPath('a/b'), [], [EpicPath('help.txt')])
>>> for p in path.walk(t='path'):
... print(p)
(WindowsPath('a'), [WindowsPath('b')], [WindowsPath('setup.py'), WindowsPath('file.txt')])
(WindowsPath('a/b'), [], [WindowsPath('help.txt')])
>>> for p in path.walk(t='str'):
... print(p)
('a', ['b'], ['setup.py', 'file.txt'])
('a/b', [], ['help.txt'])
```

**`.walkfiles(t='epic')`**

This method will return all the files encountered in a `.walk()` process.
The returned types are `EpicPath` for `t='epic'` (default), `Path` for `t='path'` and `str` for `t='str'`.

```python
>>> path = EPath('a')
>>> for p in path.walkfiles():
... print(p)
setup.py # EpicPath object
file.txt # EpicPath object
help.txt # EpicPath object
>>> for p in path.walkfiles(t='path'):
... print(p)
setup.py # WindowsPath object
file.txt # WindowsPath object
help.txt # WindowsPath object
>>> for p in path.walkfiles(t='str'):
... print(p)
setup.py # string object
file.txt # string object
help.txt # string object
```



2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from epicpath import EpicPath as EPath
```

I actually already created some aliases for you, so you can do all the fallowing import to get the same object:
I actually already created some aliases for you, so you can do all the fallowing imports to get the same object:

```python
from epicpath import EpicPath # All these 3 imports are the same objects
Expand Down

0 comments on commit d5a4899

Please sign in to comment.