当前位置: 首页>>代码示例>>Python>>正文


Python Path.ctime方法代码示例

本文整理汇总了Python中unipath.Path.ctime方法的典型用法代码示例。如果您正苦于以下问题:Python Path.ctime方法的具体用法?Python Path.ctime怎么用?Python Path.ctime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unipath.Path的用法示例。


在下文中一共展示了Path.ctime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: objects

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import ctime [as 别名]
def objects():

    Project = rt.models.tickets.Project
    Ticket = rt.models.tickets.Ticket
    TicketStates = rt.models.tickets.TicketStates

    prj = Project(name="Lino")
    yield prj

    settings.SITE.loading_from_dump = True

    for ln in TICKETS.splitlines():
        ln = ln.strip()
        if ln:
            a = ln.split(':')
            state = TicketStates.accepted
            a2 = []
            for i in a:
                if '[closed]' in i:
                    state = TicketStates.closed
                i = i.replace('[closed]', '')
                a2.append(i.strip())
            num = a2[0][1:]
            title = a2[1]

            import lino
            fn = Path(lino.__file__).parent.parent.child('docs', 'tickets')
            fn = fn.child(num + '.rst')
            kw = dict()
            kw.update(created=datetime.datetime.fromtimestamp(fn.ctime()))
            kw.update(modified=datetime.datetime.fromtimestamp(fn.mtime()))
            kw.update(id=int(num), summary=title, project=prj, state=state)
            logger.info("%s %s", fn, kw['modified'])
            kw.update(description=fn.read_file())
            # fd = open(fn)
            yield Ticket(**kw)
开发者ID:lino-framework,项目名称:noi,代码行数:38,代码来源:linotickets.py

示例2: print

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import ctime [as 别名]
print("\n*** Expand, Expand User and Expand Vars")
print(Path("~").expand_user())  # Expands ~ to a absolute path name
print(Path("$HOME").expand_vars())  # Expands system variables
print(Path("/home/luke/..").norm())  # Expands .. and . notation
print(Path("$HOME/..").expand())  # Expands system variables, ~ and also ..


# Expands system variable and ~. Will also normalise the path ( remove redundant
# .. . incorrect slashes and correct capitalisation on case sensitive file systems. Calls os.path.normpath

# File Attributes and permissions
print("\n*** File Attributes and permissions")
# noinspection PyArgumentList
print(here.atime())  # Last access time; seconds past epcoh
# noinspection PyArgumentList
print(here.ctime())  # Last permission or ownership modification; windows is creation time;
# noinspection PyArgumentList
print(here.isfile())  # Is a file; symbolic links are followed.
print(here.isdir())  # Is a directory; symbolic links are followed.
# noinspection PyArgumentList
print(here.islink())  # Is a symbolic link
# noinspection PyArgumentList
print(here.ismount())  # Is a mount point; ie the parent is on a different device.
# noinspection PyArgumentList
print(here.exists())  # File exists; symbolic links are followed.
# noinspection PyArgumentList
print(here.lexists())  # Same as exists but symbolic links are not followed.
# noinspection PyArgumentList
print(here.size())  # File size in bytes.
print(Path("/foo").isabsolute())  # Is absolute and not relative path
开发者ID:lukewickstead,项目名称:PythonPit,代码行数:32,代码来源:unipath_example.py

示例3: __get_image_tag

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import ctime [as 别名]
    def __get_image_tag(self, image):
        """
        Get a path to a image file and return the tags to sort this image
        :param image: (str or unipath.Path) path to an image file
        :return: (tuple) with the tags to sort the image
        """

        # load sorting methods
        criteria = [self.sort]
        if self.sub_sorts:
            criteria.extend(self.sub_sorts)
        full_tags = list()

        # find all tags
        for criterion in criteria:

            # method for size
            if criterion == 'size':
                image_properties = dimensions(str(image))
                tag = '{}x{}'.format(image_properties[0], image_properties[1])
                full_tags.append(self.__image_tag(tag))

            # method for date
            if criterion == 'date':

                # set possible date exif keys
                keys = ['Image DateTime',
                        'EXIF DateTimeDigitized',
                        'GPS GPSDate']

                # fetch the key values
                with open(image, 'r') as file_handler:
                    exif = process_file(file_handler)
                    for key in keys:
                        tag = exif.get(key, False)
                        if tag:
                            break
                    if not tag:
                        file_path = Path(image)
                        tag = strftime('%Y:%m:%d', localtime(file_path.ctime()))

                # create sub tags
                tag = str(tag)
                if tag != 'Undefined Date':
                    if len(tag.strip()) > 10:
                        date_tag = datetime.strptime(tag, '%Y:%m:%d %H:%M:%S')
                    else:
                        date_tag = datetime.strptime(tag, '%Y:%m:%d')
                    for sub_tag in ['%Y', '%m', '%d']:
                        formatted = date_tag.strftime(sub_tag)
                        full_tags.append(self.__image_tag(formatted, True))
                else:
                    full_tags.append(self.__image_tag(tag))

            # method for origin
            if criterion == 'origin':

                # fetch the key values
                with open(image, 'r') as file_handler:

                    # get info
                    exif = process_file(file_handler)
                    model = exif.get('Image Model', False)
                    software = exif.get('Image Software', False)
                    make = exif.get('Image Make', False)

                    # if software is just a version number, skip it
                    regex = compile('[^a-zA-Z]+')
                    test = str(software)
                    if len(regex.sub('', test.replace('Camera', ''))) == 0:
                        software = False

                    # generate tag
                    if model and software:
                        tag = '{} - {}'.format(model, software)
                    elif model:
                        tag = str(model)
                    elif software:
                        tag = str(software)
                    elif make:
                        tag = str(make)
                    else:
                        tag = 'Undefined Origin'

                # append tag
                full_tags.append(self.__image_tag(tag))

        return tuple(full_tags)
开发者ID:cuducos,项目名称:sortimages,代码行数:90,代码来源:sortimages.py


注:本文中的unipath.Path.ctime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。