fb-tools 3.1.0__tar.gz → 3.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.
Files changed (42) hide show
  1. {fb_tools-3.1.0 → fb_tools-3.2.0}/PKG-INFO +1 -1
  2. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/__init__.py +1 -1
  3. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/socket_obj/__init__.py +36 -1
  4. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/socket_obj/tcp.py +27 -4
  5. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/socket_obj/unix.py +10 -1
  6. {fb_tools-3.1.0 → fb_tools-3.2.0}/LICENSE +0 -0
  7. {fb_tools-3.1.0 → fb_tools-3.2.0}/README.md +0 -0
  8. {fb_tools-3.1.0 → fb_tools-3.2.0}/data/share/locale/de/LC_MESSAGES/fb_tools.mo +0 -0
  9. {fb_tools-3.1.0 → fb_tools-3.2.0}/data/share/locale/en/LC_MESSAGES/fb_tools.mo +0 -0
  10. {fb_tools-3.1.0 → fb_tools-3.2.0}/pyproject.toml +0 -0
  11. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/any_config.py +0 -0
  12. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/app.py +0 -0
  13. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/application/__init__.py +0 -0
  14. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/application/cfg_converter.py +0 -0
  15. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/application/get_file_rm.py +0 -0
  16. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/application/show_spinner.py +0 -0
  17. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/argparse_actions.py +0 -0
  18. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_app.py +0 -0
  19. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/__init__.py +0 -0
  20. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/dump.py +0 -0
  21. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/hjson.py +0 -0
  22. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/inifile.py +0 -0
  23. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/json.py +0 -0
  24. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/toml.py +0 -0
  25. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/cfg_options/yaml.py +0 -0
  26. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/colcts.py +0 -0
  27. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/collections.py +0 -0
  28. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/common.py +0 -0
  29. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/config.py +0 -0
  30. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/errors.py +0 -0
  31. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/handler/__init__.py +0 -0
  32. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/handler/lock.py +0 -0
  33. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/handling_obj.py +0 -0
  34. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/mailaddress.py +0 -0
  35. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/merge.py +0 -0
  36. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/multi_config/__init__.py +0 -0
  37. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/multi_config/files.py +0 -0
  38. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/multi_config/inits.py +0 -0
  39. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/obj.py +0 -0
  40. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/pidfile.py +0 -0
  41. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/spinner.py +0 -0
  42. {fb_tools-3.1.0 → fb_tools-3.2.0}/src/fb_tools/xlate.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fb_tools
3
- Version: 3.1.0
3
+ Version: 3.2.0
4
4
  Summary: @summary: A module for common used objects, error classes and functions.
5
5
  Author-email: Frank Brehm <frank@brehm-online.com>
6
6
  Requires-Python: >=3.8
@@ -32,6 +32,6 @@ MAX_INDENT = 12
32
32
  from .mailaddress import MailAddress, MailAddressList, QualifiedMailAddress # noqa: F401
33
33
  from .multi_config import BaseMultiConfig # noqa: F401
34
34
 
35
- __version__ = "3.1.0"
35
+ __version__ = "3.2.0"
36
36
 
37
37
  # vim: ts=4 et list
@@ -34,7 +34,7 @@ from ..errors import GenericSocketError
34
34
  from ..handling_obj import HandlingObject
35
35
  from ..xlate import XLATOR
36
36
 
37
- __version__ = "0.7.2"
37
+ __version__ = "0.8.0"
38
38
 
39
39
  LOG = logging.getLogger(__name__)
40
40
 
@@ -71,6 +71,7 @@ class GenericSocket(HandlingObject):
71
71
  * initialized (bool - rw) (inherited from FbBaseObject)
72
72
  * interrupted (bool - rw) (inherited from HandlingObject)
73
73
  * is_venv (bool - ro) (inherited from HandlingObject)
74
+ * name (str - ro)
74
75
  * polling_interval (float - rw)
75
76
  * prompt_timeout (int - rw) (inherited from HandlingObject)
76
77
  * quiet (bool - rw) (inherited from HandlingObject)
@@ -365,6 +366,12 @@ class GenericSocket(HandlingObject):
365
366
 
366
367
  self._polling_interval = v
367
368
 
369
+ # -----------------------------------------------------------
370
+ @property
371
+ def name(self):
372
+ """Return a descriptive name of this socket."""
373
+ return self._name()
374
+
368
375
  # -------------------------------------------------------------------------
369
376
  @abstractmethod
370
377
  def connect(self):
@@ -377,6 +384,17 @@ class GenericSocket(HandlingObject):
377
384
  """Create the socket and listen on it."""
378
385
  raise FunctionNotImplementedError("bind", self.__class__.__name__)
379
386
 
387
+ # -------------------------------------------------------------------------
388
+ @abstractmethod
389
+ def _name(self):
390
+ """
391
+ Return a descriptive name of this socket.
392
+
393
+ It might be unique on the system as possible.
394
+ This methos ha to be overridden in descendent classes.
395
+ """
396
+ raise FunctionNotImplementedError("_name", self.__class__.__name__)
397
+
380
398
  # -------------------------------------------------------------------------
381
399
  def as_dict(self, short=False):
