예제 #1
0
파일: __init__.py 프로젝트: vipod/cmdhelper
    def find_config_files(self):
        """Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        Look for configuration file in the user's home directory named
        .karm.cfg on Unix and karm.cfg on Windows/Mac.
        """
        files = []
        if self.config_file:
            files.append(self.config_file)
        check_environ()

        # What to call the per-user config file
        if os.name == 'posix':
            user_filename = ".karm.cfg"
        else:
            user_filename = "karm.cfg"

        # And look for the user config file
        if os.environ.has_key('HOME'):
            user_file = os.path.join(os.environ.get('HOME'), user_filename)
            if os.path.isfile(user_file):
                files.append(user_file)

        return files
예제 #2
0
 def find_config_files(self):
     """Find as many configuration files as should be processed for this
     platform, and return a list of filenames in the order in which they
     should be parsed.  The filenames returned are guaranteed to exist
     (modulo nasty race conditions).
     
     There are three possible config files: distutils.cfg in the
     Distutils installation directory (ie. where the top-level
     Distutils __inst__.py file lives), a file in the user's home
     directory named .pydistutils.cfg on Unix and pydistutils.cfg
     on Windows/Mac; and setup.cfg in the current directory.
     
     The file in the user's home directory can be disabled with the
     --no-user-cfg option.
     """
     files = []
     check_environ()
     sys_dir = os.path.dirname(sys.modules["distutils"].__file__)
     sys_file = os.path.join(sys_dir, "distutils.cfg")
     if os.path.isfile(sys_file):
         files.append(sys_file)
     if os.name == "posix":
         user_filename = ".pydistutils.cfg"
     else:
         user_filename = "pydistutils.cfg"
     if self.want_user_cfg:
         user_file = os.path.join(os.path.expanduser("~"), user_filename)
         if os.path.isfile(user_file):
             files.append(user_file)
     local_file = "setup.cfg"
     if os.path.isfile(local_file):
         files.append(local_file)
     if DEBUG:
         self.announce("using config files: %s" % ", ".join(files))
     return files
예제 #3
0
    def test_check_environ(self):
        util._environ_checked = 0
        os.environ.pop('HOME', None)

        check_environ()

        self.assertEqual(os.environ['PLAT'], get_platform())
        self.assertEqual(util._environ_checked, 1)
예제 #4
0
    def test_check_environ(self):
        util._environ_checked = 0

        # posix without HOME
        if os.name == 'posix':  # this test won't run on windows
            check_environ()
            import pwd
            self.assertEquals(self.environ['HOME'],
                            pwd.getpwuid(os.getuid())[5])
        else:
            check_environ()

        self.assertEquals(self.environ['PLAT'], get_platform())
        self.assertEquals(util._environ_checked, 1)
예제 #5
0
    def test_check_environ(self):
        util._environ_checked = 0
        if 'HOME' in os.environ:
            del os.environ['HOME']

        # posix without HOME
        if os.name == 'posix':  # this test won't run on windows
            check_environ()
            import pwd
            self.assertEqual(os.environ['HOME'], pwd.getpwuid(os.getuid())[5])
        else:
            check_environ()

        self.assertEqual(os.environ['PLAT'], get_platform())
        self.assertEqual(util._environ_checked, 1)
예제 #6
0
    def test_check_environ(self):
        util._environ_checked = 0
        if "HOME" in os.environ:
            del os.environ["HOME"]

        # posix without HOME
        if os.name == "posix":  # this test won't run on windows
            check_environ()
            import pwd

            self.assertEqual(os.environ["HOME"], pwd.getpwuid(os.getuid())[5])
        else:
            check_environ()

        self.assertEqual(os.environ["PLAT"], get_platform())
        self.assertEqual(util._environ_checked, 1)
