コード例 #1
0
 def makeDataProducts(self, files, unbanish=False, unignore=False):
     """makes a list of DPs from a list of (filename,quiet) pairs.
     If unbanish is False, DPs with a default "banish" policy will be skipped.
     Symlinks will be resolved, and non-unique filenames removed from list.
     """
     paths = set()
     dps = []
     for filename, quiet in files:
         filename = filename.rstrip('/')
         sourcepath = Purr.canonizePath(filename)
         if sourcepath not in paths:
             paths.add(sourcepath)
             filename = os.path.basename(filename)
             policy, filename, comment = self._default_dp_props.get(
                 filename, ("copy", filename, ""))
             dprintf(4, "%s: default policy is %s,%s,%s\n", sourcepath,
                     policy, filename, comment)
             if policy == "banish":
                 if unbanish:
                     policy = "copy"
                 else:
                     continue
             if unignore and policy == "ignore":
                 policy = "copy"
             dps.append(
                 Purr.DataProduct(filename=filename,
                                  sourcepath=sourcepath,
                                  policy=policy,
                                  comment=comment,
                                  quiet=quiet))
     return sorted(dps, lambda a, b: cmp(a.filename, b.filename))
コード例 #2
0
 def _handle_start_DP(self,
                      filename=None,
                      src=None,
                      policy=None,
                      quiet=False,
                      timestamp=0,
                      comment=None,
                      render=None,
                      **kw):
     # dispence with previous DP tag, if any
     self._add_data_product()
     # setup data for this tag
     comment = comment or ""
     try:
         timestamp = float(timestamp)
     except:
         timestamp = time.time()
     if not isinstance(quiet, bool):
         try:
             quiet = bool(int(quiet))
         except:
             quiet = bool(quiet)
     comment = comment.replace("&lt;", "<").replace("&gt;", ">")
     self._new_dp = Purr.DataProduct(filename=filename,
                                     sourcepath=src,
                                     timestamp=timestamp,
                                     comment=comment,
                                     fullpath=os.path.join(
                                         self._dirname, filename or ""),
                                     policy=policy,
                                     render=render,
                                     quiet=quiet,
                                     archived=True)