Giter Club home page Giter Club logo

acre's Introduction

Acre

Acre is a lightweight cross-platform environment management Python package that makes it trivial to launch applications in their own configurable working environment.

Examples

Compute a dynamic environment acre.compute

This sample will compute the result of a dynamic environment that has values that use values from other keys in the environment.

To compute the result of a dynamic environment use acre.compute

import acre

data = {
    "MAYA_VERSION": "2018",
    "MAYA_LOCATION": "C:/Program Files/Autodesk/Maya{MAYA_VERSION}"

}

env = acre.compute(data)
assert env["MAYA_LOCATION"] == "C:/Program Files/Autodesk/Maya2018"

This also works with recursion.

import acre

data = {
    "MAYA_VERSION": "2018",
    "PIPELINE": "Z:/pipeline",
    "APPS": "{PIPELINE}/apps",
    "MAYA_LOCATION": "{APPS}/Autodesk/Maya{MAYA_VERSION}"
}

env = acre.compute(data)
assert env["MAYA_LOCATION"] == "Z:/pipeline/apps/Autodesk/Maya2018"

Platform specific paths acre.parse

You can set up your data with platform specific paths, by using a dictionary. These need to be parsed with acre.parse

import acre

data = {
    "VERSION": "2018",
    "MY_LOCATION": {
        "windows": "C:/path/on/windows/{VERSION}",
        "darwin": "/path/on/mac/osx/{VERSION}",
        "linux": "/path/on/linux/{VERSION}"
    }
}

env = acre.parse(data, platform_name="windows")
assert env["MY_LOCATION"] == "C:/path/on/windows/{VERSION}"

env = acre.compute(env)
assert env["MY_LOCATION"] == "C:/path/on/windows/2018"

# When *not* explicitly providing a platform name, the current active
# platform is used. So for your active OS:
env = acre.parse(data)
env = acre.compute(env)
print(env["MY_LOCATION"])

Apply the environment on your system

The final touch for getting your environment ready and in use is to merge it with your environment. So:

import os
import acre

data = {
    "PIPELINE": {
        "windows": "P:/pipeline",
        "darwin": "//share/pipeline",
        "linux": "//share/pipeline",
    },
    "CUSTOMPATH": "{PATH}",
    "DATAPATH": "{PIPELINE}/mydata"
}

# Parse the platform specific variables
env = acre.parse(data, platform_name="windows")

# Compute the dynamic environment
env = acre.compute(env)

# Merge it with your local environment
env = acre.merge(env, current_env=os.environ)

# Update your local environment
os.environ.update(env)

# Now it's live!
assert os.environ["DATAPATH"] == "P:/pipeline/mydata"

More samples?

For more usage examples see tests/

acre's People

Contributors

bigroy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.