Ejemplo n.º 1
0
 def process_principal(self, event, principals, legacy_principal, name, color, full_access=None, roles=None):
     if isinstance(legacy_principal, basestring):
         user = self.all_users_by_email.get(legacy_principal)
         principal = user or EmailPrincipal(legacy_principal)
     else:
         principal = self.convert_principal(legacy_principal)
     if principal is None:
         self.print_warning(
             cformat("%%{%s}{}%%{reset}%%{yellow} does not exist:%%{reset} {}" % color).format(
                 name, legacy_principal
             ),
             event_id=event.id,
         )
         return
     try:
         entry = principals[principal]
     except KeyError:
         entry = EventPrincipal(event_id=event.id, principal=principal, full_access=False, roles=[])
         principals[principal] = entry
     if full_access:
         entry.full_access = True
     if roles:
         entry.roles = sorted(set(entry.roles) | set(roles))
     if not self.quiet:
         self.print_msg(cformat("    - %%{%s}[{}]%%{reset} {}" % color).format(name.lower(), principal))
     return principal
Ejemplo n.º 2
0
 def process_principal(self, event, principals, legacy_principal, name, color, full_access=None, roles=None):
     if isinstance(legacy_principal, basestring):
         user = self.all_users_by_email.get(legacy_principal)
         principal = user or EmailPrincipal(legacy_principal)
     else:
         principal = self.convert_principal(legacy_principal)
     if principal is None:
         self.print_warning(cformat('%%{%s}{}%%{reset}%%{yellow} does not exist:%%{reset} {}' % color)
                            .format(name, legacy_principal), event_id=event.id)
         return
     try:
         entry = principals[principal]
     except KeyError:
         entry = EventPrincipal(event_id=event.id, principal=principal, full_access=False, roles=[])
         principals[principal] = entry
     if full_access:
         entry.full_access = True
     if roles:
         entry.roles = sorted(set(entry.roles) | set(roles))
     if not self.quiet:
         self.print_msg(cformat('    - %%{%s}[{}]%%{reset} {}' % color).format(name.lower(), principal))
     return principal
Ejemplo n.º 3
0
 def process_principal(self,
                       principals,
                       legacy_principal,
                       name,
                       color,
                       full_access=None,
                       roles=None,
                       read_access=None):
     if isinstance(legacy_principal, basestring):
         user = self.global_ns.users_by_email.get(legacy_principal)
         principal = user or EmailPrincipal(legacy_principal)
     else:
         principal = self.convert_principal(legacy_principal)
     if principal is None:
         self.print_warning(
             ('%%[%s]{}%%[reset]%%[yellow] does not exist:%%[reset] {} ({})'
              % color).format(name, legacy_principal,
                              getattr(legacy_principal, 'id', '-')))
         return
     try:
         entry = principals[principal]
     except KeyError:
         entry = EventPrincipal(event_id=self.event.id,
                                principal=principal,
                                full_access=False,
                                roles=[])
         principals[principal] = entry
     if full_access:
         entry.full_access = True
     if read_access:
         entry.read_access = True
     if roles:
         entry.roles = sorted(set(entry.roles) | set(roles))
     if not self.quiet:
         self.print_log('      %%[%s][{}]%%[reset] {}' %
                        color.format(name.lower(), principal))
     return principal