示例#1
0
    def saveCode(self, filename, filters=None, packages=None, ignore=None, head=None, tail=None, module=False, template=False, version=None, patch=None):
        """
        saves the workspace as python code so it can be recreated later
        """
        if version is None:
            version = self.version
        if patch is None:
            patch = self.patch
        if self.packageWriter is None:
            self.packageWriter = autosar.writer.package_writer.PackageWriter(version, patch)
            if self.useDefaultWriters:
                self._registerDefaultElementWriters(self.packageWriter)
        writer=autosar.writer.WorkspaceWriter(version, patch, None, self.packageWriter)
        if isinstance(packages,str): packages=[packages]
        if isinstance(filters,str): filters=[filters]
        if isinstance(ignore,str): ignore=[ignore]
        if packages is not None:
            if filters is None:
                filters = []
            for package in packages:
                if package[-1]=='/':
                    filters.append(package+'*')
                else:
                    filters.append(package+'/*')
        if filters is not None:
            filters = [prepareFilter(x) for x in filters]

        with open(filename,'w', encoding="utf-8") as fp:
            writer.saveCode(self, fp, filters, ignore, head, tail, module, template)
示例#2
0
文件: workspace.py 项目: cogu/autosar
   def saveCode(self, filename, filters=None, packages=None, ignore=None, head=None, tail=None, module=False, version=None, patch=None):
      """
      saves the workspace as python code so it can be recreated later
      """
      if version is None:
         version = self.version
      if patch is None:
         patch = self.patch
      if self.packageWriter is None:
         self.packageWriter = autosar.writer.package_writer.PackageWriter(version, patch)
         self._registerDefaultElementWriters(self.packageWriter)
      writer=autosar.writer.WorkspaceWriter(version, patch, None, self.packageWriter)
      if isinstance(packages,str): packages=[packages]
      if isinstance(filters,str): filters=[filters]
      if isinstance(ignore,str): ignore=[ignore]
      if packages is not None:
         if filters is None:
            filters = []
         for package in packages:
            if package[-1]=='/':
               filters.append(package+'*')
            else:
               filters.append(package+'/*')
      if filters is not None:
         filters = [prepareFilter(x) for x in filters]

      with open(filename,'w', encoding="utf-8") as fp:
         writer.saveCode(self, fp, filters, ignore, head, tail, module)
示例#3
0
 def saveCode(self,
              filename,
              packages=None,
              ignore=None,
              head=None,
              tail=None,
              module=False):
     """
   saves the workspace as python code so it can be recreated later
   """
     writer = autosar.writer.WorkspaceWriter()
     if isinstance(packages, str): packages = [packages]
     with open(filename, 'w', encoding="utf-8") as fp:
         writer.saveCode(self, fp, packages, ignore, head, tail, module)