Example #1
0
def translate(args):
    if args.update_translation:
        # from website
        _, fname = mkstemp(suffix=".pot")
        os.system("pybabel extract -F website/babel.cfg -o %s website/" % fname)
        os.system("pybabel update -D messages -i %s -d translations/" % fname)
        os.remove(fname)

        # from documentation
        from website.utils import Documentation
        fhandle, fname = mkstemp(suffix=".pot")
        with os.fdopen(fhandle, "w") as fid:
            docs = Documentation(os.path.join(args.repo, 'website', 'docs', 'sources'))
            docs.extract_messages(fid)
        os.system("pybabel update -D docs -d translations -i %s" % fname)
        os.remove(fname)

        # from parts data
        repo = Repository(args.repo)
        from backends.translations import TranslationBackend
        fhandle, fname = mkstemp(suffix=".pot")
        TranslationBackend(repo, []).write_output(fname)

        os.system("pybabel update -D parts -d translations -i %s" % fname)
        os.remove(fname)

    if args.compile_translation:
        os.system("pybabel compile -D messages -d translations/")
        os.system("pybabel compile -D parts -d translations/")
        os.system("pybabel compile -D docs -d translations/")
Example #2
0
def add_lang(args):
    # from website
    _, fname = mkstemp(suffix=".pot")
    os.system("pybabel extract -F website/babel.cfg -o %s website/" % fname)
    os.system("pybabel init -D messages -d translations/ -i %s -l %s" % (fname, args.lang))
    os.remove(fname)

    # from documentation
    from website.utils import Documentation
    fhandle, fname = mkstemp(suffix=".pot")
    with os.fdopen(fhandle, "w") as fid:
        docs = Documentation(os.path.join(args.repo, 'website', 'docs', 'sources'))
        docs.extract_messages(fid)
    os.system("pybabel init -D docs -d translations/ -i %s -l %s" % (fname, args.lang))
    os.remove(fname)

    # from parts data
    repo = Repository(args.repo)
    from backends.translations import TranslationBackend
    fhandle, fname = mkstemp(suffix=".pot")
    TranslationBackend(repo, []).write_output(fname)

    os.system("pybabel init -D parts -d translations/ -i %s -l %s" % (fname, args.lang))
    os.remove(fname)
    print(
        "Don't forget to edit website/templates/base.html "
        "and add the language to the dropdown menu"
    )
Example #3
0
def connectors(args):
    repo = Repository(args.repo)
    dbs = {}
    dbs["openscad"] = OpenSCADData(repo)
    dbs["drawings"] = DrawingsData(repo)

    out_path = os.path.join(repo.path, "output", "connectordrawings")

    from backends.connectordrawings import ConnectorDrawingsBackend
    ConnectorDrawingsBackend(repo, dbs).write_output(out_path)
Example #4
0
def tasks(args):
    repo = Repository(args.repo)
    dbs = {}
    dbs["openscad"] = OpenSCADData(repo)
    dbs["freecad"] = FreeCADData(repo)
    dbs["drawings"] = DrawingsData(repo)
    # dbs["solidworks"] = SolidWorksData(repo)

    from backends.checker import CheckerBackend
    checker = CheckerBackend(repo, dbs)

    for task in checker.tasks.values():
        print(task.print_table(),)
Example #5
0
def export(args):
    # load data
    repo = Repository(args.repo)
    dbs = {}
    license = LICENSES_SHORT[args.license]

    out_path = os.path.join(repo.path, "output", args.target)
    if args.target == "openscad":
        dbs["openscad"] = OpenSCADData(repo)
        from backends.openscad import OpenSCADBackend
        OpenSCADBackend(repo, dbs).write_output(
            out_path, target_license=license, version="development", expand=args.debug
        )
        copyfile(
            os.path.join(repo.path, "backends", "licenses", args.license.strip("+")),
            os.path.join(out_path, "LICENSE")
        )
    elif args.target == "freecad":
        dbs["freecad"] = FreeCADData(repo)
        from backends.freecad import FreeCADBackend
        FreeCADBackend(repo, dbs).write_output(
            out_path, target_license=license, version="development"
        )
        copyfile(
            os.path.join(repo.path, "backends", "licenses", args.license.strip("+")),
            os.path.join(out_path, "BOLTS", "LICENSE")
        )
    elif args.target == "pythonpackage":
        dbs["pythonpackage"] = PythonPackageData(repo)
        from backends.pythonpackage import PythonPackageBackend
        PythonPackageBackend(repo, dbs).write_output(
            out_path, target_license=license, version="development"
        )
    # elif args.target == "solidworks":
    #     dbs["solidworks"] = SolidWorksData(repo)
    #     from backends.solidworks import SolidWorksBackend
    #     SolidWorksBackend(repo,dbs).write_output(out_path,"development")
    elif args.target == "iges":
        from backends.exchange import IGESBackend
        IGESBackend(repo, dbs).write_output(out_path, "development")
    elif args.target == "website":
        dbs["drawings"] = DrawingsData(repo)
        dbs["freecad"] = FreeCADData(repo)
        dbs["openscad"] = OpenSCADData(repo)
        from backends.webpage import WebsiteBackend
        WebsiteBackend(repo, dbs).write_output(out_path)
    elif args.target == "drawings":
        dbs["drawings"] = DrawingsData(repo)
