|
@@ -8,7 +8,7 @@ import re
|
|
|
from path import Path
|
|
from path import Path
|
|
|
|
|
|
|
|
# TODO: gérer les cas où des objets de types différents portent le même nom. Ex: une table et un formulaire... Note: une requete et une table ne peuvent pas porter le même nom.
|
|
# TODO: gérer les cas où des objets de types différents portent le même nom. Ex: une table et un formulaire... Note: une requete et une table ne peuvent pas porter le même nom.
|
|
|
-# TODO: ignorer les commentaires dans le modules
|
|
|
|
|
|
|
+# TODO: ignorer les commentaires dans les modules
|
|
|
# TODO: ignorer les labels dans les formulaires et états
|
|
# TODO: ignorer les labels dans les formulaires et états
|
|
|
# TODO: Gérer les références circulaires
|
|
# TODO: Gérer les références circulaires
|
|
|
# TODO: Stocker un aperçu du contexte de la ou des références dans le code source, pour contrôle ultérieur
|
|
# TODO: Stocker un aperçu du contexte de la ou des références dans le code source, pour contrôle ultérieur
|
|
@@ -32,8 +32,8 @@ class AccessObject():
|
|
|
_valid_file_exts = (".bas")
|
|
_valid_file_exts = (".bas")
|
|
|
_re_w_sep = """^|\s|\[|\]|&|\(|\)|\.|!|"|'"""
|
|
_re_w_sep = """^|\s|\[|\]|&|\(|\)|\.|!|"|'"""
|
|
|
|
|
|
|
|
- def __init__(self, nom):
|
|
|
|
|
- self.nom = nom
|
|
|
|
|
|
|
+ def __init__(self, name_):
|
|
|
|
|
+ self.name_ = name_
|
|
|
self.functions = []
|
|
self.functions = []
|
|
|
self.sourcefile = ""
|
|
self.sourcefile = ""
|
|
|
self.deps = []
|
|
self.deps = []
|
|
@@ -41,7 +41,7 @@ class AccessObject():
|
|
|
self._sourcecode = ""
|
|
self._sourcecode = ""
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
def __repr__(self):
|
|
|
- return "<{}: {}>".format(self.type_, self.nom)
|
|
|
|
|
|
|
+ return "<{}: {}>".format(self.type_, self.name_)
|
|
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
|
def from_file(cls, file):
|
|
def from_file(cls, file):
|
|
@@ -76,7 +76,7 @@ class AccessObject():
|
|
|
return name_
|
|
return name_
|
|
|
|
|
|
|
|
def search_me_regex(self):
|
|
def search_me_regex(self):
|
|
|
- return re.compile(r"""({sep}){nom}({sep})""".format(sep=self._re_w_sep, nom=self.nom))
|
|
|
|
|
|
|
+ return re.compile(r"""({sep}){name_}({sep})""".format(sep=self._re_w_sep, name_=self.name_))
|
|
|
|
|
|
|
|
def containsRefsTo(self, access_object):
|
|
def containsRefsTo(self, access_object):
|
|
|
if access_object is self:
|
|
if access_object is self:
|
|
@@ -139,10 +139,17 @@ class Analyse():
|
|
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
|
def register(cls, obj):
|
|
def register(cls, obj):
|
|
|
- if obj.nom in [other.nom for other in cls.objects] and not obj.nom in cls.duplicated_names:
|
|
|
|
|
- cls.duplicated_names.append(obj.nom)
|
|
|
|
|
|
|
+ if obj.name_ in [other.name_ for other in cls.objects] and not obj.name_ in cls.duplicated_names:
|
|
|
|
|
+ cls.duplicated_names.append(obj.name_)
|
|
|
cls.objects.append(obj)
|
|
cls.objects.append(obj)
|
|
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
|
+ def register_dep(cls, subject, target, mode=DEPS_AND_REFS):
|
|
|
|
|
+ if mode in (DEPS_AND_REFS, DEPS_ONLY):
|
|
|
|
|
+ subject.add_dep(target)
|
|
|
|
|
+ if mode in (DEPS_AND_REFS, REFS_ONLY):
|
|
|
|
|
+ target.add_ref(subject)
|
|
|
|
|
+
|
|
|
@classmethod
|
|
@classmethod
|
|
|
def run(cls, source_dir, mode=DEPS_AND_REFS):
|
|
def run(cls, source_dir, mode=DEPS_AND_REFS):
|
|
|
source_dir = Path(source_dir)
|
|
source_dir = Path(source_dir)
|
|
@@ -174,20 +181,22 @@ class Analyse():
|
|
|
total = len(cls.objects)
|
|
total = len(cls.objects)
|
|
|
cls.report(0, total, "> {} objets trouvés".format(total))
|
|
cls.report(0, total, "> {} objets trouvés".format(total))
|
|
|
|
|
|
|
|
- # met à jour les dependances en listant les noms d'objets mentionnés dans le fichier subject
|
|
|
|
|
|
|
+ # Mise à jour des dépendances:
|
|
|
|
|
+ # # parcourt les objets, et recherche dans le code source de chacun des mentions du nom des autres objets.
|
|
|
|
|
+ # # Si l'objet dont on recherche le nom fait partie des noms dupliqués, essaie de deviner son type.
|
|
|
|
|
+
|
|
|
for index, subject in enumerate(cls.objects):
|
|
for index, subject in enumerate(cls.objects):
|
|
|
|
|
|
|
|
- cls.report(index, total, "* {}: {}".format(subject.type_, subject.nom))
|
|
|
|
|
|
|
+ cls.report(index, total, "* {}: {}".format(subject.type_, subject.name_))
|
|
|
|
|
|
|
|
for candidate in cls.objects[:index] + cls.objects[index + 1:]:
|
|
for candidate in cls.objects[:index] + cls.objects[index + 1:]:
|
|
|
|
|
|
|
|
if subject.containsRefsTo(candidate):
|
|
if subject.containsRefsTo(candidate):
|
|
|
|
|
|
|
|
- if mode in (DEPS_AND_REFS, DEPS_ONLY):
|
|
|
|
|
- subject.add_dep(candidate)
|
|
|
|
|
|
|
+ if candidate.name_ in cls.duplicated_names:
|
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
- if mode in (DEPS_AND_REFS, REFS_ONLY):
|
|
|
|
|
- candidate.add_ref(subject)
|
|
|
|
|
|
|
+ cls.register_dep(subject, candidate, mode)
|
|
|
|
|
|
|
|
cls.report(total, total, "Analyse terminée")
|
|
cls.report(total, total, "Analyse terminée")
|
|
|
cls.ended()
|
|
cls.ended()
|
|
@@ -196,11 +205,6 @@ class Analyse():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
source_dir = Path(r"c:\dev\access\Analytique\source")
|
|
source_dir = Path(r"c:\dev\access\Analytique\source")
|
|
|
|
|
|
|
@@ -217,7 +221,7 @@ if __name__ == "__main__":
|
|
|
|
|
|
|
|
with open("data.txt", "w+") as f:
|
|
with open("data.txt", "w+") as f:
|
|
|
for o in Analyse.objects:
|
|
for o in Analyse.objects:
|
|
|
- msg = "# {}: '{}'".format(o.type_, o.nom)
|
|
|
|
|
|
|
+ msg = "# {}: '{}'".format(o.type_, o.name_)
|
|
|
msg += "\n\t Utilise: {}".format(", ".join(["'{}'".format(d) for d in o.deps]))
|
|
msg += "\n\t Utilise: {}".format(", ".join(["'{}'".format(d) for d in o.deps]))
|
|
|
msg += "\n\t Est utilisé par: {}".format(", ".join(["'{}'".format(d) for d in o.refs]))
|
|
msg += "\n\t Est utilisé par: {}".format(", ".join(["'{}'".format(d) for d in o.refs]))
|
|
|
msg += "\n"
|
|
msg += "\n"
|