How to use the pin.registry.pathfor function in pin

To help you get started, we’ve selected a few pin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dustinlacewell / pin / pin / delegate.py View on Github external
def do_delegation(self, cmd, args):
        load_plugins()
        # project precondition
        proj_path = registry.pathfor(cmd)
        if proj_path is not None:
            os.chdir(proj_path)
            cmd = args[0]
            args = args[1:]
        if '-' in cmd:
            cmd, newargs = cmd.split('-', 1)
            args = [newargs, ] + args
        comcls = command.get(cmd) or command.get('help')
        try:
            if comcls:
                comobj = comcls(args)
                if comobj.is_relevant():
                    comobj._execute()
                else:
                    helpcls = command.get('help')
                    helpobj = helpcls((cmd,))
github dustinlacewell / pin / pin / plugins / core.py View on Github external
def execute(self):
#        pdb.set_trace()
        name = self.options.name
        project = getattr(self.options, 'project', None)
        if project:
            proj_path = registry.pathfor(project)
            if not proj_path:
                print "* Project", project, "not found."
                return
        elif self.root:
            proj_path = self.root
        else:
            print "Must provide -p/--project option, if outside of pin project."
            return
        if name in registry._aliases:
            if proj_path != registry._aliases[name]:
                print "Alias `{alias}' already exists for other project:".format(alias=name)
                print registry._aliases[name]
                return
            else:
                print "Alias `{alias}' already set.".format(alias=name)
                return
github dustinlacewell / pin / pin / util.py View on Github external
we need to complete a base command name. If the
    offset is one less than the number of arguments we
    know to complete a subcommand. Even with a project
    prefix this works:

    pin myproj help fab deplo[tab] :
       off   = (1 + myproj + help) = 3
       nargs = 4
       = subcommand!
    """
    off = 1
    proj_path = None
    # # # # # # # #
    # Project Name
    if args:
        proj_path = registry.pathfor(args[0])
        # only increase the offset if we're not completing 
        # the first argument.
        if nargs > 1 and proj_path is not None:
            # increase the offset
            off += 1 
            # change to project directory
            os.chdir(proj_path)
    # # # # # # # #
    # Help command
    if args:
        # complete help command
        if nargs == off and "help".startswith(args[-1]):
            return 'help'
        # or increase offset by 1
        elif "help" in args:
            off += 1
github dustinlacewell / pin / pin / plugins / core.py View on Github external
def execute(self):
        self.path = registry.pathfor(self.options.project, ask=True)
        if self.path:
            return self.path
        else:
            print "There are no registered pin projects."