rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
(LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier) | (LMC.profiles.Select(filters.ALL), lambda x: x) | def mod_profile(self, opts, args): """ Modify a system wide User profile. """ include_id_lists=[ (opts.name, LMC.profiles.name_to_group), (opts.group, LMC.profiles.confirm_group) ] exclude_id_lists=[ (opts.exclude, LMC.profiles.guess_identifier), ] if opts.all and ( ( # NOTE TO THE READER: don't event try to simplify these conditions, # or the order the tests: they just MATTER. Read the tests in pure # english to undestand them and why the order is important. opts.non_interactive and opts.force) or opts.batch \ or (opts.non_interactive and logging.ask_for_repair( 'Are you sure you want to modify all profiles ?', opts.auto_answer) \ or not opts.non_interactive) ): include_id_lists.extend([ (LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier) ]), profiles_to_mod = self.select(LMC.profiles, 'profile', args, include_id_lists=include_id_lists, exclude_id_lists=exclude_id_lists) |
(LMC.users.Select(filters.STD), LMC.users.confirm_uid), (LMC.users.Select(filters.SYSUNRSTR), LMC.users.confirm_uid) | (LMC.users.Select(filters.STD), lambda x: x), (LMC.users.Select(filters.SYSUNRSTR), lambda x: x) | def chk_user(self, opts, args): """ Check one or more user account(s). """ include_id_lists=[ (opts.login, LMC.users.login_to_uid), (opts.uid, LMC.users.confirm_uid) ] exclude_id_lists=[ (opts.exclude, LMC.users.guess_identifier), (opts.exclude_login, LMC.users.login_to_uid), (opts.exclude_uid, LMC.users.confirm_uid) ] if opts.all and ( ( # NOTE TO THE READER: don't event try to simplify these conditions, # or the order the tests: they just MATTER. Read the tests in pure # english to undestand them and why the order is important. opts.non_interactive and opts.force) or opts.batch \ or (opts.non_interactive and logging.ask_for_repair( 'Are you sure you want to check all users ?', auto_answer=opts.auto_answer) or not opts.non_interactive) ): include_id_lists.extend([ (LMC.users.Select(filters.STD), LMC.users.confirm_uid), (LMC.users.Select(filters.SYSUNRSTR), LMC.users.confirm_uid) ]) uids_to_chk = self.select(LMC.users, 'user', args, include_id_lists=include_id_lists, exclude_id_lists=exclude_id_lists) |
(LMC.groups.Select(filters.STD), LMC.groups.confirm_gid), (LMC.groups.Select(filters.SYSUNRSTR), LMC.groups.confirm_gid) | (LMC.groups.Select(filters.STD), lambda x: x), (LMC.groups.Select(filters.SYSUNRSTR), lambda x: x) | def chk_group(self, opts, args): """ Check one or more group(s). """ include_id_lists=[ (opts.name, LMC.groups.name_to_gid), (opts.gid, LMC.groups.confirm_gid) ] exclude_id_lists = [ (opts.exclude, LMC.groups.guess_identifier), (opts.exclude_group, LMC.groups.name_to_gid), (opts.exclude_gid, LMC.groups.confirm_gid) ] if opts.all and ( ( # NOTE TO THE READER: don't event try to simplify these conditions, # or the order the tests: they just MATTER. Read the tests in pure # english to undestand them and why the order is important. opts.non_interactive and opts.force) or opts.batch \ or (opts.non_interactive and logging.ask_for_repair( 'Are you sure you want to check all groups ?', auto_answer=opts.auto_answer) or not opts.non_interactive) ): include_id_lists.extend([ (LMC.groups.Select(filters.STD), LMC.groups.confirm_gid), (LMC.groups.Select(filters.SYSUNRSTR), LMC.groups.confirm_gid) ]) gids_to_chk = self.select(LMC.groups, 'group', args, include_id_lists=include_id_lists, exclude_id_lists=exclude_id_lists, default_selection=filters.STD, all=opts.all) |
(LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier) | (LMC.profiles.Select(filters.ALL), lambda x: x) | def chk_profile(self, opts, args): """ TODO: to be implemented. """ include_id_lists=[ (opts.name, LMC.profiles.name_to_group), (opts.group, LMC.profiles.confirm_group) ] exclude_id_lists=[ (opts.exclude, LMC.profiles.guess_identifier) ] if opts.all and ( ( # NOTE TO THE READER: don't event try to simplify these conditions, # or the order the tests: they just MATTER. Read the tests in pure # english to undestand them and why the order is important. opts.non_interactive and opts.force) or opts.batch \ or (opts.non_interactive and logging.ask_for_repair( 'Are you sure you want to delete all profiles ?', opts.auto_answer) \ or not opts.non_interactive) ): include_id_lists.extend([ (LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier) ]) |
''' % (styles.stylize(styles.ST_OK, "Call trace"))) | ''' % (stylize(ST_OK, "Call trace"))) | def error(mesg, returncode=1, full=False, tb=None, listener=None): """ Display a styles.stylized error message and exit badly. """ if full: if tb: sys.stderr.write(tb + '\n') else: import traceback sys.stderr.write ('''>>> %s: ''' % (styles.stylize(styles.ST_OK, "Call trace"))) traceback.print_tb( sys.exc_info()[2] ) sys.stderr.write("\n") sys.stderr.write('%s %s %s\n' % ( styles.stylize(styles.ST_BAD, 'ERROR:'), mytime(), mesg)) raise SystemExit(returncode) |
styles.stylize(styles.ST_BAD, 'ERROR:'), | stylize(ST_BAD, 'ERROR:'), | def error(mesg, returncode=1, full=False, tb=None, listener=None): """ Display a styles.stylized error message and exit badly. """ if full: if tb: sys.stderr.write(tb + '\n') else: import traceback sys.stderr.write ('''>>> %s: ''' % (styles.stylize(styles.ST_OK, "Call trace"))) traceback.print_tb( sys.exc_info()[2] ) sys.stderr.write("\n") sys.stderr.write('%s %s %s\n' % ( styles.stylize(styles.ST_BAD, 'ERROR:'), mytime(), mesg)) raise SystemExit(returncode) |
styles.stylize(styles.ST_WARNING, '/!\\'), mytime(), mesg) | stylize(ST_WARNING, '/!\\'), mytime(), mesg) | def warning(mesg, once=False, listener=None): """Display a styles.stylized warning message on stderr.""" if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True text_message = "%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/!\\'), mytime(), mesg) if listener: listener.process( LicornMessage(data=text_message), options.msgproc.getProxy()) sys.stderr.write(text_message) |
""" Display a styles.stylized warning message on stderr, only if verbose | """ Display a stylized warning message on stderr, only if verbose | def warning2(mesg, once=False, listener=None): """ Display a styles.stylized warning message on stderr, only if verbose level > INFO. """ if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True if listener and listener.verbose >= verbose.INFO: listener.process( LicornMessage(data="%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)), options.msgproc.getProxy()) if options.verbose >= verbose.INFO: sys.stderr.write("%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)) |
styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)), | stylize(ST_WARNING, '/2\\'), mytime(), mesg)), | def warning2(mesg, once=False, listener=None): """ Display a styles.stylized warning message on stderr, only if verbose level > INFO. """ if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True if listener and listener.verbose >= verbose.INFO: listener.process( LicornMessage(data="%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)), options.msgproc.getProxy()) if options.verbose >= verbose.INFO: sys.stderr.write("%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)) |
styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)) | stylize(ST_WARNING, '/2\\'), mytime(), mesg)) | def warning2(mesg, once=False, listener=None): """ Display a styles.stylized warning message on stderr, only if verbose level > INFO. """ if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True if listener and listener.verbose >= verbose.INFO: listener.process( LicornMessage(data="%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)), options.msgproc.getProxy()) if options.verbose >= verbose.INFO: sys.stderr.write("%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)) |
styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)), | stylize(ST_INFO, '*'), mytime(), mesg)), | def notice(mesg, listener=None): """ Display a non-styles.stylized notice message on stderr.""" assert ltrace('logging', '| notice(%s L%s/R%s)' % (verbose.NOTICE, options.verbose, listener.verbose if listener else '-')) if listener and listener.verbose >= verbose.NOTICE: listener.process(LicornMessage(data=" %s %s %s\n" % ( styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)), options.msgproc.getProxy()) if options.verbose >= verbose.NOTICE: sys.stderr.write(" %s %s %s\n" % ( styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)) |
styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)) | stylize(ST_INFO, '*'), mytime(), mesg)) | def notice(mesg, listener=None): """ Display a non-styles.stylized notice message on stderr.""" assert ltrace('logging', '| notice(%s L%s/R%s)' % (verbose.NOTICE, options.verbose, listener.verbose if listener else '-')) if listener and listener.verbose >= verbose.NOTICE: listener.process(LicornMessage(data=" %s %s %s\n" % ( styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)), options.msgproc.getProxy()) if options.verbose >= verbose.NOTICE: sys.stderr.write(" %s %s %s\n" % ( styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)) |
styles.stylize(styles.ST_DEBUG, 'DEBUG'), mesg) ) | stylize(ST_DEBUG, 'DEBUG'), mesg) ) | def debug(mesg): """Display a styles.stylized debug message on stderr.""" if options.verbose >= verbose.DEBUG: sys.stderr.write( "%s: %s\n" % ( styles.stylize(styles.ST_DEBUG, 'DEBUG'), mesg) ) |
styles.stylize(styles.ST_DEBUG, 'DEBUG2'), mesg)) | stylize(ST_DEBUG, 'DEBUG2'), mesg)) | def debug2(mesg): """Display a styles.stylized debug2 message on stderr.""" if options.verbose >= verbose.DEBUG2: sys.stderr.write("%s: %s\n" % ( styles.stylize(styles.ST_DEBUG, 'DEBUG2'), mesg)) |
@staticmethod def is_standard_login(login): """ Return true if login is standard (not system). """ try: return UsersController.is_standard_uid( UsersController.login_cache[login]) except KeyError: raise exceptions.DoesntExistsException( logging.SYSU_USER_DOESNT_EXIST % login) | def is_system_login(login): """ return true if login is system. """ try: return UsersController.is_system_uid( UsersController.login_cache[login]) except KeyError: raise exceptions.DoesntExistsException( logging.SYSU_USER_DOESNT_EXIST % login) |
|
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" | def minifind(path, type=None, perms=None, mindepth=0, maxdepth=99, exclude=[], followlinks=False, followmounts=True): """ Mimic the GNU find behaviour in python. returns an iterator. """ | def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth.") if maxdepth > 99: raise exceptions.BadArgumentError("please don't try to exhaust maxdepth.") logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude)) paths_to_walk = [ path ] next_paths_to_walk = [] current_depth = 0 S_IFSTD = S_IFDIR | S_IFREG while True: if paths_to_walk != []: entry = paths_to_walk.pop(0) elif next_paths_to_walk != []: paths_to_walk = next_paths_to_walk next_paths_to_walk = [] entry = paths_to_walk.pop(0) current_depth += 1 else: break try: entry_stat = os.lstat(entry) entry_type = entry_stat.st_mode & 0170000 entry_mode = entry_stat.st_mode & 07777 if current_depth >= mindepth \ and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \ and ( perms is None or (entry_mode & perms) ): yield entry if (entry_type & S_IFLNK and not followlinks) \ or (os.path.ismount(entry) and not followmounts): continue if entry_type & S_IFDIR and current_depth < maxdepth: for x in os.listdir(entry): if x not in exclude: next_paths_to_walk.append("%s/%s" % (entry, x)) except OSError, e: if e.errno == 2 or (e.errno == 13 and entry[-5:] == '.gvfs'): continue raise e |
logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude)) | ltrace('fsapi', '''> minifind(%s, type=%s, mindepth=%s, maxdepth=%s, ''' '''exclude=%s, followlinks=%s, followmounts=%s)''' % ( path, type, mindepth, maxdepth, exclude, followlinks, followmounts)) | def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth.") if maxdepth > 99: raise exceptions.BadArgumentError("please don't try to exhaust maxdepth.") logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude)) paths_to_walk = [ path ] next_paths_to_walk = [] current_depth = 0 S_IFSTD = S_IFDIR | S_IFREG while True: if paths_to_walk != []: entry = paths_to_walk.pop(0) elif next_paths_to_walk != []: paths_to_walk = next_paths_to_walk next_paths_to_walk = [] entry = paths_to_walk.pop(0) current_depth += 1 else: break try: entry_stat = os.lstat(entry) entry_type = entry_stat.st_mode & 0170000 entry_mode = entry_stat.st_mode & 07777 if current_depth >= mindepth \ and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \ and ( perms is None or (entry_mode & perms) ): yield entry if (entry_type & S_IFLNK and not followlinks) \ or (os.path.ismount(entry) and not followmounts): continue if entry_type & S_IFDIR and current_depth < maxdepth: for x in os.listdir(entry): if x not in exclude: next_paths_to_walk.append("%s/%s" % (entry, x)) except OSError, e: if e.errno == 2 or (e.errno == 13 and entry[-5:] == '.gvfs'): continue raise e |
and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \ | and ( (type is None and entry_type & S_IFSTD) \ or entry_type == type) \ | def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth.") if maxdepth > 99: raise exceptions.BadArgumentError("please don't try to exhaust maxdepth.") logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude)) paths_to_walk = [ path ] next_paths_to_walk = [] current_depth = 0 S_IFSTD = S_IFDIR | S_IFREG while True: if paths_to_walk != []: entry = paths_to_walk.pop(0) elif next_paths_to_walk != []: paths_to_walk = next_paths_to_walk next_paths_to_walk = [] entry = paths_to_walk.pop(0) current_depth += 1 else: break try: entry_stat = os.lstat(entry) entry_type = entry_stat.st_mode & 0170000 entry_mode = entry_stat.st_mode & 07777 if current_depth >= mindepth \ and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \ and ( perms is None or (entry_mode & perms) ): yield entry if (entry_type & S_IFLNK and not followlinks) \ or (os.path.ismount(entry) and not followmounts): continue if entry_type & S_IFDIR and current_depth < maxdepth: for x in os.listdir(entry): if x not in exclude: next_paths_to_walk.append("%s/%s" % (entry, x)) except OSError, e: if e.errno == 2 or (e.errno == 13 and entry[-5:] == '.gvfs'): continue raise e |
if (entry_type & S_IFLNK and not followlinks) \ | if (entry_type == S_IFLNK and not followlinks) \ | def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth.") if maxdepth > 99: raise exceptions.BadArgumentError("please don't try to exhaust maxdepth.") logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude)) paths_to_walk = [ path ] next_paths_to_walk = [] current_depth = 0 S_IFSTD = S_IFDIR | S_IFREG while True: if paths_to_walk != []: entry = paths_to_walk.pop(0) elif next_paths_to_walk != []: paths_to_walk = next_paths_to_walk next_paths_to_walk = [] entry = paths_to_walk.pop(0) current_depth += 1 else: break try: entry_stat = os.lstat(entry) entry_type = entry_stat.st_mode & 0170000 entry_mode = entry_stat.st_mode & 07777 if current_depth >= mindepth \ and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \ and ( perms is None or (entry_mode & perms) ): yield entry if (entry_type & S_IFLNK and not followlinks) \ or (os.path.ismount(entry) and not followmounts): continue if entry_type & S_IFDIR and current_depth < maxdepth: for x in os.listdir(entry): if x not in exclude: next_paths_to_walk.append("%s/%s" % (entry, x)) except OSError, e: if e.errno == 2 or (e.errno == 13 and entry[-5:] == '.gvfs'): continue raise e |
except OSError, e: | else: ltrace('fsapi', ' minifind(excluded=%s)' % entry) except (IOError, OSError), e: | def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth.") if maxdepth > 99: raise exceptions.BadArgumentError("please don't try to exhaust maxdepth.") logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude)) paths_to_walk = [ path ] next_paths_to_walk = [] current_depth = 0 S_IFSTD = S_IFDIR | S_IFREG while True: if paths_to_walk != []: entry = paths_to_walk.pop(0) elif next_paths_to_walk != []: paths_to_walk = next_paths_to_walk next_paths_to_walk = [] entry = paths_to_walk.pop(0) current_depth += 1 else: break try: entry_stat = os.lstat(entry) entry_type = entry_stat.st_mode & 0170000 entry_mode = entry_stat.st_mode & 07777 if current_depth >= mindepth \ and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \ and ( perms is None or (entry_mode & perms) ): yield entry if (entry_type & S_IFLNK and not followlinks) \ or (os.path.ismount(entry) and not followmounts): continue if entry_type & S_IFDIR and current_depth < maxdepth: for x in os.listdir(entry): if x not in exclude: next_paths_to_walk.append("%s/%s" % (entry, x)) except OSError, e: if e.errno == 2 or (e.errno == 13 and entry[-5:] == '.gvfs'): continue raise e |
for cmd in self.pre_cmds: out_path += 'pre_%s/' % make_path(cmd) | for pre_cmd in self.pre_cmds: out_path += 'pre_%s/' % make_path(pre_cmd) | def Prepare(self, cmd): """ Run commands mandatory for func_test to succeed. """ |
execute(cmd) | execute(pre_cmd) | def Prepare(self, cmd): """ Run commands mandatory for func_test to succeed. """ |
[ 'sudo', 'rm', '-rf', '%s/*' % configuration.home_archive_dir ] | [ 'sudo', 'rm', '-vrf', '%s/*' % configuration.home_archive_dir ] | def chk_acls_cmds(group, subdir=None): return [ 'sudo', 'getfacl', '-R', '%s/%s/%s%s' % ( configuration.defaults.home_base_path, configuration.groups.names['plural'], group, '/%s' % subdir if subdir else '') ] |
['sudo', 'rm', '-rf', "%s/%s/%s" % ( | ['sudo', 'rm', '-vrf', "%s/%s/%s" % ( | def chk_acls_cmds(group, subdir=None): return [ 'sudo', 'getfacl', '-R', '%s/%s/%s%s' % ( configuration.defaults.home_base_path, configuration.groups.names['plural'], group, '/%s' % subdir if subdir else '') ] |
'''deleted) is deleted (avoids | def chk_acls_cmds(group, subdir=None): return [ 'sudo', 'getfacl', '-R', '%s/%s/%s%s' % ( configuration.defaults.home_base_path, configuration.groups.names['plural'], group, '/%s' % subdir if subdir else '') ] |
|
if need_rewriting: self.save_group(gid) | def load_groups(self): """ Load groups from /etc/{group,gshadow} and /etc/licorn/group. """ |
|
return LicornWarningsDB.__warnings[item] | return LicornWarningsDB.warnings[item] | def __getitem__(self, item): return LicornWarningsDB.__warnings[item] |
LicornWarningsDB.__warningsdb[item] = value | LicornWarningsDB.warnings[item] = value | def __setitem__(self, item, value): LicornWarningsDB.__warningsdb[item] = value |
return LicornWarningsDB.__warningsdb.keys() | return LicornWarningsDB.warnings.keys() __warningsdb = LicornWarningsDB() | def keys(self): return LicornWarningsDB.__warningsdb.keys() |
UsersController.users, UsersController.login_cache = self.backend.load_users(self.groups) | UsersController.users, UsersController.login_cache = \ self.backend.load_users(self.groups) | def reload(self): """ Load (or reload) the data structures from the system files. """ UsersController.users, UsersController.login_cache = self.backend.load_users(self.groups) |
raise exceptions.LicornRuntimeError("Can't build a valid login (%s) with the firstname/lastname (%s/%s) you provided." % (login, firstname, lastname)) | raise exceptions.LicornRuntimeError( "Can't build a valid login (%s) with the " \ "firstname/lastname (%s/%s) you provided." % ( login, firstname, lastname) ) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
raise exceptions.BadArgumentError(logging.SYSU_MALFORMED_LOGIN % (login, styles.stylize(styles.ST_REGEX, hlstr.regex['login']))) if not login_autogenerated and len(login) > UsersController.configuration.users.login_maxlenght: raise exceptions.LicornRuntimeError("Login too long (%d characters, but must be shorter or equal than %d)." % (len(login),UsersController.configuration.users.login_maxlenght) ) | raise exceptions.BadArgumentError( logging.SYSU_MALFORMED_LOGIN % ( login, styles.stylize(styles.ST_REGEX, hlstr.regex['login']))) if not login_autogenerated and \ len(login) > UsersController.configuration.users.login_maxlenght: raise exceptions.LicornRuntimeError( "Login too long (%d characters," \ " but must be shorter or equal than %d)." % ( len(login), UsersController.configuration.users.login_maxlenght) ) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
raise exceptions.LicornRuntimeError("Can't build a valid GECOS (%s) with the firstname/lastname (%s/%s) or login you provided." % (gecos, firstname, lastname)) | raise exceptions.LicornRuntimeError( "Can't build a valid GECOS (%s) with the" \ " firstname/lastname (%s/%s) or login you provided." % ( gecos, firstname, lastname) ) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
raise exceptions.BadArgumentError("The skel you specified doesn't exist on this system. Valid skels are: %s." % UsersController.configuration.users.skels) | raise exceptions.BadArgumentError( "The skel you specified doesn't exist on this system." \ " Valid skels are: %s." % \ UsersController.configuration.users.skels) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
raise exceptions.AlreadyExistsException, "A user named « %s » already exists !" % login | raise exceptions.AlreadyExistsException, \ "A user named « %s » already exists !" % login | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
raise exceptions.UpstreamBugException, "A group named `%s' exists on the system, this could eventually conflict in Debian/Ubuntu system tools. Please choose another user's login." % login | raise exceptions.UpstreamBugException, \ "A group named `%s' exists on the system," \ " this could eventually conflict in Debian/Ubuntu system" \ " tools. Please choose another user's login." % login | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
tmp_user_dict['loginShell'] = UsersController.profiles.profiles[profile]['shell'] tmp_user_dict['gid'] = UsersController.groups.name_to_gid(UsersController.profiles.profiles[profile]['primary_group']) | tmp_user_dict['loginShell'] = \ UsersController.profiles.profiles[profile]['shell'] tmp_user_dict['gid'] = \ UsersController.groups.name_to_gid( UsersController.profiles.profiles[profile]['primary_group']) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
skel_to_apply = UsersController.profiles.profiles[profile]['skel_dir'] | skel_to_apply = \ UsersController.profiles.profiles[profile]['skel_dir'] | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
raise exceptions.LicornRuntimeError("The profile %s does not exist on this system (was: %s) !" % (profile, e)) | raise exceptions.LicornRuntimeError( "The profile %s does not exist on this system (was: %s) !" \ % (profile, e)) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
tmp_user_dict['loginShell'] = UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % (UsersController.configuration.users.base_path, login) | tmp_user_dict['loginShell'] = \ UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % ( UsersController.configuration.users.base_path, login) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
if skel is None and os.path.isdir(UsersController.groups.groups[pg_gid]['skel']): | if skel is None and \ os.path.isdir(UsersController.groups.groups[pg_gid]['skel']): | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
tmp_user_dict['gid'] = UsersController.configuration.users.default_gid tmp_user_dict['loginShell'] = UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % (UsersController.configuration.users.base_path, login) | tmp_user_dict['gid'] = \ UsersController.configuration.users.default_gid tmp_user_dict['loginShell'] = \ UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % ( UsersController.configuration.users.base_path, login) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
logging.warning( "ROLLBACK because " + str(e)) | logging.warning( "ROLLBACK create user because '%s'." % str(e)) | def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass).""" |
logging.warning("Home dir %s doesn't exist, thus not archived." % styles.stylize(styles.ST_PATH, homedir)) | logging.warning( "Home dir %s doesn't exist, thus not archived." % \ styles.stylize(styles.ST_PATH, homedir)) | def DeleteUser(self, login=None, no_archive=False, uid=None, batch=False): """ Delete a user """ if login is None and uid is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LGN_OR_UID) |
logging.warning(logging.SYSU_SET_EMPTY_PASSWD % styles.stylize(styles.ST_LOGIN, login)) | logging.warning(logging.SYSU_SET_EMPTY_PASSWD % \ styles.stylize(styles.ST_LOGIN, login)) | def ChangeUserPassword(self, login, password = None, display = False): """ Change the password of a user """ if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN) if password is None: password = hlstr.generate_password(UsersController.configuration.mAutoPasswdSize) elif password == "": logging.warning(logging.SYSU_SET_EMPTY_PASSWD % styles.stylize(styles.ST_LOGIN, login)) # TODO: automatically remove user from remotessh ? |
logging.notice("Set user %s's password to %s." % (styles.stylize(styles.ST_NAME, login), styles.stylize(styles.ST_IMPORTANT, password))) else: logging.info('Changed password for user %s.' % styles.stylize(styles.ST_NAME, login)) | logging.notice("Set user %s's password to %s." % ( styles.stylize(styles.ST_NAME, login), styles.stylize(styles.ST_IMPORTANT, password))) else: logging.info('Changed password for user %s.' % \ styles.stylize(styles.ST_NAME, login)) | def ChangeUserPassword(self, login, password = None, display = False): """ Change the password of a user """ if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN) if password is None: password = hlstr.generate_password(UsersController.configuration.mAutoPasswdSize) elif password == "": logging.warning(logging.SYSU_SET_EMPTY_PASSWD % styles.stylize(styles.ST_LOGIN, login)) # TODO: automatically remove user from remotessh ? |
raise exceptions.LicornRuntimeError("Invalid shell ! valid shells are %s." % UsersController.configuration.users.shells) | raise exceptions.LicornRuntimeError( "Invalid shell ! valid shells are %s." % \ UsersController.configuration.users.shells) | def ChangeUserShell(self, login, shell = ""): """ Change the shell of a user. """ if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN) |
UsersController.users[uid]['crypted_password'] = '!' + UsersController.users[uid]['crypted_password'] logging.info('Locked user account %s.' % styles.stylize(styles.ST_LOGIN, login)) else: UsersController.users[uid]['crypted_password'] = UsersController.users[uid]['crypted_password'][1:] logging.info('Unlocked user account %s.' % styles.stylize(styles.ST_LOGIN, login)) | UsersController.users[uid]['crypted_password'] = '!' + \ UsersController.users[uid]['crypted_password'] logging.info('Locked user account %s.' % \ styles.stylize(styles.ST_LOGIN, login)) else: UsersController.users[uid]['crypted_password'] = \ UsersController.users[uid]['crypted_password'][1:] logging.info('Unlocked user account %s.' % \ styles.stylize(styles.ST_LOGIN, login)) | def LockAccount(self, login, lock = True): """(Un)Lock a user account.""" if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN) |
data += " <groups>%s</groups>\n" % ','.join(UsersController.users[uid]['groups']) | data += " <groups>%s</groups>\n" % \ ','.join(UsersController.users[uid]['groups']) | def build_xml_output_user_data(uid): data = ''' |
logging.progress("Checking user %s..." % styles.stylize(styles.ST_LOGIN, user)) | logging.progress("Checking user %s..." % \ styles.stylize(styles.ST_LOGIN, user)) | def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer): |
logging.progress("Checking user account %s..." % styles.stylize(styles.ST_NAME, user)) | logging.progress("Checking user account %s..." % \ styles.stylize(styles.ST_NAME, user)) | def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer): |
} for dir in home_exclude_list if os.path.exists('%s/%s' % (user_home, dir)) ]) | } for dir in home_exclude_list if \ os.path.exists('%s/%s' % (user_home, dir)) ]) | def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer): |
UsersController.configuration.users.mailbox_type == UsersController.configuration.MAIL_TYPE_HOME_MAILDIR: maildir_base = '%s/%s' % (user_home, UsersController.configuration.users.mailbox) home_exclude_list.append(UsersController.configuration.users.mailbox[:-1]) for dir in ( maildir_base, '%stmp' % maildir_base, '%scur' % maildir_base,'%snew' % maildir_base ): | UsersController.configuration.users.mailbox_type == \ UsersController.configuration.MAIL_TYPE_HOME_MAILDIR: maildir_base = '%s/%s' % (user_home, UsersController.configuration.users.mailbox) home_exclude_list.append( UsersController.configuration.users.mailbox[:-1]) for dir in ( maildir_base, '%stmp' % maildir_base, '%scur' % maildir_base,'%snew' % maildir_base ): | def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer): |
logging.progress("Checking user home dir %s contents, this can take a while..." % styles.stylize( | logging.progress("Checking user home dir %s contents," " this can take a while..." % styles.stylize( | def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer): |
logging.warning("User home dir %s is missing, please repair this first." % styles.stylize( | logging.warning("User home dir %s is missing," " please repair this first." % styles.stylize( | def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer): |
logging.warning("You passed an uid to login_to_uid(): %d (guess its login is « %s » )." % (login, UsersController.users[login]['login'])) | logging.warning("You passed an uid to login_to_uid():" " %d (guess its login is « %s » )." % ( login, UsersController.users[login]['login'])) | def login_to_uid(login): """ Return the uid of the user 'login' """ try: # use the cache, Luke ! return UsersController.login_cache[login] except KeyError: try: int(login) logging.warning("You passed an uid to login_to_uid(): %d (guess its login is « %s » )." % (login, UsersController.users[login]['login'])) except ValueError: pass raise exceptions.LicornRuntimeException(logging.SYSU_USER_DOESNT_EXIST % login) |
return uid < UsersController.configuration.users.uid_min or uid > UsersController.configuration.users.uid_max | return uid < UsersController.configuration.users.uid_min or \ uid > UsersController.configuration.users.uid_max | def is_system_uid(uid): """ Return true if uid is system.""" return uid < UsersController.configuration.users.uid_min or uid > UsersController.configuration.users.uid_max |
raise exceptions.LicornRuntimeError("Can't build a valid login (got %s, which doesn't verify %s) with the firstname/lastname you provided (%s %s)." % (login, hlstr.regex['login'], firstname, lastname) ) | raise exceptions.LicornRuntimeError( "Can't build a valid login (got %s, which doesn't verify %s)" " with the firstname/lastname you provided (%s %s)." % ( login, hlstr.regex['login'], firstname, lastname) ) | def make_login(lastname = "", firstname = "", inputlogin = ""): """ Make a valid login from user's firstname and lastname.""" |
socket.gethostbyaddr(self.server.server_address[0])[0], wmi_port, retdata)) | hostaddr, wmi_port, retdata)) | def serve_virtual_uri(self): """ Serve dynamic URIs with our own code, and create pages on the fly. """ |
def strip_dates(str): | def strip_moving_data(str): | def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'(\.\d\d\d\d\d\d\d\d-\d\d\d\d\d\d|\s\[\d\d\d\d/\d\d/\d\d\s\d\d:\d\d:\d\d\.\d\d\d\d\]\s)', r' [D/T] ', str) |
r' [D/T] ', str) | r' [D/T] ',re.sub(r'Autogenerated\spassword\sfor\suser\s(.*):\s.*', r'Autogenerated password for user \1: [Password]', str)) | def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'(\.\d\d\d\d\d\d\d\d-\d\d\d\d\d\d|\s\[\d\d\d\d/\d\d/\d\d\s\d\d:\d\d:\d\d\.\d\d\d\d\]\s)', r' [D/T] ', str) |
strip_dates(output)) | strip_moving_data(output)) | def SaveOutput(self, cmdnum, output, code): |
output = strip_dates(output) | output = strip_moving_data(output) | def RunCommand(self, cmdnum, batch=False): |
strip_dates(output), | strip_moving_data(output), | def RunCommand(self, cmdnum, batch=False): |
return (strip_dates(output), retcode) | return (strip_moving_data(output), retcode) | def RunCommand(self, cmdnum, batch=False): |
file = gzip.GzipFile( filename='%s/%s/out.txt.gz' % (self.base_path, cmdnum), mode='wb', compresslevel=9) | try: os.unlink(filename_txt) except (OSError, IOError), e: if e.errno != 2: raise e file = gzip.GzipFile(filename=filename_gz, mode='wb', compresslevel=9) | def SaveOutput(self, cmdnum, output, code): |
file = open('%s/%s/out.txt' % (self.base_path, cmdnum), 'w') | try: os.unlink(filename_gz) except (OSError, IOError), e: if e.errno != 2: raise e file = open(filename_txt, 'w') | def SaveOutput(self, cmdnum, output, code): |
for login in opts.login.split(','): | for login in opts.login.split(',') if opts.login != None else [ None ]: | def add_user(opts, args): """ Add a user account on the system. """ configuration = LicornConfiguration() users = UsersController(configuration) groups = GroupsController(configuration, users) if opts.profile: profiles = ProfilesController(configuration, groups, users) if opts.firstname is None: firstname = None else: firstname = unicode(opts.firstname) if opts.lastname is None: lastname = None else: lastname = unicode(opts.lastname) if opts.gecos is None: gecos = None else: gecos = unicode(opts.gecos) if opts.password is None: password = None else: password = unicode(opts.password) if opts.primary_gid: # if the opts.primary_gid is not an existing GID, try to guess if it is # an existing group name, and then convert it to a GID. if not groups.has_key(opts.primary_gid): opts.primary_gid = groups.name_to_gid(opts.primary_gid) for login in opts.login.split(','): if login != '': try: users.AddUser(lastname=lastname, firstname=firstname, password=password, primary_gid=opts.primary_gid, desired_uid=opts.uid, profile=opts.profile, skel=opts.skel, login=login, gecos=gecos, system=opts.system, home=opts.home, batch=False, force=opts.force) except exceptions.AlreadyExistsException: logging.warning('User %s already exists on the system.' % login) |
shutil.rmtree(home) | try: shutil.rmtree(home) except (IOError, OSError), e: if e.errno == 2: logging.notice("Can't remove %s, it doesn't exist !" % \ styles.stylize(styles.ST_PATH, home)) else: raise e | def DeleteGroup(self, name, del_users, no_archive, bygid=None, batch=False): """ Delete an Licorn group """ if name is None and bygid is None: raise exceptions.BadArgumentError( "You must specify a name or a GID.") |
logging.warning("Can't archive %s, it doesn't exist !" % \ | logging.notice("Can't archive %s, it doesn't exist !" % \ | def DeleteGroup(self, name, del_users, no_archive, bygid=None, batch=False): """ Delete an Licorn group """ if name is None and bygid is None: raise exceptions.BadArgumentError( "You must specify a name or a GID.") |
(opts.gid, groups.confirm_gid) ]) | (opts.gid, groups.confirm_gid), ], selection ) | def del_group(opts, args): """ delete an Licorn group. """ configuration = LicornConfiguration() users = UsersController(configuration) groups = GroupsController(configuration, users, warnings=False) profiles = ProfilesController(configuration, groups, users) gids_to_del = cli_select(groups, 'group', args, [ (opts.name, groups.name_to_gid), (opts.gid, groups.confirm_gid) ]) for gid in gids_to_del: groups.DeleteGroup(gid=gid, del_users=opts.del_users, no_archive=opts.no_archive) |
if users.user_exists(login = authorization[0]) \ and users.check_password(authorization[0], authorization[1]): if groups.group_exists(wmi_group): if authorization[0] in \ groups.auxilliary_members(wmi_group): | try : if users.user_exists(login = authorization[0]) \ and users.check_password(authorization[0], authorization[1]): if groups.group_exists(wmi_group): if authorization[0] in \ groups.auxilliary_members(wmi_group): self.http_user = authorization[0] return True else: | def user_authorized(self): """ Return True if authorization exists AND user is authorized.""" |
else: self.http_user = authorization[0] return True | except exceptions.BadArgumentError: logging.warning('empty username or password sent as authentification string into WMI.') return False | def user_authorized(self): """ Return True if authorization exists AND user is authorized.""" |
<title>%s WMI: %s</title> | <title>%s %s</title> | def head(title = _("administration %s") % configuration.app_name): """Build the HTML Page header. Bubble Tooltips come from: http://www.dustindiaz.com/sweet-titles Rounded Divs comme from : http://www.html.it/articoli/niftycube/index.html """ return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
""" % (configuration.app_name, title) | """ % (_("%s WMI:") %configuration.app_name, title) | def head(title = _("administration %s") % configuration.app_name): """Build the HTML Page header. Bubble Tooltips come from: http://www.dustindiaz.com/sweet-titles Rounded Divs comme from : http://www.html.it/articoli/niftycube/index.html """ return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
descr='''scenario for ticket | descr='''scenario for ticket ''' --add-group and --del-groups & fix | def test_profiles(context): """Test the applying feature of profiles.""" pname = 'profil_test' gname = 'group_test' #fix #271 ScenarioTest([ ADD + [ 'profile', '--name=%s' % pname, '-v' ], GET + [ 'profiles' ], ADD + [ 'group', '--name=%s' % gname, '--system', '-v' ], ADD + [ 'group', '--name=%s2' % gname, '--system', '-v' ], ADD + [ 'group', '--name=%s3' % gname, '--system', '-v' ], GET + [ 'privileges' ], ADD + [ 'privilege', '--name=%s' % gname ], GET + [ 'groups', '-a' ], GET + [ 'privileges' ], MOD + [ 'profile', '--name=%s' % pname, '--add-groups=%s,%s2,%s3' % (gname, gname, gname), '-v' ], GET + [ 'profiles' ], DEL + [ 'group', '--name=%s' % gname, '-v' ], GET + [ 'profiles' ], MOD + [ 'profile', '--name=%s' % pname, '--del-groups=%s' % gname, '-v' ], MOD + [ 'profile', '--name=%s' % pname, '--del-groups=%s2,%s3' % (gname, gname), '-v' ], GET + [ 'profiles' ], DEL + [ 'group', '--name=%s2' % gname, '-v' ], DEL + [ 'group', '--name=%s3' % gname, '-v' ], # don't work with --name option DEL + [ 'profile', '--group=%s' % pname, '-v' ], DEL + [ 'privilege', '--name=%s' % gname, '-v' ], ], context=context, descr='''scenario for ticket #271 - test some commands of mod profile --add-group and --del-groups''' ).Run() ScenarioTest([ ADD + [ 'profile', '--name=%s' % pname, '-v' ], GET + [ 'profiles' ], #should fail MOD + [ 'profile', '--name=%s' % pname, '--add-groups=%s' % gname, '-v' ], GET + [ 'profiles' ], DEL + [ 'profile', '--group=%s' % pname, '-v' ], ], context=context, descr='check if a error occurs when a non-existing group is added to a profile' ).Run() """ # start of old test_profiles() commands test_message('''starting profiles related tests.''') log_and_exec(ADD + " profile --name Utilisagers --group utilisagers --comment 'profil normal créé pour la suite de tests utilisateurs'") log_and_exec(ADD + " profile --name Responsibilisateurs --group responsibilisateurs --groups cdrom,lpadmin,plugdev,audio,video,scanner,fuse --comment 'profil power user créé pour la suite de tests utilisateurs.'") log_and_exec(ADD + " user toto --profile utilisagers") log_and_exec(ADD + " user tutu --profile utilisagers") log_and_exec(ADD + " user tata --profile utilisagers") log_and_exec(MOD + " profile --group utilisagers --apply-groups --to-groups utilisagers") log_and_exec(MOD + " profile --group utilisagers --apply-groups --to-members") log_and_exec(MOD + " profile --group utilisagers --apply-skel --to-users toto --auto-no") log_and_exec(MOD + " profile --group utilisagers --apply-skel --to-users toto --batch") log_and_exec(MOD + " profile --group utilisagers --apply-group --to-users toto") log_and_exec(MOD + " profile --group utilisagers --apply-all --to-users toto") log_and_exec(MOD + " profile --group utilisagers --apply-all --to-users toto") log_and_exec(MOD + " profile --group utilisagers --apply-all --to-all") log_and_exec(DEL + " profile --group responsibilisateurs --no-archive") log_and_exec(DEL + " user toto --no-archive") log_and_exec(DEL + " profile --group utilisagers --del-users --no-archive") test_message('''profiles related tests finished.''') """ # ends of old test_profiles() commands |
if opts.profile and opts.profile not in LMC.profiles: opts.profile = LMC.profiles.name_to_group(opts.profile) | if opts.profile: opts.profile = LMC.profiles.guess_identifier(opts.profile) | def add_user(self, opts, args): """ Add a user account on the system. """ |
def __init__(self, configuration, users=None, groups=None): | def __init__(self, configuration, users=None, groups=None, warnings=True): | def __init__(self, configuration, users=None, groups=None): """ Init the LDAP backend instance. """ |
except herror: hostaddr = self.server.server_address | except socket.herror: hostaddr = self.server.server_address[0] | def serve_virtual_uri(self): """ Serve dynamic URIs with our own code, and create pages on the fly. """ |
return __pyc_primitive__(__pyc_symbol__("index_object"), self, key) | return __pyc_primitive__(__pyc_symbol__("index_object"), self, __pyc_clone_constants__(key)) | def __getitem__(self, key): return __pyc_primitive__(__pyc_symbol__("index_object"), self, key) |
return __pyc_primitive__(__pyc_symbol__("set_index_object"), self, key, value) | return __pyc_primitive__(__pyc_symbol__("set_index_object"), self, __pyc_clone_constants__(key), value) | def __setitem__(self, key, value): return __pyc_primitive__(__pyc_symbol__("set_index_object"), self, key, value) |
self.longTypes = set(('ACTI','ALCH','AMMO','FURN','MISC','MSTT','PROJ','WEAP','CONT','DOOR','LIGH','STAT', 'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT','NOTE','QUST')) | self.longTypes = set(('ACTI','ALCH','AMMO','ARMO','BOOK','CONT','CREA','DEBR','DIAL', 'DOOR','ENCH','EXPL','FACT','FLOR','FLST','FURN','INFO','INGR', 'IPDS','KEYM','LIGH','MGEF','MISC','MSTT','NOTE','NPC_','PROJ', 'QUST','SCPT','SOUN','SPEL','STAT','TERM','TXST','WATR','WEAP')) | def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreActi,MreAlch,MreAmmo,MreFurn,MreMisc,MreMstt,MreProj,MreWeap): recAttrs_class[recClass] = ('destructable',) for recClass in (MreCont,MreDoor,MreTerm): recAttrs_class[recClass] = ('destructable','script',) for recClass in (MreLigh,): recAttrs_class[recClass] = ('script',) for recClass in (MreStat,): recAttrs_class[recClass] = ('model',) self.longTypes = set(('ACTI','ALCH','AMMO','FURN','MISC','MSTT','PROJ','WEAP','CONT','DOOR','LIGH','STAT', 'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT','NOTE','QUST')) |
MelString('DESC','descriptio'), | MelString('DESC','description'), | def loadData(self,record,ins,type,size,readId): if size == 4: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 3: unpacked = ins.unpack('BBB',size,readId) else: raise "Unexpected size encountered for TERM:DNAM subrecord: %s" % size unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def checkMasterCellBlockData(cellBlock): if not cellBlock.cell.flags1.ignored: fid = cellBlock.cell.fid if fid not in tempCellData: return if fid not in cellData: cellData[fid] = {} cellData[fid+('flags',)] = {} for attr in attrs: if tempCellData[fid][attr] != cellBlock.cell.__getattribute__(attr): cellData[fid][attr] = tempCellData[fid][attr] for flag in flags: if tempCellData[fid+('flags',)][flag] != cellBlock.cell.flags.__getattr__(flag): cellData[fid+('flags',)][flag] = tempCellData[fid+('flags',)][flag] |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceMods)) cachedMasters = {} for index,srcMod in enumerate(self.sourceMods): temp_id_data = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) masters = srcInfo.header.masters srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in srcFile.tops: continue self.srcClasses.add(recClass) self.classestemp.add(recClass) for record in srcFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) temp_id_data[fid] = dict((attr,record.__getattribute__(attr)) for attr in recAttrs) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in masterFile.tops: continue if recClass not in self.classestemp: continue for record in masterFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) if fid not in temp_id_data: continue for attr, value in temp_id_data[fid].iteritems(): if value == record.__getattribute__(attr): continue else: if fid not in id_data: id_data[fid] = dict() try: id_data[fid][attr] = temp_id_data[fid][attr] except KeyError: id_data[fid].setdefault(attr,value) progress.plus() temp_id_data = None self.longTypes = self.longTypes & set(x.classType for x in self.srcClasses) self.isActive = bool(self.srcClasses) |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,MreNpc,MreCrea) longTypes = self.longTypes & set(x.classType for x in self.actorClasses) progress.setFull(len(self.sourceMods)) cachedMasters = {} for index,srcMod in enumerate(self.sourceMods): temp_id_data = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) masters = srcInfo.header.masters srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for actorClass in self.actorClasses: if actorClass.classType not in srcFile.tops: continue self.srcClasses.add(actorClass) self.classestemp.add(actorClass) attrs = set(reduce(operator.add, (self.recAttrs_class[actorClass][bashKey] for bashKey in srcInfo.getBashTags() if bashKey in self.recAttrs_class[actorClass]))) for record in srcFile.tops[actorClass.classType].getActiveRecords(): fid = mapper(record.fid) temp_id_data[fid] = dict((attr,record.__getattribute__(attr)) for attr in attrs) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for actorClass in self.actorClasses: if actorClass.classType not in masterFile.tops: continue if actorClass not in self.classestemp: continue for record in masterFile.tops[actorClass.classType].getActiveRecords(): fid = mapper(record.fid) if fid not in temp_id_data: continue for attr, value in temp_id_data[fid].iteritems(): if value == record.__getattribute__(attr): continue else: if fid not in id_data: id_data[fid] = dict() try: id_data[fid][attr] = temp_id_data[fid][attr] except KeyError: id_data[fid].setdefault(attr,value) progress.plus() temp_id_data = None self.longTypes = self.longTypes & set(x.classType for x in self.srcClasses) self.isActive = bool(self.srcClasses) |
progress.setFull(len(self.srcMods)) | progress.setFull(1+len(self.srcMods)) | def initData(self,progress): """Get data from source files.""" OOOandUOP = False if GPath("Oscuro's_Oblivion_Overhaul.esm") in self.srcMods or GPath("Oscuro's_Oblivion_Overhaul.esp") in self.srcMods: if GPath("Unofficial Oblivion Patch.esp") in self.srcMods: OOOandUOP = True longTypes = self.longTypes loadFactory = LoadFactory(False,MreCrea,MreNpc) progress.setFull(len(self.srcMods)) cachedMasters = {} data = self.data for index,srcMod in enumerate(self.srcMods): tempData = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) masters = srcInfo.header.masters bashTags = srcInfo.getBashTags() srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for recClass in (MreNpc,MreCrea): if recClass.classType not in srcFile.tops: continue for record in srcFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) tempData[fid] = list(record.aiPackages) for master in reversed(masters): if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for block in (MreNpc, MreCrea): if block.classType not in srcFile.tops: continue if block.classType not in masterFile.tops: continue for record in masterFile.tops[block.classType].getActiveRecords(): fid = mapper(record.fid) if not fid in tempData: continue if record.aiPackages == tempData[fid] and not 'Actors.AIPackagesForceAdd' in bashTags: # if subrecord is identical to the last master then we don't care about older masters. del tempData[fid] continue if fid in data: if tempData[fid] == data[fid]['merged']: continue recordData = {'deleted':[],'merged':tempData[fid]} for pkg in list(record.aiPackages): if not pkg in tempData[fid]: recordData['deleted'].append(pkg) if not fid in data: data[fid] = recordData else: for pkg in recordData['deleted']: if pkg in data[fid]['merged']: data[fid]['merged'].remove(pkg) data[fid]['deleted'].append(pkg) if data[fid]['merged'] == []: for pkg in recordData['merged']: if pkg in data[fid]['deleted'] and not 'Actors.AIPackagesForceAdd' in bashTags: continue data[fid]['merged'].append(pkg) continue for index, pkg in enumerate(recordData['merged']): if not pkg in data[fid]['merged']: # so needs to be added... (unless deleted that is) # find the correct position to add and add. if pkg in data[fid]['deleted'] and not 'Actors.AIPackagesForceAdd' in bashTags: continue #previously deleted if index == 0: data[fid]['merged'].insert(0,pkg) #insert as first item elif index == (len(recordData['merged'])-1): data[fid]['merged'].append(pkg) #insert as last item else: #figure out a good spot to insert it based on next or last recognized item (ugly ugly ugly) i = index - 1 while i >= 0: if recordData['merged'][i] in data[fid]['merged']: slot = data[fid]['merged'].index(recordData['merged'][i])+1 data[fid]['merged'].insert(slot, pkg) break i -= 1 else: i = index + 1 while i != len(recordData['merged']): if recordData['merged'][i] in data[fid]['merged']: slot = data[fid]['merged'].index(recordData['merged'][i]) data[fid]['merged'].insert(slot, pkg) break i += 1 continue # Done with this package elif index == data[fid]['merged'].index(pkg) or (len(recordData['merged'])-index) == (len(data[fid]['merged'])-data[fid]['merged'].index(pkg)): continue #pkg same in both lists. else: #this import is later loading so we'll assume it is better order data[fid]['merged'].remove(pkg) if index == 0: data[fid]['merged'].insert(0,pkg) #insert as first item elif index == (len(recordData['merged'])-1): data[fid]['merged'].append(pkg) #insert as last item else: i = index - 1 while i >= 0: if recordData['merged'][i] in data[fid]['merged']: slot = data[fid]['merged'].index(recordData['merged'][i]) + 1 data[fid]['merged'].insert(slot, pkg) break i -= 1 else: i = index + 1 while i != len(recordData['merged']): if recordData['merged'][i] in data[fid]['merged']: slot = data[fid]['merged'].index(recordData['merged'][i]) data[fid]['merged'].insert(slot, pkg) break i += 1 if OOOandUOP: for pkg in recordData['merged']: if pkg[0] == bolt.Path("Oscuro's_Oblivion_Overhaul.esm"): if pkg[1] in [12892,12893,12894,12895,23921,23922,23926,40669,40671]: if pkg in data[fid]['merged']: data[fid]['merged'].remove(pkg) progress.plus() |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return self.classestemp = set() id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceMods)) cachedMasters = {} for index,srcMod in enumerate(self.sourceMods): temp_id_data = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) masters = srcInfo.header.masters srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in srcFile.tops: continue self.srcClasses.add(recClass) self.classestemp.add(recClass) for record in srcFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) temp_id_data[fid] = dict((attr,record.__getattribute__(attr)) for attr in recAttrs) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in masterFile.tops: continue if recClass not in self.classestemp: continue for record in masterFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) if fid not in temp_id_data: continue for attr, value in temp_id_data[fid].iteritems(): if value == record.__getattribute__(attr): continue else: if fid not in id_data: id_data[fid] = dict() try: id_data[fid][attr] = temp_id_data[fid][attr] except KeyError: id_data[fid].setdefault(attr,value) progress.plus() temp_id_data = None self.longTypes = self.longTypes & set(x.classType for x in self.srcClasses) self.isActive = bool(self.srcClasses) |
progress.setFull(len(self.srcFiles)) | progress.setFull(1+len(self.srcFiles)) | def initData(self,progress): """Get names from source files.""" if not self.isActive: return actorFactions = ActorFactions(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not in modInfos: continue srcInfo = modInfos[GPath(srcFile)] actorFactions.readFromMod(srcInfo) else: if srcPath not in patchesDir: continue actorFactions.readFromText(dirs['patches'].join(srcFile)) progress.plus() #--Finish id_factions= self.id_factions for type,aFid_factions in actorFactions.type_id_factions.iteritems(): if type not in ('CREA','NPC_'): continue self.activeTypes.append(type) for longid,factions in aFid_factions.iteritems(): self.id_factions[longid] = factions self.isActive = bool(self.activeTypes) |
progress.setFull(len(self.srcFiles)) | progress.setFull(1+len(self.srcFiles)) | def initData(self,progress): """Get names from source files.""" if not self.isActive: return factionRelations = FactionRelations(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not in modInfos: continue srcInfo = modInfos[GPath(srcFile)] factionRelations.readFromMod(srcInfo) else: if srcPath not in patchesDir: continue factionRelations.readFromText(dirs['patches'].join(srcFile)) progress.plus() #--Finish self.id_relations = factionRelations.id_relations self.isActive = bool(self.id_relations) |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get script links from source files.""" if not self.isActive: return self.classestemp = set() id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceMods)) cachedMasters = {} for index,srcMod in enumerate(self.sourceMods): temp_id_data = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) masters = srcInfo.header.masters srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in srcFile.tops: continue self.srcClasses.add(recClass) self.classestemp.add(recClass) for record in srcFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) temp_id_data[fid] = dict((attr,record.__getattribute__(attr)) for attr in recAttrs) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in masterFile.tops: continue if recClass not in self.classestemp: continue for record in masterFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) if fid not in temp_id_data: continue for attr, value in temp_id_data[fid].iteritems(): if value == record.__getattribute__(attr): continue else: if fid not in id_data: id_data[fid] = dict() try: id_data[fid][attr] = temp_id_data[fid][attr] except KeyError: id_data[fid].setdefault(attr,value) progress.plus() temp_id_data = None self.longTypes = self.longTypes & set(x.classType for x in self.srcClasses) self.isActive = bool(self.srcClasses) |
progress.setFull(len(self.srcMods)) | progress.setFull(1+len(self.srcMods)) | def initData(self,progress): """Get data from source files.""" if not self.isActive or not self.srcMods: return loadFactory = LoadFactory(False,'CREA','NPC_','CONT') progress.setFull(len(self.srcMods)) for index,srcMod in enumerate(self.srcMods): srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) srcFile.load(True) mapper = srcFile.getLongMapper() for block in (srcFile.CREA, srcFile.NPC_, srcFile.CONT): for record in block.getActiveRecords(): self.touched.add(mapper(record.fid)) progress.plus() |
progress.setFull(len(self.srcFiles)) | progress.setFull(1+len(self.srcFiles)) | def initData(self,progress): """Get names from source files.""" if not self.isActive: return fullNames = FullNames(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not in modInfos: continue srcInfo = modInfos[GPath(srcFile)] fullNames.readFromMod(srcInfo) else: if srcPath not in patchesDir: continue fullNames.readFromText(dirs['patches'].join(srcFile)) progress.plus() #--Finish id_full = self.id_full knownTypes = set(MreRecord.type_class.keys()) for type,id_name in fullNames.type_id_name.iteritems(): if type not in knownTypes: self.skipTypes.append(type) continue self.activeTypes.append(type) for longid,(eid,name) in id_name.iteritems(): if name != 'NO NAME': id_full[longid] = name self.isActive = bool(self.activeTypes) |
progress.setFull(len(self.faceMods)) | progress.setFull(1+len(self.faceMods)) | def initData(self,progress): """Get faces from Project Beauty files.""" if not self.isActive: return faceData = self.faceData loadFactory = LoadFactory(False,MreNpc) progress.setFull(len(self.faceMods)) cachedMasters = {} for index,faceMod in enumerate(self.faceMods): if faceMod not in modInfos: continue temp_faceData = {} faceInfo = modInfos[faceMod] faceFile = ModFile(faceInfo,loadFactory) masters = faceInfo.header.masters faceFile.load(True) faceFile.convertToLongFids(('NPC_',)) for npc in faceFile.NPC_.getActiveRecords(): if npc.fid[0] != faceMod: temp_faceData[npc.fid] = {} for attr in ('fggs_p','fgga_p','fgts_p','eye','hair','hairLength','hairRed','hairBlue','hairGreen','unused3','headParts','race'): temp_faceData[npc.fid][attr] = npc.__getattribute__(attr) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(('NPC_',)) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() if 'NPC_' not in masterFile.tops: continue for npc in masterFile.NPC_.getActiveRecords(): if npc.fid not in temp_faceData: continue for attr, value in temp_faceData[npc.fid].iteritems(): if value == npc.__getattribute__(attr): continue if npc.fid not in faceData: faceData[npc.fid] = dict() try: faceData[npc.fid][attr] = temp_faceData[npc.fid][attr] except KeyError: faceData[npc.fid].setdefault(attr,value) progress.plus() |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get cells from source files.""" if not self.isActive: return loadFactory = LoadFactory(False,MreCell,MreWrld,MreRoad) progress.setFull(len(self.sourceMods)) for srcMod in self.sourceMods: if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) srcFile.load(True) srcFile.convertToLongFids(('WRLD','ROAD')) for worldBlock in srcFile.WRLD.worldBlocks: if worldBlock.road: worldId = worldBlock.world.fid road = worldBlock.road.getTypeCopy() self.world_road[worldId] = road self.isActive = bool(self.world_road) |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get sounds from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceMods)) cachedMasters = {} for index,srcMod in enumerate(self.sourceMods): temp_id_data = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) bashTags = srcFile.fileInfo.getBashTags() masters = srcInfo.header.masters srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in srcFile.tops: continue self.srcClasses.add(recClass) self.classestemp.add(recClass) for record in srcFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) temp_id_data[fid] = dict((attr,record.__getattribute__(attr)) for attr in recAttrs) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in masterFile.tops: continue if recClass not in self.classestemp: continue for record in masterFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) if fid not in temp_id_data: continue for attr, value in temp_id_data[fid].iteritems(): if value == record.__getattribute__(attr): continue else: if fid not in id_data: id_data[fid] = dict() try: id_data[fid][attr] = temp_id_data[fid][attr] except KeyError: id_data[fid].setdefault(attr,value) progress.plus() temp_id_data = None self.longTypes = self.longTypes & set(x.classType for x in self.srcClasses) self.isActive = bool(self.srcClasses) |
progress.setFull(len(self.srcFiles)) | progress.setFull(1+len(self.srcFiles)) | def initData(self,progress): """Get stats from source files.""" if not self.isActive: return itemStats = ItemStats(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not in modInfos: continue srcInfo = modInfos[GPath(srcFile)] itemStats.readFromMod(srcInfo) else: if srcPath not in patchesDir: continue itemStats.readFromText(dirs['patches'].join(srcFile)) progress.plus() #--Finish id_stat = self.id_stat for type in itemStats.type_stats: typeStats = itemStats.type_stats[type] if typeStats: self.activeTypes.append(type) id_stat.update(typeStats) self.typeFields[type] = itemStats.type_attrs[type][1:] self.isActive = bool(self.activeTypes) |
progress.setFull(len(self.srcFiles)) | progress.setFull(1+len(self.srcFiles)) | def initData(self,progress): """Get stats from source files.""" if not self.isActive: return itemStats = SpellRecords(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not in modInfos: continue srcInfo = modInfos[GPath(srcFile)] itemStats.readFromMod(srcInfo) else: if srcPath not in patchesDir: continue itemStats.readFromText(dirs['patches'].join(srcFile)) progress.plus() #--Finish id_stat = self.id_stat for type in itemStats.type_stats: typeStats = itemStats.type_stats[type] if typeStats: self.activeTypes.append(type) id_stat.update(typeStats) self.typeFields[type] = itemStats.type_attrs[type][1:] self.isActive = bool(self.activeTypes) |
progress.setFull(len(self.sourceMods)) | progress.setFull(1+len(self.sourceMods)) | def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceMods)) cachedMasters = {} for index,srcMod in enumerate(self.sourceMods): temp_id_data = {} if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) bashTags = srcFile.fileInfo.getBashTags() masters = srcInfo.header.masters srcFile.load(True) srcFile.convertToLongFids(longTypes) mapper = srcFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in srcFile.tops: continue self.srcClasses.add(recClass) self.classestemp.add(recClass) for record in srcFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) temp_id_data[fid] = dict((attr,record.__getattribute__(attr)) for attr in recAttrs) for master in masters: if not master in modInfos: continue # or break filter mods if master in cachedMasters: masterFile = cachedMasters[master] else: masterInfo = modInfos[master] masterFile = ModFile(masterInfo,loadFactory) masterFile.load(True) masterFile.convertToLongFids(longTypes) cachedMasters[master] = masterFile mapper = masterFile.getLongMapper() for recClass,recAttrs in recAttrs_class.iteritems(): if recClass.classType not in masterFile.tops: continue if recClass not in self.classestemp: continue for record in masterFile.tops[recClass.classType].getActiveRecords(): fid = mapper(record.fid) if fid not in temp_id_data: continue for attr, value in temp_id_data[fid].iteritems(): if value == record.__getattribute__(attr): continue else: if fid not in id_data: id_data[fid] = dict() try: id_data[fid][attr] = temp_id_data[fid][attr] except KeyError: id_data[fid].setdefault(attr,value) progress.plus() temp_id_data = None self.longTypes = self.longTypes & set(x.classType for x in self.srcClasses) self.isActive = bool(self.srcClasses) |
progress.setFull(len(self.srcFiles)) | progress.setFull(1+len(self.srcFiles)) | def initData(self,progress): """Get names from source files.""" if not self.isActive: return progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if srcPath not in patchesDir: continue self.readFromText(dirs['patches'].join(srcFile)) progress.plus() |
Subsets and Splits