Skip to content

Commit da6fb09

Browse files
committed
Merge remote-tracking branch 'origin/develop'
Signed-off-by: Lunik <[email protected]>
2 parents 57bded8 + e1db77c commit da6fb09

38 files changed

+1091
-685
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ build
55
dist
66
.task
77
.pytest_cache
8-
.checks
8+
.checks
9+
.coverage
10+
.DS_Store

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ expected-line-ending-format=
330330
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
331331

332332
# Number of spaces of indent required inside a hanging or continued line.
333-
indent-after-paren=2
333+
indent-after-paren=4
334334

335335
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
336336
# tab).
337-
indent-string=' '
337+
indent-string=' '
338338

339339
# Maximum number of characters on a single line.
340340
max-line-length=120

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# CHANGELOG
22

3+
## v0.3.0
4+
5+
### Features
6+
7+
- Add `self` collection with `upgrade` module
8+
- Add `python` collection with `venv-create`, `venv-cleanup` modules
9+
10+
### Fixes
11+
12+
- Ensure that all `dist` files are removed before building a new one
13+
14+
315
## v0.2.1
416

517
### Fixes

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ To install LaFlem, simply run the following command:
1212
pip install --user laflem
1313
```
1414

15+
or with an isolated environment:
16+
17+
```bash
18+
python -m venv ~/bin/laflem_venv
19+
~/bin/laflem_venv/bin/pip install laflem
20+
21+
ln -s ~/bin/laflem_venv/bin/laflem ~/bin/laflem
22+
ln -s ~/bin/laflem_venv/bin/lf ~/bin/lf
23+
```
24+
1525
## Usage
1626

1727
To use LaFlem, simply run the following command :

Taskfile.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ vars:
1010
PIP_BIN: "{{ .VENV_DIR }}/bin/pip3"
1111
PYTEST_BIN: "{{ .VENV_DIR }}/bin/pytest"
1212
PYLINT_BIN: "{{ .VENV_DIR }}/bin/pylint"
13+
BLACK_BIN: "{{ .VENV_DIR }}/bin/black"
1314
TWINE_BIN: "{{ .VENV_DIR }}/bin/twine"
1415
FLEM_BIN: "{{ .VENV_DIR }}/bin/laflem"
16+
COVERAGE_BIN: "{{ .VENV_DIR }}/bin/coverage"
1517

1618
tasks:
1719
venv:
@@ -86,6 +88,7 @@ tasks:
8688
deps: [ venv, install-dev ]
8789
desc: Build and compile the application
8890
cmds:
91+
- rm -rf dist
8992
- >
9093
{{ .PYTHON_BIN }}
9194
-m build
@@ -112,6 +115,13 @@ tasks:
112115
deps: [ venv, install-dev, check_folder ]
113116
desc: Run pylint on the application
114117
cmds:
118+
- >
119+
{{ .BLACK_BIN }}
120+
--check
121+
lib setup.py
122+
|
123+
tee
124+
"{{ .CHECKS_DIR }}/black.result.txt"
115125
- >
116126
{{ .PYLINT_BIN }}
117127
lib setup.py
@@ -123,6 +133,7 @@ tasks:
123133
- tests/**/*
124134
- setup.py
125135
generates:
136+
- "{{ .CHECKS_DIR }}/black.result.txt"
126137
- "{{ .CHECKS_DIR }}/pylint.result.txt"
127138

128139
test:
@@ -133,11 +144,34 @@ tasks:
133144
vars:
134145
PACKAGE: dist/{{ .NAME }}-*.tar.gz
135146
- >
136-
{{ .PYTEST_BIN }}
137-
tests
147+
{{ .PYTHON_BIN }}
148+
-m pytest
149+
-v
150+
-n 4
151+
--cov={{ .NAME }}
152+
--junitxml="{{ .CHECKS_DIR }}/result.xml"
153+
--html="{{ .CHECKS_DIR }}/report.html"
154+
"tests/{{ .NAME }}"
155+
- >
156+
{{ .COVERAGE_BIN }}
157+
html
158+
-d "{{ .CHECKS_DIR }}/htmlcov"
159+
- >
160+
{{ .COVERAGE_BIN }}
161+
xml
162+
-o "{{ .CHECKS_DIR }}/coverage.xml"
138163
- task: uninstall-package
139164
vars:
140165
PACKAGE: "{{ .NAME }}"
166+
#- open "{{ .CHECKS_DIR }}/report.html"
167+
#- open "{{ .CHECKS_DIR }}/htmlcov/index.html"
168+
sources:
169+
- lib/**/*
170+
- tests/**/*
171+
- setup.py
172+
generates:
173+
- "{{ .CHECKS_DIR }}/result.xml"
174+
- "{{ .CHECKS_DIR }}/coverate.xml"
141175

142176
package_check:
143177
internal: true
@@ -192,6 +226,7 @@ tasks:
192226
lib/*.egg-info
193227
"{{ .CHECKS_DIR }}"
194228
.pytest_cache
229+
.coverage
195230
196231
run-dev:
197232
deps: [ install ]

lib/laflem/__init__.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
'''
1+
"""
22
Main module for laflem
3-
'''
3+
"""
44
import sys
55

66
from .flem import Flem
77
from .exceptions import FlemException
88
from .log import error_console
99

10-
__version__ = '0.2.1'
10+
__version__ = "0.3.0"
11+
1112

1213
def main():
13-
'''
14-
Main function for laflem.
15-
'''
16-
flem = Flem(
17-
version=__version__
18-
)
19-
args = flem.parser.parse_args()
20-
21-
try:
22-
if args.collection:
23-
collection = flem.get_collection(args.collection)
24-
if args.module:
25-
module = collection.get_module(args.module)
26-
27-
module.run(**args.__dict__)
28-
sys.exit(0)
29-
30-
except Exception as error: # pylint: disable=broad-except
31-
if isinstance(error, FlemException):
32-
error_console.print(error, style="bold red")
33-
else:
34-
error_console.print_exception()
35-
36-
sys.exit(1)
37-
38-
if __name__ == '__main__':
39-
main()
14+
"""
15+
Main function for laflem.
16+
"""
17+
flem = Flem(version=__version__)
18+
args = flem.parser.parse_args()
19+
20+
try:
21+
if args.collection:
22+
collection = flem.get_collection(args.collection)
23+
if args.module:
24+
module = collection.get_module(args.module)
25+
26+
module.run(**args.__dict__)
27+
sys.exit(0)
28+
29+
except Exception as error: # pylint: disable=broad-except
30+
if isinstance(error, FlemException):
31+
error_console.print(error, style="bold red")
32+
else:
33+
error_console.print_exception()
34+
35+
sys.exit(1)
36+
37+
38+
if __name__ == "__main__":
39+
main()
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
'''
1+
"""
22
Define the base collection with basic functionality.
3-
'''
3+
"""
44
from laflem.exceptions import ModuleNotFound
55

66
from .helloworld import HelloWorldModule
77
from .ask import AskModule
88

9+
910
class BaseCollection:
10-
'''
11-
The base collection.
12-
'''
13-
name = "base"
14-
description = "Base collection with basic functionality."
15-
modules = {
16-
'helloworld': HelloWorldModule,
17-
'ask': AskModule,
18-
}
11+
"""
12+
The base collection.
13+
"""
14+
15+
name = "base"
16+
description = "Base collection with basic functionality."
17+
modules = {
18+
"helloworld": HelloWorldModule,
19+
"ask": AskModule,
20+
}
1921

20-
def get_module(self, name):
21-
'''
22-
Return an instance of the requested module if it exists.
23-
Else raise a ModuleNotFound exception.
24-
'''
25-
if name in self.modules:
26-
return self.modules[name]()
22+
def get_module(self, name):
23+
"""
24+
Return an instance of the requested module if it exists.
25+
Else raise a ModuleNotFound exception.
26+
"""
27+
if name in self.modules:
28+
return self.modules[name]()
2729

28-
raise ModuleNotFound(name)
30+
raise ModuleNotFound(name)
2931

30-
@classmethod
31-
def build_parser(cls, parser):
32-
'''
33-
Add arguments to the parser or options.
34-
'''
32+
@classmethod
33+
def build_parser(cls, parser):
34+
"""
35+
Add arguments to the parser or options.
36+
"""

lib/laflem/collections/base/ask.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
'''
1+
"""
22
Define the ask module.
33
This module is used to ask the user about him.
44
This is a demonstration module.
5-
'''
5+
"""
66
from rich.prompt import Prompt
77

88
from laflem.log import console
99
from .helloworld import HelloWorldModule
1010

11+
1112
class AskModule(HelloWorldModule):
12-
'''
13-
The ask module.
14-
'''
15-
name = "ask"
16-
description = "Ask the user about him."
17-
version = "0.1.0"
13+
"""
14+
The ask module.
15+
"""
16+
17+
name = "ask"
18+
description = "Ask the user about him."
19+
version = "0.1.0"
1820

19-
def _main(self, *_args, **_kwargs):
20-
'''
21-
Core the module.
22-
'''
23-
name = None
24-
while not name:
25-
name = Prompt.ask('Please provide your [bold red]name[/]')
26-
if not name:
27-
console.print("Please enter your name.", style="blue")
21+
def _main(self, *_args, **_kwargs):
22+
"""
23+
Core the module.
24+
"""
25+
name = None
26+
while not name:
27+
name = Prompt.ask("Please provide your [bold red]name[/]")
28+
if not name:
29+
console.print("Please enter your name.", style="blue")
2830

29-
console.print(f"Hello, {name} !", style="green")
31+
console.print(f"Hello, {name} !", style="green")

0 commit comments

Comments
 (0)