File: generate_module_list.py

package info (click to toggle)
sympy 1.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,784 kB
  • sloc: python: 460,598; xml: 359; makefile: 162; sh: 59; lisp: 4
file content (71 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Execute like this:

$ python bin/generate_module_list.py
modules = [
    'sympy.assumptions',
    'sympy.assumptions.handlers',
    'sympy.benchmarks',
    'sympy.calculus',
    'sympy.categories',
    'sympy.codegen',
    'sympy.combinatorics',
    'sympy.concrete',
    'sympy.core',
    'sympy.core.benchmarks',
    'sympy.crypto',
    'sympy.deprecated',
    'sympy.diffgeom',
    'sympy.external',
    'sympy.functions',
    'sympy.functions.combinatorial',
    'sympy.functions.elementary',
    'sympy.functions.elementary.benchmarks',
...
]

"""

from __future__ import print_function

from glob import glob


def get_paths(level=15):
    """
    Generates a set of paths for modules searching.

    Examples
    ========

    >>> get_paths(2)
    ['sympy/__init__.py', 'sympy/*/__init__.py', 'sympy/*/*/__init__.py']
    >>> get_paths(6)
    ['sympy/__init__.py', 'sympy/*/__init__.py', 'sympy/*/*/__init__.py',
    'sympy/*/*/*/__init__.py', 'sympy/*/*/*/*/__init__.py',
    'sympy/*/*/*/*/*/__init__.py', 'sympy/*/*/*/*/*/*/__init__.py']

    """
    wildcards = ["/"]
    for i in range(level):
        wildcards.append(wildcards[-1] + "*/")
    p = ["sympy" + x + "__init__.py" for x in wildcards]
    return p

def generate_module_list():
    g = []
    for x in get_paths():
        g.extend(glob(x))
    g = [".".join(x.split("/")[:-1]) for x in g]
    g = [i for i in g if not i.endswith('.tests')]
    g.remove('sympy')
    g = list(set(g))
    g.sort()
    return g

if __name__ == '__main__':
    g = generate_module_list()
    print("modules = [")
    for x in g:
        print("    '%s'," % x)
    print("]")