parameters: (self, version_file=None, version_variable=None)
return_statement: return version
docstring: Try to get version string of a package.
  
          Return a version string of the current package or None if the version
          information could not be detected.
  
          Notes
          -----
          This method scans files named
          __version__.py, <packagename>_version.py, version.py, and
          __svn_version__.py for string variables version, __version__, and
          <packagename>_version, until a version number is found.
docstring_summary: Try to get version string of a package.
docstring_tokens: Try to get version string of a package .
function: def get_version(self, version_file=None, version_variable=None):
          """Try to get version string of a package.
  
          Return a version string of the current package or None if the version
          information could not be detected.
  
          Notes
          -----
          This method scans files named
          __version__.py, <packagename>_version.py, version.py, and
          __svn_version__.py for string variables version, __version__, and
          <packagename>_version, until a version number is found.
          """
          version = getattr(self, 'version', None)
          if version is not None:
              return version
  
          # Get version from version file.
          if version_file is None:
              files = ['__version__.py',
                       self.name.split('.')[-1]+'_version.py',
                       'version.py',
                       '__svn_version__.py',
                       '__hg_version__.py']
          else:
              files = [version_file]
          if version_variable is None:
              version_vars = ['version',
                              '__version__',
                              self.name.split('.')[-1]+'_version']
          else:
              version_vars = [version_variable]
          for f in files:
              fn = njoin(self.local_path, f)
              if os.path.isfile(fn):
                  info = ('.py', 'U', 1)
                  name = os.path.splitext(os.path.basename(fn))[0]
                  n = dot_join(self.name, name)
                  try:
                      version_module = npy_load_module('_'.join(n.split('.')),
                                                       fn, info)
                  except ImportError:
                      msg = get_exception()
                      self.warn(str(msg))
                      version_module = None
                  if version_module is None:
                      continue
  
                  for a in version_vars:
                      version = getattr(version_module, a, None)
                      if version is not None:
                          break
                  if version is not None:
                      break
  
          if version is not None:
              self.version = version
              return version
  
          # Get version as SVN or Mercurial revision number
          revision = self._get_svn_revision(self.local_path)
          if revision is None:
              revision = self._get_hg_revision(self.local_path)
  
          if revision is not None:
              version = str(revision)
              self.version = version
  
          return version
function_tokens: def get_version ( self , version_file = None , version_variable = None ) : version = getattr ( self , 'version' , None ) if version is not None : return version # Get version from version file. if version_file is None : files = [ '__version__.py' , self . name . split ( '.' ) [ - 1 ] + '_version.py' , 'version.py' , '__svn_version__.py' , '__hg_version__.py' ] else : files = [ version_file ] if version_variable is None : version_vars = [ 'version' , '__version__' , self . name . split ( '.' ) [ - 1 ] + '_version' ] else : version_vars = [ version_variable ] for f in files : fn = njoin ( self . local_path , f ) if os . path . isfile ( fn ) : info = ( '.py' , 'U' , 1 ) name = os . path . splitext ( os . path . basename ( fn ) ) [ 0 ] n = dot_join ( self . name , name ) try : version_module = npy_load_module ( '_' . join ( n . split ( '.' ) ) , fn , info ) except ImportError : msg = get_exception ( ) self . warn ( str ( msg ) ) version_module = None if version_module is None : continue for a in version_vars : version = getattr ( version_module , a , None ) if version is not None : break if version is not None : break if version is not None : self . version = version return version # Get version as SVN or Mercurial revision number revision = self . _get_svn_revision ( self . local_path ) if revision is None : revision = self . _get_hg_revision ( self . local_path ) if revision is not None : version = str ( revision ) self . version = version return version