aboutsummaryrefslogtreecommitdiff
path: root/pip-bins/odfuserfield
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-03-19 15:05:32 +0100
committerLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-03-19 15:05:32 +0100
commitb1844d805a8f190af00faf3f6e5bed7d997ecaae (patch)
treed6296ba5e85034836e203a542d2ad34a9e5c5b32 /pip-bins/odfuserfield
parentc74163f1ecbd809c83bb465ee89fa04369a89972 (diff)
downloadbin-b1844d805a8f190af00faf3f6e5bed7d997ecaae.tar.gz
bin-b1844d805a8f190af00faf3f6e5bed7d997ecaae.zip
created sorter for sorting downloads with custom rules; created straper for recreation of server
Diffstat (limited to 'pip-bins/odfuserfield')
-rwxr-xr-xpip-bins/odfuserfield101
1 files changed, 101 insertions, 0 deletions
diff --git a/pip-bins/odfuserfield b/pip-bins/odfuserfield
new file mode 100755
index 0000000..cae1574
--- /dev/null
+++ b/pip-bins/odfuserfield
@@ -0,0 +1,101 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
+#
+# This is free software. You may redistribute it under the terms
+# of the Apache license and the GNU General Public License Version
+# 2 or at your option any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Contributor(s): Michael Howitz, gocept gmbh & co. kg
+
+import sys
+import getopt
+
+import odf.userfield
+
+if sys.version_info[0]==3: unicode=str
+
+listfields = False
+Listfields = False
+xfields = []
+Xfields = []
+setfields = {}
+outputfile = None
+inputfile = None
+
+
+def exitwithusage(exitcode=2):
+ """ print out usage information """
+ sys.stderr.write("Usage: %s [-lL] [-xX metafield] [-s metafield:value]... "
+ "[-o output] [inputfile]\n" % sys.argv[0])
+ sys.stderr.write("\tInputfile must be OpenDocument format\n")
+ sys.exit(exitcode)
+
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "lLs:o:x:X:")
+except getopt.GetoptError:
+ exitwithusage()
+
+if len(opts) == 0:
+ exitwithusage()
+
+for o, a in opts:
+ if o == '-s':
+ if a.find(":") >= 0:
+ k,v = a.split(":",1)
+ else:
+ k,v = (a, "")
+ if len(k) == 0:
+ exitwithusage()
+ setfields[unicode(k)] = unicode(v)
+ if o == '-l':
+ listfields = True
+ Listfields = False
+ if o == '-L':
+ Listfields = True
+ listfields = False
+ if o == "-x":
+ xfields.append(unicode(a))
+ if o == "-X":
+ Xfields.append(unicode(a))
+ if o == "-o":
+ outputfile = unicode(a)
+
+if len(args) != 0:
+ inputfile = unicode(args[0])
+
+user_fields = odf.userfield.UserFields(inputfile, outputfile)
+
+if xfields:
+ for value in user_fields.list_values(xfields):
+ print (value)
+
+if Listfields or Xfields:
+ if Listfields:
+ Xfields = None
+ for field_name, value_type, value in user_fields.list_fields_and_values(
+ Xfields):
+ print ("%s#%s:%s" % (field_name, value_type, value))
+
+if listfields:
+ for value in user_fields.list_fields():
+ print (value)
+
+if setfields:
+ user_fields.update(setfields)
+
+
+
+# Local Variables: ***
+# mode: python ***
+# End: ***