mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Support multiple configuration directories for update-all subcommand (#1925)
This commit is contained in:
		| @@ -296,7 +296,6 @@ def command_vscode(args): | ||||
|  | ||||
|     logging.disable(logging.INFO) | ||||
|     logging.disable(logging.WARNING) | ||||
|     CORE.config_path = args.configuration | ||||
|     vscode.read_config(args) | ||||
|  | ||||
|  | ||||
| @@ -406,7 +405,7 @@ def command_update_all(args): | ||||
|     import click | ||||
|  | ||||
|     success = {} | ||||
|     files = list_yaml_files(args.configuration[0]) | ||||
|     files = list_yaml_files(args.configuration) | ||||
|     twidth = 60 | ||||
|  | ||||
|     def print_bar(middle_text): | ||||
| @@ -694,14 +693,12 @@ def parse_args(argv): | ||||
|     ) | ||||
|  | ||||
|     parser_vscode = subparsers.add_parser("vscode") | ||||
|     parser_vscode.add_argument( | ||||
|         "configuration", help="Your YAML configuration file.", nargs=1 | ||||
|     ) | ||||
|     parser_vscode.add_argument("configuration", help="Your YAML configuration file.") | ||||
|     parser_vscode.add_argument("--ace", action="store_true") | ||||
|  | ||||
|     parser_update = subparsers.add_parser("update-all") | ||||
|     parser_update.add_argument( | ||||
|         "configuration", help="Your YAML configuration file directory.", nargs=1 | ||||
|         "configuration", help="Your YAML configuration file directories.", nargs="+" | ||||
|     ) | ||||
|  | ||||
|     return parser.parse_args(argv[1:]) | ||||
|   | ||||
| @@ -98,7 +98,7 @@ class DashboardSettings: | ||||
|         return os.path.join(self.config_dir, *args) | ||||
|  | ||||
|     def list_yaml_files(self): | ||||
|         return util.list_yaml_files(self.config_dir) | ||||
|         return util.list_yaml_files([self.config_dir]) | ||||
|  | ||||
|  | ||||
| settings = DashboardSettings() | ||||
|   | ||||
| @@ -247,17 +247,24 @@ class OrderedDict(collections.OrderedDict): | ||||
|         return dict(self).__repr__() | ||||
|  | ||||
|  | ||||
| def list_yaml_files(folder): | ||||
|     files = filter_yaml_files([os.path.join(folder, p) for p in os.listdir(folder)]) | ||||
| def list_yaml_files(folders): | ||||
|     files = filter_yaml_files( | ||||
|         [os.path.join(folder, p) for folder in folders for p in os.listdir(folder)] | ||||
|     ) | ||||
|     files.sort() | ||||
|     return files | ||||
|  | ||||
|  | ||||
| def filter_yaml_files(files): | ||||
|     files = [f for f in files if os.path.splitext(f)[1] == ".yaml"] | ||||
|     files = [f for f in files if os.path.basename(f) != "secrets.yaml"] | ||||
|     files = [f for f in files if not os.path.basename(f).startswith(".")] | ||||
|     return files | ||||
|     return [ | ||||
|         f | ||||
|         for f in files | ||||
|         if ( | ||||
|             os.path.splitext(f)[1] == ".yaml" | ||||
|             and os.path.basename(f) != "secrets.yaml" | ||||
|             and not os.path.basename(f).startswith(".") | ||||
|         ) | ||||
|     ] | ||||
|  | ||||
|  | ||||
| class SerialPort: | ||||
|   | ||||
| @@ -67,7 +67,7 @@ def read_config(args): | ||||
|         CORE.ace = args.ace | ||||
|         f = data["file"] | ||||
|         if CORE.ace: | ||||
|             CORE.config_path = os.path.join(args.configuration[0], f) | ||||
|             CORE.config_path = os.path.join(args.configuration, f) | ||||
|         else: | ||||
|             CORE.config_path = data["file"] | ||||
|         vs = VSCodeResult() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user