Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created the amixer sget command parser - READY FOR REVIEW #616

Merged
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b3601bb
created the amixer first skeleton
Nov 21, 2024
6a02b3d
push testing and integrate this commit and branch with issue: #591
Nov 21, 2024
27ce3b2
#591 checks the input data with jc utils
Nov 22, 2024
37dc01f
created the data parser of the sget control of the amixer sget <contr…
AvocadoStyle Nov 24, 2024
f3261d3
test commit - just for tests
Nov 25, 2024
2475452
another test commit
Nov 25, 2024
ca62b6a
another test commit
AvocadoStyle Nov 25, 2024
9049805
created a dedicated pseudo algorithm for the amixer sget and tried va…
AvocadoStyle Nov 27, 2024
1002afc
orginized the docstring with general explanation about the tool and t…
AvocadoStyle Nov 27, 2024
d0b8d05
created raw implementation, but it's raw either or either.
AvocadoStyle Nov 27, 2024
2c9d6dc
orginized the content inside the amixer parser
AvocadoStyle Nov 28, 2024
9a4c055
removed endpoint name
AvocadoStyle Nov 28, 2024
b603286
added amixer to the jc parser in lib
AvocadoStyle Nov 28, 2024
f26d286
more explanations
AvocadoStyle Nov 28, 2024
85c9c8e
added tests for the amixer sget
AvocadoStyle Nov 28, 2024
3e39cdc
added tests for the amixer sget
AvocadoStyle Nov 28, 2024
d80d340
Merge branch 'dev' into feature/amixer-new-parser
kellyjonbrazil Nov 29, 2024
8f20ea4
fine versioning fix
AvocadoStyle Nov 29, 2024
8966600
created docstring+another explanations seperated.
AvocadoStyle Nov 29, 2024
1876e2d
created the amixer parser docu
AvocadoStyle Nov 29, 2024
6ae5ae5
Merge branch 'feature/amixer-new-parser' of github.com:AvocadoStyle/j…
AvocadoStyle Nov 29, 2024
58990f3
added the amixer in alphabet order to the json convert lib
AvocadoStyle Dec 3, 2024
241d1a1
Fix PEP 8: E302 violation as part of boy scout principle
AvocadoStyle Dec 3, 2024
99a3757
deleted not necessary file
AvocadoStyle Dec 4, 2024
a2ea7fc
fixed the spaces between sections in the amixer description
AvocadoStyle Dec 4, 2024
d14b273
resolved commits such as amixer module docstring and preperations for…
AvocadoStyle Dec 4, 2024
6741f19
Revert "Fix PEP 8: E302 violation as part of boy scout principle"
AvocadoStyle Dec 4, 2024
b45b1d6
created the dedicated _process for raw=False
AvocadoStyle Dec 4, 2024
ce338f6
created the dedicated _process for raw=False
AvocadoStyle Dec 4, 2024
4b098bc
added tests for the _process raw=False.
AvocadoStyle Dec 4, 2024
f0c710c
changed keys to be lowercase snake-case - Change 'dB' to 'db'
AvocadoStyle Dec 18, 2024
ccb9903
added more dB -> db changes and used int convertor of the jc utils
AvocadoStyle Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
created the amixer first skeleton
  • Loading branch information
EdenRafael committed Nov 22, 2024
commit b3601bb7757174782b7e824ac3d1e6d6e8d544f0
146 changes: 146 additions & 0 deletions jc/parsers/amixer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
from typing import List, Dict
AvocadoStyle marked this conversation as resolved.
Show resolved Hide resolved

import jc.utils


class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1'
AvocadoStyle marked this conversation as resolved.
Show resolved Hide resolved
description = '`amixer` command parser'
author = 'Eden Refael'
author_email = 'edenraf@hotmail.com'
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
magic_commands = ['amixer']
tags = ['command']


__version__ = info.version

def _process(proc_data: List[Dict]) -> List[Dict]:
"""
Final processing to conform to the schema.

Parameters:

proc_data: (List of Dictionaries) raw structured data to process

Returns:

List of Dictionaries. Structured data to conform to the schema:
"""
# int_list = {'expires'}
#
# # in BSD style, change name to null if it is a question mark
# for entry in proc_data:
# if 'name' in entry and entry['name'] == '?':
# entry['name'] = None
#
# for key in entry:
# if key in int_list:
# entry[key] = jc.utils.convert_to_int(entry[key])
#
# return proc_data


def parse(
data: str,
raw: bool = False,
quiet: bool = False
) -> List[Dict]:
"""
Main text parsing function

Parameters:

data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True

Returns:

List of Dictionaries. Raw or processed structured data.
"""
# jc.utils.compatibility(__name__, info.compatible, quiet)
# jc.utils.input_type_check(data)
#
# raw_output = []
# cleandata = list(filter(None, data.splitlines()))
#
# if jc.utils.has_data(data):
#
# # remove final Entries row if -v was used
# if cleandata[-1].startswith('Entries:'):
# cleandata.pop(-1)
#
# # detect if freebsd/osx style was used
# if cleandata[0][-1] == ']':
# for line in cleandata:
# splitline = line.split()
# output_line: Dict[str, Any] = {
# 'name': splitline[0],
# 'address': splitline[1].lstrip('(').rstrip(')'),
# 'hwtype': splitline[-1].lstrip('[').rstrip(']'),
# 'hwaddress': splitline[3],
# 'iface': splitline[5]
# }
#
# if 'permanent' in splitline:
# output_line['permanent'] = True
# else:
# output_line['permanent'] = False
#
# if 'expires' in splitline:
# output_line['expires'] = splitline[-3]
#
# raw_output.append(output_line)
#
# # detect if linux style was used
# elif cleandata[0].startswith('Address'):
#
# # fix header row to change Flags Mask to flags_mask
# cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
# cleandata[0] = cleandata[0].lower()
#
# raw_output = jc.parsers.universal.simple_table_parse(cleandata)
#
# # otherwise, try bsd style
# else:
# for line in cleandata:
# splitline = line.split()
#
# # Ignore AIX bucket information
# if 'bucket:' in splitline[0]:
# continue
# elif 'There' in splitline[0] and 'are' in splitline[1]:
# continue
#
# # AIX uses (incomplete)
# elif '<incomplete>' not in splitline and '(incomplete)' not in splitline:
# output_line = {
# 'name': splitline[0],
# 'address': splitline[1].lstrip('(').rstrip(')'),
# 'hwtype': splitline[4].lstrip('[').rstrip(']'),
# 'hwaddress': splitline[3],
# }
# # Handle permanence and ignore interface in AIX
# if 'permanent' in splitline:
# output_line['permanent'] = True
# elif 'in' not in splitline[6]: # AIX doesn't show interface
# output_line['iface'] = splitline[6]
#
# else:
# output_line = {
# 'name': splitline[0],
# 'address': splitline[1].lstrip('(').rstrip(')'),
# 'hwtype': None,
# 'hwaddress': None,
# }
# # AIX doesn't show interface
# if len(splitline) >= 5:
# output_line['iface'] = splitline[5]
#
# raw_output.append(output_line)
#
# return raw_output if raw else _process(raw_output)