mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-22 09:21:33 +00:00
Revert 5619
Fix find_json_objects when there is a newline at the end of the string Add test for find_json_objects
This commit is contained in:
parent
5f561dabda
commit
ac9be780cf
@ -72,7 +72,6 @@ import shutil
|
||||
import os
|
||||
|
||||
import deluge.common
|
||||
import deluge.configmanager
|
||||
from deluge.log import LOG as log
|
||||
|
||||
json = deluge.common.json
|
||||
@ -115,9 +114,9 @@ def find_json_objects(s):
|
||||
opens += 1
|
||||
elif c == "}":
|
||||
opens -= 1
|
||||
if opens == 0:
|
||||
objects.append((start, index+offset+1))
|
||||
start = index + offset + 1
|
||||
if opens == 0:
|
||||
objects.append((start, index+offset+1))
|
||||
start = index + offset + 1
|
||||
|
||||
return objects
|
||||
|
||||
@ -153,7 +152,7 @@ class Config(object):
|
||||
if config_dir:
|
||||
self.__config_file = os.path.join(config_dir, filename)
|
||||
else:
|
||||
self.__config_file = deluge.configmanager.get_config_dir(filename)
|
||||
self.__config_file = deluge.common.get_default_config_dir(filename)
|
||||
|
||||
self.load()
|
||||
|
||||
|
@ -96,4 +96,19 @@ class ConfigTestCase(unittest.TestCase):
|
||||
from twisted.internet import reactor
|
||||
d = deferLater(reactor, 7, check_config, config)
|
||||
return d
|
||||
|
||||
def test_find_json_objects(self):
|
||||
s = """{
|
||||
"file": 1,
|
||||
"format": 1
|
||||
}{
|
||||
"ssl": true,
|
||||
"enabled": false,
|
||||
"port": 8115
|
||||
}\n"""
|
||||
|
||||
from deluge.config import find_json_objects
|
||||
|
||||
objects = find_json_objects(s)
|
||||
self.assertEquals(len(objects), 2)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user