-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from kellyjonbrazil/dev
Dev v1.25.1
- Loading branch information
Showing
36 changed files
with
1,279 additions
and
573 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
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 |
---|---|---|
|
@@ -98,4 +98,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd | |
|
||
Source: [`jc/parsers/ini.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ini.py) | ||
|
||
Version 2.1 by Kelly Brazil ([email protected]) | ||
Version 2.2 by Kelly Brazil ([email protected]) |
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
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
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 |
---|---|---|
|
@@ -92,4 +92,4 @@ Source: [`jc/parsers/uptime.py`](https://github.com/kellyjonbrazil/jc/blob/maste | |
|
||
This parser can be used with the `--slurp` command-line option. | ||
|
||
Version 1.8 by Kelly Brazil ([email protected]) | ||
Version 1.9 by Kelly Brazil ([email protected]) |
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 |
---|---|---|
|
@@ -100,4 +100,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd | |
|
||
Source: [`jc/parsers/xml.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/xml.py) | ||
|
||
Version 1.9 by Kelly Brazil ([email protected]) | ||
Version 1.10 by Kelly Brazil ([email protected]) |
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
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
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
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
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,23 @@ | ||
"""jc - JSON Convert broken parser - for testing purposes only""" | ||
import non_existent_library | ||
|
||
class info(): | ||
"""Provides parser metadata (version, author, etc.)""" | ||
version = '1.0' | ||
description = 'broken parser' | ||
author = 'N/A' | ||
author_email = 'N/A' | ||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] | ||
hidden = True | ||
|
||
|
||
__version__ = info.version | ||
|
||
|
||
def parse( | ||
data: str, | ||
raw: bool = False, | ||
quiet: bool = False | ||
) -> dict: | ||
"""Main text parsing function""" | ||
return {} |
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,26 @@ | ||
"""jc - JSON Convert disabled parser | ||
This parser has been disabled due to an error in the parser code. | ||
""" | ||
from jc.exceptions import ParseError | ||
|
||
class info(): | ||
"""Provides parser metadata (version, author, etc.)""" | ||
version = '1.0' | ||
description = 'Disabled parser' | ||
author = 'N/A' | ||
author_email = 'N/A' | ||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] | ||
hidden = True | ||
|
||
|
||
__version__ = info.version | ||
|
||
|
||
def parse( | ||
data: str, | ||
raw: bool = False, | ||
quiet: bool = False | ||
) -> dict: | ||
"""Main text parsing function""" | ||
raise ParseError('This parser is disabled.') |
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 |
---|---|---|
|
@@ -75,7 +75,7 @@ | |
|
||
class info(): | ||
"""Provides parser metadata (version, author, etc.)""" | ||
version = '2.1' | ||
version = '2.2' | ||
description = 'INI file parser' | ||
author = 'Kelly Brazil' | ||
author_email = '[email protected]' | ||
|
@@ -87,14 +87,10 @@ class info(): | |
__version__ = info.version | ||
|
||
|
||
class MyDict(dict): | ||
def __setitem__(self, key, value): | ||
# convert None values to empty string | ||
if value is None: | ||
self[key] = '' | ||
|
||
else: | ||
super().__setitem__(key, value) | ||
def _none_to_empty_string(data): | ||
if data is None: | ||
return '' | ||
return data | ||
|
||
|
||
def _process(proc_data): | ||
|
@@ -110,13 +106,18 @@ def _process(proc_data): | |
Dictionary representing the INI file. | ||
""" | ||
# remove quotation marks from beginning and end of values | ||
# and convert None to empty string | ||
for k, v in proc_data.items(): | ||
if isinstance(v, dict): | ||
for key, value in v.items(): | ||
v[key] = jc.utils.remove_quotes(value) | ||
value = _none_to_empty_string(value) | ||
value = jc.utils.remove_quotes(value) | ||
v[key] = value | ||
continue | ||
|
||
proc_data[k] = jc.utils.remove_quotes(v) | ||
v = _none_to_empty_string(v) | ||
v = jc.utils.remove_quotes(v) | ||
proc_data[k] = v | ||
|
||
return proc_data | ||
|
||
|
@@ -143,7 +144,6 @@ def parse(data, raw=False, quiet=False): | |
if jc.utils.has_data(data): | ||
|
||
ini_parser = configparser.ConfigParser( | ||
dict_type = MyDict, | ||
allow_no_value=True, | ||
interpolation=None, | ||
default_section=None, | ||
|
@@ -175,4 +175,3 @@ def parse(data, raw=False, quiet=False): | |
raw_output.update(temp_dict) | ||
|
||
return raw_output if raw else _process(raw_output) | ||
|
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 |
---|---|---|
|
@@ -44,6 +44,12 @@ | |
... | ||
} | ||
""" | ||
import sys | ||
|
||
# ugly hack because I accidentally shadowed the xml module from the | ||
# standard library with the xml parser. :( | ||
sys.path = [x for x in sys.path if 'jc/jc/parsers' not in x] | ||
|
||
from typing import Dict, Union | ||
import plistlib | ||
import binascii | ||
|
@@ -53,7 +59,7 @@ | |
|
||
class info(): | ||
"""Provides parser metadata (version, author, etc.)""" | ||
version = '1.1' | ||
version = '1.2' | ||
description = 'PLIST file parser' | ||
author = 'Kelly Brazil' | ||
author_email = '[email protected]' | ||
|
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
Oops, something went wrong.