Exemple #1
0
def test1():
    models = example()
    assert len(models)


    m2p = render_java.Model2Package(models, dir='.');
    m2p.run()
    mymodel = Path('java_model')
    mymodel.chdir()
    os.system('nosetests')

    Path('..').chdir()
    """if csharp_model.exists():
        csharp_model.rmtree()"""

    return models
Exemple #2
0
    def test_chdir_or_cd(self):
        """ tests the chdir or cd method """
        d = Path(self.tempdir)
        cwd = d.getcwd()

        assert str(d) != str(cwd)  # ensure the cwd isn't our tempdir
        d.chdir()  # now, we're going to chdir to tempdir

        assert str(d.getcwd()) == str(self.tempdir)  # we now ensure that our
                                                     # cwd is the tempdir
        d = Path(cwd)  # we're resetting our path

        assert str(d.getcwd()) == str(self.tempdir)  # we ensure that our cwd
                                                     # is still set to tempdir

        d.cd()  # we're calling the alias cd method
        assert str(d.getcwd()) == str(cwd)  # now, we ensure cwd isn'r tempdir
        assert str(d.getcwd()) != str(self.tempdir)
    def test_chdir_or_cd(self):
        """ tests the chdir or cd method """
        d = Path(self.tempdir)
        cwd = d.getcwd()

        assert str(d) != str(cwd)  # ensure the cwd isn't our tempdir
        d.chdir()  # now, we're going to chdir to tempdir

        assert str(d.getcwd()) == str(self.tempdir)  # we now ensure that our
        # cwd is the tempdir
        d = Path(cwd)  # we're resetting our path

        assert str(d.getcwd()) == str(self.tempdir)  # we ensure that our cwd
        # is still set to tempdir

        d.cd()  # we're calling the alias cd method
        assert str(d.getcwd()) == str(cwd)  # now, we ensure cwd isn'r tempdir
        assert str(d.getcwd()) != str(self.tempdir)
Exemple #4
0
def test1():
    models = totalparse.totalexample()
    assert len(models)

    m2p = render_python.Model2Package(models, dir='.')
    m2p.run()

    code = m2p.code
    exec(code)

    codetest = m2p.codetest

    mymodel = Path('mymodel')
    mymodel.chdir()
    os.system('nosetests')

    Path('..').chdir()
    if mymodel.exists():
        mymodel.rmtree()

    return models
def test1():
    models = example()
    assert len(models)

    m2p = render_csharp.Model2Package(models, dir='.')
    m2p.run()

    code = m2p.code
    #exec(code)

    codetest = m2p.codetest

    mymodel = Path('csharp_model')
    mymodel.chdir()
    os.system('nosetests')

    Path('..').chdir()
    """if csharp_model.exists():
        csharp_model.rmtree()"""

    return models
Exemple #6
0
def isolated_filesystem(dir=None, remove=True):
    """A context manager that creates a temporary folder and changes
    the current working directory to it for isolated filesystem tests.
    """
    cwd = Path.getcwd()
    if dir is None:
        t = Path(tempfile.mkdtemp(prefix='mhc-'))
    else:
        t = Path(dir).abspath()
        t.mkdir_p()
    t.chdir()
    try:
        yield t
    except Exception as e:
        logger.error('Error occured, temporary files are in ' + t)
        raise
    else:
        cwd.chdir()
        if remove:
            Path(t).rmtree_p()
    finally:
        cwd.chdir()
Exemple #7
0
def svn_versions(package_path):
    """ Extract all the svn versions of a given directory

    """
    cwd = Path('.').abspath()
    pp = Path(package_path)
    if pp.exists():
        pp.chdir()
    else:
        return []

    revisions = []
    try:
        svn_revs = subprocess.check_output(['svn', 'log'])
        revisions = [
            l.split(' | ')[0] for l in re.split("\n+", svn_revs)
            if re.match(r"^r[0-9]+", l)
        ]
        revisions.reverse()
    except:
        pass
    cwd.chdir()

    return revisions
Exemple #8
0
#!/usr/bin/python3
import os
from path import Path

#This is a hack for Atom, since it doesn't run your file from the files own directory.
here = Path(__file__).abspath().parent
if here != os.getcwd():
    print("Changing dir")
    here.chdir()

FILELIST = []
STARTFOLDER = "./testfolder"

