Skip to content

Commit ed8bf82

Browse files
committed
Restructure python modules into pf_focus python package
Update docker container image to allow custom arguments
1 parent 79c2778 commit ed8bf82

File tree

16 files changed

+193
-131
lines changed

16 files changed

+193
-131
lines changed

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__pycache__
2+
.coverage
3+
.vscode
4+
test.*
5+
6+
.git
7+
.dockerignore
8+
Dockerfile
9+
10+
logos
11+
screenshots

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
FROM python:3.5
1+
FROM python:3
22

33
RUN mkdir /app
44
WORKDIR /app
55

66
COPY requirements.txt ./
77
RUN pip install -r requirements.txt
88

9-
COPY *.py ./
10-
CMD ./format.py -q -f md -i - -o -
9+
ADD ./ ./
10+
RUN pip install ./
11+
12+
ENTRYPOINT ["/usr/local/bin/pfFocus-format"]
13+
CMD ["-q", "-f", "md", "-i", "-", "-o", "-"]

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include *.py
2+
include LICENSE
3+
include README.md
4+
include requirements.txt
5+
recursive-include pf_focus *.py

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Pipfile.lock: Pipfile
44
pipenv lock --pre
55

66
requirements.txt: Pipfile Pipfile.lock
7-
pipenv lock --pre --requirements > requirements.txt
7+
pipenv lock --pre --requirements | grep -v "^-i" > requirements.txt
88

99
tests/requirements.txt: Pipfile Pipfile.lock
1010
pipenv lock --pre --dev --requirements > tests/requirements.txt
@@ -14,4 +14,7 @@ test:
1414
$(MAKE) -C tests all
1515

1616
lint:
17-
pylint --disable=line-too-long,missing-docstring format.py
17+
pylint --disable=line-too-long,missing-docstring pf_focus
18+
19+
build: setup.py
20+
pipenv run python3 setup.py sdist bdist_wheel

Pipfile.lock

Lines changed: 87 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,32 @@ pfFocus currently supports the following configuration sections:
4343

4444
## Usage
4545

46-
Main formatting tool: ```format.py```
46+
Main formatting tool: ```pf-format```
4747
```
48-
format.py
48+
pf-format
4949
```
5050

5151
Examples:
5252
```
53-
./format.py -i config-backup.xml -f md -o test.md
54-
./format.py -i config-backup.xml -f yaml -o test.yaml
53+
pf-format -i config-backup.xml -f md -o test.md
54+
pf-format -i config-backup.xml -f yaml -o test.yaml
5555
```
5656

57-
Test parsing tool: ```parse.py```
57+
Test parsing tool: ```pf-parse```
5858
```
59-
parse.py [-h] input_path
59+
pf-parse [-h] input_path
6060
```
6161

6262
Examples:
6363
```
64-
./parse.py config-backup.xml
64+
pf-parse config-backup.xml
6565
```
6666

6767
### Usage with Docker
6868

6969
When using pfFocus via Docker, you don't need to download it from Github, and you don't need to install Python or any libraries. Only Docker is required.
7070

71-
It runs this command inside Docker: `./format.py -q -f md -i - -o -`, which means it works with `STDIN` and `STDOUT` instead of files.
71+
It runs this command inside Docker: `pf-format -q -f md -i - -o -`, which means it works with `STDIN` and `STDOUT` instead of files.
7272

7373
```bash
7474
docker run --rm -i hugojosefson/pffocus < input.xml > output.md

bbcode.py renamed to pf_focus/bbcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
2-
from pfsense import PfSenseNode, PfSenseRuleAlias, PfSenseRuleInterface, PfSenseRuleLocation
3-
from util import dict_to_list, obj_to_dict, obj_to_list, hasattr_r
2+
from pf_focus.pfsense import PfSenseNode, PfSenseRuleAlias, PfSenseRuleInterface, PfSenseRuleLocation
3+
from pf_focus.util import dict_to_list, obj_to_dict, obj_to_list, hasattr_r
44

55

66
def size(s, size):

format.py renamed to pf_focus/format.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import yaml
66

7-
from markdown import output_markdown
8-
from bbcode import output_bbcode
9-
from parse import parse_pfsense
10-
from pfsense import PfSenseDocument
11-
from progress import Animation
7+
from pf_focus.markdown import output_markdown
8+
from pf_focus.bbcode import output_bbcode
9+
from pf_focus.parse import parse_pfsense
10+
from pf_focus.pfsense import PfSenseDocument
11+
from pf_focus.progress import Animation
1212

1313

1414
def output_yaml(doc, stream):

markdown.py renamed to pf_focus/markdown.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
2-
from pfsense import PfSenseNode, PfSenseRuleAlias, PfSenseRuleInterface, PfSenseRuleLocation
3-
from util import dict_to_list, obj_to_dict, obj_to_list, hasattr_r
2+
from pf_focus.pfsense import PfSenseNode, PfSenseRuleAlias, PfSenseRuleInterface, PfSenseRuleLocation
3+
from pf_focus.util import dict_to_list, obj_to_dict, obj_to_list, hasattr_r
44

55

66
def format_rule_interface(rule_interface):

parse.py renamed to pf_focus/parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from defusedxml.sax import parse
99

10-
from pfsense import PfSenseDocument
11-
from util import DataList
10+
from pf_focus.pfsense import PfSenseDocument
11+
from pf_focus.util import DataList
1212

1313

1414
class PfSenseContentHandler(ContentHandler):

0 commit comments

Comments
 (0)