Пример #1
0
 def view_source_code(self, event=None):
     if hasattr(self.object, '_get_source_code'):
         file = self.object._get_source_code()
     else:
         file = get_code_file(self.object)
     if file:
         wx.GetApp().code_editor.open_code_file(file)
Пример #2
0
 def view_source_code(self, event=None):
     if hasattr(self.object, '_get_source_code'):
         file = self.object._get_source_code()
     else:
         file = get_code_file(self.object)
     if file:
         wx.GetApp().code_editor.open_code_file( file)
Пример #3
0
    def create_code(self):
        """create_code(): create all the code for exporting
"""
        # create code for individual objects
        file_user_code = {'top_of_file':"", 'import autocode':""}
        for storage_dict in self.exportDictList:
            obj = storage_dict['obj']
            try:
                file = open(get_code_file(obj), 'r')
                old_code = file.read()
                file.close()
                user_code_dict = self.extract_usercode(old_code)
                for k in file_user_code.iterkeys():
                    if user_code_dict.has_key(k):
                        if file_user_code[k]:
                            file_user_code[k] += '\n' + user_code_dict[k]
                        else:
                            file_user_code[k] = user_code_dict[k]
                user_code_dict.pop('top_of_file',None)
                user_code_dict.pop('import autocode',None)
            except:
                user_code_dict = {}
            name, obj_code = self.create_object_block(obj, storage_dict)
            obj_code = self.inject_usercode(obj_code,user_code_dict) + '\n'
            self.objCode.setdefault(name, obj_code)
            if not storage_dict['as_class']:
                self.dotest = False # don't run code that creates objects
        # create file label
        code = [""]            
        # create code for imports and other initialization
        code += [self.create_import_code()]
        for storage_dict in self.exportDictList:
            obj_name = storage_dict['storage_name']
            obj_code = self.objCode[obj_name]
            code.append(obj_code)
        all_code = ''.join(code)
        all_code = self.inject_usercode(all_code, file_user_code)
        return all_code
Пример #4
0
    def create_code(self):
        """create_code(): create all the code for exporting
"""
        # create code for individual objects
        file_user_code = {'top_of_file': "", 'import autocode': ""}
        for storage_dict in self.exportDictList:
            obj = storage_dict['obj']
            try:
                file = open(get_code_file(obj), 'r')
                old_code = file.read()
                file.close()
                user_code_dict = self.extract_usercode(old_code)
                for k in file_user_code.iterkeys():
                    if user_code_dict.has_key(k):
                        if file_user_code[k]:
                            file_user_code[k] += '\n' + user_code_dict[k]
                        else:
                            file_user_code[k] = user_code_dict[k]
                user_code_dict.pop('top_of_file', None)
                user_code_dict.pop('import autocode', None)
            except:
                user_code_dict = {}
            name, obj_code = self.create_object_block(obj, storage_dict)
            obj_code = self.inject_usercode(obj_code, user_code_dict) + '\n'
            self.objCode.setdefault(name, obj_code)
            if not storage_dict['as_class']:
                self.dotest = False  # don't run code that creates objects
        # create file label
        code = [""]
        # create code for imports and other initialization
        code += [self.create_import_code()]
        for storage_dict in self.exportDictList:
            obj_name = storage_dict['storage_name']
            obj_code = self.objCode[obj_name]
            code.append(obj_code)
        all_code = ''.join(code)
        all_code = self.inject_usercode(all_code, file_user_code)
        return all_code
Пример #5
0
 def _get_source_code(self):
     "_get_source_code(): try to return module filename for external editors"
     return get_code_file(self)
Пример #6
0
 def _get_source_code(self):
     "_get_source_code(): try to return module filename for external editors"
     return get_code_file(self)