Fix configuration on new project

Julien LepillerSat Dec 12 22:36:06+0100 2020

2b33a4a

Fix configuration on new project

offlate/core/manager.py

1717
from pathlib import Path
1818
from ..formats.exception import UnsupportedFormatException
1919
from ..systems.list import systems
20+
from ..systems.project import Project
2021
2122
import json
2223
import os

187188
        settings = self.settings.conf[system['key']]
188189
        for s in self.settings.conf['Generic'].keys():
189190
            settings[s] = self.settings.conf['Generic'][s]
190-
        return system['system'].isConfigured(settings)
191+
        return Project.isConfigured(system['system'], settings)
191192
192193
    def isNew(self):
193194
        if not 'Generic' in self.settings.conf:

offlate/systems/project.py

111111
        raise Exception("Unimplemented method in concrete class: reload")
112112
113113
    @staticmethod
114-
    def isConfigured(conf):
114+
    def isConfigured(project_class, conf):
115115
        """
116116
        :param dict conf: Offlate configuration
117117
        :returns: Whether the configuration is sufficient for this project (system)
118118
        :rtype: bool
119119
        """
120-
        for spec in getSystemConfigSpec():
120+
        for spec in project_class.getSystemConfigSpec():
121121
            if not spec.isConfigured(conf):
122122
                return False
123123
        return True

offlate/systems/tp.py

142142
                 'lang': self.lang})
143143
        return {'default': self.po.content()}
144144
145-
    @staticmethod
146-
    def isConfigured(conf):
147-
        res = 'email' in conf and conf['email'] != '' and conf['email'] != None
148-
        res = res and 'name' in conf and conf['name'] != '' and \
149-
                conf['name'] != None
150-
        res = res and 'server' in conf and conf['server'] != '' and \
151-
                conf['server'] != None
152-
        res = res and 'user' in conf and conf['user'] != '' and \
153-
                conf['user'] != None
154-
        return res
155-
156145
    def getExternalFiles(self):
157146
        return [self.po.getExternalFiles()]
158147