コード例 #1
0
ファイル: project.py プロジェクト: anoopajay91/issue-checker
def project(raw_path):
    path = FilePath(raw_path)

    git_dir = path.child(".git")
    if git_dir.isdir():
        return GitPath(git_dir)

    hg_dir = path.child(".hg")
    if hg_dir.isdir():
        return HgPath(path)

    return path
コード例 #2
0
def _find_suite():
    root = os.environ.get("JSON_SCHEMA_TEST_SUITE")
    if root is not None:
        return FilePath(root)

    root = FilePath(jsonschema.__file__).parent().sibling("json")
    if not root.isdir():
        raise ValueError(
            ("Can't find the JSON-Schema-Test-Suite directory. "
             "Set the 'JSON_SCHEMA_TEST_SUITE' environment "
             "variable or run the tests from alongside a checkout "
             "of the suite."), )
    return root
コード例 #3
0
ファイル: _suite.py プロジェクト: w1r2p1/jsonschema
def _find_suite():
    root = os.environ.get("JSON_SCHEMA_TEST_SUITE")
    if root is not None:
        return FilePath(root)

    root = FilePath(jsonschema.__file__).parent().sibling("json")
    if not root.isdir():
        raise ValueError(
            (
                "Can't find the JSON-Schema-Test-Suite directory. "
                "Set the 'JSON_SCHEMA_TEST_SUITE' environment "
                "variable or run the tests from alongside a checkout "
                "of the suite."
            ),
        )
    return root
コード例 #4
0
def run(
    paths,
    output=_I_STILL_HATE_EVERYTHING,
    recurse=core.flat,
    sort_by=lambda x: x,
    ls=core.ls,
    stdout=stdout,
):
    """
    Project-oriented directory and file information lister.

    """

    if output is _I_STILL_HATE_EVERYTHING:
        output = core.columnized if stdout.isatty() else core.one_per_line

    def _sort_by(thing):
        return not getattr(thing, "_always_sorts_first", False), sort_by(thing)

    contents = [
        path_and_children
        for path in paths or (project.from_path(FilePath(".")), )
        for path_and_children in recurse(path=path, ls=ls)
    ]
    for line in output(contents, sort_by=_sort_by):
        stdout.write(line)
        stdout.write("\n")
コード例 #5
0
ファイル: files.py プロジェクト: MostAwesomeDude/dcon
def assets_in_paths(app, segments):
    """
    Select some assets from all of the static paths in the app which match the
    given segments, and return the available basenames.

    Useful for getting a list of options for random selections of banners or
    other images.
    """

    names = []

    for path in app.static_paths:
        root = FilePath(path)
        fp = root.descendant(segments)

        # Get some banners, if they exist.
        if fp.exists():
            names.extend([p.basename() for p in fp.children()])

    return names
コード例 #6
0
ファイル: cli.py プロジェクト: nosup/medhacks_backend
def run(
    paths,
    output=_I_STILL_HATE_EVERYTHING,
    recurse=core.flat,
    sort_by=None,
    ls=core.ls,
    stdout=stdout,
):
    """
    Project-oriented directory and file information lister.

    """

    if output is _I_STILL_HATE_EVERYTHING:
        output = core.columnized if stdout.isatty() else core.one_per_line
    if sort_by is None:
        if output == core.as_tree:

            def sort_by(thing):
                return (
                    thing.parent(),
                    thing.basename().lstrip(string.punctuation).lower(),
                )
        else:

            def sort_by(thing):
                return thing

    def _sort_by(thing):
        return not getattr(thing, "_always_sorts_first", False), sort_by(thing)

    contents = [
        path_and_children
        for path in paths or (project.from_path(FilePath(".")), )
        for path_and_children in recurse(path=path, ls=ls)
    ]
    for line in output(contents, sort_by=_sort_by):
        stdout.write(line)
        stdout.write("\n")
コード例 #7
0
 def test_it_works(self):
     self.cycy.interpret(
         [FilePath(__file__).sibling("example.c").getContent()],
     )
     self.assertEqual(self.stdout.getvalue(), "Hello, world!\n")
コード例 #8
0
ファイル: cli.py プロジェクト: nosup/medhacks_backend
 def convert(self, value, param, context):
     return project.from_path(FilePath(value))
コード例 #9
0
 def getStatusChangeTime(self):
     """
     Return the archive file's status change time.
     """
     return FilePath(self.zipfile.filename).getStatusChangeTime()
コード例 #10
0
 def getModificationTime(self):
     """
     Return the archive file's modification time.
     """
     return FilePath(self.zipfile.filename).getModificationTime()
コード例 #11
0
 def getAccessTime(self):
     """
     Return the archive file's last access time.
     """
     return FilePath(self.zipfile.filename).getAccessTime()
コード例 #12
0
 def exists(self):
     """
     Returns whether the underlying archive exists.
     """
     return FilePath(self.zipfile.filename).exists()
コード例 #13
0
ファイル: example.py プロジェクト: Julian/opencv-cffi
    $ pypy example.py ~/Desktop/haarcascade_frontalface_default.xml

"""

from time import time
import sys

from bp.filepath import FilePath

from opencv_cffi.core import Color, invert
from opencv_cffi.imaging import Camera
from opencv_cffi.gui import ESCAPE, Window
from opencv_cffi.object_detection import HaarClassifier


cascade_filepath = FilePath(sys.argv[1])
classifier = HaarClassifier.from_path(cascade_filepath, canny_pruning=True)


def uglify(frame, facetangle):
    with frame.region_of_interest(facetangle.right_half):
        invert(frame)


def prettify(frame, facetangle):
    with frame.region_of_interest(facetangle.right_half):
        prettified = frame.flipped_vertical()

    with frame.region_of_interest(facetangle.left_half):
        prettified.write_into(frame)
コード例 #14
0
ファイル: main.py プロジェクト: jameysharp/dcon

@app.context_processor
def site_config():
    d = app.config["DCON_CONFIG"]
    return {"dcon": d}


load_filters(app)


wd = None
if wd is None:
    wd = os.getcwd()

wd = FilePath(wd)

app.debug = True

# This default should be sufficient to limp along for starters.
app.config["DCON_STATIC_URL"] = "/static/"

app.config["DCON_PATH"] = wd
app.config["DCON_PASSWORD_FILE"] = wd.child("passwords.dcon")
app.config["DCON_UPLOAD_PATH"] = wd.child("uploads")
app.config["SECRET_KEY"] = wd.child("secret.key").open("rb").read()

app.config["UPLOADS_DEFAULT_DEST"] = app.config["DCON_UPLOAD_PATH"].path
app.config["SESSION_PROTECTION"] = None

load_config(app)
コード例 #15
0
ファイル: issue232.py プロジェクト: tliu/parse
#!/usr/bin/env python
"""
A performance benchmark using the example from issue #232:

https://github.com/Julian/jsonschema/pull/232

"""
from bp.filepath import FilePath
from perf import Runner
from pyrsistent import m

from jsonschema.tests._suite import Collection
import jsonschema

collection = Collection(
    path=FilePath(__file__).sibling("issue232"),
    remotes=m(),
    name="issue232",
    validator=jsonschema.Draft7Validator,
)

if __name__ == "__main__":
    collection.benchmark(runner=Runner())
コード例 #16
0
 def children(self):
     return [FilePath(path) for path in self.listdir()]