"Fossies" - the Fresh Open Source Software Archive

Member "viewvc-1.2.1/lib/vclib/ccvs/__init__.py" (26 Mar 2020, 2255 Bytes) of package /linux/misc/viewvc-1.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "__init__.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.1.28_vs_1.2.1.

    1 # -*-python-*-
    2 #
    3 # Copyright (C) 1999-2020 The ViewCVS Group. All Rights Reserved.
    4 #
    5 # By using this file, you agree to the terms and conditions set forth in
    6 # the LICENSE.html file which can be found at the top level of the ViewVC
    7 # distribution or at http://viewvc.org/license-1.html.
    8 #
    9 # For more information, visit http://viewvc.org/
   10 #
   11 # -----------------------------------------------------------------------
   12 import os
   13 import os.path
   14 import time
   15 
   16 
   17 def cvs_strptime(timestr):
   18   return time.strptime(timestr, '%Y/%m/%d %H:%M:%S')[:-1] + (0,)
   19 
   20 
   21 def canonicalize_rootpath(rootpath):
   22   assert os.path.isabs(rootpath)
   23   return os.path.normpath(rootpath)
   24 
   25 
   26 def _is_cvsroot(path):
   27   return os.path.exists(os.path.join(path, "CVSROOT", "config"))
   28 
   29 
   30 def expand_root_parent(parent_path):
   31   # Each subdirectory of PARENT_PATH that contains a child
   32   # "CVSROOT/config" is added the set of returned roots.  Or, if the
   33   # PARENT_PATH itself contains a child "CVSROOT/config", then all its
   34   # subdirectories are returned as roots.
   35   assert os.path.isabs(parent_path)
   36   roots = {}
   37   subpaths = os.listdir(parent_path)
   38   for rootname in subpaths:
   39     rootpath = os.path.join(parent_path, rootname)
   40     if _is_cvsroot(parent_path) or _is_cvsroot(rootpath):
   41       roots[rootname] = canonicalize_rootpath(rootpath)
   42   return roots
   43 
   44 
   45 def find_root_in_parent(parent_path, rootname):
   46   """Search PARENT_PATH for a root named ROOTNAME, returning the
   47   canonicalized ROOTPATH of the root if found; return None if no such
   48   root is found."""
   49   # Is PARENT_PATH itself a CVS repository?  If so, we allow ROOTNAME
   50   # to be any subdir within it.  Otherwise, we expect
   51   # PARENT_PATH/ROOTNAME to be a CVS repository.
   52   assert os.path.isabs(parent_path)
   53   rootpath = os.path.join(parent_path, rootname)
   54   if (_is_cvsroot(parent_path) and os.path.exists(rootpath)) \
   55      or _is_cvsroot(rootpath):
   56     return canonicalize_rootpath(rootpath)
   57   return None
   58 
   59 
   60 def CVSRepository(name, rootpath, authorizer, utilities, use_rcsparse):
   61   rootpath = canonicalize_rootpath(rootpath)
   62   if use_rcsparse:
   63     import ccvs
   64     return ccvs.CCVSRepository(name, rootpath, authorizer, utilities)
   65   else:
   66     import bincvs
   67     return bincvs.BinCVSRepository(name, rootpath, authorizer, utilities)