Skip to content

Commit 440a333

Browse files
authored
EHN: Using native json replace demjson (#15)
1 parent 89f6ca6 commit 440a333

File tree

5 files changed

+18
-24
lines changed

5 files changed

+18
-24
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ include MANIFEST.in
22
include setup.py
33
include README.md
44
include LICENSE
5-
include requirements.txt
65

76
include assets/*.png

flowlauncher/FlowLauncher.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
import inspect
55
import sys
6-
7-
import demjson
6+
from json import loads, dumps
87

98

109
class FlowLauncher:
@@ -17,8 +16,11 @@ def __init__(self):
1716
# defalut jsonrpc
1817
self.rpc_request = {'method': 'query', 'parameters': ['']}
1918
self.debugMessage = ""
20-
if len(sys.argv) > 1: # from input to get jsonrpc
21-
self.rpc_request = demjson.decode(sys.argv[1])
19+
20+
if len(sys.argv) > 1:
21+
22+
# Gets JSON-RPC from Flow Launcher process.
23+
self.rpc_request = loads(sys.argv[1])
2224

2325
# proxy is not working now
2426
# self.proxy = self.rpc_request.get("proxy", {})
@@ -31,7 +33,7 @@ def __init__(self):
3133
results = request_method(*request_parameters)
3234

3335
if request_method_name in ("query", "context_menu"):
34-
print(demjson.encode({
36+
print(dumps({
3537
"result": results,
3638
"debugMessage": self.debugMessage
3739
}))

flowlauncher/FlowLauncherAPI.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
import demjson
4-
3+
from json import dumps
54

65
class FlowLauncherAPI:
76

@@ -10,7 +9,7 @@ def change_query(cls, query, requery: bool = False):
109
"""
1110
change flow launcher query
1211
"""
13-
print(demjson.encode({
12+
print(dumps({
1413
"method": "Flow.Launcher.ChangeQuery",
1514
"parameters": [query, requery]}))
1615

@@ -19,7 +18,7 @@ def shell_run(cls, cmd):
1918
"""
2019
run shell commands
2120
"""
22-
print(demjson.encode({
21+
print(dumps({
2322
"method": "Flow.Launcher.ShellRun",
2423
"parameters": [cmd]}))
2524

@@ -28,7 +27,7 @@ def close_app(cls):
2827
"""
2928
close flow launcher
3029
"""
31-
print(demjson.encode({
30+
print(dumps({
3231
"method": "Flow.Launcher.CloseApp",
3332
"parameters": []}))
3433

@@ -37,7 +36,7 @@ def hide_app(cls):
3736
"""
3837
hide flow launcher
3938
"""
40-
print(demjson.encode({
39+
print(dumps({
4140
"method": "Flow.Launcher.HideApp",
4241
"parameters": []}))
4342

@@ -46,7 +45,7 @@ def show_app(cls):
4645
"""
4746
show flow launcher
4847
"""
49-
print(demjson.encode({
48+
print(dumps({
5049
"method": "Flow.Launcher.ShowApp",
5150
"parameters": []}))
5251

@@ -55,7 +54,7 @@ def show_msg(cls, title: str, sub_title: str, ico_path: str = ""):
5554
"""
5655
show messagebox
5756
"""
58-
print(demjson.encode({
57+
print(dumps({
5958
"method": "Flow.Launcher.ShowMsg",
6059
"parameters": [title, sub_title, ico_path]}))
6160

@@ -64,7 +63,7 @@ def open_setting_dialog(cls):
6463
"""
6564
open setting dialog
6665
"""
67-
print(demjson.encode({
66+
print(dumps({
6867
"method": "Flow.Launcher.OpenSettingDialog",
6968
"parameters": []}))
7069

@@ -73,7 +72,7 @@ def start_loadingbar(cls):
7372
"""
7473
start loading animation in flow launcher
7574
"""
76-
print(demjson.encode({
75+
print(dumps({
7776
"method": "Flow.Launcher.StartLoadingBar",
7877
"parameters": []}))
7978

@@ -82,7 +81,7 @@ def stop_loadingbar(cls):
8281
"""
8382
stop loading animation in flow launcher
8483
"""
85-
print(demjson.encode({
84+
print(dumps({
8685
"method": "Flow.Launcher.StopLoadingBar",
8786
"parameters": []}))
8887

@@ -91,6 +90,6 @@ def reload_plugins(cls):
9190
"""
9291
reload all flow launcher plugins
9392
"""
94-
print(demjson.encode({
93+
print(dumps({
9594
"method": "Flow.Launcher.ReloadPlugins",
9695
"parameters": []}))

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
"Topic :: Software Development :: Libraries :: Application Frameworks",
4646
]
4747

48-
with open("requirements.txt", "r") as f:
49-
REQUIRES = [package.strip() for package in f.readlines()]
50-
5148

5249
setup(
5350
name=NAME,
@@ -65,7 +62,5 @@
6562
packages=find_packages(),
6663
include_package_data=True,
6764
download_url=DOWNLOAD_URL,
68-
install_requires=REQUIRES,
69-
requires=REQUIRES,
7065
classifiers=CLASSIFIERS
7166
)

0 commit comments

Comments
 (0)