<commit_before>#!/usr/bin/env python
# Author: <NAME>

import argparse
import os
import sys
from profile_tool import profile_tool
from proj_helper import full_project_name

def delete_proj( proj_name, profile='' ):
   if proj_name == os.environ[ 'CURR_WS' ]:
      print "can't delete the workspace you're currently in"
      exit( 1 )

   if profile:
      pt = profile_tool( profile )
   else:
      pt = profile_tool()
   groups = pt.readGroups()
   projects = dict( groups[ 'projects' ] )
   full_proj_name = full_project_name( proj_name, projects.items() )
   del projects[ full_proj_name ]
   if full_proj_name == groups[ 'default_project' ][ 0 ][ 0 ]:
      # if deleted project was default, change default project to
      # the first other project in the dictionary of projects
      groups[ 'default_project' ] = [ ( projects.keys()[ 0 ], ) ]
   groups[ 'projects' ] = projects.items()
   pt.writeGroups( groups )

if __name__ == '__main__':
   parser = argparse.ArgumentParser( description='delete project' )<commit_msg>Fixed issue when CURR_WS env variable isn't set<commit_after>#!/usr/bin/env python
# Author: <NAME>

import argparse
import os
import sys
from profile_tool import profile_tool
from proj_helper import full_project_name

def delete_proj( proj_name, profile='' ):
   if proj_name == os.environ.get( 'CURR_WS', '' ):
      print "can't delete the workspace you're currently in"
      exit( 1 )

   if profile:
      pt = profile_tool( profile )
   else:
      pt = profile_tool()
   groups = pt.readGroups()
   projects = dict( groups[ 'projects' ] )
   full_proj_name = full_project_name( proj_name, projects.items() )
   del projects[ full_proj_name ]
   if full_proj_name == groups[ 'default_project' ][ 0 ][ 0 ]:
      # if deleted project was default, change default project to
      # the first other project in the dictionary of projects
      groups[ 'default_project' ] = [ ( projects.keys()[ 0 ], ) ]
   groups[ 'projects' ] = projects.items()
   pt.writeGroups( groups )

if __name__ == '__main__':
   parser = argparse.ArgumentParser( description='delete project' )
{'fraction_non_alphanumeric': 0.10979087452471482, 'fraction_numerical': 0.0038022813688212928, 'mean_word_length': 3.6986607142857144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7630759', 'n_tokens_mistral': 670, 'n_tokens_neox': 645, 'n_words': 201}