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


Python DateTime.split方法代码示例

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


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

示例1: _createFolderStructure

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import split [as 别名]
    def _createFolderStructure(self, folder, structure='ymd', date=None):
        """ Create a folder structure and then return our innermost folder
        """
        if not date:
            date = DateTime()

        dateFormat = structure

        if '%B' in dateFormat:
            translation = getToolByName(self.context, 'translation_service')
            PLMF = MessageFactory('plonelocales')
            dateFormat = dateFormat.replace('%B', '%m')
            date = date.strftime(dateFormat)
            folderStructure = [str(p) for p in date.split('/')]
            index = dateFormat.split('/').index('%m')
            month_msgid = PLMF(translation.month_msgid(folderStructure[index]))
            try:
                target_language = i18n.negotiate(self.context.REQUEST)
            except:
                target_language = None
            transale_month = translate(month_msgid, target_language=target_language)
            folderStructure[index] = transale_month
        else:
            date = date.strftime(dateFormat)
            folderStructure = [str(p) for p in date.split('/')]

        container = self.element.container
        language = folder.Language()
        normalizer = getUtility(IIDNormalizer)

        portal_workflow = getToolByName(self.context, 'portal_workflow')
        pw = portal_workflow.doActionFor

        # We run IRuleExecutor here to make sure other rules will be
        # executed for the newly created folders
        executor = IRuleExecutor(self.context, None)
        for fId in folderStructure:
            fTitle = fId
            fId = normalizer.normalize(fId)
            if not fId in folder.objectIds():
                _createObjectByType(container, folder, id=normalizer.normalize(fId),
                                    title=fTitle, description=fTitle)
                folder = folder[fId]
                pw(folder, 'publish')
                # this makes happy multilang sites
                folder.setLanguage(language)
                event = ObjectAddedEvent(folder, aq_parent(folder), fId)
                if executor is not None:
                    executor(event)
            else:
                folder = folder[fId]
        return folder
开发者ID:aquinocom,项目名称:sc.contentrules.groupbydate,代码行数:54,代码来源:groupbydate.py

示例2: _checkType

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import split [as 别名]
 def _checkType(self, obj, prop, type, value):
     """
     @param obj: the object returned in the caller from getObject(uid)
     @param prop: the id, zProperty, or cProperty
     @param type: the type of property value
     @param value: the value itself
     """
     # make sure it is the correct type
     ztype = obj.getPropertyType(prop)
     if ztype == 'int':
         value = int(value)
     if ztype == 'float':
         value = float(value)
     if ztype == 'string':
         value = str(value)
     if ztype == 'date':
         value = value.replace('%20', ' ') # Ugh. Manually decode spaces
         value = DateTime(value)
     if ztype == "lines" and isinstance(value, basestring):
         if value:
             value = value.split("\n")
         else:
             # if there is an empty string passed in save it as an empty array
             value = []
     return value
开发者ID:bbc,项目名称:zenoss-prodbin,代码行数:27,代码来源:propertiesfacade.py

示例3: _createFolderStructure

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import split [as 别名]
    def _createFolderStructure(self, folder, structure='ymd', date=None):
        """ Create a folder structure and then return our innermost folder
        """
        if not date:
            date = DateTime()

        dateFormat = structure

        date = date.strftime(dateFormat)

        folderStructure = [str(p) for p in date.split('/')]

        container = self.element.container
        language = folder.Language()
        # We run IRuleExecutor here to make sure other rules will be
        # executed for the newly created folders
        executor = IRuleExecutor(self.context, None)
        for fId in folderStructure:
            if fId not in folder.objectIds():
                _createObjectByType(container, folder, id=fId,
                                    title=fId, description=fId)
                folder = folder[fId]
                # this makes happy multilang sites
                folder.setLanguage(language)
                event = ObjectAddedEvent(folder, aq_parent(folder), fId)
                if executor is not None:
                    executor(event)
            else:
                folder = folder[fId]
        return folder
开发者ID:collective,项目名称:sc.contentrules.groupbydate,代码行数:32,代码来源:groupbydate.py

示例4: process_form

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import split [as 别名]
    def process_form(self, instance, field, form, empty_marker=None):
        """Basic impl for form processing in a widget"""

        value = form.get(field.getName(), None)
        if not value:
            return empty_marker

        try:
            value = DateTime(datetime(*map(int, value.split('-'))))
        except:
            return empty_marker

        return value, {}
开发者ID:ampsport,项目名称:plone.app.widgets,代码行数:15,代码来源:at.py

示例5: _createFolderStructure

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import split [as 别名]
    def _createFolderStructure(self, folder, structure='ymd', date=None):
        ''' Create a folder structure and then return our innermost folder
        '''
        if not date:
            date = DateTime()

        # BBB:to avoid breaking old rules
        if structure in [k for k, v in STRUCTURES]:
            if structure == 'ymd':
                dateFormat = '%Y/%m/%d'
            elif structure == 'ym':
                dateFormat = '%Y/%m'
            elif structure == 'y':
                dateFormat = '%Y'
        else:
            # Create a list stating if the folder should be hiddden from 
            # navigation
            should_exclude = ['ee' in i for i in structure.split('/')]
            # Now remove all the 'h' that may be in the structure
            dateFormat = structure.replace('ee','')

        date = date.strftime(dateFormat)

        folderStructure = [str(p) for p in date.split('/')]

        container = self.element.container
        default_view = self.element.default_view
        for (fId, exclude) in zip(folderStructure, should_exclude):
            if not fId in folder.objectIds():
                _createObjectByType(container, folder, id=fId,
                                    title=fId, description=fId)
                folder = folder[fId]
                folder.setLayout(default_view)
                self._addWorkflowPolicy(folder)
                if exclude:
                    folder.setExcludeFromNav(True)
            else:
                folder = folder[fId]
        return folder
开发者ID:frapell,项目名称:sc.contentrules.groupbydate,代码行数:41,代码来源:groupbydate.py

示例6: _checkType

# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import split [as 别名]
 def _checkType(self, obj, prop, type, value):
     """
     @param obj: the object returned in the caller from getObject(uid)
     @param prop: the id, zProperty, or cProperty
     @param type: the type of property value
     @param value: the value itself
     """
     # make sure it is the correct type
     ztype = obj.getPropertyType(prop)
     if ztype == 'int':
         try:
             value = int(value)
         except ValueError:
             raise Exception('Invalid value entered for {}'.format(prop))
     if ztype == 'float':
         value = float(value)
     if ztype == 'string':
         value = str(value)
     if ztype == 'date':
         value = value.replace('%20', ' ')  # Ugh. Manually decode spaces
         value = DateTime(value)
     if ztype == "lines" and isinstance(value, basestring):
         value = value.split("\n") if value else []
     return value
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:26,代码来源:propertiesfacade.py


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