Describe all packages/Source Code

From SimsWiki
Jump to: navigation, search


This page contains a code in R that describes (in a human-readable, text list) all packages.

Use at your own risk. Any comments please use the Talk:Describe all packages/Source Code page.


In order to run this function, the user must load (using the "source" function) the script in Detect Pets Body Shop bug/Source Code.

# The next routine opens _all_ package files since
# some date and displays package name and description
# start_date must be passed as an ISO-8601 string.
describe_all_packages <- function(start_date = "2005-01-01")
  # create vector with all filenames that end in .package
  item_list <- c("category", "age", "gender", "outfit")
  s_date <- as.POSIXlt(start_date, "GMT")
  fnlist <- list.files(pattern = ".package$") 
  cat("item_list = (", item_list, ")\n")
  for (i in 1:length(fnlist)) {
    filename <- fnlist[i]
    # get modification time of package
    m_date  <- as.POSIXlt($mtime, "GMT")
    # skip if package is older than start date
    if (m_date < s_date)
      next  # in C or similar languages, this would be a continue
    # now let's do the hard work
    x <- try(read_package(filename, get.str = T, get.everything = F))
    # there should be some sanity checks here!
    if (is.null(x)) {
      cat(filename, "seems to have another error\n")
    if (is.null(x$files)) next
    cat(filename, " ")
    if (!is.null(x$property.set) & !is.null(x$property.set$human)) {
      prop <- ""
      for (item in item_list) {
        if (!is.null(x$property.set$human[[item]]))
          prop <- sprintf("%s %s=%X", prop, item, x$property.set$human[[item]])
      cat("(", prop, " ) ", sep="")
    for (i in 1:length(x$files)) {
      if (x$index[[i]]$ == "53545223") {
        cat(x$files[[i]]$human, " ")
  # done
  cat("Total of", length(fnlist), "files processed\n")

See Also

Personal tools

game select