Loading Makefile +3 Changes for Makefile: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ format: ## Formatage des sources avec Black rye run black ./src/ .PHONY: format tests: ## Lancer les tests rye run python tests.py .PHONY: tests help: ## afficher l'aide @echo "\nChoisissez une commande. Les choix sont:\n" Loading pyproject.toml +1 Changes for pyproject.toml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ dependencies = [ "requests>=2.32.3", "basexclient>=8.4.4", "beautifulsoup4>=4.12.3", "lxml>=5.3.0", ] readme = "README.md" requires-python = ">= 3.12" Loading src/climax/__main__.py +11 −5 Changes for src/climax/__main__.py: 11 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -54,9 +54,9 @@ class MaXProjectConfig: self.config_file_path = Path(path_to_config_file).resolve() if os.path.isfile(self.config_file_path): with open(self.config_file_path, "r") as f: self.xml_soup = BeautifulSoup(f, "html.parser") self.xml_soup = BeautifulSoup(f, "xml") else: self.xml_soup = BeautifulSoup(CONFIG_INIT_TEMPLATE, "html.parser") self.xml_soup = BeautifulSoup(CONFIG_INIT_TEMPLATE, "xml") first = self.xml_soup.find() if first and first.name != "configuration": raise ValueError(f"{self.config_file_path} is not a MaX configuration file") Loading @@ -65,6 +65,7 @@ class MaXProjectConfig: conf = self.xml_soup.new_tag("configuration") conf["env"] = "dev" conf["vocabulary-bundle"] = "max-tei-bundle" conf["xmlns"] = "http://certic.unicaen.fr/max/ns/1.0" self.xml_soup.append(conf) @property Loading Loading @@ -177,10 +178,15 @@ def dir_is_max(directory: Path = None) -> bool: directory = os.getcwd() directory = Path(directory) config_file = Path(directory, "config.xml") max_dir = Path(directory, ".max") if not config_file.exists() or not max_dir.is_dir(): return False if config_file.exists(): with open(config_file, "r") as f: soup = BeautifulSoup(f, "xml") conf = soup.find("configuration") if conf: ns = conf.get("xmlns") if ns == "http://certic.unicaen.fr/max/ns/1.0": return True return False def check_cwd_is_max(): Loading tests.py +6 −1 Changes for tests.py: 6 added lines, 1 removed line. Original line number Diff line number Diff line import unittest from src.climax.__main__ import MaXProjectConfig from src.climax.__main__ import MaXProjectConfig, dir_is_max from pathlib import Path TEST_CONFIG_FILE = "tests_assets/max_config.xml" TEST_CONFIG_EMPTY_FILE = "tests_assets/empty_max_config.xml" TEST_CONFIG_FILE_BAD_ROOT = "tests_assets/bad_root_max_config.xml" TEST_MAX_PROJECT_DIR = "tests_assets/max_project_dir" class TestConfigFiles(unittest.TestCase): Loading Loading @@ -34,6 +35,10 @@ class TestConfigFiles(unittest.TestCase): config.languages = ["fr", "en", "es", "jp"] self.assertEqual(["fr", "en", "es", "jp"], config.languages) def test_dir_is_max_project(self): self.assertTrue(dir_is_max(Path(TEST_MAX_PROJECT_DIR))) self.assertFalse(dir_is_max(Path("."))) if __name__ == '__main__': unittest.main() tests_assets/max_config.xml +2 −1 Changes for tests_assets/max_config.xml: 2 added lines, 1 removed line. Original line number Diff line number Diff line <configuration env="dev" vocabulary-bundle="max-tei-bundle"> <?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="http://certic.unicaen.fr/max/ns/1.0" env="dev" vocabulary-bundle="max-tei-bundle"> <!-- wont find me here --> <languages> <language>fr</language> Loading Loading
Makefile +3 Changes for Makefile: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ format: ## Formatage des sources avec Black rye run black ./src/ .PHONY: format tests: ## Lancer les tests rye run python tests.py .PHONY: tests help: ## afficher l'aide @echo "\nChoisissez une commande. Les choix sont:\n" Loading
pyproject.toml +1 Changes for pyproject.toml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ dependencies = [ "requests>=2.32.3", "basexclient>=8.4.4", "beautifulsoup4>=4.12.3", "lxml>=5.3.0", ] readme = "README.md" requires-python = ">= 3.12" Loading
src/climax/__main__.py +11 −5 Changes for src/climax/__main__.py: 11 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -54,9 +54,9 @@ class MaXProjectConfig: self.config_file_path = Path(path_to_config_file).resolve() if os.path.isfile(self.config_file_path): with open(self.config_file_path, "r") as f: self.xml_soup = BeautifulSoup(f, "html.parser") self.xml_soup = BeautifulSoup(f, "xml") else: self.xml_soup = BeautifulSoup(CONFIG_INIT_TEMPLATE, "html.parser") self.xml_soup = BeautifulSoup(CONFIG_INIT_TEMPLATE, "xml") first = self.xml_soup.find() if first and first.name != "configuration": raise ValueError(f"{self.config_file_path} is not a MaX configuration file") Loading @@ -65,6 +65,7 @@ class MaXProjectConfig: conf = self.xml_soup.new_tag("configuration") conf["env"] = "dev" conf["vocabulary-bundle"] = "max-tei-bundle" conf["xmlns"] = "http://certic.unicaen.fr/max/ns/1.0" self.xml_soup.append(conf) @property Loading Loading @@ -177,10 +178,15 @@ def dir_is_max(directory: Path = None) -> bool: directory = os.getcwd() directory = Path(directory) config_file = Path(directory, "config.xml") max_dir = Path(directory, ".max") if not config_file.exists() or not max_dir.is_dir(): return False if config_file.exists(): with open(config_file, "r") as f: soup = BeautifulSoup(f, "xml") conf = soup.find("configuration") if conf: ns = conf.get("xmlns") if ns == "http://certic.unicaen.fr/max/ns/1.0": return True return False def check_cwd_is_max(): Loading
tests.py +6 −1 Changes for tests.py: 6 added lines, 1 removed line. Original line number Diff line number Diff line import unittest from src.climax.__main__ import MaXProjectConfig from src.climax.__main__ import MaXProjectConfig, dir_is_max from pathlib import Path TEST_CONFIG_FILE = "tests_assets/max_config.xml" TEST_CONFIG_EMPTY_FILE = "tests_assets/empty_max_config.xml" TEST_CONFIG_FILE_BAD_ROOT = "tests_assets/bad_root_max_config.xml" TEST_MAX_PROJECT_DIR = "tests_assets/max_project_dir" class TestConfigFiles(unittest.TestCase): Loading Loading @@ -34,6 +35,10 @@ class TestConfigFiles(unittest.TestCase): config.languages = ["fr", "en", "es", "jp"] self.assertEqual(["fr", "en", "es", "jp"], config.languages) def test_dir_is_max_project(self): self.assertTrue(dir_is_max(Path(TEST_MAX_PROJECT_DIR))) self.assertFalse(dir_is_max(Path("."))) if __name__ == '__main__': unittest.main()
tests_assets/max_config.xml +2 −1 Changes for tests_assets/max_config.xml: 2 added lines, 1 removed line. Original line number Diff line number Diff line <configuration env="dev" vocabulary-bundle="max-tei-bundle"> <?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="http://certic.unicaen.fr/max/ns/1.0" env="dev" vocabulary-bundle="max-tei-bundle"> <!-- wont find me here --> <languages> <language>fr</language> Loading