Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def execute(self):
if self.cwd == self.root:
self.raise_exists()
else:
print "Creating .pin directory structure..."
alias = None
if self.options.alias:
alias = self.options.alias[0]
registry.initialize_project(self.cwd, alias=alias)
self.root = self.cwd
return True
return
else:
print "Alias `{alias}' already set.".format(alias=name)
return
else:
current_alias = registry._projects[proj_path].get('alias')
if current_alias:
prompt = "Alias `{alias}' already set, overwrite?".format(alias=current_alias)
answer = option_select(['y','n'], prompt)
if answer == 'n':
print "Aborted."
return
_projects[proj_path]['alias'] = name
_aliases[name] = proj_path
registry.save_registry()
print "Alias `{alias}' has been set for, {path}".format(alias=name,
path=proj_path)
return True
def activate_virtualenv(path):
if path:
path = os.path.join(path,
PROJECT_FOLDERNAME,
VIRTUALENV_FOLDERNAME)
settings = os.path.join(registry.get_settings_path(), 'source.sh')
with open(settings, 'w') as file:
file.write("source %s\n" % os.path.join(path, "bin/activate"))
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
else:
current_alias = registry._projects[proj_path].get('alias')
if current_alias:
prompt = "Alias `{alias}' already set, overwrite?".format(alias=current_alias)
answer = option_select(['y','n'], prompt)
if answer == 'n':
print "Aborted."
return
def deactivate_virtualenv():
settings = os.path.join(registry.get_settings_path(), 'source.sh')
with open(settings, 'w') as file:
file.write("deactivate\n")
@classmethod
def get_subcommands(cls):
subs = dict()
for p, meta in registry._projects.items():
alias = meta.get('alias')
if alias:
subs[alias] = PinProjectProxy(p)
else:
subs[os.path.basename(p)] = PinProjectProxy(p)
return subs
def execute(self):
if not self.root:
return self.raise_no_project()
else:
repeat = True
while repeat:
pinpath = os.path.join(self.root, PROJECT_FOLDER)
print "WARNING: Will destory all data in the .pin directory!"
os.system("ls %s" % pinpath)
selection = option_select(['y', 'n'], "Really destroy?")
if selection == 'n':
print "Aborted."
return
elif selection == 'y':
shutil.rmtree(pinpath)
registry.unregister(self.root)
return True
def done(self):