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

Python path.toUnicode函数代码示例

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

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



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

示例1: _loadPackage

 def _loadPackage(self, client, filename, newLoad=True,
                  destinationPackage=None):
     """Load the package named 'filename'"""
     try:
         encoding = sys.getfilesystemencoding()
         if encoding is None:
             encoding = 'utf-8'
         filename2 = toUnicode(filename, encoding)
         log.debug("filename and path" + filename2)
         # see if the file exists AND is readable by the user
         try:
             open(filename2, 'rb').close()
         except IOError:
             filename2 = toUnicode(filename, 'utf-8')
             try:
                 open(filename2, 'rb').close()
             except IOError:
                 client.alert(_(u'File %s does not exist or is not readable.') % filename2)
                 return None
         package = Package.load(filename2, newLoad, destinationPackage)
         if package is None:
             raise Exception(_("Couldn't load file, please email file to [email protected]"))
     except Exception, exc:
         if log.getEffectiveLevel() == logging.DEBUG:
             client.alert(_(u'Sorry, wrong file format:\n%s') % unicode(exc))
         else:
             client.alert(_(u'Sorry, wrong file format'))
         log.error(u'Error loading package "%s": %s' % (filename2, unicode(exc)))
         log.error(u'Traceback:\n%s' % traceback.format_exc())
         raise
开发者ID:giorgil2,项目名称:eXe,代码行数:30,代码来源:mainpage.py


示例2: render_POST

    def render_POST(self, request=None):
        log.debug("render_POST")

        lang_only = False

        data = {}
        try:
            clear = False
            if 'clear' in request.args:
                clear = True
                request.args.pop('clear')
            if 'lang_only' in request.args:
                lang_only = True
                request.args.pop('lang_only')
            if 'lom_general_title_string1' in request.args:
                if clear:
                    self.package.setLomDefaults()
                else:
                    self.setLom(request.args)
            elif 'lomes_general_title_string1' in request.args:
                if clear:
                    self.package.setLomEsDefaults()
                else:
                    self.setLomes(request.args)
            else:
                items = request.args.items()
                if 'pp_lang' in request.args:
                    value = request.args['pp_lang']
                    item = ('pp_lang', value)
                    items.remove(item)
                    items.insert(0, item)
                for key, value in items:
                    obj, name = self.fieldId2obj(key)
                    if key in self.booleanFieldNames:
                        setattr(obj, name, value[0] == 'true')
                    else:
                        if key in self.imgFieldNames:
                            path = Path(toUnicode(value[0]))
                            if path.isfile():
                                setattr(obj, name, path)
                                data[key] = getattr(obj, name).basename()
                            else:
                                if getattr(obj, name):
                                    if getattr(obj, name).basename() != path:
                                        setattr(obj, name, None)
                        else:
                            #if name=='docType': common.setExportDocType(toUnicode(value[0]))

                            setattr(obj, name, toUnicode(value[0]))

        except Exception as e:
            log.exception(e)
            return json.dumps({'success': False, 'errorMessage': _("Failed to save properties")})

        if not self.package.isTemplate or not lang_only:
            self.package.isChanged = True

        return json.dumps({'success': True, 'data': data})
开发者ID:exelearning,项目名称:iteexe,代码行数:58,代码来源:propertiespage.py


示例3: recieveFieldData

 def recieveFieldData(self, client, fieldId, value, total, onDone=None):
     """
     Called by client to give us a value from a certain field
     """
     total = int(total)
     self.fieldsReceived.add(fieldId)
     obj, name = self.fieldId2obj(fieldId)
     # Decode the value
     decoded = ''
     toSearch = value
     def getMatch():
         if toSearch and toSearch[0] == '%':
             match1 = self.reUni.search(toSearch)
             match2 = self.reChr.search(toSearch)
             if match1 and match2:
                 if match1.start() < match2.start():
                     return match1
                 else:
                     return match2
             else:
                 return match1 or match2
         else:
             return self.reRaw.search(toSearch)
     match = getMatch()
     while match:
         num = match.groups()[-1]
         if len(num) > 1:
             decoded += unichr(int(num, 16))
         else:
             decoded += num
         toSearch = toSearch[match.end():]
         match = getMatch()
     # Check the field type
     if fieldId in self.booleanFieldNames:
         setattr(obj, name, decoded[0].lower() == 't')
     elif fieldId in self.imgFieldNames:
         if not decoded.startswith("resources"):
             setattr(obj, name, toUnicode(decoded))
     else:
         # Must be a string
         setattr(obj, name, toUnicode(decoded))
     client.sendScript(js(
         'document.getElementById("%s").style.color = "black"' % fieldId))
     if len(self.fieldsReceived) == total:
         self.fieldsReceived = set()
         client.sendScript(js.alert(
             (u"%s" % _('Settings saved')).encode('utf8')))
         if onDone:
             client.sendScript(js(onDone))
