From 8882613f07b6e5d6ec2eccb9d521a12c4405e540 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Thu, 9 May 2019 22:20:46 +0200 Subject: [PATCH] lib/adapter/rosetta.py: initial rosetta support --- lib/adapter/rosetta.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/adapter/rosetta.py b/lib/adapter/rosetta.py index 02b49f6..2ec46bb 100644 --- a/lib/adapter/rosetta.py +++ b/lib/adapter/rosetta.py @@ -3,7 +3,7 @@ Implementation of RosettaCode Adapter. Exports: - Rosetta(Adapter) + Rosetta(GitRepositoryAdapter) """ # pylint: disable=relative-import @@ -12,10 +12,10 @@ import os import glob import yaml -from adapter import Adapter +from git_adapter import GitRepositoryAdapter from cheat_sheets import CheatSheets -class Rosetta(Adapter): +class Rosetta(GitRepositoryAdapter): """ Adapter for RosettaCode @@ -24,17 +24,22 @@ class Rosetta(Adapter): _adapter_name = "rosetta" _output_format = "code" _local_repository_location = "RosettaCodeData" + _repository_url = "https://github.com/acmeism/RosettaCodeData" __section_name = "rosetta" + def __init__(self): + GitRepositoryAdapter.__init__(self) + self._rosetta_code_name = self._load_rosetta_code_names() + @staticmethod def _load_rosetta_code_names(): answer = {} - lang_files_location = CheatSheets.local_repository_location() + lang_files_location = CheatSheets.local_repository_location(cheat_sheets_location=True) for filename in glob.glob(os.path.join(lang_files_location, '*/_info.yaml')): text = open(filename, 'r').read() - data = yaml.load(text) + data = yaml.load(text, Loader=yaml.SafeLoader) if data is None: continue lang = os.path.basename(os.path.dirname(filename)) @@ -140,6 +145,3 @@ class Rosetta(Adapter): def is_found(self, _): return True - def __init__(self): - Adapter.__init__(self) - self._rosetta_code_name = self._load_rosetta_code_names()