Exemple #1
0
class MetaInfo:
    def __init__(self, protect=None, mod_ts=None, comment=None):
        self.set_protect(protect)
        self.set_mod_ts(mod_ts)
        self.set_comment(comment)

    def __str__(self):
        res = []
        res.append(self.get_protect_str())
        res.append(self.get_time_str())
        res.append(self.get_comment_str())
        return "  ".join(res)

    def get_time_str(self):
        if self.mod_ts != None:
            return str(self.mod_ts)
        else:
            return ts_empty_string

    def get_protect_str(self):
        if self.protect_flags != None:
            return str(self.protect_flags)
        else:
            return ProtectFlags.empty_string

    def get_comment_str(self):
        if self.comment != None:
            return self.comment
        else:
            return ""

    def set_protect(self, protect):
        self.protect = protect
        if self.protect != None:
            self.protect_flags = ProtectFlags(protect)
        else:
            self.protect_flags = None

    def set_default_protect(self):
        self.protect = 0
        self.protect_flags = ProtectFlags(self.protect)

    def set_current_time(self):
        mod_time = time.mktime(time.localtime())
        self.set_mod_time(mod_time)

    def set_mod_time(self, mod_time):
        self.mod_time = mod_time
        if self.mod_time != None:
            self.mod_ts = TimeStamp()
            self.mod_ts.from_secs(mod_time)
        else:
            self.mod_ts = None

    def set_mod_ts(self, mod_ts):
        self.mod_ts = mod_ts
        if self.mod_ts != None:
            self.mod_time = self.mod_ts.get_secsf()
        else:
            self.mod_time = None

    def set_comment(self, comment):
        self.comment = comment

    def get_protect(self):
        return self.protect

    def get_protect_flags(self):
        return self.protect_flags

    def get_mod_time(self):
        return self.mod_time

    def get_mod_ts(self):
        return self.mod_ts

    def get_comment(self):
        return self.comment
Exemple #2
0
class RootMetaInfo:
  def __init__(self, create_ts=None, disk_ts=None, mod_ts=None):
    self.set_create_ts(create_ts)
    self.set_disk_ts(disk_ts)
    self.set_mod_ts(mod_ts)
  
  def __str__(self):
    res = []
    res.append(self.get_create_time_str())
    res.append(self.get_disk_time_str())
    res.append(self.get_mod_time_str())
    return "  ".join(res)
      
  # create_ts
  def set_create_time(self, create_time):
    self.create_time = create_time
    if self.create_time != None:
      self.create_ts = TimeStamp()
      self.create_ts.from_secs(create_time)
    else:
      self.create_ts = None
  
  def set_create_ts(self, create_ts):
    self.create_ts = create_ts
    if self.create_ts != None:
      self.create_time = self.create_ts.get_secsf()
    else:
      self.create_time = None
  
  def get_create_time(self):
    return self.create_time
  
  def get_create_ts(self):
    return self.create_ts

  def get_create_time_str(self):
    if self.create_ts != None:
      return str(self.create_ts)
    else:
      return ts_empty_string

  def set_current_as_create_time(self):
    create_time = time.mktime(time.localtime())
    self.set_create_time(create_time)

  # disk_ts
  def set_disk_time(self, disk_time):
    self.disk_time = disk_time
    if self.disk_time != None:
      self.disk_ts = TimeStamp()
      self.disk_ts.from_secs(disk_time)
    else:
      self.disk_ts = None
  
  def set_disk_ts(self, disk_ts):
    self.disk_ts = disk_ts
    if self.disk_ts != None:
      self.disk_time = self.disk_ts.get_secsf()
    else:
      self.disk_time = None
  
  def get_disk_time(self):
    return self.disk_time
  
  def get_disk_ts(self):
    return self.disk_ts

  def get_disk_time_str(self):
    if self.disk_ts != None:
      return str(self.disk_ts)
    else:
      return ts_empty_string

  def set_current_as_disk_time(self):
    disk_time = time.mktime(time.localtime())
    self.set_disk_time(disk_time)

  # mod_ts
  def set_mod_time(self, mod_time):
    self.mod_time = mod_time
    if self.mod_time != None:
      self.mod_ts = TimeStamp()
      self.mod_ts.from_secs(mod_time)
    else:
      self.mod_ts = None
  
  def set_mod_ts(self, mod_ts):
    self.mod_ts = mod_ts
    if self.mod_ts != None:
      self.mod_time = self.mod_ts.get_secsf()
    else:
      self.mod_time = None
  
  def get_mod_time(self):
    return self.mod_time
  
  def get_mod_ts(self):
    return self.mod_ts
  
  def get_mod_time_str(self):
    if self.mod_ts != None:
      return str(self.mod_ts)
    else:
      return ts_empty_string
 
  def set_current_as_mod_time(self):
    mod_time = time.mktime(time.localtime())
    self.set_mod_time(mod_time)
