Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
diff --git a/src/services/json_yaml.py b/src/services/json_yaml.py | ||
index 619f69f..45fa8b8 100644 | ||
--- a/src/services/json_yaml.py | ||
+++ b/src/services/json_yaml.py | ||
@@ -3,9 +3,9 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from gi.repository import Gio, GObject | ||
-from ruamel import yaml | ||
+from ruamel.yaml import YAML | ||
import json | ||
- | ||
+from io import StringIO | ||
|
||
class JsonYamlService(): | ||
|
||
@@ -25,15 +25,15 @@ class JsonYamlService(): | ||
task.return_value(outcome) | ||
|
||
def _convert_json_to_yaml(self, json_str:str, indents:int) -> str: | ||
- return yaml.dump( | ||
- json.loads(json_str), | ||
- indent=indents, | ||
- default_flow_style=False | ||
- ) | ||
+ output_buffer = StringIO() | ||
+ yaml = YAML(typ='unsafe', pure=True) | ||
+ yaml.dump(json.loads(json_str), output_buffer) | ||
+ return output_buffer.getvalue() | ||
|
||
def _convert_yaml_to_json(self, yaml_str:str, indents:int) -> str: | ||
+ yaml = YAML(typ='rt') | ||
return json.dumps( | ||
- yaml.load(yaml_str, Loader=yaml.Loader), | ||
+ yaml.load(yaml_str), | ||
indent=indents, | ||
ensure_ascii=False | ||
) | ||
diff --git a/src/utils.py b/src/utils.py | ||
index e2aecb1..b7a6821 100644 | ||
--- a/src/utils.py | ||
+++ b/src/utils.py | ||
@@ -3,7 +3,7 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from gi.repository import Gdk, GLib | ||
-from ruamel import yaml | ||
+from ruamel.yaml import YAML, YAMLError | ||
from enum import Enum | ||
from lxml import etree | ||
from crontab import CronSlices | ||
@@ -52,10 +52,11 @@ class Utils: | ||
|
||
@staticmethod | ||
def is_yaml(test_input) -> bool: | ||
+ yaml = YAML(typ='rt') | ||
try: | ||
- yaml.load(test_input, Loader=yaml.Loader) | ||
+ yaml.load(test_input) | ||
return True | ||
- except yaml.YAMLError: | ||
+ except YAMLError: | ||
return False | ||
|
||
@staticmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{ lib | ||
, python3Packages | ||
, fetchFromGitHub | ||
, meson | ||
, ninja | ||
, pkg-config | ||
, gobject-introspection | ||
, blueprint-compiler | ||
, wrapGAppsHook4 | ||
, desktop-file-utils | ||
, libadwaita | ||
, gtksourceview5 | ||
, webkitgtk_6_0 | ||
, gcr_4 | ||
, gdk-pixbuf | ||
}: | ||
|
||
python3Packages.buildPythonApplication rec { | ||
pname = "devtoolbox"; | ||
version = "1.1.1"; | ||
pyproject = false; | ||
|
||
src = fetchFromGitHub { | ||
owner = "aleiepure"; | ||
repo = "devtoolbox"; | ||
rev = "v${version}"; | ||
hash = "sha256-QFGEA+VhhRlvcch2AJrEzvRJGCSqtvZdMXWUvdAGkoU="; | ||
}; | ||
|
||
# Upstream is using an incompatible version of ruamel.yaml | ||
# May be removed in next update | ||
patches = [ ./incompatible_ruamel_yaml.patch ]; | ||
|
||
nativeBuildInputs = [ | ||
meson | ||
ninja | ||
pkg-config | ||
gobject-introspection | ||
blueprint-compiler | ||
wrapGAppsHook4 | ||
desktop-file-utils | ||
]; | ||
|
||
buildInputs = [ | ||
libadwaita | ||
gtksourceview5 | ||
webkitgtk_6_0 | ||
gcr_4 | ||
gdk-pixbuf | ||
]; | ||
|
||
propagatedBuildInputs = with python3Packages; [ | ||
pygobject3 | ||
ruamel-yaml | ||
lxml | ||
python-crontab | ||
jwt | ||
jsonschema | ||
pytz | ||
tzlocal | ||
python-lorem | ||
uuid6 | ||
textstat | ||
markdown2 | ||
daltonlens | ||
asn1crypto | ||
qrcode | ||
sqlparse | ||
jsbeautifier | ||
cssbeautifier | ||
humanize | ||
croniter | ||
python-dateutil | ||
]; | ||
|
||
dontWrapGApps = true; | ||
|
||
# Contains an unusable devtoolbox-run-script | ||
postInstall = '' | ||
rm -r $out/devtoolbox | ||
''; | ||
|
||
preFixup = '' | ||
makeWrapperArgs+=("''${gappsWrapperArgs[@]}") | ||
''; | ||
|
||
meta = with lib; { | ||
description = "Development tools at your fingertips"; | ||
longDescription = '' | ||
If you're tired of endlessly looking online for the right | ||
tool, or to find again that website of which you don't | ||
recall the name to do a quick conversion, this is the | ||
right app for you. This is a collection of powerful yet | ||
simple-to-use tools and utilities to solve the most common | ||
daily development problems: | ||
- JSON to YAML converter and vice-versa | ||
- CRON expressions parser | ||
- Formatters for common languages | ||
- Hash generators | ||
- Regex tester | ||
- Markdown Previewer | ||
- Image converters | ||
- Much more... | ||
''; | ||
homepage = "https://github.com/aleiepure/devtoolbox"; | ||
license = with licenses; [ | ||
gpl3Plus | ||
cc0 | ||
lgpl3Only | ||
mit | ||
unlicense | ||
]; | ||
mainProgram = "devtoolbox"; | ||
maintainers = with maintainers; [ aleksana ]; | ||
platforms = platforms.linux; # webkitgtk_6_0 is broken on darwin | ||
}; | ||
} |