def find_files(p):
    global FILELIST
    for f in p.files():
        FILELIST.append(f)
    if p.dirs() != []:
        for sub in p.dirs():
            find_files(sub)

if __name__ == "__main__":
    find_files(Path(STARTFOLDER))
    for fi in FILELIST:
        print(fi.abspath())
Exemple #9
0
def folder_check():
    #This is a hack for Atom, since it doesn't run your file from the files own directory.
    here = Path(__file__).abspath().parent
    if here != os.getcwd():
        print("Changing dir")
        here.chdir()
Exemple #10
0
def set_dir(file_path):
    here = Path(file_path).parent
    here.chdir()
Exemple #11
0
LOCAL_TEST_PROJECT = False

if LOCAL_TEST_PROJECT:
    TEMP_LOCATION = Path("temp") / "temp_project"
    Path("temp").mkdir_p()
    TEMP_LOCATION.rmtree_p()
    TEMP_LOCATION.mkdir_p()
    project_dir = Path(TEMP_LOCATION.abspath())
else:
    TEMP_LOCATION = tempfile.mkdtemp()
    project_dir = Path(TEMP_LOCATION)

# TESTS_LOCATION = os.getcwd()
# TEMP_LOCATION = "C:\\Users\\james\\AppData\\Local\\Temp\\tmp6q_l1n1g"

project_dir.chdir()
print(os.getcwd())
req_folder = (project_dir / "requirements")

base_txt = (req_folder / "base.txt")
base_locked_txt = (req_folder / "base-locked.txt")
dev_txt = (req_folder / "dev.txt")
dev_locked_txt = (req_folder / "dev-locked.txt")
piper_file = (project_dir / "piper.json")
virtualenv_dir = (project_dir / ".virtualenvs" / "project_virtualenv")

# sys.path.append(".")
# sys.path.append("..")
from mrpiper import piper

try:
Exemple #12
0
#!/usr/bin/python3
# WebComic App by Exodus111
# www.github.com/exodus111
# Use freely, but credit me.

from flask import Flask, render_template, url_for, redirect
from path import Path
from comics import Series
import os

#This is a hack for Atom, since it doesn't run your file from the files own directory.
here = Path(__file__).abspath().parent
if here != os.getcwd():
    print("Changing dir")
    here.chdir()

app = Flask(__name__)


@app.route("/")
def index():
    """
    Our entry point, and Home destination.
    Thumbs is a dictionary where the keys are url routes and the values image src.
    Series is an object that handles all the Comic Objects.
    """
    global series
    return render_template("index.html", thumbs=series.toplayer_thumbs)


@app.route("/folder<int:fid>")
Exemple #13
0
def folder_check():
    #This is a hack for Atom, since it doesn't run your file from the files own directory.
    here = Path(__file__).abspath().parent
    if here != os.getcwd():
        print("Changing dir")
        here.chdir()
Exemple #14
0
def set_dir(file_path):
    here = Path(file_path).parent
    here.chdir()
Exemple #15
0
import json
from copy import deepcopy
from dataclasses import dataclass
from pprint import pprint

import pandas

from path import Path
cwd = Path("/Users/macmini/projects/asaka/asaka/python_kiso_2021_05")
cwd.chdir()

print(cwd)

@dataclass
class Datum:
    name : str
    total : int
    male : int
    female : int

    def as_dict(self):
        return {
            "name":self.name,
            "total": self.total,
            "male" : self.male[1],
            "female" : self.female[1]
        }

    def as_dict_no_total(self):
        return {
            "name": self.name,
Exemple #16
0
    build_dir.rmtree()

Path(version_file).remove_p()

deps = [
    X264Builder(),
    X265Builder(),
    SVTAV1Builder(),
    SDL2Builder(),
]

for dep in deps:
    print("Building dep", dep.name)

    dep.build()
    base_dir.chdir()

    with open(version_file, "a") as f:
        f.write(f"{dep.name}: {dep.git_address} {dep.version}\n")

for linkage in ("static", "shared"):
    print("Building final FFmpeg", linkage)
    ffmpeg_builder = FFmpegBuilder(linkage=linkage)
    ffmpeg_builder.build()
    base_dir.chdir()

    with zf.ZipFile(f"{ffmpeg_builder.build_name}.zip",
                    mode="w",
                    compression=zf.ZIP_DEFLATED) as zff:
        for dirname, subdirs, files in os.walk(
                os.path.join(ffmpeg_builder.build_path,