开发者ID:luisgg,项目名称:iteexe,代码行数:49,代码来源:propertiespage.py


示例4: upgradeToVersion6

 def upgradeToVersion6(self):
     """
     Upgrades for v0.18
     """
     self.defaultImage = toUnicode(G.application.config.webDir/'images'/DEFAULT_IMAGE)
     for question in self.questions:
         question.setupImage(self)
开发者ID:Rafav,项目名称:iteexe,代码行数:7,代码来源:casestudyidevice.py


示例5: render_POST

 def render_POST(self, request=None):
     log.debug("render_POST")
     
     data = {}
     try:
         for key, value in request.args.items():
             obj, name = self.fieldId2obj(key)
             if key in self.booleanFieldNames:
                 setattr(obj, name, value[0] == 'true')
             else:
                 if key in self.imgFieldNames:
                     path = Path(value[0])
                     if path.isfile():
                         setattr(obj, name, toUnicode(value[0]))
                         data[key] = getattr(obj, name).basename()
                 else:
                     setattr(obj, name, toUnicode(value[0]))
     except Exception as e:
         log.exception(e)
         return json.dumps({'success': False, 'errorMessage': _("Failed to save properties")})
     return json.dumps({'success': True, 'data': data})
开发者ID:manamani,项目名称:iteexe,代码行数:21,代码来源:propertiespage.py


示例6: __init__

    def __init__(self, story="", defaultImage=None):
        """
        Initialize 
        """
        Idevice.__init__(self,
                         x_(u"Case Study"),
                         x_(u"University of Auckland"), 
                         x_(u"""A case study is a device that provides learners 
with a simulation that has an educational basis. It takes a situation, generally 
based in reality, and asks learners to demonstrate or describe what action they 
would take to complete a task or resolve a situation. The case study allows 
learners apply their own knowledge and experience to completing the tasks 
assigned. when designing a case study consider the following:<ul> 
<li>	What educational points are conveyed in the story</li>
<li>	What preparation will the learners need to do prior to working on the 
case study</li>
<li>	Where the case study fits into the rest of the course</li>
<li>	How the learners will interact with the materials and each other e.g.
if run in a classroom situation can teams be setup to work on different aspects
of the case and if so how are ideas feed back to the class</li></ul>"""), 
                         "",
                         u"casestudy")
        self.emphasis     = Idevice.SomeEmphasis
        self.short_desc = x_("Template for providing a case study text, activity and feedback")
        
        self._storyInstruc = x_(u"""Create the case story. A good case is one 
that describes a controversy or sets the scene by describing the characters 
involved and the situation. It should also allow for some action to be taken 
in order to gain resolution of the situation.""")
        self.storyTextArea = TextAreaField(x_(u'Story:'), self._storyInstruc, story)
        self.storyTextArea.idevice = self


        self.questions    = []
        self._questionInstruc = x_(u"""Describe the activity tasks relevant 
to the case story provided. These could be in the form of questions or 
instructions for activity which may lead the learner to resolving a dilemma 
presented. """)
        self._feedbackInstruc = x_(u"""Provide relevant feedback on the 
situation.""")
        if defaultImage is None:
            defaultImage = G.application.config.webDir/'images'/DEFAULT_IMAGE
        self.defaultImage = toUnicode(defaultImage)
        self.addQuestion()
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:44,代码来源:casestudyidevice.py


示例7: set_email

 def set_email(self, value):
     self._email = toUnicode(value)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:2,代码来源:package.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python path.Path类代码示例发布时间:2022-05-24
下一篇:
Python package.Package类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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