• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tools.strip函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tools.strip函数的典型用法代码示例。如果您正苦于以下问题:Python strip函数的具体用法?Python strip怎么用?Python strip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _parseInput

    def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=None, note=None):
        result = {"title": title, "content": content, "tags": tags, "notebook": notebook, "resources": resources}
        result = tools.strip(result)

        # if get note without params
        if note and title is None and content is None and tags is None and notebook is None:
            content = config.EDITOR_OPEN

        if title is None and note:
            result["title"] = note.title

        if content:
            if content != config.EDITOR_OPEN:
                if isinstance(content, str) and os.path.isfile(content):
                    logging.debug("Load content from the file")
                    content = open(content, "r").read()

                logging.debug("Convert content")
                content = Editor.textToENML(content)
            result["content"] = content

        if tags:
            result["tags"] = tools.strip(tags.split(","))

        if notebook:
            notepadGuid = Notebooks().getNoteGUID(notebook)
            if notepadGuid is None:
                newNotepad = Notebooks().create(notebook)
                notepadGuid = newNotepad.guid

            result["notebook"] = notepadGuid
            logging.debug("Search notebook")

        return result
开发者ID:Gems,项目名称:geeknote,代码行数:34,代码来源:geeknote.py


示例2: __init__

 def __init__(self, pos, *groups):
     super(Player, self).__init__(*groups)
     self.pos = pos        
     self.move_keys = {
             pg.K_LEFT: "left",
             pg.K_RIGHT: "right",
             pg.K_DOWN: "down",
             pg.K_UP: "up"}
     self.direct_to_velocity = {
             "left": (-1, 0),
             "right": (1, 0),
             "down": (0, 1),
             "up": (0, -1)}
     self.direction_stack = []
     self.direction = "left"
     self.last_direction = self.direction
     img_size = (32, 36)
     self.image_dict = {
             "left": cycle(strip(GFX["ranger_f"], (0, 108), img_size, 3)), 
             "right": cycle(strip(GFX["ranger_f"], (0,36), img_size, 3)), 
             "down": cycle(strip(GFX["ranger_f"], (0, 72), img_size, 3)), 
             "up": cycle(strip(GFX["ranger_f"], (0, 0), img_size, 3))}
     self.images = self.image_dict[self.direction]
     self.image = next(self.images)
     self.rect = self.image.get_rect(center=self.pos)
     self.frame_time = 60
     self.frame_timer = 0
     self.speed = .1
     self.footprint = pg.Rect(0, 0, 30, 6)
     self.footprint.midbottom = self.rect.midbottom
开发者ID:paddypolson,项目名称:Foggy,代码行数:30,代码来源:player.py


示例3: _createSearchRequest

    def _createSearchRequest(self, search=None, tags=None,
                             notebooks=None, date=None,
                             exact_entry=None, content_search=None):

        request = ""
        if notebooks:
            for notebook in tools.strip(notebooks.split(',')):
                if notebook.startswith('-'):
                    request += '-notebook:"%s" ' % tools.strip(notebook[1:])
                else:
                    request += 'notebook:"%s" ' % tools.strip(notebook)

        if tags:
            for tag in tools.strip(tags.split(',')):

                if tag.startswith('-'):
                    request += '-tag:"%s" ' % tag[1:]
                else:
                    request += 'tag:"%s" ' % tag

        if date:
            date = tools.strip(date.split('-'))
            try:
                dateStruct = time.strptime(date[0] + " 00:00:00", "%d.%m.%Y %H:%M:%S")
                request += 'created:%s ' % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct)))
                if len(date) == 2:
                    dateStruct = time.strptime(date[1] + " 00:00:00", "%d.%m.%Y %H:%M:%S")
                request += '-created:%s ' % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct) + 60 * 60 * 24))
            except ValueError, e:
                out.failureMessage('Incorrect date format in --date attribute. '
                                   'Format: %s' % time.strftime("%d.%m.%Y", time.strptime('19991231', "%Y%m%d")))
                return tools.exitErr()
开发者ID:khapota,项目名称:geeknote,代码行数:32,代码来源:geeknote.py


