from os import path
from json import load
from codecs import open


class Project:
    PROJECT_FILE_NAME = "package.json"

    @staticmethod
    def get_project_dir(project_path):
        pair = (project_path, True)
        while bool(pair[1]):
            if Project._has_valid_project_file(pair[0]):
                return pair[0]
            else:
                pair = path.split(pair[0])

    @staticmethod
    def _has_valid_project_file(project_path):
        try:
            json_data = open(path.join(project_path,
                                       Project.PROJECT_FILE_NAME),
                             "r", "utf-8")
            return "nativescript" in load(json_data)
        except UnicodeError:
            return False

@@ -114,16 +114,49 @@
 ge.json%22
+%0A    PROJECT_KEY = %22nativescript%22
 %0A%0A    @s
@@ -198,32 +198,73 @@
 (project_path):%0A
+        if path.isdir(project_path):%0A    
         pair = (
@@ -291,16 +291,20 @@
         
+    
 while bo
@@ -328,16 +328,20 @@
         
+ 
+   
 if Proje
@@ -389,24 +389,28 @@
             
+    
 return pair%5B
@@ -428,14 +428,22 @@
     
+    
 else:%0A
+    
     
@@ -559,104 +559,43 @@
     
-try:%0A            json_data = open(path.join(project_path,%0A                                      
+file_name = path.join(project_path,
  Pro
@@ -617,17 +617,16 @@
 LE_NAME)
-,
 %0A       
@@ -618,33 +618,59 @@
 E_NAME)%0A        
- 
+if path.isfile(file_name):%0A
                 
@@ -665,23 +665,64 @@
         
+try:%0A
        
+         json_data = open(file_name,
  %22r%22, %22u
@@ -744,29 +744,38 @@
     
+    
 return 
-%22nativescript%22
+Project.PROJECT_KEY
  in 
@@ -798,16 +798,20 @@
         
+ 
+   
 except U
@@ -823,16 +823,20 @@
 eError:%0A
+    
         

Fix error when no projects opened