Python yaml now use numeric value for indent attribute, this commit take care of that

This commit is contained in:
sti2d committed 2018-07-14 07:06:18 +02:00
1 parent d248df3826
commit 0020f029d1
12 files changed
+13 -21

No files matched your search

+1 -4
View File
@@ -243,7 +243,7 @@ class FilebasedGroupManager(GroupManager):
with atomic_write(self._groupfile, "wb", permissions=0o600, max_permissions=0o666) as f:
import yaml
yaml.safe_dump(data, f, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(data, f, default_flow_style=False, indent=4, allow_unicode=True)
self._dirty = False
self._load()
@@ -501,6 +501,3 @@ class Group(object):
def __eq__(self, other):
return isinstance(other, Group) and other.key == self.key
+1 -1
View File
@@ -499,7 +499,7 @@ class FilebasedUserManager(UserManager):
}
with atomic_write(self._userfile, "wb", permissions=0o600, max_permissions=0o666) as f:
yaml.safe_dump(data, f, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(data, f, default_flow_style=False, indent=4, allow_unicode=True)
self._dirty = False
self._load()
+1 -1
View File
@@ -70,4 +70,4 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
click.echo("DONE:{}s".format(time.time() - start_time))
click.echo("RESULTS:")
click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=" ", allow_unicode=True))
click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=4, allow_unicode=True))
+2 -2
View File
@@ -207,7 +207,7 @@ def get_command(ctx, path, as_json=False, as_yaml=False, as_raw=False):
if as_json:
output = json.dumps(value)
elif as_yaml:
output = yaml.safe_dump(value, default_flow_style=False, indent=" ", allow_unicode=True)
output = yaml.safe_dump(value, default_flow_style=False, indent=4, allow_unicode=True)
elif as_raw:
output = value
else:
@@ -232,7 +232,7 @@ def effective_command(ctx, as_json=False, as_yaml=False, as_raw=False):
if as_json:
output = json.dumps(value)
elif as_yaml:
output = yaml.safe_dump(value, default_flow_style=False, indent=" ", allow_unicode=True)
output = yaml.safe_dump(value, default_flow_style=False, indent=4, allow_unicode=True)
elif as_raw:
output = value
else:
+1 -1
View File
@@ -145,7 +145,7 @@ class EnvironmentDetector(object):
dumped_environment = yaml.safe_dump(environment,
default_flow_style=False,
indent=" ",
indent=4,
allow_unicode=True).strip()
environment_lines = "\n".join(map(lambda l: "| {}".format(l), dumped_environment.split("\n")))
return u"Detected environment is Python {} under {} ({}). Details:\n{}".format(environment["python"]["version"],
+1 -1
View File
@@ -626,7 +626,7 @@ class FileManager(object):
date=time.time())
try:
with atomic_write(self._recovery_file, max_permissions=0o666) as f:
yaml.safe_dump(data, stream=f, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(data, stream=f, default_flow_style=False, indent=2, allow_unicode=True)
except:
self._logger.exception("Could not write recovery data to file {}".format(self._recovery_file))
+1 -4
View File
@@ -474,7 +474,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
def _save_profile(self, path, profile, allow_overwrite=True):
import yaml
with octoprint.util.atomic_write(path, "wb", max_permissions=0o666) as f:
yaml.safe_dump(profile, f, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(profile, f, default_flow_style=False, indent=2, allow_unicode=True)
def _convert_to_engine(self, profile_path, printer_profile, pos_x=None, pos_y=None, used_extruders=1):
profile = Profile(self._load_profile(profile_path), printer_profile, pos_x, pos_y)
@@ -527,6 +527,3 @@ __plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/cura.html"
__plugin_description__ = "Adds support for slicing via CuraEngine versions up to and including version 15.04 from within OctoPrint"
__plugin_license__ = "AGPLv3"
__plugin_implementation__ = CuraPlugin()
+1 -1
View File
@@ -189,7 +189,7 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin,
# save
with octoprint.util.atomic_write(self._get_logging_file(), "wb", max_permissions=0o666) as f:
yaml.safe_dump(config, f, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(config, f, default_flow_style=False, indent=2, allow_unicode=True)
# set runtime logging levels now
for logger, level in new_levels.items():
@@ -226,7 +226,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._version_cache["__version"] = octoprint_version
with atomic_write(self._version_cache_path, max_permissions=0o666) as file_obj:
yaml.safe_dump(self._version_cache, stream=file_obj, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(self._version_cache, stream=file_obj, default_flow_style=False, indent=2, allow_unicode=True)
self._version_cache_dirty = False
self._version_cache_timestamp = time.time()
@@ -1198,5 +1198,3 @@ def __plugin_load__():
"octoprint.cli.commands": cli.commands,
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions
}
+1 -1
View File
@@ -461,7 +461,7 @@ class PrinterProfileManager(object):
import yaml
try:
with atomic_write(path, "wb", max_permissions=0o666) as f:
yaml.safe_dump(profile, f, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(profile, f, default_flow_style=False, indent=2, allow_unicode=True)
except Exception as e:
self._logger.exception("Error while trying to save profile %s" % profile["id"])
raise SaveError("Cannot save profile %s: %s" % (profile["id"], str(e)))
+1 -1
View File
@@ -833,7 +833,7 @@ class PreemptiveCache(object):
with self._lock:
try:
with atomic_write(self.cachefile, "wb", max_permissions=0o666) as handle:
yaml.safe_dump(data, handle,default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(data, handle,default_flow_style=False, indent=4, allow_unicode=True)
except:
self._logger.exception("Error while writing {}".format(self.cachefile))
+1 -1
View File
@@ -1320,7 +1320,7 @@ class Settings(object):
from octoprint.util import atomic_write
try:
with atomic_write(self._configfile, "wb", prefix="octoprint-config-", suffix=".yaml", permissions=0o600, max_permissions=0o666) as configFile:
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=" ", allow_unicode=True)
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=4, allow_unicode=True)
self._dirty = False
except:
self._logger.exception("Error while saving config.yaml!")