From 32972d8fdbdc71923978fd5c2a87fd6cfa4b7f8e Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 2 Jan 2022 11:00:52 -0800 Subject: [PATCH] doc update --- CHANGELOG | 3 + README.md | 1 + docs/parsers/jar_manifest.md | 104 +++++++++++++++++++++++++++++++++++ jc/__init__.py | 2 +- jc/parsers/jar_manifest.py | 12 ++-- man/jc.1 | 7 ++- setup.py | 2 +- 7 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 docs/parsers/jar_manifest.md diff --git a/CHANGELOG b/CHANGELOG index 51883582..9697f207 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ jc changelog +20220102 v1.17.6 +- Add jar-manifest file parser (for MANIFEST.MF files) + 20211221 v1.17.5 - Add zipinfo parser tested on linux and macOS diff --git a/README.md b/README.md index 8f79e3ff..6a13d0bc 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--iostat-s` enables the `iostat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s)) - `--iptables` enables the `iptables` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables)) - `--iw-scan` enables the `iw dev [device] scan` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan)) +- `--jar-manifest` enables the MANIFEST.MF file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest)) - `--jobs` enables the `jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs)) - `--kv` enables the Key/Value file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/kv)) - `--last` enables the `last` and `lastb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/last)) diff --git a/docs/parsers/jar_manifest.md b/docs/parsers/jar_manifest.md new file mode 100644 index 00000000..3f4f181c --- /dev/null +++ b/docs/parsers/jar_manifest.md @@ -0,0 +1,104 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + +# jc.parsers.jar_manifest +jc - JSON CLI output utility `MANIFES.MF` file parser + +Usage (cli): + + $ cat MANIFEST.MF | jc --jar-manifest + +Usage (module): + + import jc.parsers.jar_manifest + result = jc.parsers.jar_manifest.parse(jar_manifest_file_output) + +Schema: + + [ + { + "key1": string, + "key2": string + } + ] + +Examples: + + $ cat MANIFEST.MF | jc --jar-manifest -p + $ unzip -c apache-log4j-2.16.0-bin/log4j-core-2.16.0.jar META-INF/MANIFEST.MF | jc --jar-manifest -p + $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar-manifest -p + + $ cat MANIFEST.MF | jc --jar-manifest -p + + [ + { + "Import_Package": "com.conversantmedia.util.concurrent;resolution:=optional,com.fasterxml.jackson.annotation;version="[2.12,3)";resolution:=optional,com.fasterxml.jackson.core;version="[2.12,3)";resolution:=optional,com.fasterxml.jackson.core.type;version="[2.12,3)";resolution:=optional,com.fasterxml.jackson.cor...", + "Export_Package": "org.apache.logging.log4j.core;uses:="org.apache.logging.log4j,org.apache.logging.log4j.core.config,org.apache.logging.log4j.core.impl,org.apache.logging.log4j.core.layout,org.apache.logging.log4j.core.time,org.apache.logging.log4j.message,org.apache.logging.log4j.spi,org.apache.logging.log4j.status...", + "Manifest_Version": "1.0", + "Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt", + "Bundle_SymbolicName": "org.apache.logging.log4j.core", + "Built_By": "matt", + "Bnd_LastModified": "1639373735804", + "Implementation_Vendor_Id": "org.apache.logging.log4j", + "Specification_Title": "Apache Log4j Core", + "Log4jReleaseManager": "Matt Sicker", + ... + } + ] + + $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar-manifest -p + + [ + ... + { + "Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-sources.jar", + "Manifest_Version": "1.0", + "Built_By": "matt", + "Created_By": "Apache Maven 3.8.4", + "Build_Jdk": "1.8.0_312" + }, + { + "Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-javadoc.jar", + "Manifest_Version": "1.0", + "Built_By": "matt", + "Created_By": "Apache Maven 3.8.4", + "Build_Jdk": "1.8.0_312" + }, + { + "Bundle_SymbolicName": "org.apache.logging.log4j.spring-cloud-config-client.logging.log4j.core.util;version="[2.16,3)",org.springframework.boot.autoconfigure.condition,org.springframework.cloud.context.environment,org.springframework.context,org.springframework.stereotype", + "Export_Package": "org.apache.logging.log4j.spring.cloud.config.controller;version="2.16.0"ient", + "Archive": "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-client-2.16.0.jar", + "Manifest_Version": "1.0", + "Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt", + ... + } + ... + ] + + +## info +```python +info() +``` +Provides parser metadata (version, author, etc.) + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of Dictionaries. Raw or processed structured data. + +## Parser Information +Compatibility: linux, darwin, cygwin, win32, aix, freebsd + +Version 0.01 by Matt J (https://github.com/listuser) diff --git a/jc/__init__.py b/jc/__init__.py index 6910bd63..8f56cd9c 100644 --- a/jc/__init__.py +++ b/jc/__init__.py @@ -73,4 +73,4 @@ Module Example: """ name = 'jc' -__version__ = '1.17.5' +__version__ = '1.17.6' diff --git a/jc/parsers/jar_manifest.py b/jc/parsers/jar_manifest.py index 7e8366c8..47bcc988 100644 --- a/jc/parsers/jar_manifest.py +++ b/jc/parsers/jar_manifest.py @@ -2,7 +2,7 @@ Usage (cli): - $ cat MANIFEST.MF | jc --jar_manifest + $ cat MANIFEST.MF | jc --jar-manifest Usage (module): @@ -20,11 +20,11 @@ Schema: Examples: - $ cat MANIFEST.MF | jc --jar_manifest -p - $ unzip -c apache-log4j-2.16.0-bin/log4j-core-2.16.0.jar META-INF/MANIFEST.MF | jc --jar_manifest -p - $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar_manifest -p + $ cat MANIFEST.MF | jc --jar-manifest -p + $ unzip -c apache-log4j-2.16.0-bin/log4j-core-2.16.0.jar META-INF/MANIFEST.MF | jc --jar-manifest -p + $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar-manifest -p - $ cat MANIFEST.MF | jc --jar_manifest -p + $ cat MANIFEST.MF | jc --jar-manifest -p [ { @@ -42,7 +42,7 @@ Examples: } ] - $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar_manifest -p + $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | jc --jar-manifest -p [ ... diff --git a/man/jc.1 b/man/jc.1 index 64043b63..2c68c95a 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2021-12-23 1.17.5 "JSON CLI output utility" +.TH jc 1 2022-01-02 1.17.6 "JSON CLI output utility" .SH NAME jc \- JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -197,6 +197,11 @@ INI file parser \fB--iw-scan\fP `iw dev [device] scan` command parser +.TP +.B +\fB--jar-manifest\fP +MANIFEST.MF file parser + .TP .B \fB--jobs\fP diff --git a/setup.py b/setup.py index 3fe39996..f612e16e 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open('README.md', 'r') as f: setuptools.setup( name='jc', - version='1.17.5', + version='1.17.6', author='Kelly Brazil', author_email='kellyjonbrazil@gmail.com', description='Converts the output of popular command-line tools and file-types to JSON.',