Exemplo n.º 1
0
def test_addons():
    noop_file_name = os.path.join("anyci", "noop") + ".py"
    noop_file_name_pyc = os.path.join("anyci", "noop") + ".pyc"
    noop_file_path = os.path.join(ci_addons.home(), noop_file_name)
    noop_file_path_pyc = os.path.join(ci_addons.home(), noop_file_name_pyc)

    py_compile.main([noop_file_path])

    if sys.version_info < (3, ):
        assert os.path.exists(noop_file_path_pyc)

    assert noop_file_name in ci_addons.addons()
    assert noop_file_name_pyc not in ci_addons.addons()
Exemplo n.º 2
0
def check_code_style(
        pathnames):

    style = pycodestyle.StyleGuide(
        ignore=["E402"]
    )
    nr_modules = 0
    nr_succeeding_modules = 0

    for pathname in pathnames:
        if os.path.isdir(pathname):
            check_code_style(find_python_modules(pathname))
        else:
            print("→ {}".format(pathname))

            nr_modules += 1
            status = py_compile.main([pathname])

            if status == 0:
                result = style.check_files([pathname])

                if result.total_errors == 0:
                    nr_succeeding_modules += 1

    if nr_modules > 0:
        print("{}/{} ({}%) of the modules were fine".format(
            nr_succeeding_modules, nr_modules,
            (100.0 * nr_succeeding_modules) / nr_modules))
Exemplo n.º 3
0
def check_code_style(pathnames):

    style = pycodestyle.StyleGuide(ignore=["E402"])
    nr_modules = 0
    nr_succeeding_modules = 0

    for pathname in pathnames:
        if os.path.isdir(pathname):
            check_code_style(find_python_modules(pathname))
        else:
            print("→ {}".format(pathname))

            nr_modules += 1
            status = py_compile.main([pathname])

            if status == 0:
                result = style.check_files([pathname])

                if result.total_errors == 0:
                    nr_succeeding_modules += 1

    if nr_modules > 0:
        print(
            "{}/{} ({}%) of the modules were fine".format(
                nr_succeeding_modules, nr_modules, (100.0 * nr_succeeding_modules) / nr_modules
            )
        )
Exemplo n.º 4
0
def main(argv, dir='.'):
    """ Main function that parses and compiles the files """
    parser = ClassParser()
    if isinstance(dir, str):
        dir = [dir]

    for dir in dir[:]:
        # Create py files from ui files
        # file_names is passed around here as it is outside of each functions scope
        del file_names[:]
        uic.compileUiDir(dir, map=modname)

        # Parse those py_ui files for the class names
        file_classes = {}
        for file in file_names:
            with open(file,'rb') as fid:
                code = fid.read()
            file_classes[file] = parser.parse(code)

        # Create an init file filling it with import statements using the class
        # names that were parse above
        init_file = os.path.join(dir, "__init__.py")
        with open(init_file, "wb") as fid:
            fid.write("#This file is generated by BuildUiFiles.py")
            fid.write(os.linesep)
            for k, v in file_classes.items():
                file = os.path.split(k)[1]
                i_from = os.path.splitext(file)[0]
                print(i_from)
                for mod in v:
                    stmt = "from {} import {}".format(i_from, mod)
                    fid.write(stmt)
                    fid.write(os.linesep)
        py_compile.compile(init_file)

        # Compile the py_ui file and then remove the uncompiled versions unless
        # the dontremove flag was set.
        py_compile.main(file_names)
        if not("--dontremove" in argv):
            for k in file_names:
                os.remove(k)
Exemplo n.º 5
0
# Downloaded from: https://github.com/lyricat/Hotot

# By Simon Edwards <*****@*****.**>
# This file is in the public domain.
import py_compile, sys
sys.exit(py_compile.main())
Exemplo n.º 6
0
import py_compile
py_compile.main()
Exemplo n.º 7
0
#!/usr/bin/python
import py_compile

py_compile.main(['client.py', 'server.py'])
Exemplo n.º 8
0
zipfilelist = {
    'KiteBase.zip': ['Instance.py', 'fno_calendar.py'],
    'KiteRange.zip': ['Range.py'],
    'KiteSwing.zip': ['Swing.py', 'Container.py']
}

try:
    for thefile in ziplist[install_type]:
        with zipfile.ZipFile(directory + bs + thefile, 'r') as zip_ref:
            zip_ref.extractall(
                directory,
                pwd=bytes(
                    getpass.getpass('Please give secret code to install ' +
                                    thefile[:-4] + ':'), 'utf-8'))
            files = zipfilelist[thefile]
            py_compile.main(files)
            for file in files:
                os.remove(directory + bs + file)
            pycache = '__pycache__'
            for file in os.listdir(directory + bs + pycache):
                os.rename(directory + bs + pycache + bs + file,
                          directory + bs + file.split('.')[0] + '.pyc')
            zip_ref.close()
        os.remove(directory + bs + thefile)

    print('DONE! Modules successfully installed\n')
    time.sleep(1)

    #chromedriver
    if not os.path.isfile(os.getcwd() + bs + 'chromedriver.exe' if system ==
                          'nt' else os.getcwd() + bs + 'chromedriver'):
Exemplo n.º 9
0
def compile(conf):
    args = find_files(conf.srcdir, '*.py')
    py_compile.main(args)

    copy(conf.srcdir, conf.objdir, '*.pyc')
Exemplo n.º 10
0
"""
from distutils.core import setup
from Cython.Build import cythonize
import py_compile
import os

# collect all py and __init__.py files
base_dir = os.getcwd()
init_py = "__init__.py"

py_files = []
pyc_files = ["stock_alert.py"]
for dir, subdir, files in os.walk(base_dir):
    rel_path = dir.split(base_dir)
    if len(rel_path) > 1:
        rel_path = rel_path[1].replace("\\", "/")
    else:
        rel_path = ""

    for filename in files:
        if filename == init_py:
            pyc_files.append((rel_path + "/" + init_py).lstrip("/"))
        elif filename[-3:] == ".py":
            if filename == pyc_files[0]:
                continue
            py_files.append((rel_path + "/" + filename).lstrip("/"))

py_compile.main(pyc_files)

setup(script_args=['build_ext', '--inplace'], ext_modules=cythonize(py_files))
Exemplo n.º 11
0
 def update_event(self, inp=-1):
     self.set_output_val(0, py_compile.main(self.input(0)))