gophermap 0.0.4__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gophermap-0.1.0/PKG-INFO +112 -0
- gophermap-0.1.0/README.md +86 -0
- {gophermap-0.0.4 → gophermap-0.1.0}/pyproject.toml +1 -1
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/gopher_map.py +2 -2
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/item_type.py +1 -1
- gophermap-0.0.4/PKG-INFO +0 -49
- gophermap-0.0.4/README.md +0 -23
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/__init__.py +0 -0
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/__main__.py +0 -0
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/exceptions.py +0 -0
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/item.py +0 -0
- {gophermap-0.0.4 → gophermap-0.1.0}/src/gophermap/py.typed +0 -0
gophermap-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gophermap
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple library for parsng Gophermaps
|
|
5
|
+
Keywords: Gopher,Gophermap,Hypertext,library,Markup,parser,Small Web,smolweb
|
|
6
|
+
Author: Dave Pearson
|
|
7
|
+
Author-email: Dave Pearson <davep@davep.org>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Project-URL: Homepage, https://gophermap.davep.dev/
|
|
20
|
+
Project-URL: Repository, https://github.com/davep/gophermap
|
|
21
|
+
Project-URL: Documentation, https://gophermap.davep.dev/
|
|
22
|
+
Project-URL: Source, https://github.com/davep/gophermap
|
|
23
|
+
Project-URL: Issues, https://github.com/davep/gophermap/issues
|
|
24
|
+
Project-URL: Discussions, https://github.com/davep/gophermap/discussions
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# gophermap - A simple library for parsing Gopher maps
|
|
28
|
+
|
|
29
|
+
`gophermap` is a small and simple library that provides code for parsing
|
|
30
|
+
Gopher responses.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
`gophermap` is [available from pypi](https://pypi.org/project/gophermap/)
|
|
35
|
+
and can be installed with your package installer of choice.
|
|
36
|
+
|
|
37
|
+
With `pip`:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install gophermap
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
With `uv`:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
uv add gophermap
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick start
|
|
50
|
+
|
|
51
|
+
The library provides a single main parsing class called `GopherMap`. It is
|
|
52
|
+
initialised with a response from a Gopher server, and the `items` property
|
|
53
|
+
provides a list of `GopherItem` objects.
|
|
54
|
+
|
|
55
|
+
A very minimal parser might look like this:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import fileinput
|
|
59
|
+
from gophermap import GopherMap
|
|
60
|
+
|
|
61
|
+
def parse_input() -> None:
|
|
62
|
+
with fileinput.input() as gopher_map:
|
|
63
|
+
for gopher_item in GopherMap("".join(gopher_map)).items:
|
|
64
|
+
print(f"{gopher_item!r}")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The library contains a simple test command line tool, which can be accessed
|
|
68
|
+
either via the Python `-m` switch, or depending on your environment, via the
|
|
69
|
+
`gophermap` command. For example, given this content of a file called
|
|
70
|
+
`gophermap`:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
iSome places to find me and more of my stuff null.host 1
|
|
74
|
+
i~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ null.host 0
|
|
75
|
+
i null.host 1
|
|
76
|
+
hFind me all over URL:https://davep.at/ tilde.team 70
|
|
77
|
+
hFind me in Geminispace URL:gemini://tilde.team/~davep/ tilde.team 70
|
|
78
|
+
hMy blog URL:https://blog.davep.org/ tilde.team 70
|
|
79
|
+
hfinger://plan.cat/davep URL:finger://plan.cat/davep tilde.team 70
|
|
80
|
+
hfinger://tilde.team/davep URL:finger://tilde.team/davep tilde.team 70
|
|
81
|
+
i null.host 1
|
|
82
|
+
iMy current projects null.host 1
|
|
83
|
+
i~~~~~~~~~~~~~~~~~~~ null.host 0
|
|
84
|
+
i null.host 1
|
|
85
|
+
h[Web] Rogallo - A Gemini/Gopher/Finger client for the terminal URL:https://rogallo.davep.dev/ tilde.team 70
|
|
86
|
+
h[Gemini] Rogallo - A Gemini/Gopher/Finger client for the terminal URL:gemini://tilde.team/~davep/rogallo/ tilde.team 70
|
|
87
|
+
.
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The `gophermap` command (or `python -m gophermap`) would produce:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
$ gophermap gophermap
|
|
94
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='Some places to find me and more of my stuff', selector='', host='null.host', port=1)
|
|
95
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', selector='', host='null.host', port=0)
|
|
96
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
|
|
97
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='Find me all over', selector='URL:https://davep.at/', host='tilde.team', port=70)
|
|
98
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='Find me in Geminispace', selector='URL:gemini://tilde.team/~davep/', host='tilde.team', port=70)
|
|
99
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='My blog', selector='URL:https://blog.davep.org/', host='tilde.team', port=70)
|
|
100
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='finger://plan.cat/davep', selector='URL:finger://plan.cat/davep', host='tilde.team', port=70)
|
|
101
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='finger://tilde.team/davep', selector='URL:finger://tilde.team/davep', host='tilde.team', port=70)
|
|
102
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
|
|
103
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='My current projects', selector='', host='null.host', port=1)
|
|
104
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='~~~~~~~~~~~~~~~~~~~', selector='', host='null.host', port=0)
|
|
105
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
|
|
106
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='[Web] Rogallo - A Gemini/Gopher/Finger client for the terminal', selector='URL:https://rogallo.davep.dev/', host='tilde.team', port=70)
|
|
107
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='[Gemini] Rogallo - A Gemini/Gopher/Finger client for the terminal', selector='URL:gemini://tilde.team/~davep/rogallo/', host='tilde.team', port=70)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
See [the main documentation](https://gophermap.davep.dev/) for the full API.
|
|
111
|
+
|
|
112
|
+
[//]: # (README.md ends here)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# gophermap - A simple library for parsing Gopher maps
|
|
2
|
+
|
|
3
|
+
`gophermap` is a small and simple library that provides code for parsing
|
|
4
|
+
Gopher responses.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
`gophermap` is [available from pypi](https://pypi.org/project/gophermap/)
|
|
9
|
+
and can be installed with your package installer of choice.
|
|
10
|
+
|
|
11
|
+
With `pip`:
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
pip install gophermap
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
With `uv`:
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
uv add gophermap
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
The library provides a single main parsing class called `GopherMap`. It is
|
|
26
|
+
initialised with a response from a Gopher server, and the `items` property
|
|
27
|
+
provides a list of `GopherItem` objects.
|
|
28
|
+
|
|
29
|
+
A very minimal parser might look like this:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import fileinput
|
|
33
|
+
from gophermap import GopherMap
|
|
34
|
+
|
|
35
|
+
def parse_input() -> None:
|
|
36
|
+
with fileinput.input() as gopher_map:
|
|
37
|
+
for gopher_item in GopherMap("".join(gopher_map)).items:
|
|
38
|
+
print(f"{gopher_item!r}")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The library contains a simple test command line tool, which can be accessed
|
|
42
|
+
either via the Python `-m` switch, or depending on your environment, via the
|
|
43
|
+
`gophermap` command. For example, given this content of a file called
|
|
44
|
+
`gophermap`:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
iSome places to find me and more of my stuff null.host 1
|
|
48
|
+
i~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ null.host 0
|
|
49
|
+
i null.host 1
|
|
50
|
+
hFind me all over URL:https://davep.at/ tilde.team 70
|
|
51
|
+
hFind me in Geminispace URL:gemini://tilde.team/~davep/ tilde.team 70
|
|
52
|
+
hMy blog URL:https://blog.davep.org/ tilde.team 70
|
|
53
|
+
hfinger://plan.cat/davep URL:finger://plan.cat/davep tilde.team 70
|
|
54
|
+
hfinger://tilde.team/davep URL:finger://tilde.team/davep tilde.team 70
|
|
55
|
+
i null.host 1
|
|
56
|
+
iMy current projects null.host 1
|
|
57
|
+
i~~~~~~~~~~~~~~~~~~~ null.host 0
|
|
58
|
+
i null.host 1
|
|
59
|
+
h[Web] Rogallo - A Gemini/Gopher/Finger client for the terminal URL:https://rogallo.davep.dev/ tilde.team 70
|
|
60
|
+
h[Gemini] Rogallo - A Gemini/Gopher/Finger client for the terminal URL:gemini://tilde.team/~davep/rogallo/ tilde.team 70
|
|
61
|
+
.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The `gophermap` command (or `python -m gophermap`) would produce:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
$ gophermap gophermap
|
|
68
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='Some places to find me and more of my stuff', selector='', host='null.host', port=1)
|
|
69
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', selector='', host='null.host', port=0)
|
|
70
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
|
|
71
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='Find me all over', selector='URL:https://davep.at/', host='tilde.team', port=70)
|
|
72
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='Find me in Geminispace', selector='URL:gemini://tilde.team/~davep/', host='tilde.team', port=70)
|
|
73
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='My blog', selector='URL:https://blog.davep.org/', host='tilde.team', port=70)
|
|
74
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='finger://plan.cat/davep', selector='URL:finger://plan.cat/davep', host='tilde.team', port=70)
|
|
75
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='finger://tilde.team/davep', selector='URL:finger://tilde.team/davep', host='tilde.team', port=70)
|
|
76
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
|
|
77
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='My current projects', selector='', host='null.host', port=1)
|
|
78
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='~~~~~~~~~~~~~~~~~~~', selector='', host='null.host', port=0)
|
|
79
|
+
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
|
|
80
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='[Web] Rogallo - A Gemini/Gopher/Finger client for the terminal', selector='URL:https://rogallo.davep.dev/', host='tilde.team', port=70)
|
|
81
|
+
GopherItem(type=<ItemType.HTML: 'h'>, display_text='[Gemini] Rogallo - A Gemini/Gopher/Finger client for the terminal', selector='URL:gemini://tilde.team/~davep/rogallo/', host='tilde.team', port=70)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
See [the main documentation](https://gophermap.davep.dev/) for the full API.
|
|
85
|
+
|
|
86
|
+
[//]: # (README.md ends here)
|
|
@@ -11,7 +11,7 @@ from typing import Final
|
|
|
11
11
|
from .item import GopherItem
|
|
12
12
|
|
|
13
13
|
##############################################################################
|
|
14
|
-
EOF: Final = "
|
|
14
|
+
EOF: Final[str] = "."
|
|
15
15
|
"""The EOF marker for a Gopher map."""
|
|
16
16
|
|
|
17
17
|
|
|
@@ -39,7 +39,7 @@ class GopherMap:
|
|
|
39
39
|
Gopher items.
|
|
40
40
|
"""
|
|
41
41
|
for line in map_text.splitlines(keepends=True):
|
|
42
|
-
if line == EOF:
|
|
42
|
+
if line.strip() == EOF:
|
|
43
43
|
break
|
|
44
44
|
yield GopherItem(line)
|
|
45
45
|
|
|
@@ -92,7 +92,7 @@ class ItemType(StrEnum):
|
|
|
92
92
|
ItemType.AUDIO: "application/octet-stream",
|
|
93
93
|
ItemType.PDF: "application/pdf",
|
|
94
94
|
ItemType.XML: "application/xml",
|
|
95
|
-
}.get(self, "application/
|
|
95
|
+
}.get(self, "application/x-gopher-unknown")
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
### item_type.py ends here
|
gophermap-0.0.4/PKG-INFO
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: gophermap
|
|
3
|
-
Version: 0.0.4
|
|
4
|
-
Summary: A simple library for parsng Gophermaps
|
|
5
|
-
Keywords: Gopher,Gophermap,Hypertext,library,Markup,parser,Small Web,smolweb
|
|
6
|
-
Author: Dave Pearson
|
|
7
|
-
Author-email: Dave Pearson <davep@davep.org>
|
|
8
|
-
License-Expression: MIT
|
|
9
|
-
Classifier: Development Status :: 3 - Alpha
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
-
Classifier: Typing :: Typed
|
|
18
|
-
Requires-Python: >=3.12
|
|
19
|
-
Project-URL: Homepage, https://gophermap.davep.dev/
|
|
20
|
-
Project-URL: Repository, https://github.com/davep/gophermap
|
|
21
|
-
Project-URL: Documentation, https://gophermap.davep.dev/
|
|
22
|
-
Project-URL: Source, https://github.com/davep/gophermap
|
|
23
|
-
Project-URL: Issues, https://github.com/davep/gophermap/issues
|
|
24
|
-
Project-URL: Discussions, https://github.com/davep/gophermap/discussions
|
|
25
|
-
Description-Content-Type: text/markdown
|
|
26
|
-
|
|
27
|
-
# gophermap - A simple library for parsing Gopher maps
|
|
28
|
-
|
|
29
|
-
`gophermap` is a small and simple library that provides code for parsing
|
|
30
|
-
Gopher responses.
|
|
31
|
-
|
|
32
|
-
## Installation
|
|
33
|
-
|
|
34
|
-
`gophermap` is [available from pypi](https://pypi.org/project/gophermap/)
|
|
35
|
-
and can be installed with your package installer of choice.
|
|
36
|
-
|
|
37
|
-
With `pip`:
|
|
38
|
-
|
|
39
|
-
```shell
|
|
40
|
-
pip install gophermap
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
With `uv`:
|
|
44
|
-
|
|
45
|
-
```shell
|
|
46
|
-
uv add gophermap
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
[//]: # (README.md ends here)
|
gophermap-0.0.4/README.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# gophermap - A simple library for parsing Gopher maps
|
|
2
|
-
|
|
3
|
-
`gophermap` is a small and simple library that provides code for parsing
|
|
4
|
-
Gopher responses.
|
|
5
|
-
|
|
6
|
-
## Installation
|
|
7
|
-
|
|
8
|
-
`gophermap` is [available from pypi](https://pypi.org/project/gophermap/)
|
|
9
|
-
and can be installed with your package installer of choice.
|
|
10
|
-
|
|
11
|
-
With `pip`:
|
|
12
|
-
|
|
13
|
-
```shell
|
|
14
|
-
pip install gophermap
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
With `uv`:
|
|
18
|
-
|
|
19
|
-
```shell
|
|
20
|
-
uv add gophermap
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
[//]: # (README.md ends here)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|