Commit 2c6ba47c authored by Jérome Perrin's avatar Jérome Perrin

master: use print as a function

parent 84dd197b
...@@ -58,9 +58,9 @@ for group, reverse_security_uid_dict in reverse_group_security_uid_dict.iteritem ...@@ -58,9 +58,9 @@ for group, reverse_security_uid_dict in reverse_group_security_uid_dict.iteritem
used_security_uid_set = used_group_security_uid_dict[group] used_security_uid_set = used_group_security_uid_dict[group]
unused_security_uid_set = set(reverse_security_uid_dict).difference(used_security_uid_set) unused_security_uid_set = set(reverse_security_uid_dict).difference(used_security_uid_set)
if unused_security_uid_set: if unused_security_uid_set:
print '# Will delete', len(unused_security_uid_set), 'security_uids in group', repr(group) print('# Will delete', len(unused_security_uid_set), 'security_uids in group', repr(group))
for unused_security_uid in unused_security_uid_set: for unused_security_uid in unused_security_uid_set:
print ' * ', unused_security_uid, reverse_security_uid_dict[unused_security_uid] print(' * ', unused_security_uid, reverse_security_uid_dict[unused_security_uid])
delitem((group, reverse_security_uid_dict[unused_security_uid])) delitem((group, reverse_security_uid_dict[unused_security_uid]))
portal.z_delete_security_uid_set_from_roles_and_users(uid=unused_security_uid) portal.z_delete_security_uid_set_from_roles_and_users(uid=unused_security_uid)
...@@ -68,25 +68,25 @@ for group, reverse_security_uid_dict in reverse_group_security_uid_dict.iteritem ...@@ -68,25 +68,25 @@ for group, reverse_security_uid_dict in reverse_group_security_uid_dict.iteritem
cataloged_security_uid_set = set([x.uid for x in portal.z_get_uid_group_from_roles_and_users()]) cataloged_security_uid_set = set([x.uid for x in portal.z_get_uid_group_from_roles_and_users()])
existing_security_uid_set = set(dict(security_uid_dict).values()) existing_security_uid_set = set(dict(security_uid_dict).values())
print '# Catalog secuirity_uid count', len(cataloged_security_uid_set) print('# Catalog secuirity_uid count', len(cataloged_security_uid_set))
print '# ZODB secuirity_uid count', len(existing_security_uid_set) print('# ZODB secuirity_uid count', len(existing_security_uid_set))
not_existing_security_uid_set = existing_security_uid_set.difference(cataloged_security_uid_set) not_existing_security_uid_set = existing_security_uid_set.difference(cataloged_security_uid_set)
print '# Not catalogued', len(not_existing_security_uid_set), 'security_uid' print('# Not catalogued', len(not_existing_security_uid_set), 'security_uid')
for security_uid in not_existing_security_uid_set: for security_uid in not_existing_security_uid_set:
print ' * ', security_uid, reverse_groupless_security_uid_dict[security_uid] print(' * ', security_uid, reverse_groupless_security_uid_dict[security_uid])
not_existing_security_uid_set = cataloged_security_uid_set.difference(existing_security_uid_set) not_existing_security_uid_set = cataloged_security_uid_set.difference(existing_security_uid_set)
if not_existing_security_uid_set: if not_existing_security_uid_set:
print '# Will uncatalog', len(not_existing_security_uid_set), 'security_uid' print('# Will uncatalog', len(not_existing_security_uid_set), 'security_uid')
print ' * like: ', list(not_existing_security_uid_set)[:10] print(' * like: ', list(not_existing_security_uid_set)[:10])
for security_uid in not_existing_security_uid_set: for security_uid in not_existing_security_uid_set:
assert security_uid not in reverse_groupless_security_uid_dict assert security_uid not in reverse_groupless_security_uid_dict
portal.z_delete_security_uid_set_from_roles_and_users(security_uid=security_uid) portal.z_delete_security_uid_set_from_roles_and_users(security_uid=security_uid)
if 0: if 0:
print 'DRY' print('DRY')
context.REQUEST.RESPONSE.write(printed) context.REQUEST.RESPONSE.write(printed)
raise Exception('dry') raise Exception('dry')
return printed return printed
...@@ -28,7 +28,7 @@ for document in portal.web_page_module.searchFolder( ...@@ -28,7 +28,7 @@ for document in portal.web_page_module.searchFolder(
break break
if print_web_content: if print_web_content:
print getWebContentHash(document) print(getWebContentHash(document))
container.REQUEST.RESPONSE.setHeader('content-type', 'text/plain') container.REQUEST.RESPONSE.setHeader('content-type', 'text/plain')
return '\n'.join(sorted(printed.splitlines())) return '\n'.join(sorted(printed.splitlines()))
...@@ -22,10 +22,10 @@ for user_id in sorted(user_id_list): ...@@ -22,10 +22,10 @@ for user_id in sorted(user_id_list):
info_list.append(info) info_list.append(info)
print ','.join(['user_id', 'group_count',] + [x[1] for x in print(','.join(['user_id', 'group_count',] + [x[1] for x in
uid_groups_columns_items]) uid_groups_columns_items]))
for info in info_list: for info in info_list:
print ','.join([str(x) for x in info]) print(','.join([str(x) for x in info]))
response = portal.REQUEST.RESPONSE response = portal.REQUEST.RESPONSE
response.setHeader('Content-Disposition', 'attachement;filename=%s-%s.csv' % response.setHeader('Content-Disposition', 'attachement;filename=%s-%s.csv' %
(script.getId(), DateTime().strftime('%Y%m%d'))) (script.getId(), DateTime().strftime('%Y%m%d')))
......
...@@ -4,7 +4,7 @@ portal = context.getPortalObject() ...@@ -4,7 +4,7 @@ portal = context.getPortalObject()
for portal_type in ("Access Token Module" ,"Account Module" ,"Account" ,"Accounting Period" ,"Accounting Transaction Module" ,"Accounting Transaction" ,"Acknowledgement" ,"Assignment" ,"Balance Transaction" ,"Bank Account" ,"Compute Node", "Compute Partition", "Business Process Module" ,"Business Process" ,"Campaign Module" ,"Campaign" ,"Cash Register" ,"Cloud Contract Module" ,"Cloud Contract" ,"Component Module" ,"Component" ,"Computer Consumption TioXML File" ,"Computer Model Module" ,"Computer Model" ,"Compute Node Module" ,"Computer Network Module" ,"Computer Network" ,"Consumption Document Module" ,"Contribution Tool" ,"Credential Update Module" ,"Credit Card" ,"Currency Module" ,"Currency" ,"Data Set Module" ,"Data Set" ,"Document Ingestion Module" ,"Document Module" ,"Drawing" ,"Event Module" ,"Fax Message" ,"File" ,"Gadget Tool" ,"Gadget" ,"Instance Tree Module" ,"Instance Tree" ,"Image Module" ,"Image" ,"Integration Site" ,"Integration Tool" ,"Inventory Module" ,"Inventory" ,"Knowledge Box" ,"Knowledge Pad Module" ,"Knowledge Pad" ,"Letter" ,"Mail Message" ,"Meeting Module" ,"Meeting" ,"Note" ,"Notification Message Module" ,"Notification Message" ,"One Time Restricted Access Token" ,"Open Sale Order Module" ,"Open Sale Order" ,"Organisation Module" ,"Organisation" ,"PDF" ,"Payment Transaction" ,"Payzen Event" ,"Person Module" ,"Person" ,"Phone Call" ,"Presentation" ,"Product Module" ,"Product" ,"Project Module" ,"Project" ,"Purchase Invoice Transaction" ,"Purchase Order Module" ,"Purchase Order" ,"Purchase Trade Condition Module" ,"Purchase Trade Condition" ,"Query Module" ,"Query" ,"Regularisation Request Module" ,"Regularisation Request" ,"Restricted Access Token" ,"Sale Invoice Transaction" ,"Sale Opportunity Module" ,"Sale Opportunity" ,"Sale Order Module" ,"Sale Order" ,"Sale Packing List Module" ,"Sale Trade Condition Module" ,"Sale Trade Condition" ,"Service Module" ,"Service" ,"Short Message" ,"Site Message" ,"Slave Instance" ,"Software Installation Module" ,"Software Installation" ,"Software Instance Module" ,"Software Instance" ,"Software Product Module" ,"Software Product" ,"Software Release Module" ,"Software Release" ,"Spreadsheet" ,"Support Request Module" ,"Support Request" ,"System Event Module" ,"Text" ,"Transformation Module" ,"Transformation" ,"Upgrade Decision Module" ,"Upgrade Decision" ,"User Consumption HTML File" ,"Visit" ,"Web Message" ,"Web Page Module" ,"Web Page"): for portal_type in ("Access Token Module" ,"Account Module" ,"Account" ,"Accounting Period" ,"Accounting Transaction Module" ,"Accounting Transaction" ,"Acknowledgement" ,"Assignment" ,"Balance Transaction" ,"Bank Account" ,"Compute Node", "Compute Partition", "Business Process Module" ,"Business Process" ,"Campaign Module" ,"Campaign" ,"Cash Register" ,"Cloud Contract Module" ,"Cloud Contract" ,"Component Module" ,"Component" ,"Computer Consumption TioXML File" ,"Computer Model Module" ,"Computer Model" ,"Compute Node Module" ,"Computer Network Module" ,"Computer Network" ,"Consumption Document Module" ,"Contribution Tool" ,"Credential Update Module" ,"Credit Card" ,"Currency Module" ,"Currency" ,"Data Set Module" ,"Data Set" ,"Document Ingestion Module" ,"Document Module" ,"Drawing" ,"Event Module" ,"Fax Message" ,"File" ,"Gadget Tool" ,"Gadget" ,"Instance Tree Module" ,"Instance Tree" ,"Image Module" ,"Image" ,"Integration Site" ,"Integration Tool" ,"Inventory Module" ,"Inventory" ,"Knowledge Box" ,"Knowledge Pad Module" ,"Knowledge Pad" ,"Letter" ,"Mail Message" ,"Meeting Module" ,"Meeting" ,"Note" ,"Notification Message Module" ,"Notification Message" ,"One Time Restricted Access Token" ,"Open Sale Order Module" ,"Open Sale Order" ,"Organisation Module" ,"Organisation" ,"PDF" ,"Payment Transaction" ,"Payzen Event" ,"Person Module" ,"Person" ,"Phone Call" ,"Presentation" ,"Product Module" ,"Product" ,"Project Module" ,"Project" ,"Purchase Invoice Transaction" ,"Purchase Order Module" ,"Purchase Order" ,"Purchase Trade Condition Module" ,"Purchase Trade Condition" ,"Query Module" ,"Query" ,"Regularisation Request Module" ,"Regularisation Request" ,"Restricted Access Token" ,"Sale Invoice Transaction" ,"Sale Opportunity Module" ,"Sale Opportunity" ,"Sale Order Module" ,"Sale Order" ,"Sale Packing List Module" ,"Sale Trade Condition Module" ,"Sale Trade Condition" ,"Service Module" ,"Service" ,"Short Message" ,"Site Message" ,"Slave Instance" ,"Software Installation Module" ,"Software Installation" ,"Software Instance Module" ,"Software Instance" ,"Software Product Module" ,"Software Product" ,"Software Release Module" ,"Software Release" ,"Spreadsheet" ,"Support Request Module" ,"Support Request" ,"System Event Module" ,"Text" ,"Transformation Module" ,"Transformation" ,"Upgrade Decision Module" ,"Upgrade Decision" ,"User Consumption HTML File" ,"Visit" ,"Web Message" ,"Web Page Module" ,"Web Page"):
print portal_type print(portal_type)
portal.portal_types[portal_type].updateRoleMapping(priority=4) portal.portal_types[portal_type].updateRoleMapping(priority=4)
context.portal_catalog.searchAndActivate( context.portal_catalog.searchAndActivate(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment