3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 Script to generate https://wiki.documentfoundation.org/Development/DispatchCommands
18 def get_files_list(directory
, extension
):
21 dh
= os
.scandir(directory
)
24 array_items
+= get_files_list(entry
.path
, extension
)
26 if entry
.name
.endswith(extension
):
27 array_items
.append(entry
.path
)
32 def analyze_file(filename
, all_slots
):
33 with
open(filename
) as fh
:
35 if not line
.startswith('// Slot Nr. '):
39 slot_id
= tmp
[1].strip()
48 mode
= 'C' if 'CACHABLE' in line
else ' '
49 mode
+= 'U' if 'AUTOUPDATE' in line
else ' '
50 mode
+= 'M' if 'MENUCONFIG' in line
else ' '
51 mode
+= 'T' if 'TOOLBOXCONFIG' in line
else ' '
52 mode
+= 'A' if 'ACCELCONFIG' in line
else ' '
61 slot_name
= '.uno:' + tmp
[1]
63 print("Warning: expected \" in line '%s' from file %s" % (line
.strip(), filename
),
67 if slot_name
not in all_slots
:
68 all_slots
[slot_name
] = {'slot_id': slot_id
,
71 'slot_description': ''}
74 def analyze_xcu(filename
, all_slots
):
75 with
open(filename
) as fh
:
77 if '<node oor:name=".uno:' not in line
:
83 while '<value xml:lang="en-US">' not in line
:
87 print("Warning: couldn't find '<value xml:lang=\"en-US\">' line in %s" % filename
,
91 line
= line
.replace('<value xml:lang="en-US">', '')
92 line
= line
.replace('</value>', '').strip()
94 if slot_name
in all_slots
:
95 all_slots
[slot_name
]['slot_description'] = line
.replace('~', '')
99 modules
= ['basslots', 'scslots', 'sdgslots', 'sdslots', 'sfxslots', 'smslots', 'svxslots', 'swslots']
100 sdi_dir
= './workdir/SdiTarget'
102 xcu_dir
= 'officecfg/registry/data/org/openoffice/Office/UI'
106 parser
= argparse
.ArgumentParser()
107 parser
.add_argument('module', choices
=modules
)
108 args
= parser
.parse_args()
110 module_filename
= args
.module
+ sdi_ext
112 sdi_files
= get_files_list(sdi_dir
, sdi_ext
)
113 for sdi_file
in sdi_files
:
114 sdi_file_basename
= os
.path
.basename(sdi_file
)
115 if sdi_file_basename
== module_filename
:
116 analyze_file(sdi_file
, all_slots
)
118 xcu_files
= get_files_list(xcu_dir
, xcu_ext
)
119 for xcu_file
in xcu_files
:
120 analyze_xcu(xcu_file
, all_slots
)
122 for name
in sorted(all_slots
.keys()):
123 props
= all_slots
[name
]
124 print('|-\n| %s' % name
)
125 print('| %(slot_rid)s\n| %(slot_id)s\n| %(mode)s\n| %(slot_description)s' % props
)
129 if __name__
== '__main__':