Skip to content

Commit cdd8a98

Browse files
committed
renamed everything because pypacer was already taken
1 parent 003fd4c commit cdd8a98

14 files changed

+59
-49
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generate auto proxy config files (PAC) from a declaration
22

3-
[![Tests](https://github.com/73h/pypacer/actions/workflows/tests.yml/badge.svg)](https://github.com/73h/pypacer/actions/workflows/tests.yml)
3+
[![Tests](https://github.com/73h/paccreator/actions/workflows/tests.yml/badge.svg)](https://github.com/73h/paccreator/actions/workflows/tests.yml)
44

55
---
66

@@ -12,12 +12,12 @@ subtleties. If you have unusual requirements, it is better to write the proxy sc
1212

1313
You can install the package with pip.
1414
```
15-
pip install pypacer <-- not yet available
15+
pip install paccreator
1616
```
1717

1818
You can also load the script directly from github with pip.
1919
```
20-
pip install git+https://github.com/73h/pypacer.git@main#egg=pypacer
20+
pip install git+https://github.com/73h/paccreator.git@main#egg=paccreator
2121
```
2222

2323
Create a file called myproxy.yaml and define your proxy rules in it like this.
@@ -43,14 +43,24 @@ proxies:
4343
Run this in python.
4444
```python
4545
import os
46-
from pypacer import PyPacer
46+
from paccreator import PacCreator
4747

48-
p = PyPacer()
48+
p = PacCreator()
4949
with open(os.path.join("myproxy.yaml"), "r") as f:
5050
p.load_from_yaml(f.read())
5151
print(p.output())
5252
```
5353
54+
You can also use with contextmanager.
55+
```python
56+
import os
57+
from paccreator import load_from_yaml
58+
59+
with open(os.path.join("myproxy.yaml"), "r") as f:
60+
with load_from_yaml(f.read()) as p:
61+
print(p.output())
62+
```
63+
5464
## Examples
5565
5666
### A simple Example for a random company

bin/run_tests_in_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
cd $(dirname "$0")/..
44

5-
docker compose run --rm pypacer watching_testrunner -- pytest --disable-warnings --tb=short $@
5+
docker compose run --rm paccreator watching_testrunner -- pytest --disable-warnings --tb=short $@

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
2-
pypacer:
2+
paccreator:
33
restart: "no"
44
build:
55
context: .

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "pypacer"
6+
name = "paccreator"
77
version = "0.2.0"
88
dynamic = ["dependencies"]
99
authors = [
@@ -23,7 +23,7 @@ classifiers = [
2323
"Operating System :: OS Independent",
2424
]
2525
[project.urls]
26-
Homepage = "https://github.com/73h/pypacer"
26+
Homepage = "https://github.com/73h/paccreator"
2727

2828
[project.optional-dependencies]
2929
test = [

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pypacer import load_from_yaml
1+
from paccreator import load_from_yaml
22

33
if __name__ == "__main__":
44
simple_proxy = """

src/paccreator/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from paccreator.paccreator import load_from_yaml, load_from_dict
2+
from .helpers import TargetType
3+
from .paccreator import PacCreator
4+
5+
__all__ = [
6+
"PacCreator",
7+
"load_from_yaml",
8+
"load_from_dict",
9+
"TargetType",
10+
]
File renamed without changes.

src/pypacer/pypacer.py renamed to src/paccreator/paccreator.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
from jinja2 import Environment, FileSystemLoader
88

99
from .helpers import sort_by_rating
10-
from .pypacerconfig import PyPacerConfig
10+
from .paccreatorconfig import PacCreatorConfig
1111

1212

13-
class PyPacer:
13+
class PacCreator:
1414
def __init__(self):
15-
self.config: Optional[PyPacerConfig] = None
15+
self.config: Optional[PacCreatorConfig] = None
1616

1717
def load_from_dict(self, config: dict):
18-
self.config = PyPacerConfig(**config)
18+
self.config = PacCreatorConfig(**config)
1919
self.config.validate()
2020

2121
def load_from_yaml(self, config: str):
@@ -78,14 +78,14 @@ def output(self, excludes: list[str] = None, includes: list[str] = None) -> str:
7878

7979

8080
@contextmanager
81-
def load_from_yaml(config: str) -> PyPacer():
82-
p = PyPacer()
81+
def load_from_yaml(config: str) -> PacCreator():
82+
p = PacCreator()
8383
p.load_from_yaml(config)
8484
yield p
8585

8686

8787
@contextmanager
88-
def load_from_dict(config: dict) -> PyPacer():
89-
p = PyPacer()
88+
def load_from_dict(config: dict) -> PacCreator():
89+
p = PacCreator()
9090
p.load_from_dict(config)
9191
yield p

src/pypacer/pypacerconfig.py renamed to src/paccreator/paccreatorconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ipaddress
22
from dataclasses import dataclass, field
33

4-
from pypacer.helpers import get_target_type, TargetType
4+
from paccreator.helpers import get_target_type, TargetType
55

66

77
class Target:
@@ -42,7 +42,7 @@ def __post_init__(self):
4242

4343

4444
@dataclass
45-
class PyPacerConfig:
45+
class PacCreatorConfig:
4646
proxies: list
4747
version: str = "0.1"
4848
description: str = "pac file for my company"
File renamed without changes.

src/pypacer/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/tests/helpers_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import unittest
22

3-
from pypacer.helpers import get_target_type, sort_by_rating, is_ipaddress, is_network, \
3+
from paccreator.helpers import get_target_type, sort_by_rating, is_ipaddress, is_network, \
44
is_hostname, TargetType
5-
from pypacer.pypacerconfig import PyPacerConfig
5+
from paccreator.paccreatorconfig import PacCreatorConfig
66

77

88
class TestHelpers(unittest.TestCase):
@@ -54,7 +54,7 @@ def test_is_hostname(self):
5454
def test_sort_by_rating(self):
5555
config = {"proxies": [{"route": "A", "tags": ["default"], "targets": [".example.com"]},
5656
{"route": "B", "targets": ["foo.example.com"]}]}
57-
config = PyPacerConfig(**config)
57+
config = PacCreatorConfig(**config)
5858
config.recognize_overlaps()
5959
self.assertEqual(config.proxies[0].route, "A")
6060
self.assertEqual(config.proxies[1].targets[0].rating, 1)

src/tests/pypacer_test.py renamed to src/tests/paccreator_test.py

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

55
from pypac.parser import PACFile
66

7-
from pypacer import PyPacer
8-
from pypacer.pypacerconfig import PyPacerConfig
7+
from paccreator import PacCreator
8+
from paccreator.paccreatorconfig import PacCreatorConfig
99

1010
location = pathlib.Path(__file__).parent.resolve()
1111

1212

13-
class TestPyPacer(unittest.TestCase):
13+
class TestPacCreator(unittest.TestCase):
1414

1515
def setUp(self):
1616
self.pac_file = open(os.path.join(location, "..", "examples", "unittests.yaml"), "r").read()
1717

1818
def test_load_config_from_yaml(self):
19-
p = PyPacer()
19+
p = PacCreator()
2020
p.load_from_yaml(self.pac_file)
21-
self.assertIsInstance(p.config, PyPacerConfig)
21+
self.assertIsInstance(p.config, PacCreatorConfig)
2222
self.assertEqual(p.config.proxies[0].route, "DIRECT")
2323
output = p.output()
2424
open(os.path.join(location, "..", "examples", "unittests.pac"), "w").write(output)
2525

2626
def test_exclude_by_tag(self):
27-
p = PyPacer()
27+
p = PacCreator()
2828
p.load_from_yaml(self.pac_file)
2929
output = p.output(excludes=["foo"])
3030
self.assertTrue("PROXY netmask.example.com" not in output)
3131

3232
def test_exclude_by_tags(self):
33-
p = PyPacer()
33+
p = PacCreator()
3434
p.load_from_yaml(self.pac_file)
3535
output = p.output(excludes=["foo", "default"])
3636
self.assertTrue("PROXY netmask.example.com" not in output)
3737
self.assertTrue("PROXY default.example.com" not in output)
3838

3939
def test_include_by_tag(self):
40-
p = PyPacer()
40+
p = PacCreator()
4141
p.load_from_yaml(self.pac_file)
4242
output = p.output(includes=["foo"])
4343
self.assertTrue("PROXY netmask.example.com" in output)
4444

4545
def test_include_by_tags(self):
46-
p = PyPacer()
46+
p = PacCreator()
4747
p.load_from_yaml(self.pac_file)
4848
output = p.output(includes=["foo", "default"])
4949
self.assertTrue("PROXY netmask.example.com" in output)
5050
self.assertTrue("PROXY default.example.com" in output)
5151

5252
def test_output(self):
53-
p = PyPacer()
53+
p = PacCreator()
5454
p.load_from_yaml(self.pac_file)
5555
pac_file = PACFile(p.output())
5656
self.assertEqual(pac_file.find_proxy_for_url("", "foo.bar"), "PROXY default.example.com")
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import unittest
22

3-
from pypacer.pypacerconfig import PyPacerConfig
3+
from paccreator.paccreatorconfig import PacCreatorConfig
44

55

6-
class TestPyPacerConfig(unittest.TestCase):
6+
class TestPacCreatorConfig(unittest.TestCase):
77

88
def test_proxy_has_no_route(self):
99
config = {"proxies": [{"route": ""}]}
10-
config = PyPacerConfig(**config)
10+
config = PacCreatorConfig(**config)
1111
with self.assertRaises(ValueError) as err:
1212
config.validate()
1313
self.assertEqual(str(err.exception), "one proxy has no route")
1414

1515
def test_get_default_proxy_route(self):
1616
config = {"proxies": [{"route": "foo"}, {"route": "bar", "tags": ["default"]}]}
17-
config = PyPacerConfig(**config)
17+
config = PacCreatorConfig(**config)
1818
self.assertEqual(config.get_default_proxy().route, "bar")
1919

2020
def test_get_default_proxy_route_with_no_default_proxy(self):
2121
config = {"proxies": [{"route": "foo"}, {"route": "bar"}]}
22-
config = PyPacerConfig(**config)
22+
config = PacCreatorConfig(**config)
2323
self.assertEqual(config.get_default_proxy().route, "foo")
2424

2525
def test_target_is_string(self):
2626
config = {"proxies": [{"route": "foo", "targets": [10., "foo"]}]}
27-
PyPacerConfig(**config)
27+
PacCreatorConfig(**config)

0 commit comments

Comments
 (0)