示例4: _parseInput

    def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=[], note=None, reminder=None):
        result = {
            "title": title,
            "content": content,
            "tags": tags,
            "notebook": notebook,
            "resources": resources,
            "reminder": reminder,
        }
        result = tools.strip(result)

        # if get note without params
        if note and title is None and content is None and tags is None and notebook is None:
            content = config.EDITOR_OPEN

        if title is None and note:
            result['title'] = note.title

        if content:
            if content != config.EDITOR_OPEN:
                if isinstance(content, str) and os.path.isfile(content):
                    logging.debug("Load content from the file")
                    content = open(content, "r").read()

                logging.debug("Convert content")
                content = Editor.textToENML(content)
            result['content'] = content

        if tags:
            result['tags'] = tools.strip(tags.split(','))

        if notebook:
            notepadGuid = Notebooks().getNoteGUID(notebook)
            if notepadGuid is None:
                newNotepad = Notebooks().create(notebook)
                notepadGuid = newNotepad.guid

            result['notebook'] = notepadGuid
            logging.debug("Search notebook")

        if reminder:
            then = config.REMINDER_SHORTCUTS.get(reminder)
            if then:
                now = int(round(time.time() * 1000))
                result['reminder'] = now + then
            elif reminder not in [config.REMINDER_NONE, config.REMINDER_DONE, config.REMINDER_DELETE]:
                reminder = tools.strip(reminder.split('-'))
                try:
                    dateStruct = time.strptime(reminder[0] + " " + reminder[1] + ":00", config.DEF_DATE_AND_TIME_FORMAT)
                    reminderTime = int(round(time.mktime(dateStruct) * 1000))
                    result['reminder'] = reminderTime
                except (ValueError, IndexError):
                    out.failureMessage('Incorrect date format in --reminder attribute. '
                                       'Format: %s' % time.strftime(config.DEF_DATE_FORMAT, time.strptime('199912311422', "%Y%m%d%H%M")))
                    return tools.exitErr()

        return result
开发者ID:IntrepidSuccess,项目名称:geeknote,代码行数:57,代码来源:geeknote.py


示例5: _parseInput

    def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=None, note=None):
        result = {
            "title": title,
            "content": content,
            "tags": tags,
            "notebook": notebook,
            "resources": resources if resources else []
        }
        result = tools.strip(result)

        # if get note without params
        if note and title is None and content is None and tags is None and notebook is None:
            content = config.EDITOR_OPEN

        if title is None and note:
            result['title'] = note.title

        if content:
            if content == config.EDITOR_OPEN:
                logging.debug("launch system editor")
                if note:
                    self.getEvernote().loadNoteContent(note)
                    content = editor.edit(note.content)
                else:
                    content = editor.edit()

            elif isinstance(content, str) and os.path.isfile(content):
                logging.debug("Load content from the file")
                content = open(content, "r").read()

            logging.debug("Convert content")
            content = editor.textToENML(content)

            result['content'] = content

        if tags:
            result['tags'] = tools.strip(tags.split(','))

        if notebook:
            notepadGuid = Notebooks().getNoteGUID(notebook)
            if notepadGuid is None:
                newNotepad = Notebooks().create(notebook)
                notepadGuid = newNotepad.guid
            
            result['notebook'] = notepadGuid
            logging.debug("Search notebook")
            
        return result
开发者ID:ddierickx,项目名称:geeknote,代码行数:48,代码来源:geeknote.py


示例6: __init__

 def __init__(self, pos, *groups):
     super(Wolf, self).__init__(*groups)
     self.pos = pos
     self.image_dict = {
             (-1, 0): cycle(strip(GFX["wolfleft"], (0, 0), (64, 32), 5)),
             (1, 0): cycle(strip(GFX["wolfright"], (0, 0), (64, 32), 5)), 
             (0, 1): cycle(strip(GFX["wolfdown"], (0, 0), (32, 64), 4)),
             (0, -1): cycle(strip(GFX["wolfup"], (0, 0), (32, 64), 4))}
     self.direction = choice(self.directions)
     self.images = self.image_dict[self.direction]
     self.image = next(self.images)
     self.rect = self.image.get_rect(center=self.pos)
     self.speed = 3
     self.move_time = randint(500, 2000)
     self.frame_time = 60
     self.frame_timer = 0
开发者ID:paddypolson,项目名称:Foggy,代码行数:16,代码来源:wolf.py


示例7: _searchNote

    def _searchNote(self, note):
        note = tools.strip(note)

        # load search result
        result = self.getStorage().getSearch()
        if result and tools.checkIsInt(note) and 1 <= int(note) <= len(result.notes):
            note = result.notes[int(note) - 1]

        else:
            request = self._createSearchRequest(search=note)

            logging.debug("Search notes: %s" % request)
            result = self.getEvernote().findNotes(request, 20)

            logging.debug("Search notes result: %s" % str(result))
            if result.totalNotes == 0:
                out.failureMessage("Notes have not been found.")
                return tools.exitErr()

            elif result.totalNotes == 1 or self.selectFirstOnUpdate:
                note = result.notes[0]

            else:
                logging.debug("Choose notes: %s" % str(result.notes))
                note = out.SelectSearchResult(result.notes)

        logging.debug("Selected note: %s" % str(note))
        return note
开发者ID:khapota,项目名称:geeknote,代码行数:28,代码来源:geeknote.py