Exemple #3
0
class MetaInfo:
  def __init__(self, protect=None, mod_ts=None, comment=None):
    self.set_protect(protect)
    self.set_mod_ts(mod_ts)
    self.set_comment(comment)
  
  def __str__(self):
    res = []
    res.append(self.get_protect_str())
    res.append(self.get_time_str())
    res.append(self.get_comment_str())
    return "  ".join(res)
    
  def get_time_str(self):
    if self.mod_ts != None:
      return str(self.mod_ts)
    else:
      return ts_empty_string
      
  def get_protect_str(self):
    if self.protect_flags != None:
      return str(self.protect_flags)
    else:
      return ProtectFlags.empty_string
      
  def get_comment_str(self):
    if self.comment != None:
      return self.comment
    else:
      return ""
  
  def set_protect(self, protect):
    self.protect = protect
    if self.protect != None:
      self.protect_flags = ProtectFlags(protect)
    else:
      self.protect_flags = None
  
  def set_default_protect(self):
    self.protect = 0
    self.protect_flags = ProtectFlags(self.protect)
  
  def set_current_time(self):
    mod_time = time.mktime(time.localtime())
    self.set_mod_time(mod_time)
    
  def set_mod_time(self, mod_time):
    self.mod_time = mod_time
    if self.mod_time != None:
      self.mod_ts = TimeStamp()
      self.mod_ts.from_secs(mod_time)
    else:
      self.mod_ts = None
  
  def set_mod_ts(self, mod_ts):
    self.mod_ts = mod_ts
    if self.mod_ts != None:
      self.mod_time = self.mod_ts.get_secsf()
    else:
      self.mod_time = None
  
  def set_comment(self, comment):
    self.comment = comment
  
  def get_protect(self):
    return self.protect
  
  def get_protect_flags(self):
    return self.protect_flags
  
  def get_mod_time(self):
    return self.mod_time

  def get_mod_ts(self):
    return self.mod_ts
  
  def get_comment(self):
    return self.comment
class MetaInfo:
  def __init__(self, protect=None, mod_ts=None, comment=None, protect_flags=None):
    if protect_flags != None:
      self.set_protect_flags(protect_flags)
    else:
      self.set_protect(protect)
    self.set_mod_ts(mod_ts)
    self.set_comment(comment)
  
  def get_str_line(self):
    """Return a unicode string with protect flags, mod time and (optional) comment"""
    res = []
    res.append(self.get_protect_str())
    res.append(self.get_mod_time_str())
    comment = self.get_comment()
    if comment == None:
      res.append(u'')
    else:
      res.append(self.get_comment().get_unicode())
    return u'  '.join(res)
    
  def get_mod_time_str(self):
    if self.mod_ts != None:
      return str(self.mod_ts)
    else:
      return ts_empty_string
      
  def get_protect_str(self):
    if self.protect_flags != None:
      return str(self.protect_flags)
    else:
      return ProtectFlags.empty_string
      
  def get_protect_short_str(self):
    if self.protect_flags != None:
      return self.protect_flags.short_str()
    else:
      return ""
      
  def set_protect(self, protect):
    self.protect = protect
    if self.protect != None:
      self.protect_flags = ProtectFlags(protect)
    else:
      self.protect_flags = None
  
  def set_protect_flags(self, pf):
    self.protect_flags = pf
    self.protect = pf.mask
  
  def set_default_protect(self):
    self.protect = 0
    self.protect_flags = ProtectFlags(self.protect)
  
  def set_current_as_mod_time(self):
    mod_time = time.mktime(time.localtime())
    self.set_mod_time(mod_time)
    
  def set_mod_time(self, mod_time):
    self.mod_time = mod_time
    if self.mod_time != None:
      self.mod_ts = TimeStamp()
      self.mod_ts.from_secs(mod_time)
    else:
      self.mod_ts = None
  
  def set_mod_ts(self, mod_ts):
    self.mod_ts = mod_ts
    if self.mod_ts != None:
      self.mod_time = self.mod_ts.get_secsf()
    else:
      self.mod_time = None
  
  def set_comment(self, comment):
    """Set comment as a FSString"""
    if comment != None and not isinstance(comment, FSString):
      raise ValueError("Comment must be a FSString")
    self.comment = comment
  
  def get_protect(self):
    return self.protect
  
  def get_protect_flags(self):
    return self.protect_flags
  
  def get_mod_time(self):
    return self.mod_time

  def get_mod_ts(self):
    return self.mod_ts

  def get_comment(self):
    return self.comment

  def get_comment_ami_str(self):
    if self.comment != None:
      return self.comment.get_ami_str()
    else:
      return ""
  
  def get_comment_unicode_str(self):
    if self.comment != None:
      return self.comment.get_unicode()
    else:
      return u""
