def doCommand(self, base, basecmd, extcmds): logger = logging.getLogger("yum.verbose.main") def msg(x): logger.log(logginglevels.INFO_2, x) def msg_warn(x): logger.warn(x) self._done_spkgs = {} self._pkgs = 0 self._spkgs = 0 self._changelogs = 0 self._since_all = False self._since_dto = None self._since_tt = None self._since_num = None if not len(extcmds): return 1, [basecmd + " " + self.getUsage()] since = extcmds[0] extcmds = extcmds[1:] if since == 'all': self._since_all = True else: try: num = int(since) if num <= 0: raise ValueError self._since_num = num except: if dateutil_parser is None: msg = "Dateutil module not available, so can't parse dates" raise PluginYumExit(msg) try: self._since_dto = dateutil_parser.parse(since, fuzzy=True) except ValueError: msg = "Argument -- %s -- is not \"all\", a positive number or a date" % since raise PluginYumExit(msg) try: tt = self._since_dto.timetuple() self._since_tt = time.mktime(tt) except ValueError, e: msg = "Argument -- %s -- is not valid: %s" % (since, to_str(e)) raise PluginYumExit(msg) if self._since_dto == dateutil_parser.parse('garbage', fuzzy=True): # 'since' was a package name, not a date extcmds.insert(0, since) # assume since="all" self._since_all = True self._since_dto = None self._since_tt = None
def fd__get_data(pkg, attr, strip=True): if not hasattr(pkg, attr): return fd__unknown val = getattr(pkg, attr) if val is None: return fd__unknown if type(val) == type([]): return fd__unknown tval = to_str(val).strip() if tval == "": return fd__unknown if strip: return to_utf8(tval) return val