Example #6
0
def release(args):
    # check that there are no uncommitted changes
    if call(["git", "diff", "--exit-code", "--quiet"]) == 1:
        print(
            "There are uncommitted changes present in the git repository. "
            "Please take care of them before releasing"
        )
        exit(1)

    if args.kind == "stable" and args.version is None:
        print("Please specify a version using -v when releasing a stable version")
        exit(2)
    if args.kind == "development" and args.version is not None:
        print("No explicit version can be given for development releases")
        exit(2)
    repo = Repository(args.repo)

    version = datetime.now().strftime("%Y%m%d%H%M")
    stable = args.kind == "stable"
    if stable:
        version = args.version

    targets = [args.target]
    if targets[0] == "all":
        targets = ["freecad", "openscad", "iges"]

    from backends.openscad import OpenSCADBackend
    from backends.freecad import FreeCADBackend

    dbs = {}
    dbs["openscad"] = OpenSCADData(repo)
    dbs["freecad"] = FreeCADData(repo)

    backend_names = {"freecad": "FreeCAD", "openscad": "OpenSCAD", "iges": "IGES"}

    # OpenSCAD, FreeCAD export
    for li_short in ["lgpl2.1+", "gpl3"]:
        license = LICENSES_SHORT[li_short]
        OpenSCADBackend(repo, dbs).write_output(
            os.path.join(repo.path, "output", "openscad"),
            target_license=license,
            version=version,
            expand=not stable
        )
        copyfile(
            os.path.join(repo.path, "backends", "licenses", li_short.strip("+")),
            os.path.join(repo.path, "output", "openscad", "LICENSE")
        )
        FreeCADBackend(repo, dbs).write_output(
            os.path.join(repo.path, "output", "freecad"),
            target_license=license,
            version=version
        )
        copyfile(
            os.path.join(repo.path, "backends", "licenses", li_short.strip("+")),
            os.path.join(repo.path, "output", "freecad", "BOLTS", "LICENSE")
        )

        for backend in ["openscad", "freecad"]:
            if backend not in targets:
                continue
            backend_name = backend_names[backend]
            # construct filename from date
            template = "BOLTS_%s_%s_%s" % (backend_name, version, li_short)

            # create archives
            root_dir = os.path.join(repo.path, "output", backend)
            base_name = os.path.join(repo.path, "downloads", backend, template)
            make_archive(base_name, "gztar", root_dir)
            make_archive(base_name, "zip", root_dir)

    # iges export
    from backends.exchange import IGESBackend
    if "iges" in targets:
        try:
            import tarfile
            import lzma
        except ImportError:
            print("Could not find python-lzma, which is required for IGES export")
            return
        IGESBackend(repo, dbs).write_output(
            os.path.join(repo.path, "output", "iges"), version=version
        )

        # write xz file, see http://stackoverflow.com/a/13131500
        backend_name = backend_names["iges"]
        xz_name = "BOLTS_%s_%s.tar.xz" % (backend_name, version)
        xz_fid = lzma.LZMAFile(os.path.join(repo.path, "downloads", "iges", xz_name), mode="w")
        with tarfile.open(mode="w", fileobj=xz_fid) as tar_xz_fid:
            tar_xz_fid.add(os.path.join(repo.path, "output", "iges"), arcname="/")
        xz_fid.close()
Example #7
0
import website.html as html
import website.utils as utils
from website.cache import cache
from website.translation import parts_domain, gettext_parts, languages

parts = Blueprint("parts",__name__,template_folder="templates",url_prefix='/<any(%s):lang_code>/parts' % ",".join(languages))

@parts.url_defaults
def add_language_code(endpoint, values):
	values.setdefault('lang_code',g.lang_code)

@parts.url_value_preprocessor
def pull_language_code(endpoint, values):
	g.lang_code = values.pop('lang_code')

repo = Repository(environ['OPENSHIFT_REPO_DIR'])
dbs = {
	"freecad" : FreeCADData(repo),
	"openscad" : OpenSCADData(repo),
	"drawings" : DrawingsData(repo)
}

def get_identical_links(cl,prt):
	identical = []
	if repo.class_standards.contains_src(cl):
		for s in repo.class_standards.get_dsts(cl):
			if s is prt:
				continue
			identical.append(html.a(s.standard.get_nice(),href=url_for('.standard',id=s.get_id())))
	if repo.class_names.contains_src(cl):
		for n in repo.class_names.get_dsts(cl):