Last active
February 8, 2019 06:29
Revisions
-
avalanchy revised this gist
Feb 8, 2019 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,11 @@ def factories_lookup(base_dir): """Yields all model factories in a way expected by shell_plus command. Returned generator is evaluated only when running shell_plus. Evaluation itself on my machine takes ± 3.63 ms. Usage: SHELL_PLUS_POST_IMPORTS = factories_lookup(BASE_DIR) """ -
avalanchy revised this gist
Feb 7, 2019 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,6 @@ def factories_lookup(base_dir): p = p.replace('/', '.') p = p.replace('.py', '') with open(m, 'r') as f: c = re.findall('class ([A-Za-z]+Factory)', f.read()) if c: yield p, c -
avalanchy revised this gist
Feb 7, 2019 . No changes.There are no files selected for viewing
-
avalanchy revised this gist
Feb 7, 2019 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,11 @@ def factories_lookup(base_dir): """Yields all model factories in a way expected by shell_plus command Usage: SHELL_PLUS_POST_IMPORTS = factories_lookup(BASE_DIR) """ modules = pathlib.Path(base_dir).glob('**/factories.py') for module in modules: m = str(module) -
avalanchy created this gist
Feb 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import pathlib import re def factories_lookup(base_dir): """Yields all model factories in a way expected by shell_plus command""" modules = pathlib.Path(base_dir).glob('**/factories.py') for module in modules: m = str(module) p = m.replace(base_dir, '') p = p[1:] p = p.replace('/', '.') p = p.replace('.py', '') with open(m, 'r') as f: for l in f: c = re.match('class ([A-Za-z]+Factory)', l) if c: yield p, c.group(1)