def load_from_path(path): """ Creates a new Solution object from a file at path and returns it """ newSolution = Solution(solutionPath=path) filename = fileops.get_basename_less_extension(path) filenameMatcher = Definitions.get_value_matcher(Solution.NAMING_DEFINITION_KEY) newSolution.problemNumber = filenameMatcher.get_variable_value( filename, Variables.get_variable_key_name(Variables.NAME_PROBLEM_NUMBER) ) from util.writer import Writer newSolution.solutionWriter = fileops.get_basename(fileops.get_parent_dir(path)) newSolution.solutionLanguage = Languages.get_language_from_extension(fileops.get_extension(path)) return newSolution
def get_applied_language(cls, solutionPath, solutionLanguage): if solutionPath in cls._appliedLanguages: return cls._appliedLanguages[solutionPath] variableDictionary = { Variables.get_variable_key_name(Variables.NAME_FILENAME): fileops.get_basename(solutionPath), Variables.get_variable_key_name(Variables.NAME_FILENAME_LESS_EXT): fileops.get_basename_less_extension(solutionPath), Variables.get_variable_key_name(Variables.NAME_DIRECTORY): fileops.get_parent_dir(solutionPath) } cls._appliedLanguages[solutionPath] = AppliedLanguage(solutionLanguage.name, cls._get_formatted_str_rec(variableDictionary, solutionLanguage._compileExtension), cls._get_formatted_str_rec(variableDictionary, solutionLanguage._compileCommand), cls._get_formatted_str_rec(variableDictionary, solutionLanguage._compileArguments), cls._get_formatted_str_rec(variableDictionary, solutionLanguage._runExtension), cls._get_formatted_str_rec(variableDictionary, solutionLanguage._runCommand), cls._get_formatted_str_rec(variableDictionary, solutionLanguage._runArguments), solutionPath) return cls._appliedLanguages[solutionPath]