Skip to content

Commit

Permalink
fix: address PR findings
Browse files Browse the repository at this point in the history
  • Loading branch information
joehacksalot committed Nov 25, 2024
1 parent 8a29890 commit c98957e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 9 additions & 9 deletions jc/parsers/net_localgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Usage (cli):
$ net localgroup | jc --net-localgroup
$ net localgroup /domain | jc --net-localgroup
$ net localgroup Administrators | jc --net-localgroup
$ net localgroup Administrators /domain | jc --net-localgroup
$ net localgroup | jc --net-localgroup -p
$ net localgroup /domain | jc --net-localgroup -p
$ net localgroup Administrators | jc --net-localgroup -p
$ net localgroup Administrators /domain | jc --net-localgroup -p
Usage (module):
import jc
result = jc.parse('net-localgroup', net_localgroup_command_output)
result = jc.parse('net_localgroup', net_localgroup_command_output)
Schema:
Expand Down Expand Up @@ -40,7 +40,7 @@
Examples:
$ net localgroup | jc --net-localgroup -p | jq
$ net localgroup | jc --net-localgroup -p
{
"account_origin": null,
"comment": null,
Expand All @@ -57,8 +57,8 @@
}
]
}
$ net localgroup Administrators | jc --net-localgroup -p | jq
$ net localgroup /domain | jc --net-localgroup -p | jq
$ net localgroup Administrators | jc --net-localgroup -p
$ net localgroup /domain | jc --net-localgroup -p
"""

Expand All @@ -74,7 +74,7 @@ class info():
author = 'joehacksalot'
author_email = 'joehacksalot@gmail.com'
compatible = ['windows']
magic_commands = ['net-localgroup']
magic_commands = ['net localgroup']
tags = ['command']


Expand Down
10 changes: 5 additions & 5 deletions jc/parsers/net_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Usage (module):
import jc
result = jc.parse('net-user', net_user_command_output)
result = jc.parse('net_user', net_user_command_output)
Schema:
Expand Down Expand Up @@ -51,7 +51,7 @@
Examples:
$ net users | jc --net-user -p | jq
$ net users | jc --net-user -p
{
"account_origin": "\\\\WIN-SERVER16",
"domain": "",
Expand Down Expand Up @@ -184,6 +184,7 @@
from datetime import datetime
import re
import jc.utils
from jc.exceptions import ParseError


class info():
Expand All @@ -193,7 +194,7 @@ class info():
author = 'joehacksalot'
author_email = 'joehacksalot@gmail.com'
compatible = ['windows']
magic_commands = ['net-user']
magic_commands = ['net user']
tags = ['command']


Expand Down Expand Up @@ -224,7 +225,7 @@ def parse(data, raw=False, quiet=False):
return raw_output if raw else _process(raw_output)
except Exception as e:
if not quiet:
jc.utils.warning_message(['Could not parse data due to unexpected format.'])
raise ParseError('Could not parse data due to unexpected format.')
return {}

def _set_if_not_none(output_dict, key, value):
Expand Down Expand Up @@ -430,7 +431,6 @@ def _parse(data):
for username in user_matches.groups():
if username:
username = username.strip()
print(username)
user_account = {"user_name": username}
result["user_accounts"].append(user_account)
except StopIteration:
Expand Down
9 changes: 5 additions & 4 deletions jc/parsers/route_print.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
r"""jc - JSON Convert `route-print` command output parser
r"""jc - JSON Convert `route print` command output parser
Usage (cli):
Expand All @@ -8,7 +8,7 @@
Usage (module):
import jc
result = jc.parse('route-print', route_print_command_output)
result = jc.parse('route_print', route_print_command_output)
Schema:
Expand Down Expand Up @@ -312,6 +312,7 @@

import re
import jc.utils
from jc.exceptions import ParseError


class info():
Expand All @@ -321,7 +322,7 @@ class info():
author = 'joehacksalot'
author_email = 'joehacksalot@gmail.com'
compatible = ['windows']
magic_commands = ['route-print']
magic_commands = ['route print']
tags = ['command']


Expand Down Expand Up @@ -352,7 +353,7 @@ def parse(data, raw=False, quiet=False):
return raw_output if raw else _process(raw_output)
except Exception as e:
if not quiet:
jc.utils.warning_message(['Could not parse data due to unexpected format.'])
raise ParseError('Could not parse data due to unexpected format.')
return {}

def _process(proc_data):
Expand Down

0 comments on commit c98957e

Please sign in to comment.