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


Python path.toUnicode函数代码示例

本文整理汇总了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;未经允许,请勿转载。