Import folder names in lowercase. Document.

This commit is contained in:
Arun Prakash Jana 2017-04-06 07:01:27 +05:30
parent c48be129ee
commit f1a5cd4b88
No known key found for this signature in database
GPG Key ID: A75979F35C080412
3 changed files with 17 additions and 13 deletions

View File

@ -243,6 +243,7 @@ SYMBOLS:
- Bookmarks with immutable titles are listed with bold `(L)` after the URL. - Bookmarks with immutable titles are listed with bold `(L)` after the URL.
- **Tags**: - **Tags**:
- Comma (`,`) is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags are stored in lower case and can be replaced, appended or deleted. - Comma (`,`) is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags are stored in lower case and can be replaced, appended or deleted.
- Folder names are converted to all-lowercase tags during bookmarks html import.
- Releases prior to [v2.7](https://github.com/jarun/Buku/releases/tag/v2.7) support both capital and lower cases in tags. From v2.7 all tags are stored in lowercase. An undocumented option `--fixtags` is introduced to modify the older tags. It also fixes another issue where the same tag appears multiple times in the tagset of a record. Run `buku --fixtags` once. - Releases prior to [v2.7](https://github.com/jarun/Buku/releases/tag/v2.7) support both capital and lower cases in tags. From v2.7 all tags are stored in lowercase. An undocumented option `--fixtags` is introduced to modify the older tags. It also fixes another issue where the same tag appears multiple times in the tagset of a record. Run `buku --fixtags` once.
- **Update** operation: - **Update** operation:
- If --title, --tag or --comment is passed without argument, clear the corresponding field from DB. - If --title, --tag or --comment is passed without argument, clear the corresponding field from DB.

1
buku.1
View File

@ -42,6 +42,7 @@ Bookmarks with immutable titles are listed with bold '(L)' after the URL.
.IP 5. 4 .IP 5. 4
\fBTags\fR: \fBTags\fR:
- Comma (',') is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags are stored in lower case and can be replaced, appended or deleted. - Comma (',') is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags are stored in lower case and can be replaced, appended or deleted.
- Folder names are converted to all-lowercase tags during bookmarks html import.
- Releases prior to v2.7 support both capital and lower cases in tags. From v2.7 all tags are stored in lowercase. An undocumented option --\fIfixtags\fR is introduced to modify the older tags. It also fixes another issue where the same tag appears multiple times in the tagset of a record. Run \fBbuku --fixtags\fR once. - Releases prior to v2.7 support both capital and lower cases in tags. From v2.7 all tags are stored in lowercase. An undocumented option --\fIfixtags\fR is introduced to modify the older tags. It also fixes another issue where the same tag appears multiple times in the tagset of a record. Run \fBbuku --fixtags\fR once.
.PP .PP
.IP 6. 4 .IP 6. 4

28
buku.py
View File

@ -371,7 +371,7 @@ class BukuDb:
return os.path.abspath('.') return os.path.abspath('.')
else: else:
data_home = os.path.join(os.environ.get('HOME'), data_home = os.path.join(os.environ.get('HOME'),
'.local', 'share') '.local', 'share')
return os.path.join(data_home, 'buku') return os.path.join(data_home, 'buku')
@ -1491,21 +1491,23 @@ class BukuDb:
except Exception as e: except Exception as e:
logerr(e) logerr(e)
return False return False
html_tags = soup.findAll('a') html_tags = soup.findAll('a')
resp = input('Add imported folders names as tags? (y/n): ') resp = input('Add imported folders names as tags? (y/n): ')
if resp == 'y' : if resp == 'y':
for tag in html_tags : for tag in html_tags:
possible_folder = tag.find_previous('h3') # could be its folder or not # could be its folder or not
tag_list = tag.parent.parent.find_parent('dl') # get list of tags within that folder possible_folder = tag.find_previous('h3')
# get list of tags within that folder
if (possible_folder) and possible_folder.parent in list(tag_list.parents): tag_list = tag.parent.parent.find_parent('dl')
if ((possible_folder) and
possible_folder.parent in list(tag_list.parents)):
# then it's the folder of this bookmark # then it's the folder of this bookmark
if tag.has_attr('tags') : if tag.has_attr('tags'):
tag['tags'] += (DELIMITER + possible_folder.text) tag['tags'] += (DELIM + possible_folder.text)
else : else:
tag['tags'] = possible_folder.text tag['tags'] = possible_folder.text
for tag in html_tags: for tag in html_tags:
@ -1515,7 +1517,7 @@ class BukuDb:
if comment_tag: if comment_tag:
desc = comment_tag.text[0:comment_tag.text.find('\n')] desc = comment_tag.text[0:comment_tag.text.find('\n')]
self.add_rec(tag['href'], tag.string, delim_wrap(tag['tags']) self.add_rec(tag['href'], tag.string, parse_tags([tag['tags']])
if tag.has_attr('tags') else None, desc, 0, True) if tag.has_attr('tags') else None, desc, 0, True)
self.conn.commit() self.conn.commit()