382
400
  """
@@ -395,6 +413,7 @@ class GenericSocket(HandlingObject):
395
413
  res["connected"] = self.connected
396
414
  res["encoding"] = self.encoding
397
415
  res["fileno"] = self.fileno
416
+ res["name"] = self.name
398
417
  res["polling_interval"] = self.polling_interval
399
418
  res["request_queue_size"] = self.request_queue_size
400
419
  res["timeout"] = self.timeout
@@ -666,6 +685,22 @@ class GenericSocket(HandlingObject):
666
685
 
667
686
  return result
668
687
 
688
+ # -------------------------------------------------------------------------
689
+ def __enter__(self):
690
+ """Execute this action, when this socket will be opened by the with-block."""
691
+ LOG.debug(
692
+ _("Opened the {cls} {name!r} ...").format(cls=self.__class__.__name__, name=self.name)
693
+ )
694
+
695
+ # -------------------------------------------------------------------------
696
+ def __exit__(self, exc_type, exc_val, exc_traceback):
697
+ """Exit action at the end of the with-block - closing socket."""
698
+ LOG.debug(
699
+ _("Closing the {cls} {name!r} ...").format(cls=self.__class__.__name__, name=self.name)
700
+ )
701
+
702
+ self.close()
703
+
669
704
 
670
705
  # =============================================================================
671
706
 
@@ -24,7 +24,7 @@ from ..common import pp
24
24
  from ..errors import GenericSocketError
25
25
  from ..xlate import XLATOR
26
26
 
27
- __version__ = "0.4.2"
27
+ __version__ = "0.5.0"
28
28
 
29
29
  LOG = logging.getLogger(__name__)
30
30
 
@@ -67,6 +67,7 @@ class TcpSocket(GenericSocket):
67
67
  * initialized (bool - rw) (inherited from FbBaseObject)
68
68
  * interrupted (bool - rw) (inherited from HandlingObject)
69
69
  * is_venv (bool - ro) (inherited from HandlingObject)
70
+ * name (str - ro) (inherited from GenericSocket)
70
71
  * own_address (ipaddress - ro)
71
72
  * polling_interval (float - rw) (inherited from GenericSocket)
72
73
  * port (int - rw)
@@ -111,10 +112,11 @@ class TcpSocket(GenericSocket):
111
112
  @raise TcpSocketError: on a uncoverable error.
112
113
 
113
114
  @param address: the hostname or IP address, where to connect to or on which listening to.
114
- If it can be converted to a IPy.IP object, an IP address is assumed.
115
+ If it can be converted to a ipaddress._BaseAddress object,
116
+ an IP address is assumed.
115
117
  If None is given, then the socket will listen on all local IP addresses -
116
118
  not usable for client sockets. Else a hostname is assumed.
117
- @type address: str or IPy.IP or None
119
+ @type address: str or ipaddress.IPv4Address or ipaddress.IPv6Address or None
118
120
  @param port: the TCP port number, where to connect to or on which should be listened.
119
121
  @type port: int
120
122
  @param address_family: the IP address family, may be socket.AF_INET or socket.AF_INET6 or
@@ -177,7 +179,7 @@ class TcpSocket(GenericSocket):
177
179
  """
178
180
  @ivar: The resolved IP address, where to connect to or on which listening to.
179
181
  If self.address is '*', the self.resolved_address stays to None.
180
- @type: IPy.IP or None
182
+ @type: ipaddress.IPv4Address or ipaddress.IPv6Address or None
181
183
  """
182
184
 
183
185
  self.port = port
@@ -401,6 +403,8 @@ class TcpSocket(GenericSocket):
401
403
  self._resolved_address = ip_addr
402
404
  self._own_address = self.sock.getsockname()
403
405
 
406
+ return self
407
+
404
408
  # -------------------------------------------------------------------------
405
409
  def bind(self):
406
410
  """Create a TCP socket and listen on it."""
@@ -500,6 +504,25 @@ class TcpSocket(GenericSocket):
500
504
  self._resolved_address = socketaddr[0]
501
505
  self._own_address = self.sock.getsockname()
502
506
 
507
+ return self
508
+
509
+ # -------------------------------------------------------------------------
510
+ def _name(self):
511
+ """Return a descriptive name of this socket."""
512
+ if self.address is None:
513
+ return f"*:{self.port}"
514
+
515
+ addr = str(self.address)
516
+ try:
517
+ ip_addr = ipaddress.ip_address(self.address)
518
+ except ValueError:
519
+ return f"{addr}:{self.port}"
520
+
521
+ if ip_addr.version == 4:
522
+ return f"{ip_addr}:{self.port}"
523
+
524
+ return f"[{ip_addr}]:{self.port}"
525
+
503
526
 
504
527
  # =============================================================================
505
528
 
@@ -29,7 +29,7 @@ from . import GenericSocket
29
29
  from ..errors import GenericSocketError
30
30
  from ..xlate import XLATOR
31
31
 
32
- __version__ = "0.5.2"
32
+ __version__ = "0.6.0"
33
33
 
34
34
  LOG = logging.getLogger(__name__)
35
35
 
@@ -468,6 +468,8 @@ class UnixSocket(GenericSocket):
468
468
  self._connected = True
469
469
  self.fileno = self.sock.fileno()
470
470
 
471
+ return self
472
+
471
473
  # -------------------------------------------------------------------------
472
474
  def _set_socket_permissions(self):
473
475
  """Set file mode, owner and group to the socket file."""
@@ -540,6 +542,13 @@ class UnixSocket(GenericSocket):
540
542
  )
541
543
  self.sock.listen(self.request_queue_size)
542
544
 
545
+ return self
546
+
547
+ # -------------------------------------------------------------------------
548
+ def _name(self):
549
+ """Return a descriptive name of this socket."""
550
+ return str(self.filename)
551
+
543
552
 
544
553
  # =============================================================================
545
554
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes