From 7ee1e34fc71c0dbc08ba482b787d560fd5125f64 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 14 Feb 2022 10:03:52 -0800 Subject: [PATCH] doc update --- docs/parsers/xrandr.md | 60 ++++++++++++++++++++++++++++++++++++++++-- jc/parsers/xrandr.py | 60 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 116 insertions(+), 4 deletions(-) diff --git a/docs/parsers/xrandr.md b/docs/parsers/xrandr.md index 0f87ebc6..40ebff74 100644 --- a/docs/parsers/xrandr.md +++ b/docs/parsers/xrandr.md @@ -83,13 +83,69 @@ Schema: Examples: $ xrandr | jc --xrandr + { + "screens": [ + { + "screen_number": 0, + "minimum_width": 8, + "minimum_height": 8, + "current_width": 1920, + "current_height": 1080, + "maximum_width": 32767, + "maximum_height": 32767, + "associated_device": { + "associated_modes": [ + { + "resolution_width": 1920, + "resolution_height": 1080, + "is_high_resolution": false, + "frequencies": [ + { + "frequency": 60.03, + "is_current": true, + "is_preferred": true + }, + { + "frequency": 59.93, + "is_current": false, + "is_preferred": false + } + ] + }, + { + "resolution_width": 1680, + "resolution_height": 1050, + "is_high_resolution": false, + "frequencies": [ + { + "frequency": 59.88, + "is_current": false, + "is_preferred": false + } + ] + } + ], + "is_connected": true, + "is_primary": true, + "device_name": "eDP1", + "resolution_width": 1920, + "resolution_height": 1080, + "offset_width": 0, + "offset_height": 0, + "dimension_width": 310, + "dimension_height": 170 + } + } + ], + "unassociated_devices": [] + } ### parse ```python -def parse(data: str, raw: bool = False, quiet: bool = False) +def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict ``` Main text parsing function @@ -102,7 +158,7 @@ Parameters: Returns: - List of Dictionaries. Raw or processed structured data. + Dictionary. Raw or processed structured data. ### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/jc/parsers/xrandr.py b/jc/parsers/xrandr.py index 5ec6f79e..c2b0a8d2 100644 --- a/jc/parsers/xrandr.py +++ b/jc/parsers/xrandr.py @@ -78,6 +78,62 @@ Schema: Examples: $ xrandr | jc --xrandr + { + "screens": [ + { + "screen_number": 0, + "minimum_width": 8, + "minimum_height": 8, + "current_width": 1920, + "current_height": 1080, + "maximum_width": 32767, + "maximum_height": 32767, + "associated_device": { + "associated_modes": [ + { + "resolution_width": 1920, + "resolution_height": 1080, + "is_high_resolution": false, + "frequencies": [ + { + "frequency": 60.03, + "is_current": true, + "is_preferred": true + }, + { + "frequency": 59.93, + "is_current": false, + "is_preferred": false + } + ] + }, + { + "resolution_width": 1680, + "resolution_height": 1050, + "is_high_resolution": false, + "frequencies": [ + { + "frequency": 59.88, + "is_current": false, + "is_preferred": false + } + ] + } + ], + "is_connected": true, + "is_primary": true, + "device_name": "eDP1", + "resolution_width": 1920, + "resolution_height": 1080, + "offset_width": 0, + "offset_height": 0, + "dimension_width": 310, + "dimension_height": 170 + } + } + ], + "unassociated_devices": [] + } """ import re from typing import Dict, List, Optional, Union @@ -287,7 +343,7 @@ def _parse_mode(line: str) -> Optional[Mode]: return mode -def parse(data: str, raw: bool =False, quiet: bool =False): +def parse(data: str, raw: bool =False, quiet: bool =False) -> Dict: """ Main text parsing function @@ -299,7 +355,7 @@ def parse(data: str, raw: bool =False, quiet: bool =False): Returns: - List of Dictionaries. Raw or processed structured data. + Dictionary. Raw or processed structured data. """ jc.utils.compatibility(__name__, info.compatible, quiet) jc.utils.input_type_check(data)