示例8: _formatExpression

        def _formatExpression(label, value):
            """Create an expression like label:value, attending to negation and quotes """
            expression = ""

            # if negated, prepend that to the expression before labe, not value
            if value.startswith('-'):
                expression += '-'
                value = value[1:]
            value = tools.strip(value)

            # values with spaces must be quoted
            if ' ' in value:
                value = '"%s"' % value

            expression += '%s:%s ' % (label, value)
            return expression
开发者ID:IntrepidSuccess,项目名称:geeknote,代码行数:16,代码来源:geeknote.py


示例9: _get_notes

 def _get_notes(self):
     """
     Get notes from evernote.
     """
     keywords = 'notebook:"{0}"'.format(tools.strip(self.notebook_name))
     #print GeekNote().findNotes(keywords, 10000)
     #try to get all notes in a notebook
     #assum that the notebook has less than 10000 notes
     noteMetadataResultSpec = NoteStore.NotesMetadataResultSpec(includeTitle=True,\
             includeUpdated=True)
     noteList = GeekNote().findNotesMetadata(keywords, 10000, noteMetadataResultSpec)
     notes = noteList.notes
     notesSize = len(notes)
     while (notesSize < noteList.totalNotes):
         noteList = GeekNote().findNotesMetadata(keywords, 10000, offset=notesSize)
         notes += noteList.notes
         notesSize = len(notes)
         print notesSize
     return notes
开发者ID:khapota,项目名称:geeknote,代码行数:19,代码来源:gnsync.py


示例10: imgupload

    def imgupload(self, title, img, description):

        self.connectToEvernote()

	filedata = open( img, 'rb').read()
	md5 = hashlib.md5()
	md5.update(filedata)
	hashHex = md5.hexdigest()
 
  	data = Types.Data()
	data.size = len(filedata)
	data.bodyHash = hashHex
	data.body = filedata
 
	resource = Types.Resource()
	resource.data = data
 
	content = '<?xml version="1.0" encoding="UTF-8"?>'
 	content += '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml.dtd">'
	content += '<en-note>'
	content += '<en-media type="image/jpeg" hash="' + hashHex + '"/>'
	content += '<p>' + description + '</p>'
	content += '</en-note>'

        enmlText = {
            "title": title,
            "content": content,
            "resource": resource,
        }
        enmlText = tools.strip(enmlText)
		
	result = self.getEvernote().createImgNote(**enmlText)

	if result:
     		out.successMessage("Note has been successfully created.")
	else:
		out.failureMessage("Error while creating the note.")
开发者ID:KNightWeng,项目名称:ENConsole,代码行数:37,代码来源:enconsole.py


示例11: _createSearchRequest

    def _createSearchRequest(
        self,
        search=None,
        tags=None,
        notebooks=None,
        date=None,
        exact_entry=None,
        content_search=None,
        ignore_completed=None,
        reminders_only=None,
    ):

        request = ""

        def _formatExpression(label, value):
            """Create an expression like label:value, attending to negation and quotes """
            expression = ""

            # if negated, prepend that to the expression before labe, not value
            if value.startswith("-"):
                expression += "-"
                value = value[1:]
            value = tools.strip(value)

            # values with spaces must be quoted
            if " " in value:
                value = '"%s"' % value

            expression += "%s:%s " % (label, value)
            return expression

        if notebooks:
            for notebook in tools.strip(notebooks.split(",")):
                request += _formatExpression("notebook", notebook)

        if tags:
            for tag in tools.strip(tags.split(",")):
                request += _formatExpression("tag", tag)

        if date:
            date = tools.strip(re.split(config.DEF_DATE_RANGE_DELIMITER, date))
            try:
                dateStruct = time.strptime(date[0], config.DEF_DATE_FORMAT)
                request += "created:%s " % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct)))
                if len(date) == 2:
                    dateStruct = time.strptime(date[1], config.DEF_DATE_FORMAT)
                request += "-created:%s " % time.strftime(
                    "%Y%m%d", time.localtime(time.mktime(dateStruct) + 60 * 60 * 24)
                )
            except ValueError:
                out.failureMessage(
                    "Incorrect date format (%s) in --date attribute. "
                    "Format: %s" % (date, time.strftime(config.DEF_DATE_FORMAT, time.strptime("19991231", "%Y%m%d")))
                )
                return tools.exitErr()

        if search:
            search = tools.strip(search)
            if exact_entry or self.findExactOnUpdate:
                search = '"%s"' % search

            if content_search:
                request += "%s" % search
            else:
                request += "intitle:%s" % search

        if reminders_only:
            request += " reminderOrder:* "
        if ignore_completed:
            request += " -reminderDoneTime:* "

        logging.debug("Search request: %s", request)
        return request
开发者ID:artmg,项目名称:geeknote,代码行数:73,代码来源:geeknote.py


