def ls(system, user, local, include_missing):
    """List configuration files detected (and/or examined paths)."""

    # default action is to list *all* auto-detected files
    if not (system or user or local):
        system = user = local = True

    for path in get_configfile_paths(system=system, user=user, local=local,
                                     only_existing=not include_missing):
        click.echo(path)
    def test_config_file_detection_user(self):
        if sys.platform == 'win32':
            configpath = os.path.expanduser("~\\AppData\\Local\\dwavesystem\\dwave\\dwave.conf")
        elif sys.platform == 'darwin':
            configpath = os.path.expanduser("~/Library/Application Support/dwave/dwave.conf")
        else:
            configpath = os.path.expanduser("~/.config/dwave/dwave.conf")

        with mock.patch("os.path.exists", lambda path: path == configpath):
            self.assertEqual(get_configfile_paths(), [configpath])
    def test_config_file_detection_system(self):
        if sys.platform == 'win32':
            configpath = os.path.expandvars("%SYSTEMDRIVE%\\ProgramData\\dwavesystem\\dwave\\dwave.conf")
        elif sys.platform == 'darwin':
            configpath = "/Library/Application Support/dwave/dwave.conf"
        else:
            configpath = "/etc/xdg/dwave/dwave.conf"

        with mock.patch("os.path.exists", lambda path: path == configpath):
            self.assertEqual(get_configfile_paths(), [configpath])
Exemple #4
0
    def test_config_file_detection_system(self):
        if sys.platform == 'win32':
            # TODO
            pass
        elif sys.platform == 'darwin':
            configpath = os.path.expanduser("/Library/Application Support/dwave/dwave.conf")
        else:
            configpath = "/etc/xdg/dwave/dwave.conf"

        with mock.patch("os.path.exists", lambda path: path == configpath):
            self.assertEqual(get_configfile_paths(), [configpath])
Exemple #5
0
 def test_config_file_detection_nonexisting(self):
     with mock.patch("os.path.exists", lambda path: False):
         self.assertEqual(get_configfile_paths(), [])
Exemple #6
0
 def test_config_file_detection_cwd(self):
     configpath = os.path.join('.', 'dwave.conf')
     with mock.patch("os.path.exists", lambda path: path == configpath):
         self.assertEqual(get_configfile_paths(), [configpath])
Exemple #7
0
def list_local_config():
    for path in get_configfile_paths(system=False,
                                     user=False,
                                     only_existing=False):
        click.echo(path)
Exemple #8
0
def list_config_files():
    for path in get_configfile_paths():
        click.echo(path)