Browse Source

tagtool: bugfixes and related changes (#982)

pull/989/head
jzarl 2 years ago
committed by FSFE System
parent
commit
51e4f8e47c
15 changed files with 37 additions and 24 deletions
  1. +1
    -1
      events/2011/event-20110920-01.en.xml
  2. +1
    -1
      events/2019/event-20190408-02.en.xml
  3. +1
    -1
      news/2015/news-20151013-01.es.xhtml
  4. +1
    -1
      news/2015/news-20151030-01.de.xml
  5. +1
    -1
      news/2015/news-20151030-01.el.xml
  6. +1
    -1
      news/2015/news-20151030-01.en.xml
  7. +1
    -1
      news/2015/news-20151030-01.sq.xml
  8. +1
    -1
      news/2016/news-20161110-01.es.xhtml
  9. +1
    -1
      news/2017/news-20170726-01.cs.xhtml
  10. +1
    -1
      news/2017/news-20170726-01.de.xhtml
  11. +1
    -1
      news/2017/news-20170726-01.en.xhtml
  12. +1
    -1
      news/2017/news-20170726-01.fr.xhtml
  13. +1
    -1
      news/2017/news-20170726-01.nl.xhtml
  14. +1
    -1
      news/2017/news-20171108-01.nl.xhtml
  15. +23
    -10
      tools/tagtool/tagtool.sh

+ 1
- 1
events/2011/event-20110920-01.en.xml View File

@ -12,7 +12,7 @@
<tag>front-page</tag>
<tag>freedom-box</tag>
<tag>manchester-free-software</tag>
</tags>
</event>
</eventset>

+ 1
- 1
events/2019/event-20190408-02.en.xml View File

@ -12,7 +12,7 @@
<tags>
<tag content="Spain">ES</tag>
<tag>talk</tag>
<tag>panel</tag>
<tag>front-page</tag>
</tags>


+ 1
- 1
news/2015/news-20151013-01.es.xhtml View File

@ -79,7 +79,7 @@ las páginas webs gubernamentales.</p>
<tags>
<tag>front-page</tag>
<tag content="Public Administration">AdministraciónPública</tag>
<tag content="PDFreaders">pdfreaders</tag>
<tag content="Campaign">campaigns</tag>
</tags>


+ 1
- 1
news/2015/news-20151030-01.de.xml View File

@ -19,7 +19,7 @@
<tag>front-page</tag>
<tag content="Schweiz">ch</tag>
<tag content="Libreboot">Libreboot</tag>
<tag content="Laptop">Laptop</tag>
</tags>
</news>
</newsset>


+ 1
- 1
news/2015/news-20151030-01.el.xml View File

@ -24,7 +24,7 @@
<tag>front-page</tag>
<tag content="Schweiz">ch</tag>
<tag content="Libreboot">Libreboot</tag>
<tag content="Laptop">Laptop</tag>
</tags>
</news>
</newsset>


+ 1
- 1
news/2015/news-20151030-01.en.xml View File

@ -19,7 +19,7 @@
<tag>front-page</tag>
<tag content="Schweiz">ch</tag>
<tag content="Libreboot">Libreboot</tag>
<tag content="Laptop">Laptop</tag>
</tags>
</news>
</newsset>


+ 1
- 1
news/2015/news-20151030-01.sq.xml View File

@ -20,7 +20,7 @@ më ekologjik të hardware-it.</p>
<tag>front-page</tag>
<tag content="Zvicër">ch</tag>
<tag content="Libreboot">Libreboot</tag>
<tag content="Laptop">Laptop</tag>
</tags>
</news>
</newsset>

+ 1
- 1
news/2016/news-20161110-01.es.xhtml View File

@ -45,6 +45,6 @@ Los legisladores han redactado <a href="http://asozd2.duma.gov.ru/addwork/scans.
<tags>
<tag>pagina inicial</tag>
<tag>policy</tag>
<tag>Adquisición</tag>
<translator>Eulalio Barbero</translator></tags>
</html>

+ 1
- 1
news/2017/news-20170726-01.cs.xhtml View File

@ -29,6 +29,6 @@ Jsou perfektní jako dárek pro vaši rodinu, přátele nebo kolegy - a to musí
<tag>front-page</tag>
<tag content="merchandise">merchandise</tag>
<tag content="baby bib">baby bib</tag>
<tag content="pink">pink</tag>
</tags>
</html>

+ 1
- 1
news/2017/news-20170726-01.de.xhtml View File

@ -22,7 +22,7 @@
<tag>front-page</tag>
<tag content="merchandise">merchandise</tag>
<tag content="baby bib">baby bib</tag>
<tag content="pink">pink</tag>
</tags>
</html>

+ 1
- 1
news/2017/news-20170726-01.en.xhtml View File

@ -22,7 +22,7 @@
<tag>front-page</tag>
<tag content="merchandise">merchandise</tag>
<tag content="baby bib">baby bib</tag>
<tag content="pink">pink</tag>
</tags>
</html>

+ 1
- 1
news/2017/news-20170726-01.fr.xhtml View File

@ -32,7 +32,7 @@
<tag>front-page</tag>
<tag content="merchandise">merchandise</tag>
<tag content="baby bib">baby bib</tag>
<tag content="pink">pink</tag>
</tags>
<translator> nebi </translator>
</html>

+ 1
- 1
news/2017/news-20170726-01.nl.xhtml View File

@ -22,7 +22,7 @@
<tag>front-page</tag>
<tag content="fan-artikelen">merchandise</tag>
<tag content="slabbetje">baby bib</tag>
<tag content="roze">pink</tag>
</tags>
<translator>André Ockers</translator>
</html>

+ 1
- 1
news/2017/news-20171108-01.nl.xhtml View File

@ -58,7 +58,7 @@ vinden op: <a href="https://reuse.software/">https://reuse.software</a>.
<tag>reuse</tag>
<tag>developertools</tag>
<tag>herziening</tag>
</tags>
<author id="oberg" />


+ 23
- 10
tools/tagtool/tagtool.sh View File

@ -21,6 +21,17 @@ LANGUAGE=
NO_ACT=0
VERBOSE=0
log()
# log LVL MESSAGE
{
local min_lvl="$1"
shift
if [[ VERBOSE -ge min_lvl ]]
then
echo "$@" >&2
fi
}
print_help()
{
cat <<EOF >&2
@ -28,7 +39,7 @@ Usage: tagstool OPTIONS -b|--bulk-process TAGSDATAFILE
tagstool OPTIONS --find-tags TAG..
tagstool OPTIONS --remove-empty-labels
tagstool OPTIONS --remove-tags TAG..
tagstool OPTIONS --remove-tags OLD NEW
tagstool OPTIONS --rename-tags OLD NEW
tagstool OPTIONS --set-label LABEL [--force] TAG
Transform tag data by bulk.
@ -47,12 +58,12 @@ Actions (only one action per invocation):
Available transformations:
- rm: delete tag
- mv:newtag: move the tag to a newtag
--find-tags List all files containing the given tags.
--find-tags TAG.. List all files containing the given tags.
If a non-empty language is given, the output is
limited to that language.
--remove-empty-labels Remove empty content attribute for tags.
Not affected by --language option.
--remove-tags TAGS.. Remove the given tags.
--remove-tags TAG.. Remove the given tags.
--rename-tag OLD NEW Rename the OLD tag to NEW tag in all files.
--set-label LABEL Set the given label on all given tag.
The tag is given as positional parameter.
@ -69,10 +80,7 @@ performAction()
# If VERBOSE is set, also print the command.
# Please use this for all actions that perform a change on the data!
{
if [[ VERBOSE -eq 1 ]]
then
echo "${@@Q}" >&2
fi
log 1 "${@@Q}"
if [[ NO_ACT -eq 1 ]]
then
echo "NOT calling $1..." >&2
@ -119,6 +127,7 @@ renameTag()
do
if ! fileIsLanguage "$f" "$LANGUAGE"
then
log 2 "Ignoring file (language filter): $f"
continue
fi
echo " $f" >&2
@ -138,14 +147,15 @@ removeTag()
{
local tagId="$1"
echo "Deleting tag $tagId..." >&2
for f in $(findTaggedFiles "$oldTagId")
for f in $(findTaggedFiles "$tagId")
do
if ! fileIsLanguage "$f" "$LANGUAGE"
then
log 2 "Ignoring file (language filter): $f"
continue
fi
echo " $f" >&2
if ! performAction sed -E -i "s;\W*<tag\W*content=\"[^\"]*\"\W*>\W*$TagId\W*</tag>\W*;;i" "$f"
if ! performAction sed -E -i "s;\W*<tag\W*(content=\"[^\"]*\"\W*)?>\W*$tagId\W*</tag>\W*;;i" "$f"
then
echo "ERROR!" >&2
return 1
@ -171,6 +181,7 @@ setTagLabel()
# language is not empty
if ! fileIsLanguage "$f" "$LANGUAGE"
then
log 2 "Ignoring file (language filter): $f"
continue
fi
echo " $f" >&2
@ -248,6 +259,8 @@ action_findTags()
if fileIsLanguage "$f" "$LANGUAGE"
then
echo "$f"
else
log 2 "Ignoring file (language filter): $f"
fi
done
done | sort -u
@ -327,7 +340,7 @@ while true ; do
--remove-tags) ACTION=action_removeTags ; shift ;;
--rename-tag) ACTION=action_renameTag ; shift ;;
--set-label) ACTION=action_setLabel ; LABEL="$2" ; shift 2 ;;
-v|--verbose) VERBOSE=1 ; shift ;;
-v|--verbose) let VERBOSE++ ; shift ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac


Loading…
Cancel
Save