예제 #7
0
    def find_config_files(self):
        """Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        There are three possible config files: distutils.cfg in the
        Distutils installation directory (ie. where the top-level
        Distutils __inst__.py file lives), a file in the user's home
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
        on Windows/Mac; and setup.cfg in the current directory.

        The file in the user's home directory can be disabled with the
        --no-user-cfg option.
        """
        files = []
        check_environ()

        # Where to look for the system-wide Distutils config file
        sys_dir = os.path.dirname(sys.modules['distutils'].__file__)

        # Look for the system config file
        sys_file = os.path.join(sys_dir, "distutils.cfg")
        if os.path.isfile(sys_file):
            files.append(sys_file)

        # What to call the per-user config file
        if os.name == 'posix':
            user_filename = ".pydistutils.cfg"
        else:
            user_filename = "pydistutils.cfg"

        # And look for the user config file
        if self.want_user_cfg:
            user_file = os.path.join(os.path.expanduser('~'), user_filename)
            if os.path.isfile(user_file):
                files.append(user_file)

        # All platforms support local setup.cfg
        local_file = "setup.cfg"
        if os.path.isfile(local_file):
            files.append(local_file)

        if DEBUG:
            self.announce("using config files: %s" % ', '.join(files))

        return files
예제 #8
0
파일: dist.py 프로젝트: saimir/FRED
    def find_config_files(self):
        """Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        There are three possible config files: distutils.cfg in the
        Distutils installation directory (ie. where the top-level
        Distutils __inst__.py file lives), a file in the user's home
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
        on Windows/Mac, and setup.cfg in the current directory.
        """
        files = []
        check_environ()

        # Where to look for the system-wide Distutils config file
        sys_dir = os.path.dirname(sys.modules['distutils'].__file__)

        # Look for the system config file
        sys_file = os.path.join(sys_dir, "distutils.cfg")
        if os.path.isfile(sys_file):
            files.append(sys_file)

        # What to call the per-user config file
        if os.name == 'posix':
            user_filename = ".pydistutils.cfg"
        else:
            user_filename = "pydistutils.cfg"

        # And look for the user config file
        if os.environ.has_key('HOME'):
            user_file = os.path.join(os.environ.get('HOME'), user_filename)
            if os.path.isfile(user_file):
                files.append(user_file)

        # All platforms support local setup.cfg
        cfg_name = "setup.cfg"
        if os.path.isfile(cfg_name):
            # config is in current dir
            files.append(cfg_name)
        elif os.path.isfile(os.path.join(self.srcdir, cfg_name)):
            # confir is inj source dir (where is the setup.py)
            files.append(os.path.join(self.srcdir, cfg_name))

        return files
예제 #9
0
    def find_config_files (self):
        """Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        There are three possible config files: distutils.cfg in the
        Distutils installation directory (ie. where the top-level
        Distutils __inst__.py file lives), a file in the user's home
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
        on Windows/Mac, and setup.cfg in the current directory.

        The file in the user's home directory can be disabled with the
        --no-user-cfg option.
        """
        files = []
        check_environ()

        # Where to look for the system-wide Distutils config file
        sys_dir = os.path.dirname(sys.modules['distutils'].__file__)

        # Look for the system config file
        sys_file = os.path.join(sys_dir, "distutils.cfg")
        if os.path.isfile(sys_file):
            files.append(sys_file)

        # What to call the per-user config file
        if os.name == 'posix':
            user_filename = ".pydistutils.cfg"
        else:
            user_filename = "pydistutils.cfg"

        # And look for the user config file
        user_file = os.path.join(os.path.expanduser('~'), user_filename)
        if self.want_user_cfg and os.path.isfile(user_file):
            files.append(user_file)

        # All platforms support local setup.cfg
        local_file = "setup.cfg"
        if os.path.isfile(local_file):
            files.append(local_file)

        if DEBUG:
            print "using config files: %s" % ', '.join(files)
        return files
예제 #10
0
파일: dist.py 프로젝트: LANJr4D/FRED
    def find_config_files (self):
        """Find as many configuration files as should be processed for this
        platform, and return a list of filenames in the order in which they
        should be parsed.  The filenames returned are guaranteed to exist
        (modulo nasty race conditions).

        There are three possible config files: distutils.cfg in the
        Distutils installation directory (ie. where the top-level
        Distutils __inst__.py file lives), a file in the user's home
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
        on Windows/Mac, and setup.cfg in the current directory.
        """
        files = []
        check_environ()

        # Where to look for the system-wide Distutils config file
        sys_dir = os.path.dirname(sys.modules['distutils'].__file__)

        # Look for the system config file
        sys_file = os.path.join(sys_dir, "distutils.cfg")
        if os.path.isfile(sys_file):
            files.append(sys_file)

        # What to call the per-user config file
        if os.name == 'posix':
            user_filename = ".pydistutils.cfg"
        else:
            user_filename = "pydistutils.cfg"

        # And look for the user config file
        if os.environ.has_key('HOME'):
            user_file = os.path.join(os.environ.get('HOME'), user_filename)
            if os.path.isfile(user_file):
                files.append(user_file)

        # All platforms support local setup.cfg
        cfg_name = "setup.cfg"
        if os.path.isfile(cfg_name):
            # config is in current dir
            files.append(cfg_name)
        elif os.path.isfile(os.path.join(self.srcdir, cfg_name)):
            # confir is inj source dir (where is the setup.py)
            files.append(os.path.join(self.srcdir, cfg_name))
        
        return files
예제 #11
0
    def test_check_environ_getpwuid(self):
        util._environ_checked = 0
        os.environ.pop('HOME', None)

        import pwd

        # only set pw_dir field, other fields are not used
        result = pwd.struct_passwd(
            (None, None, None, None, None, '/home/distutils', None))
        with mock.patch.object(pwd, 'getpwuid', return_value=result):
            check_environ()
            self.assertEqual(os.environ['HOME'], '/home/distutils')

        util._environ_checked = 0
        os.environ.pop('HOME', None)

        # bpo-10496: Catch pwd.getpwuid() error
        with mock.patch.object(pwd, 'getpwuid', side_effect=KeyError):
            check_environ()
            self.assertNotIn('HOME', os.environ)
예제 #12
0
    def test_check_environ_getpwuid(self):
        util._environ_checked = 0
        os.environ.pop('HOME', None)

        import pwd

        # only set pw_dir field, other fields are not used
        result = pwd.struct_passwd((None, None, None, None, None,
                                    '/home/distutils', None))
        with mock.patch.object(pwd, 'getpwuid', return_value=result):
            check_environ()
            self.assertEqual(os.environ['HOME'], '/home/distutils')

        util._environ_checked = 0
        os.environ.pop('HOME', None)

        # bpo-10496: Catch pwd.getpwuid() error
        with mock.patch.object(pwd, 'getpwuid', side_effect=KeyError):
            check_environ()
            self.assertNotIn('HOME', os.environ)
예제 #13
0
 def find_config_files(self):
     files = []
     check_environ()
     sys_dir = os.path.dirname(sys.modules['distutils'].__file__)
     sys_file = os.path.join(sys_dir, 'distutils.cfg')
     if os.path.isfile(sys_file):
         files.append(sys_file)
     if os.name == 'posix':
         user_filename = '.pydistutils.cfg'
     else:
         user_filename = 'pydistutils.cfg'
     if self.want_user_cfg:
         user_file = os.path.join(os.path.expanduser('~'), user_filename)
         if os.path.isfile(user_file):
             files.append(user_file)
     local_file = 'setup.cfg'
     if os.path.isfile(local_file):
         files.append(local_file)
     if DEBUG:
         self.announce('using config files: %s' % ', '.join(files))
     return files
예제 #14
0
파일: dist.py 프로젝트: mcyril/ravel-ftn
"""distutils.dist