Skip to content
Snippets Groups Projects
Commit b393d9ce0e77 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

Add script to order hgconf files

parent 443acb469510
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
import argparse
import configparser
import logging
MASTER_MODULE_LIST = '''
base_iban_streamline
base_res_users_streamline
board_alerts
external_job
irtweaks
partner_address
x_data_loader
web_sheet_full_width
web_sheet_full_width_selective
web_m2o_enhanced
web_m2x_options
document_attachment
advanced_filter
analytic_structure
l10n_eu_nace
partner_naf
crm_naf
crm_streamline
account_streamline
account_iban
account_credit_transfer
account_voucher_sepa
account_invoice_streamline
account_move_batch
account_move_batch_export
account_report_webkit
account_report_csv
account_streamline_damig
purchase_streamline
purchase_tracker
hr_expense_streamline
oemetasl
hr_streamline
portal_analytic_structure
account_asset_streamline
account_bank_reconciliation
account_move_reversal
fichesactions
event_streamline
hr_expense_event
auth_saml
oe_osrm
quotation_template_streamline
alternate_ledger
hr_holidays_streamline
report_py3o
email_template_streamline
hr_recruitment_streamline
sale_streamline
product_streamline
rrules
sale_affair
timesheet
calendar_fields
directory
account_chart_flat
customer_billing
purchase_ffepgv
report_webkit_ffepgv
hr_expense_ffepgv
account_invoice_ffepgv
account_formiris
account_invoice_formiris
account_report_formiris
elias
hr_expense_formiris
purchase_formiris
purchase_tracker_formiris
account_numergy
hr_expense_numergy
hr_holidays_numergy
hr_numergy
purchase_numergy
purchase_order_report_numergy
purchase_tracker_numergy
hr_recruitment_numergy
account_magency
report_webkit_magency
vco_dir
be_safe
vco_timesheet
project_dev
project_issue_streamline
marketing_campaign_tracker
xcg_login_page
crm_facilogi
sales_facilogi
partner_centrinffo
'''.split()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='count')
parser.add_argument('hgconf', help="hgconf to rewrite")
args = parser.parse_args()
if args.verbose == 1:
logging.basicConfig(level=logging.INFO)
if args.verbose and args.verbose > 1:
logging.basicConfig(level=logging.DEBUG)
logging.debug('Opening %s' % args.hgconf)
hgconf = configparser.ConfigParser()
hgconf.read(args.hgconf)
logging.debug(hgconf.sections())
# Stop if there is any unknown module
module_difference = set(hgconf.sections()) - set(MASTER_MODULE_LIST)
if module_difference:
logging.critical("Unknown module in master list: %s" % ", ".join(module_difference))
exit(1)
else:
logging.debug("No unknown module")
outconfig = configparser.ConfigParser()
# reorder sections
for module in MASTER_MODULE_LIST:
if module in hgconf.sections():
outconfig.add_section(module)
order = ['pulluri', 'layout', 'track']
for option in order:
if option in hgconf[module]:
outconfig[module][option] = hgconf[module][option]
for option in hgconf[module]:
if option not in order:
outconfig[module][option] = hgconf[module][option]
# Write result
with open(args.hgconf,'w') as outfile:
outconfig.write(outfile)
logging.info("Done")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment