Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelle Spijker <j.spijker@ultimaker.com>2020-05-08 16:39:16 +0300
committerJelle Spijker <spijker.jelle@gmail.com>2020-05-08 16:39:16 +0300
commitd69bf844243eb10a398fcda9875c7f04433c302a (patch)
tree6dcb1bb297a5e2251c8fdc9dd3fa0c64ee773b66 /cura/Backups
parent176919eee0ab397f0b9c151551dbef0b5fbb046e (diff)
Updated comments in Backup
Converted doxygen style comments to reStructuredText style in the files found in Cura/cura/Backup directory recursively using the script dox_2_rst.py (provided in the Uranium repo). Comments were manually checked and changed if needed.
Diffstat (limited to 'cura/Backups')
-rw-r--r--cura/Backups/Backup.py45
-rw-r--r--cura/Backups/BackupsManager.py2
2 files changed, 30 insertions, 17 deletions
diff --git a/cura/Backups/Backup.py b/cura/Backups/Backup.py
index 4d24a46384..6d1906e1dc 100644
--- a/cura/Backups/Backup.py
+++ b/cura/Backups/Backup.py
@@ -18,24 +18,26 @@ if TYPE_CHECKING:
from cura.CuraApplication import CuraApplication
-## The back-up class holds all data about a back-up.
-#
-# It is also responsible for reading and writing the zip file to the user data
-# folder.
class Backup:
- # These files should be ignored when making a backup.
+ """The back-up class holds all data about a back-up.
+
+ It is also responsible for reading and writing the zip file to the user data folder.
+ """
+
IGNORED_FILES = [r"cura\.log", r"plugins\.json", r"cache", r"__pycache__", r"\.qmlc", r"\.pyc"]
+ """These files should be ignored when making a backup."""
- # Re-use translation catalog.
catalog = i18nCatalog("cura")
+ """Re-use translation catalog"""
def __init__(self, application: "CuraApplication", zip_file: bytes = None, meta_data: Dict[str, str] = None) -> None:
self._application = application
self.zip_file = zip_file # type: Optional[bytes]
self.meta_data = meta_data # type: Optional[Dict[str, str]]
- ## Create a back-up from the current user config folder.
def makeFromCurrent(self) -> None:
+ """Create a back-up from the current user config folder."""
+
cura_release = self._application.getVersion()
version_data_dir = Resources.getDataStoragePath()
@@ -77,10 +79,13 @@ class Backup:
"plugin_count": str(plugin_count)
}
- ## Make a full archive from the given root path with the given name.
- # \param root_path The root directory to archive recursively.
- # \return The archive as bytes.
def _makeArchive(self, buffer: "io.BytesIO", root_path: str) -> Optional[ZipFile]:
+ """Make a full archive from the given root path with the given name.
+
+ :param root_path: The root directory to archive recursively.
+ :return: The archive as bytes.
+ """
+
ignore_string = re.compile("|".join(self.IGNORED_FILES))
try:
archive = ZipFile(buffer, "w", ZIP_DEFLATED)
@@ -99,13 +104,17 @@ class Backup:
"Could not create archive from user data directory: {}".format(error)))
return None
- ## Show a UI message.
def _showMessage(self, message: str) -> None:
+ """Show a UI message."""
+
Message(message, title=self.catalog.i18nc("@info:title", "Backup"), lifetime=30).show()
- ## Restore this back-up.
- # \return Whether we had success or not.
def restore(self) -> bool:
+ """Restore this back-up.
+
+ :return: Whether we had success or not.
+ """
+
if not self.zip_file or not self.meta_data or not self.meta_data.get("cura_release", None):
# We can restore without the minimum required information.
Logger.log("w", "Tried to restore a Cura backup without having proper data or meta data.")
@@ -139,12 +148,14 @@ class Backup:
return extracted
- ## Extract the whole archive to the given target path.
- # \param archive The archive as ZipFile.
- # \param target_path The target path.
- # \return Whether we had success or not.
@staticmethod
def _extractArchive(archive: "ZipFile", target_path: str) -> bool:
+ """Extract the whole archive to the given target path.
+
+ :param archive: The archive as ZipFile.
+ :param target_path: The target path.
+ :return: Whether we had success or not.
+ """
# Implement security recommendations: Sanity check on zip files will make it harder to spoof.
from cura.CuraApplication import CuraApplication
diff --git a/cura/Backups/BackupsManager.py b/cura/Backups/BackupsManager.py
index f335a3fb04..fb758455c1 100644
--- a/cura/Backups/BackupsManager.py
+++ b/cura/Backups/BackupsManager.py
@@ -24,6 +24,7 @@ class BackupsManager:
def createBackup(self) -> Tuple[Optional[bytes], Optional[Dict[str, str]]]:
"""
Get a back-up of the current configuration.
+
:return: A tuple containing a ZipFile (the actual back-up) and a dict containing some metadata (like version).
"""
@@ -37,6 +38,7 @@ class BackupsManager:
def restoreBackup(self, zip_file: bytes, meta_data: Dict[str, str]) -> None:
"""
Restore a back-up from a given ZipFile.
+
:param zip_file: A bytes object containing the actual back-up.
:param meta_data: A dict containing some metadata that is needed to restore the back-up correctly.
"""