Exemple #5
0
class MetaInfo:
    def __init__(self,
                 protect=None,
                 mod_ts=None,
                 comment=None,
                 protect_flags=None):
        if protect_flags != None:
            self.set_protect_flags(protect_flags)
        else:
            self.set_protect(protect)
        self.set_mod_ts(mod_ts)
        self.set_comment(comment)

    def get_str_line(self):
        """Return a unicode string with protect flags, mod time and (optional) comment"""
        res = []
        res.append(self.get_protect_str())
        res.append(self.get_mod_time_str())
        comment = self.get_comment()
        if comment == None:
            res.append(u'')
        else:
            res.append(self.get_comment().get_unicode())
        return u'  '.join(res)

    def get_mod_time_str(self):
        if self.mod_ts != None:
            return str(self.mod_ts)
        else:
            return ts_empty_string

    def get_protect_str(self):
        if self.protect_flags != None:
            return str(self.protect_flags)
        else:
            return ProtectFlags.empty_string

    def get_protect_short_str(self):
        if self.protect_flags != None:
            return self.protect_flags.short_str()
        else:
            return ""

    def set_protect(self, protect):
        self.protect = protect
        if self.protect != None:
            self.protect_flags = ProtectFlags(protect)
        else:
            self.protect_flags = None

    def set_protect_flags(self, pf):
        self.protect_flags = pf
        self.protect = pf.mask

    def set_default_protect(self):
        self.protect = 0
        self.protect_flags = ProtectFlags(self.protect)

    def set_current_as_mod_time(self):
        mod_time = time.mktime(time.localtime())
        self.set_mod_time(mod_time)

    def set_mod_time(self, mod_time):
        self.mod_time = mod_time
        if self.mod_time != None:
            self.mod_ts = TimeStamp()
            self.mod_ts.from_secs(mod_time)
        else:
            self.mod_ts = None

    def set_mod_ts(self, mod_ts):
        self.mod_ts = mod_ts
        if self.mod_ts != None:
            self.mod_time = self.mod_ts.get_secsf()
        else:
            self.mod_time = None

    def set_comment(self, comment):
        """Set comment as a FSString"""
        if comment != None and not isinstance(comment, FSString):
            raise ValueError("Comment must be a FSString")
        self.comment = comment

    def get_protect(self):
        return self.protect

    def get_protect_flags(self):
        return self.protect_flags

    def get_mod_time(self):
        return self.mod_time

    def get_mod_ts(self):
        return self.mod_ts

    def get_comment(self):
        return self.comment

    def get_comment_ami_str(self):
        if self.comment != None:
            return self.comment.get_ami_str()
        else:
            return ""

    def get_comment_unicode_str(self):
        if self.comment != None:
            return self.comment.get_unicode()
        else:
            return u""