text
stringlengths
0
828
ret = []
for val in res:
val = val[1]['uid'][0]
try:
ret.append(val.decode('utf-8'))
except UnicodeDecodeError:
ret.append(val)
except KeyError:
continue
return [CSHMember(self.__lib__,
result,
uid=True)
for result in ret]"
329,"def check_member(self, member, dn=False):
""""""Check if a Member is in the bound group.
Arguments:
member -- the CSHMember object (or distinguished name) of the member to
check against
Keyword arguments:
dn -- whether or not member is a distinguished name
""""""
if dn:
res = self.__con__.search_s(
self.__dn__,
ldap.SCOPE_BASE,
""(member=%s)"" % dn,
['ipaUniqueID'])
else:
res = self.__con__.search_s(
self.__dn__,
ldap.SCOPE_BASE,
""(member=%s)"" % member.get_dn(),
['ipaUniqueID'])
return len(res) > 0"
330,"def add_member(self, member, dn=False):
""""""Add a member to the bound group
Arguments:
member -- the CSHMember object (or distinguished name) of the member
Keyword arguments:
dn -- whether or not member is a distinguished name
""""""
if dn:
if self.check_member(member, dn=True):
return
mod = (ldap.MOD_ADD, 'member', member.encode('ascii'))
else:
if self.check_member(member):
return
mod = (ldap.MOD_ADD, 'member', member.get_dn().encode('ascii'))
if self.__lib__.__batch_mods__:
self.__lib__.enqueue_mod(self.__dn__, mod)
elif not self.__lib__.__ro__:
mod_attrs = [mod]
self.__con__.modify_s(self.__dn__, mod_attrs)
else:
print(""ADD VALUE member = {} FOR {}"".format(mod[2], self.__dn__))"
331,"def read_object_from_yaml(desired_type: Type[Any], file_object: TextIOBase, logger: Logger,
fix_imports: bool = True, errors: str = 'strict', *args, **kwargs) -> Any:
""""""
Parses a yaml file.
:param desired_type:
:param file_object:
:param logger:
:param fix_imports:
:param errors:
:param args:
:param kwargs:
:return:
""""""
return yaml.load(file_object)"
332,"def read_collection_from_yaml(desired_type: Type[Any], file_object: TextIOBase, logger: Logger,
conversion_finder: ConversionFinder, fix_imports: bool = True, errors: str = 'strict',
**kwargs) -> Any:
""""""
Parses a collection from a yaml file.
:param desired_type:
:param file_object:
:param logger:
:param fix_imports:
:param errors:
:param args:
:param kwargs:
:return:
""""""
res = yaml.load(file_object)
# convert if required
return ConversionFinder.convert_collection_values_according_to_pep(res, desired_type, conversion_finder, logger,
**kwargs)"