gophermap 0.1.0__tar.gz → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gophermap
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A simple library for parsng Gophermaps
5
5
  Keywords: Gopher,Gophermap,Hypertext,library,Markup,parser,Small Web,smolweb
6
6
  Author: Dave Pearson
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gophermap"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "A simple library for parsng Gophermaps"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -0,0 +1,28 @@
1
+ """Exceptions for the library.
2
+
3
+ Note:
4
+ This module is now deprecated and will be removed in a future release.
5
+ """
6
+
7
+
8
+ ##############################################################################
9
+ class GopherMapError(Exception):
10
+ """Base exception for all errors raised by the GopherMap library.
11
+
12
+ Note:
13
+ This exception class is now deprecated and will be removed in a
14
+ future release.
15
+ """
16
+
17
+
18
+ ##############################################################################
19
+ class NoFields(GopherMapError):
20
+ """Raised when a Gopher item has no fields.
21
+
22
+ Note:
23
+ This exception class is now deprecated and will be removed in a
24
+ future release.
25
+ """
26
+
27
+
28
+ ### exceptions.py ends here
@@ -38,8 +38,8 @@ class GopherMap:
38
38
  Yields:
39
39
  Gopher items.
40
40
  """
41
- for line in map_text.splitlines(keepends=True):
42
- if line.strip() == EOF:
41
+ for line in map_text.splitlines():
42
+ if line == EOF:
43
43
  break
44
44
  yield GopherItem(line)
45
45
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  ##############################################################################
4
4
  # Local imports.
5
- from .exceptions import NoFields
6
5
  from .item_type import ItemType
7
6
 
8
7
 
@@ -16,16 +15,13 @@ class GopherItem:
16
15
  Args:
17
16
  line: The line of text from the Gopher map.
18
17
  """
19
- if not line:
20
- raise NoFields("The Gopher item line is empty.")
21
- if "\t" not in line:
22
- raise NoFields(f"The Gopher item line has no tab characters: {line!r}")
23
18
  self._raw = line
24
19
  """The raw text of the Gopher item."""
25
- fields = line.rstrip("\r\n").split("\t")
26
- self._type = ItemType(fields[0][0] or ItemType.INFO)
20
+ if not (fields := line.rstrip("\r\n").split("\t"))[0]:
21
+ fields[0] = ItemType.INFO.value
22
+ self._type = ItemType(fields[0][0])
27
23
  """The type of the Gopher item."""
28
- self._display_text = fields[0][1:] if len(fields) > 0 else ""
24
+ self._display_text = fields[0][1:]
29
25
  """The display text of the Gopher item."""
30
26
  self._selector = fields[1] if len(fields) > 1 else ""
31
27
  """The selector of the Gopher item."""
@@ -1,14 +0,0 @@
1
- """Exceptions for the library."""
2
-
3
-
4
- ##############################################################################
5
- class GopherMapError(Exception):
6
- """Base exception for all errors raised by the GopherMap library."""
7
-
8
-
9
- ##############################################################################
10
- class NoFields(GopherMapError):
11
- """Raised when a Gopher item has no fields."""
12
-
13
-
14
- ### exceptions.py ends here
File without changes