78
78
Repositories can be added with explicit values through a Python constructor.
79
79
80
80
Example:
81
-
82
81
```python
83
82
repositories = apt.RepositoryMapping()
84
83
91
90
`DebianRepository`.
92
91
93
92
Example:
94
-
95
93
```python
96
94
repositories = apt.RepositoryMapping()
97
95
124
122
125
123
# Increment this PATCH version before using `charmcraft publish-lib` or reset
126
124
# to 0 if you are raising the major API version
127
- LIBPATCH = 10
125
+ LIBPATCH = 11
128
126
129
127
130
128
VALID_SOURCE_TYPES = ("deb" , "deb-src" )
@@ -135,7 +133,7 @@ class Error(Exception):
135
133
"""Base class of most errors raised by this library."""
136
134
137
135
def __repr__ (self ):
138
- """String representation of Error."""
136
+ """Represent the Error."""
139
137
return "<{}.{} {}>" .format (type (self ).__module__ , type (self ).__name__ , self .args )
140
138
141
139
@property
@@ -212,15 +210,15 @@ def __eq__(self, other) -> bool:
212
210
) == (other ._name , other ._version .number )
213
211
214
212
def __hash__ (self ):
215
- """A basic hash so this class can be used in Mappings and dicts ."""
213
+ """Return a hash of this package ."""
216
214
return hash ((self ._name , self ._version .number ))
217
215
218
216
def __repr__ (self ):
219
- """A representation of the package."""
217
+ """Represent the package."""
220
218
return "<{}.{}: {}>" .format (self .__module__ , self .__class__ .__name__ , self .__dict__ )
221
219
222
220
def __str__ (self ):
223
- """A human-readable representation of the package."""
221
+ """Return a human-readable representation of the package."""
224
222
return "<{}: {}-{}.{} -- {}>" .format (
225
223
self .__class__ .__name__ ,
226
224
self ._name ,
@@ -267,7 +265,7 @@ def _add(self) -> None:
267
265
)
268
266
269
267
def _remove (self ) -> None :
270
- """Removes a package from the system. Implementation-specific."""
268
+ """Remove a package from the system. Implementation-specific."""
271
269
return self ._apt ("remove" , "{}={}" .format (self .name , self .version ))
272
270
273
271
@property
@@ -276,7 +274,7 @@ def name(self) -> str:
276
274
return self ._name
277
275
278
276
def ensure (self , state : PackageState ):
279
- """Ensures that a package is in a given state.
277
+ """Ensure that a package is in a given state.
280
278
281
279
Args:
282
280
state: a `PackageState` to reconcile the package to
@@ -308,7 +306,7 @@ def state(self) -> PackageState:
308
306
309
307
@state .setter
310
308
def state (self , state : PackageState ) -> None :
311
- """Sets the package state to a given value.
309
+ """Set the package state to a given value.
312
310
313
311
Args:
314
312
state: a `PackageState` to reconcile the package to
@@ -527,11 +525,11 @@ def __init__(self, version: str, epoch: str):
527
525
self ._epoch = epoch or ""
528
526
529
527
def __repr__ (self ):
530
- """A representation of the package."""
528
+ """Represent the package."""
531
529
return "<{}.{}: {}>" .format (self .__module__ , self .__class__ .__name__ , self .__dict__ )
532
530
533
531
def __str__ (self ):
534
- """A human-readable representation of the package."""
532
+ """Return human-readable representation of the package."""
535
533
return "{}{}" .format ("{}:" .format (self ._epoch ) if self ._epoch else "" , self ._version )
536
534
537
535
@property
@@ -732,6 +730,7 @@ def add_package(
732
730
"""Add a package or list of packages to the system.
733
731
734
732
Args:
733
+ package_names: single package name, or list of package names
735
734
name: the name(s) of the package(s)
736
735
version: an (Optional) version as a string. Defaults to the latest known
737
736
arch: an optional architecture for the package
@@ -788,7 +787,7 @@ def _add(
788
787
version : Optional [str ] = "" ,
789
788
arch : Optional [str ] = "" ,
790
789
) -> Tuple [Union [DebianPackage , str ], bool ]:
791
- """Adds a package.
790
+ """Add a package to the system .
792
791
793
792
Args:
794
793
name: the name(s) of the package(s)
@@ -809,7 +808,7 @@ def _add(
809
808
def remove_package (
810
809
package_names : Union [str , List [str ]]
811
810
) -> Union [DebianPackage , List [DebianPackage ]]:
812
- """Removes a package from the system.
811
+ """Remove package(s) from the system.
813
812
814
813
Args:
815
814
package_names: the name of a package
@@ -837,7 +836,7 @@ def remove_package(
837
836
838
837
839
838
def update () -> None :
840
- """Updates the apt cache via `apt-get update`."""
839
+ """Update the apt cache via `apt-get update`."""
841
840
check_call (["apt-get" , "update" ], stderr = PIPE , stdout = PIPE )
842
841
843
842
@@ -966,7 +965,7 @@ def filename(self):
966
965
967
966
@filename .setter
968
967
def filename (self , fname : str ) -> None :
969
- """Sets the filename used when a repo is written back to diskself .
968
+ """Set the filename used when a repo is written back to disk .
970
969
971
970
Args:
972
971
fname: a filename to write the repository information to.
@@ -1148,7 +1147,7 @@ def _get_key_by_keyid(keyid: str) -> str:
1148
1147
1149
1148
@staticmethod
1150
1149
def _dearmor_gpg_key (key_asc : bytes ) -> bytes :
1151
- """Converts a GPG key in the ASCII armor format to the binary format.
1150
+ """Convert a GPG key in the ASCII armor format to the binary format.
1152
1151
1153
1152
Args:
1154
1153
key_asc: A GPG key in ASCII armor format.
@@ -1172,7 +1171,7 @@ def _dearmor_gpg_key(key_asc: bytes) -> bytes:
1172
1171
1173
1172
@staticmethod
1174
1173
def _write_apt_gpg_keyfile (key_name : str , key_material : bytes ) -> None :
1175
- """Writes GPG key material into a file at a provided path.
1174
+ """Write GPG key material into a file at a provided path.
1176
1175
1177
1176
Args:
1178
1177
key_name: A key name to use for a key file (could be a fingerprint)
@@ -1220,7 +1219,7 @@ def __len__(self) -> int:
1220
1219
return len (self ._repository_map )
1221
1220
1222
1221
def __iter__ (self ) -> Iterable [DebianRepository ]:
1223
- """Iterator magic method for RepositoryMapping."""
1222
+ """Return iterator for RepositoryMapping."""
1224
1223
return iter (self ._repository_map .values ())
1225
1224
1226
1225
def __getitem__ (self , repository_uri : str ) -> DebianRepository :
0 commit comments