v1.0 final

This commit is contained in:
cjnaz
2020-03-30 23:05:06 -07:00
parent d84314ed1a
commit eb828b0f9d
2 changed files with 40 additions and 85 deletions
+14 -23
View File
@@ -9,21 +9,18 @@ If you want it to do other functions, grab the code and go for it.
## Usage
```
$ ./xbsjsonedit -h
usage: xbsjsonedit [-h] [--Print] [--Tags-Print] [--Tags-Count TAGS_COUNT]
[-V]
Infile
usage: xbsjsonedit [-h] [--print] [--tags TAGS] [--names] [-V] Infile
xBrowserSync json backup editor
positional arguments:
Infile json backup file
Infile json backup file.
optional arguments:
-h, --help show this help message and exit
--Print, -p Print bookmark hierarchy (redirect to less or a file)
--Tags-Print, -t Print tags list
--Tags-Count TAGS_COUNT, -c TAGS_COUNT
Filter Tags-List for min number of times a tag is used (defult 2). =0 prints only single use tags.
--print, -p Print bookmark hierarchy (redirect to less or a file).
--tags TAGS, -t TAGS Print tags list filtered by tags with a minimum <n> number of uses. n=0 prints only single use tags.
--names, -n Used with --tags to enable printing the titles/names for each tag.
-V, --version Return version number and exit.
```
@@ -69,35 +66,29 @@ Five modes are supported Listing/Deleting based on:
The Print function prints the full list of bookmarks in folder hierarchical form, listing the ID number and Title of each folder and bookmark. The `--Print` switch may be used for getting a good visual dump of the bookmarks in less or an editor for reference while using the interactive mode. The tags on each bookmark are listed as well.
The `--Tags-Print` switch prints bookmarks by tag name, where a minimum of 2 bookmarks share the same tag, as set by the `--Tags-Count` switch. Setting `--Tags-Count 1` prints all bookmarks with tags. Setting `--Tags-Count 0` prints all bookmarks with only one tag - useful for finding remnant tags.
The `--tags <n>` switch prints each tag where the number of bookmarks with that tag >= `<n>`. Optionally include the `--names` switch to list the bookmark titles/names for each tag. `--tags 0` is a special case that prints only tags that have exactly one occurrence, which may be useful for finding extraneous/remnant tags usage.
A lower case letter `t/g/d/f/x/y` will list the offenders, while an upper case letter
`T/G/D/F/X/Y` will allow for selective deletes of the offenders. The lower case List operation
need not be run before running the upper case Delete operation.
`T/G/D/F/X/Y` will allow for selective deletes of the offenders. The lower case List operation need not be run before running the upper case Delete operation.
Delete functions support individual bookmark selection, or all that match the selection mode.
You cannot do any damage to the original bookmark file during a session, so experiment and poke
around.
You cannot do any damage to the original bookmark file during a session, so experiment and poke around.
When deleting empty folders you may find that you need to repeat the operation a few times.
This happens when there are folders within folders that contain no bookmarks. The lower folder
must be deleted before the next higher folder is seen as empty. Just repeat the folder deletes
until the Matches count is 0.
This happens when there are folders within folders that contain no bookmarks. The lower folder must be deleted before the next higher folder is seen as empty. Just repeat the folder deletes until the Matches count is 0.
The output file defaults to the Infile + "_OUT", and can be specified during the write operation.
You may want to write out intermediate editing results to save work done up to that point.
The output format is "pretty printed" json for readability, and is accepted by the
xBrowserSync app Restore function via copy/paste. Note: xBrowserSync will allow you to restore
to (blast) your current
syncID, so you may want to Disable Sync, then create a new sync before restoring the modified bookmarks. **NOTE** that tags are not restored if sync is disabled. To recover, simply enable sync and do another restore.
The output file defaults to the Infile + "_OUT", and can be specified during the write operation. You may want to write out intermediate editing results to save work done up to that point. The output format is "pretty printed" json for readability, and is accepted by the xBrowserSync app Restore function via copy/paste.
- **Note** [_may no longer be the case_]: xBrowserSync will allow you to restore to (blast) your current syncID, so you may want to Disable Sync, then create a new sync before restoring the modified bookmarks.
- **NOTE** that tags are not restored by xBrowserSync if sync is disabled. To recover, simply enable sync and do another restore.
## Known issues:
- This code only works with Python 3. Development and testing was done on Linux with Python 3.7.3.
- This code only works with Python 3. Development and testing was done on Linux with Python 3.7.3. Limited testing was done on Windows with Python 3.8.0.
## Version history
- 200329 v1.0 Merged pull request #3 from mblais (add unbuffered getch input; add 'all' option), Reworked --tags and --names switches.
- 191206 v0.3 Added tags dump
- 191205 v0.2 Updated to xbrowsersync v1.5 and Python 3.x ONLY
- 181128 v0.1 New