示例12: _get_notes

 def _get_notes(self):
     """
     Get notes from evernote.
     """
     keywords = 'notebook:"{0}"'.format(tools.strip(self.notebook_name))
     return GeekNote().findNotes(keywords, 10000).notes
开发者ID:chamot1111,项目名称:geeknote,代码行数:6,代码来源:gnsync.py


示例13: _get_notes

 def _get_notes(self):
     """
     Get notes from evernote.
     """
     keywords = 'notebook:"{0}"'.format(tools.strip(self.notebook_name.encode('utf-8')))
     return GeekNote(sleepOnRateLimit=self.sleep_on_ratelimit).findNotes(keywords, EDAM_USER_NOTES_MAX).notes
开发者ID:jeffkowalski,项目名称:geeknote,代码行数:6,代码来源:gnsync.py


示例14: _createSearchRequest

    def _createSearchRequest(self, search=None, tags=None,
                             notebooks=None, date=None,
                             exact_entry=None, content_search=None,
                             ignore_completed=None, reminders_only=None):

        request = ""

        def _formatExpression(label, value):
            """Create an expression like label:value, attending to negation and quotes """
            expression = ""

            # if negated, prepend that to the expression before labe, not value
            if value.startswith('-'):
                expression += '-'
                value = value[1:]
            value = tools.strip(value)

            # values with spaces must be quoted
            if ' ' in value:
                value = '"%s"' % value

            expression += '%s:%s ' % (label, value)
            return expression

        if notebooks:
            for notebook in tools.strip(notebooks.split(',')):
                request += _formatExpression('notebook', notebook)

        if tags:
            for tag in tools.strip(tags.split(',')):
                request += _formatExpression('tag', tag)

        if date:
            date = tools.strip(date.split('-'))
            try:
                dateStruct = time.strptime(date[0] + " 00:00:00", config.DEF_DATE_FORMAT)
                request += 'created:%s ' % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct)))
                if len(date) == 2:
                    dateStruct = time.strptime(date[1] + " 00:00:00", config.DEF_DATE_AND_TIME_FORMAT)
                request += '-created:%s ' % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct) + 60 * 60 * 24))
            except ValueError:
                out.failureMessage('Incorrect date format in --date attribute. '
                                   'Format: %s' % time.strftime(config.DEF_DATE_FORMAT, time.strptime('19991231', "%Y%m%d")))
                return tools.exitErr()

        if search:
            search = tools.strip(search)
            if exact_entry or self.findExactOnUpdate:
                search = '"%s"' % search

            if content_search:
                request += "%s" % search
            else:
                request += "intitle:%s" % search

        if reminders_only:
            request += ' reminderOrder:* '
        if ignore_completed:
            request += ' -reminderDoneTime:* '

        logging.debug("Search request: %s", request)
        return request
开发者ID:IntrepidSuccess,项目名称:geeknote,代码行数:62,代码来源:geeknote.py


示例15: _parseInput

    def _parseInput(
        self, title=None, content=None, tags=None, created=None, notebook=None, resources=[], note=None, reminder=None
    ):
        result = {
            "title": title,
            "content": content,
            "tags": tags,
            "created": created,
            "notebook": notebook,
            "resources": resources,
            "reminder": reminder,
        }
        result = tools.strip(result)

        # if get note without params
        if (
            note
            and title is None
            and content is None
            and tags is None
            and created is None
            and reminder is None
            and notebook is None
        ):
            content = config.EDITOR_OPEN

        if title is None and note:
            result["title"] = note.title

        if content:
            if content != config.EDITOR_OPEN:
                if isinstance(content, str) and os.path.isfile(content):
                    logging.debug("Load content from the file")
                    content = open(content, "r").read()

                logging.debug("Convert content")
                content = Editor.textToENML(content)
            result["content"] = content

        if tags:
            result["tags"] = tools.strip(tags.split(","))

        if created:
            result["created"] = self._getTimeFromDate(created)

        if notebook:
            notepadGuid = Notebooks().getNoteGUID(notebook)
            if notepadGuid is None:
                newNotepad = Notebooks().create(notebook)
                notepadGuid = newNotepad.guid

            result["notebook"] = notepadGuid
            logging.debug("Search notebook")

        if reminder:
            then = config.REMINDER_SHORTCUTS.get(reminder)
            if then:
                now = int(round(time.time() * 1000))
                result["reminder"] = now + then
            elif reminder not in [config.REMINDER_NONE, config.REMINDER_DONE, config.REMINDER_DELETE]:
                result["reminder"] = self._getTimeFromDate(reminder)

        return result
开发者ID:artmg,项目名称:geeknote,代码行数:63,代码来源:geeknote.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tools.tob函数代码示例发布时间:2022-05-27
下一篇:
Python tools.stderr函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap