lockss-pybasic 0.1.0.dev6__tar.gz → 0.1.0.dev7__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.3
2
2
  Name: lockss-pybasic
3
- Version: 0.1.0.dev6
3
+ Version: 0.1.0.dev7
4
4
  Summary: Basic Python utilities
5
5
  License: BSD-3-Clause
6
6
  Author: Thib Guicherd-Callin
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lockss-pybasic"
3
- version = "0.1.0-dev6"
3
+ version = "0.1.0-dev7"
4
4
  description = "Basic Python utilities"
5
5
  authors = [
6
6
  { name = "Thib Guicherd-Callin", email = "thib@cs.stanford.edu" }
@@ -32,4 +32,4 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
32
  POSSIBILITY OF SUCH DAMAGE.
33
33
  '''.strip()
34
34
 
35
- __version__ = '0.1.0-dev6'
35
+ __version__ = '0.1.0-dev7'
@@ -28,20 +28,61 @@
28
28
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
29
  # POSSIBILITY OF SUCH DAMAGE.
30
30
 
31
+ '''
32
+ Utilities for command line processing.
33
+ '''
34
+
35
+ from abc import ABC, abstractmethod
31
36
  import sys
32
37
 
33
38
  from pydantic.v1 import BaseModel, Field
34
39
 
35
- class VersionCommand:
40
+
41
+ class Printable(ABC):
42
+
43
+ def print(self, file=sys.stdout):
44
+ print(self.get_display(), file=file)
45
+
46
+ @abstractmethod
47
+ def get_display(self):
48
+ pass
49
+
50
+
51
+ class CopyrightCommand:
36
52
 
37
53
  @staticmethod
38
- def make(version):
39
- class VersionModel(BaseModel):
54
+ def make(copyright):
55
+ class CopyrightModel(Printable, BaseModel):
56
+ def get_display(self):
57
+ return copyright
58
+ return CopyrightModel
59
+
60
+ @staticmethod
61
+ def field():
62
+ return Field(description='print the copyright and exit')
40
63
 
41
- def print_version(self, file=sys.stdout):
42
- print(version, file=file)
43
- sys.exit(0)
44
64
 
65
+ class LicenseCommand:
66
+
67
+ @staticmethod
68
+ def make(license):
69
+ class LicenseModel(Printable, BaseModel):
70
+ def get_display(self):
71
+ return license
72
+ return LicenseModel
73
+
74
+ @staticmethod
75
+ def field():
76
+ return Field(description='print the software license and exit')
77
+
78
+
79
+ class VersionCommand:
80
+
81
+ @staticmethod
82
+ def make(version):
83
+ class VersionModel(Printable, BaseModel):
84
+ def get_display(self):
85
+ return version
45
86
  return VersionModel
46
87
 
47
88
  @staticmethod