コード例 #1
0
ファイル: sources.py プロジェクト: spiralx/mypy
    def __init__(self, path, file_name):
        # Absolute path of file.
        self.path = utils.full_path(path, file_name)

        # Directory and name of file.
        self.dir_name, self.file_name = os.path.split(self.path)

        # Base name and extension.
        self.base_name, self.extension = utils.split_name(self.file_name)

        # Local URL of file.
        self.url = utils.file_name_to_url(self.path)

        # Valid identifier for HTML id attributes.
        self.id = re.sub(r"\W", "", self.base_name).lower()

        # Physical file info.
        self.file_info = os.stat(self.path)

        # Formatted info.
        self.size = "{0:,.2f}Mb".format(self.file_info.st_size / 1048576.0)
        self.date = datetime.fromtimestamp(self.file_info.st_ctime).strftime("%d/%m/%Y %H:%M")
コード例 #2
0
ファイル: sources.py プロジェクト: spiralx/mypy
    def __init__(self, path, file_name):
        super(Video, self).__init__(path, file_name)

        self.thumbnail = os.path.splitext(self.path)[0] + ".jpg"
        self.thumbnail_url = utils.file_name_to_url(self.thumbnail)